From 1945cd5e814901b5e13b9f32a5c66e263616af05 Mon Sep 17 00:00:00 2001 From: Daniel Baluta Date: Thu, 17 Feb 2022 13:37:03 +0200 Subject: [PATCH 1/3] codec_adapter: Fix trace format mismatches Two comp_err calls have mismatching formats and arguments. When built with zephyr, comp_err() translates to printk which has better format checks. Signed-off-by: Daniel Baluta --- src/audio/codec_adapter/codec/generic.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/audio/codec_adapter/codec/generic.c b/src/audio/codec_adapter/codec/generic.c index 41cb75b21aed..467a672440b4 100644 --- a/src/audio/codec_adapter/codec/generic.c +++ b/src/audio/codec_adapter/codec/generic.c @@ -176,7 +176,7 @@ int module_free_memory(struct processing_module *mod, void *ptr) } comp_err(mod->dev, "module_free_memory: error: could not find memory pointed by %p", - (uint32_t)ptr); + ptr); return -EINVAL; } @@ -398,7 +398,7 @@ int module_set_configuration(struct processing_module *mod, ret = memcpy_s(dst, size - offset, fragment, fragment_size); if (ret < 0) { - comp_err(dev, "module_set_configuration(): error: failed to copy fragment", + comp_err(dev, "module_set_configuration(): error: %d failed to copy fragment", ret); return ret; } From 64216e3b70332fa237da7873cf8ba30862b0b815 Mon Sep 17 00:00:00 2001 From: Daniel Baluta Date: Thu, 17 Feb 2022 13:41:53 +0200 Subject: [PATCH 2/3] codec_adapter: Fix DECLARE_CODEC_ADAPTER macro With the current implementation argument 'adapter' was ignored for each instance of the codec the sys_*_init function name was the same. Fix this by properly using 'adapter' name. Signed-off-by: Daniel Baluta --- src/include/sof/audio/codec_adapter/codec/generic.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/include/sof/audio/codec_adapter/codec/generic.h b/src/include/sof/audio/codec_adapter/codec/generic.h index aff0a1763829..07a1d5d44736 100644 --- a/src/include/sof/audio/codec_adapter/codec/generic.h +++ b/src/include/sof/audio/codec_adapter/codec/generic.h @@ -54,13 +54,13 @@ static SHARED_DATA struct comp_driver_info comp_codec_adapter_info = { \ .drv = &comp_codec_adapter, \ }; \ \ -UT_STATIC void sys_comp_codec_##adapter_init(void) \ +UT_STATIC void sys_comp_codec_##adapter##_init(void) \ { \ comp_register(platform_shared_get(&comp_codec_adapter_info, \ sizeof(comp_codec_adapter_info))); \ } \ \ -DECLARE_MODULE(sys_comp_codec_##adapter_init) +DECLARE_MODULE(sys_comp_codec_##adapter##_init) struct processing_module; From c4836cd260eda1eea3819b8b84f1c871d21aa1ff Mon Sep 17 00:00:00 2001 From: Daniel Baluta Date: Thu, 17 Feb 2022 13:54:29 +0200 Subject: [PATCH 3/3] zephyr: add codec adapter components This enables codec_adapter and cadence/passhtrough codecs with SOF on Zephyr. passthrough codec can be used as it is, but cadence codec will also need codec libraries from cadence. Signed-off-by: Daniel Baluta --- zephyr/CMakeLists.txt | 14 ++++++++++++++ zephyr/wrapper.c | 10 ++++++++++ 2 files changed, 24 insertions(+) diff --git a/zephyr/CMakeLists.txt b/zephyr/CMakeLists.txt index a932758afe96..a08ce761d326 100644 --- a/zephyr/CMakeLists.txt +++ b/zephyr/CMakeLists.txt @@ -609,6 +609,20 @@ zephyr_library_sources_ifdef(CONFIG_COMP_VOLUME ${SOF_AUDIO_PATH}/volume/volume.c ) +zephyr_library_sources_ifdef(CONFIG_COMP_CODEC_ADAPTER + ${SOF_AUDIO_PATH}/codec_adapter/codec_adapter.c + ${SOF_AUDIO_PATH}/codec_adapter/codec/generic.c +) + +if (CONFIG_COMP_CODEC_ADAPTER) +zephyr_library_sources_ifdef(CONFIG_CADENCE_CODEC + ${SOF_AUDIO_PATH}/codec_adapter/codec/cadence.c +) +zephyr_library_sources_ifdef(CONFIG_PASSTHROUGH_CODEC + ${SOF_AUDIO_PATH}/codec_adapter/codec/passthrough.c +) +endif() + zephyr_library_sources_ifdef(CONFIG_COMP_SRC ${SOF_AUDIO_PATH}/src/src_hifi2ep.c ${SOF_AUDIO_PATH}/src/src_generic.c diff --git a/zephyr/wrapper.c b/zephyr/wrapper.c index bdb39268098d..63053f5778c2 100644 --- a/zephyr/wrapper.c +++ b/zephyr/wrapper.c @@ -537,6 +537,8 @@ void sys_comp_kpb_init(void); void sys_comp_smart_amp_init(void); void sys_comp_basefw_init(void); void sys_comp_copier_init(void); +void sys_comp_codec_cadence_interface_init(void); +void sys_comp_codec_passthrough_interface_init(void); /* Zephyr redefines log_message() and mtrace_printf() which leaves * totally empty the .static_log_entries ELF sections for the @@ -640,6 +642,14 @@ int task_main_start(struct sof *sof) sys_comp_copier_init(); } + if (IS_ENABLED(CONFIG_CADENCE_CODEC)) { + sys_comp_codec_cadence_interface_init(); + } + + if (IS_ENABLED(CONFIG_PASSTHROUGH_CODEC)) { + sys_comp_codec_passthrough_interface_init(); + } + /* init pipeline position offsets */ pipeline_posn_init(sof);