From 0c840a380da9d036b959039eb8c6e36b3e6aa7ee Mon Sep 17 00:00:00 2001 From: Kai Vehmanen Date: Thu, 20 Mar 2025 13:42:18 +0200 Subject: [PATCH 01/11] cmake/zephyr: unify cmake rules for src/audio/module_adapter Adding all source files in a single, giant zephyr/CMakeLists.txt is inconvenient and does not scale. Modify Zephyr rules to use definitions in src/audio/module_adapter/ instead. This commit only moves the common adapter code. The codec build rules are still separate. Link: https://github.com/thesofproject/sof/issues/8260 Signed-off-by: Kai Vehmanen --- src/audio/CMakeLists.txt | 6 +++--- src/audio/module_adapter/CMakeLists.txt | 7 ++++++- zephyr/CMakeLists.txt | 6 ------ 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/audio/CMakeLists.txt b/src/audio/CMakeLists.txt index 85f3216d4c0f..802e837891b2 100644 --- a/src/audio/CMakeLists.txt +++ b/src/audio/CMakeLists.txt @@ -63,6 +63,9 @@ if(NOT CONFIG_COMP_MODULE_SHARED_LIBRARY_BUILD) if(CONFIG_COMP_MIXIN_MIXOUT) add_subdirectory(mixin_mixout) endif() + if(CONFIG_COMP_MODULE_ADAPTER) + add_subdirectory(module_adapter) + endif() if(CONFIG_COMP_MULTIBAND_DRC) add_subdirectory(multiband_drc) endif() @@ -130,9 +133,6 @@ if(NOT CONFIG_COMP_MODULE_SHARED_LIBRARY_BUILD) if(CONFIG_COMP_SMART_AMP) add_subdirectory(smart_amp) endif() - if(CONFIG_COMP_MODULE_ADAPTER) - add_subdirectory(module_adapter) - endif() if(CONFIG_COMP_IGO_NR) add_subdirectory(igo_nr) endif() diff --git a/src/audio/module_adapter/CMakeLists.txt b/src/audio/module_adapter/CMakeLists.txt index 300296dc6205..f50c996f1f3b 100644 --- a/src/audio/module_adapter/CMakeLists.txt +++ b/src/audio/module_adapter/CMakeLists.txt @@ -1,12 +1,17 @@ # SPDX-License-Identifier: BSD-3-Clause - if(CONFIG_IPC_MAJOR_3) add_local_sources(sof module_adapter.c module_adapter_ipc3.c module/generic.c) elseif(CONFIG_IPC_MAJOR_4) add_local_sources(sof module_adapter.c module_adapter_ipc4.c module/generic.c) endif() +is_zephyr(zephyr) +if(zephyr) ### Zephyr ### + # codec build rules still in sof/zephyr/CMakeLists.txt + return() +endif() + if(NOT CONFIG_COMP_MODULE_SHARED_LIBRARY_BUILD) if(CONFIG_CADENCE_CODEC) add_local_sources(sof module/cadence.c) diff --git a/zephyr/CMakeLists.txt b/zephyr/CMakeLists.txt index a9ae9f1e0c92..dd4a5193b2ae 100644 --- a/zephyr/CMakeLists.txt +++ b/zephyr/CMakeLists.txt @@ -514,12 +514,6 @@ zephyr_library_sources_ifdef(CONFIG_SAMPLE_KEYPHRASE ${SOF_SAMPLES_PATH}/audio/detect_test.c ) -zephyr_library_sources_ifdef(CONFIG_COMP_MODULE_ADAPTER - ${SOF_AUDIO_PATH}/module_adapter/module_adapter.c - ${SOF_AUDIO_PATH}/module_adapter/module_adapter_${ipc_suffix}.c - ${SOF_AUDIO_PATH}/module_adapter/module/generic.c -) - zephyr_library_sources_ifdef(CONFIG_LIBRARY_MANAGER ${SOF_SRC_PATH}/library_manager/lib_manager.c ${SOF_SRC_PATH}/library_manager/lib_notification.c From eb06e5f031c7ef19961b93aa898f6a92ecbe110b Mon Sep 17 00:00:00 2001 From: Kai Vehmanen Date: Fri, 21 Mar 2025 11:10:54 +0200 Subject: [PATCH 02/11] cmake/zephyr: unify cmake rules for modules using module_adapter Adding all source files in a single, giant zephyr/CMakeLists.txt is inconvenient and does not scale. Modify Zephyr rules for Intel IADK and Cadence codec modules to use definitions in src/audio/module_adapter/ instead. Link: https://github.com/thesofproject/sof/issues/8260 Signed-off-by: Kai Vehmanen --- src/audio/module_adapter/CMakeLists.txt | 36 +++++++++++++++++++++++- zephyr/CMakeLists.txt | 37 ------------------------- 2 files changed, 35 insertions(+), 38 deletions(-) diff --git a/src/audio/module_adapter/CMakeLists.txt b/src/audio/module_adapter/CMakeLists.txt index f50c996f1f3b..6c1637f3520a 100644 --- a/src/audio/module_adapter/CMakeLists.txt +++ b/src/audio/module_adapter/CMakeLists.txt @@ -8,7 +8,41 @@ endif() is_zephyr(zephyr) if(zephyr) ### Zephyr ### - # codec build rules still in sof/zephyr/CMakeLists.txt + + # modules and codecs in alphabetical order + + zephyr_library_sources_ifdef(CONFIG_CADENCE_CODEC module/cadence.c) + + if (CONFIG_CADENCE_CODEC_AAC_DEC) + zephyr_library_import(xa_aac_dec ${CONFIG_CADENCE_CODEC_AAC_DEC_LIB}) + endif() + + if (CONFIG_CADENCE_CODEC_MP3_DEC) + zephyr_library_import(xa_mp3_dec ${CONFIG_CADENCE_CODEC_MP3_DEC_LIB}) + endif() + + if (CONFIG_CADENCE_CODEC_MP3_ENC) + zephyr_library_import(xa_mp3_enc ${CONFIG_CADENCE_CODEC_MP3_ENC_LIB}) + endif() + + zephyr_include_directories_ifdef(CONFIG_INTEL_MODULES + ${SOF_SRC_PATH}/include/sof/audio/module_adapter/iadk/ + ${SOF_SRC_PATH}/include/sof/audio/module_adapter/library/ + ) + + zephyr_library_sources_ifdef(CONFIG_INTEL_MODULES + module/modules.c + iadk/module_initial_settings_concrete.cpp + iadk/iadk_module_adapter.cpp + iadk/system_agent.cpp + library/native_system_agent.c + library/native_system_service.c + ) + + zephyr_library_sources_ifdef(CONFIG_PASSTHROUGH_CODEC + module/passthrough.c + ) + return() endif() diff --git a/zephyr/CMakeLists.txt b/zephyr/CMakeLists.txt index dd4a5193b2ae..de66d3b4500a 100644 --- a/zephyr/CMakeLists.txt +++ b/zephyr/CMakeLists.txt @@ -135,7 +135,6 @@ set(SOF_SRC_PATH "${sof_top_dir}/src") set(SOF_PLATFORM_PATH "${SOF_SRC_PATH}/platform") set(SOF_AUDIO_PATH "${SOF_SRC_PATH}/audio") -set(SOF_AUDIO_MODULES_PATH "${SOF_SRC_PATH}/audio/module_adapter/module") set(SOF_SAMPLES_PATH "${SOF_SRC_PATH}/samples") set(SOF_LIB_PATH "${SOF_SRC_PATH}/lib") set(SOF_DRIVERS_PATH "${SOF_SRC_PATH}/drivers") @@ -525,42 +524,6 @@ zephyr_library_sources_ifdef(CONFIG_LIBRARY_MANAGER ) endif() -zephyr_include_directories_ifdef(CONFIG_INTEL_MODULES - ${SOF_SRC_PATH}/include/sof/audio/module_adapter/iadk/ - ${SOF_SRC_PATH}/include/sof/audio/module_adapter/library/ -) - -zephyr_library_sources_ifdef(CONFIG_INTEL_MODULES - ${SOF_AUDIO_PATH}/module_adapter/module/modules.c - ${SOF_AUDIO_PATH}/module_adapter/iadk/module_initial_settings_concrete.cpp - ${SOF_AUDIO_PATH}/module_adapter/iadk/iadk_module_adapter.cpp - ${SOF_AUDIO_PATH}/module_adapter/iadk/system_agent.cpp - ${SOF_AUDIO_PATH}/module_adapter/library/native_system_agent.c - ${SOF_AUDIO_PATH}/module_adapter/library/native_system_service.c -) - -if (CONFIG_COMP_MODULE_ADAPTER) -zephyr_library_sources_ifdef(CONFIG_CADENCE_CODEC - ${SOF_AUDIO_PATH}/module_adapter/module/cadence.c -) - -if (CONFIG_CADENCE_CODEC_MP3_DEC) -zephyr_library_import(xa_mp3_dec ${CONFIG_CADENCE_CODEC_MP3_DEC_LIB}) -endif() - -if (CONFIG_CADENCE_CODEC_MP3_ENC) -zephyr_library_import(xa_mp3_enc ${CONFIG_CADENCE_CODEC_MP3_ENC_LIB}) -endif() - -if (CONFIG_CADENCE_CODEC_AAC_DEC) -zephyr_library_import(xa_aac_dec ${CONFIG_CADENCE_CODEC_AAC_DEC_LIB}) -endif() - -zephyr_library_sources_ifdef(CONFIG_PASSTHROUGH_CODEC - ${SOF_AUDIO_MODULES_PATH}/passthrough.c -) -endif() - zephyr_library_sources_ifdef(CONFIG_MAXIM_DSM ${SOF_AUDIO_PATH}/smart_amp/smart_amp.c ${SOF_AUDIO_PATH}/smart_amp/smart_amp_generic.c From 1fe5fafa5298294f6f3885f58e3c06daa54b61f5 Mon Sep 17 00:00:00 2001 From: Kai Vehmanen Date: Fri, 21 Mar 2025 14:05:31 +0200 Subject: [PATCH 03/11] cmake/zephyr: unify cmake rules for Waves codec Adding all source files in a single, giant zephyr/CMakeLists.txt is inconvenient and does not scale. Modify Zephyr rules to use definitions in src/audio/module_adapter/ to build Waves codec. Link: https://github.com/thesofproject/sof/issues/8260 Signed-off-by: Kai Vehmanen --- src/audio/module_adapter/CMakeLists.txt | 17 +++++++++++++++++ zephyr/CMakeLists.txt | 17 ----------------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/audio/module_adapter/CMakeLists.txt b/src/audio/module_adapter/CMakeLists.txt index 6c1637f3520a..4b0801404bc4 100644 --- a/src/audio/module_adapter/CMakeLists.txt +++ b/src/audio/module_adapter/CMakeLists.txt @@ -43,6 +43,23 @@ if(zephyr) ### Zephyr ### module/passthrough.c ) + if(CONFIG_WAVES_CODEC) + set(WAVES_DIR module/waves) + if(CONFIG_WAVES_CODEC STREQUAL "m") + add_subdirectory(${WAVES_DIR}/llext ${PROJECT_BINARY_DIR}/waves_llext) + add_dependencies(app waves) + else() + zephyr_library_sources(${WAVES_DIR}/waves.c) + if(CONFIG_WAVES_CODEC_STUB) + zephyr_library_sources_ifdef(CONFIG_WAVES_CODEC_STUB + ${WAVES_DIR}/maxx_stub.c) + else() + zephyr_library_import(waves_codec + ${sof_top_dir}/third_party/lib/libMaxxChrome.a) + endif() + endif() + endif() + return() endif() diff --git a/zephyr/CMakeLists.txt b/zephyr/CMakeLists.txt index de66d3b4500a..3b3c09ce166a 100644 --- a/zephyr/CMakeLists.txt +++ b/zephyr/CMakeLists.txt @@ -649,23 +649,6 @@ elseif(CONFIG_DTS_CODEC) endif() endif() -if(CONFIG_WAVES_CODEC) - set(WAVES_DIR ${SOF_AUDIO_PATH}/module_adapter/module/waves) - if(CONFIG_WAVES_CODEC STREQUAL "m") - add_subdirectory(${WAVES_DIR}/llext ${PROJECT_BINARY_DIR}/waves_llext) - add_dependencies(app waves) - else() - zephyr_library_sources(${WAVES_DIR}/waves.c) - if(CONFIG_WAVES_CODEC_STUB) - zephyr_library_sources_ifdef(CONFIG_WAVES_CODEC_STUB - ${WAVES_DIR}/maxx_stub.c) - else() - zephyr_library_import(waves_codec - ${sof_top_dir}/third_party/lib/libMaxxChrome.a) - endif() - endif() -endif() - if(CONFIG_PROBE STREQUAL "m") add_subdirectory(${SOF_SRC_PATH}/probe/llext ${PROJECT_BINARY_DIR}/probe_llext) From 688b740928c920d8aa5f3f4434eefc315492547a Mon Sep 17 00:00:00 2001 From: Kai Vehmanen Date: Fri, 21 Mar 2025 19:14:50 +0200 Subject: [PATCH 04/11] audio: codec: dts: align CMakeList.txt style Fix the cmake style to match Zephyr cmake style. The file had 8 space indents with one stray tab, so not matching anything else in the codebase and non consistent even within this one file. Signed-off-by: Kai Vehmanen --- src/audio/codec/CMakeLists.txt | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/audio/codec/CMakeLists.txt b/src/audio/codec/CMakeLists.txt index 0d14dbd98221..46ce11cb8e68 100644 --- a/src/audio/codec/CMakeLists.txt +++ b/src/audio/codec/CMakeLists.txt @@ -1,13 +1,15 @@ # SPDX-License-Identifier: BSD-3-Clause if(CONFIG_DTS_CODEC) - add_local_sources(sof dts/dts.c) - target_compile_definitions(sof PRIVATE -DDTS_MATH_INT32 -DDTS_XTENSA) - if (CONFIG_DTS_CODEC_STUB) - add_local_sources(sof dts/dts_stub.c) - else() - sof_add_static_library(DtsCodec - ${SOF_ROOT_SOURCE_DIRECTORY}/third_party/lib/libdts-sof-interface-i32.a) - target_include_directories(sof PRIVATE ${CMAKE_SOURCE_DIR}/third_party/include) - endif() + add_local_sources(sof dts/dts.c) + target_compile_definitions(sof PRIVATE -DDTS_MATH_INT32 -DDTS_XTENSA) + + if (CONFIG_DTS_CODEC_STUB) + add_local_sources(sof dts/dts_stub.c) + else() + sof_add_static_library(DtsCodec + ${SOF_ROOT_SOURCE_DIRECTORY}/third_party/lib/libdts-sof-interface-i32.a) + target_include_directories(sof PRIVATE ${CMAKE_SOURCE_DIR}/third_party/include) + endif() + endif() From 856db371522433507352367404f6bc7664bc35a0 Mon Sep 17 00:00:00 2001 From: Kai Vehmanen Date: Fri, 21 Mar 2025 14:34:21 +0200 Subject: [PATCH 05/11] cmake/zephyr: unify cmake rules for DTS src/audio/codec Adding all source files in a single, giant zephyr/CMakeLists.txt is inconvenient and does not scale. Modify Zephyr rules to use definitions in src/audio/codec instead to build for CONFIG_DTS_CODEC. Link: https://github.com/thesofproject/sof/issues/8260 Signed-off-by: Kai Vehmanen --- src/audio/CMakeLists.txt | 6 +++--- src/audio/codec/CMakeLists.txt | 21 +++++++++++++++++++++ zephyr/CMakeLists.txt | 18 ------------------ 3 files changed, 24 insertions(+), 21 deletions(-) diff --git a/src/audio/CMakeLists.txt b/src/audio/CMakeLists.txt index 802e837891b2..9334cfd225b3 100644 --- a/src/audio/CMakeLists.txt +++ b/src/audio/CMakeLists.txt @@ -92,6 +92,9 @@ if(NOT CONFIG_COMP_MODULE_SHARED_LIBRARY_BUILD) if(CONFIG_COMP_VOLUME) add_subdirectory(volume) endif() + if(CONFIG_DTS_CODEC) + add_subdirectory(codec) + endif() if(CONFIG_ZEPHYR_NATIVE_DRIVERS) list(APPEND base_files host-zephyr.c) sof_list_append_ifdef(CONFIG_COMP_DAI base_files dai-zephyr.c) @@ -143,9 +146,6 @@ if(NOT CONFIG_COMP_MODULE_SHARED_LIBRARY_BUILD) add_subdirectory(mic_privacy_manager) endif() add_subdirectory(google) - if(CONFIG_DTS_CODEC) - add_subdirectory(codec) - endif() return() endif() diff --git a/src/audio/codec/CMakeLists.txt b/src/audio/codec/CMakeLists.txt index 46ce11cb8e68..bdef3031ceb5 100644 --- a/src/audio/codec/CMakeLists.txt +++ b/src/audio/codec/CMakeLists.txt @@ -1,5 +1,26 @@ # SPDX-License-Identifier: BSD-3-Clause +is_zephyr(zephyr) +if(zephyr) ### Zephyr ### + + if(CONFIG_DTS_CODEC STREQUAL "m") + add_subdirectory(dts/llext ${PROJECT_BINARY_DIR}/dts_llext) + add_dependencies(app dts) + + else(CONFIG_DTS_CODEC) + zephyr_library_sources(dts/dts.c) + if (CONFIG_DTS_CODEC_STUB) + zephyr_library_sources(dts/dts_stub.c) + else() + zephyr_library_import(DtsCodec + ${sof_top_dir}/third_party/lib/libdts-sof-interface-i32.a) + endif() + endif() + + return() +endif() + +### XTOS ### if(CONFIG_DTS_CODEC) add_local_sources(sof dts/dts.c) target_compile_definitions(sof PRIVATE -DDTS_MATH_INT32 -DDTS_XTENSA) diff --git a/zephyr/CMakeLists.txt b/zephyr/CMakeLists.txt index 3b3c09ce166a..45377fcca419 100644 --- a/zephyr/CMakeLists.txt +++ b/zephyr/CMakeLists.txt @@ -631,24 +631,6 @@ zephyr_library_sources_ifdef(CONFIG_COMP_GOOGLE_HOTWORD_DETECT ${SOF_AUDIO_PATH}/google/google_hotword_detect.c ) -if(CONFIG_DTS_CODEC STREQUAL "m") - add_subdirectory(${SOF_AUDIO_PATH}/codec/dts/llext - ${PROJECT_BINARY_DIR}/dts_llext) - add_dependencies(app dts) -elseif(CONFIG_DTS_CODEC) - zephyr_library_sources( - ${SOF_AUDIO_PATH}/codec/dts/dts.c - ) - if (CONFIG_DTS_CODEC_STUB) - zephyr_library_sources( - ${SOF_AUDIO_PATH}/codec/dts/dts_stub.c - ) - else() - zephyr_library_import(DtsCodec - ${sof_top_dir}/third_party/lib/libdts-sof-interface-i32.a) - endif() -endif() - if(CONFIG_PROBE STREQUAL "m") add_subdirectory(${SOF_SRC_PATH}/probe/llext ${PROJECT_BINARY_DIR}/probe_llext) From 40f840c73d029917d07b35d144f0589b8134ca82 Mon Sep 17 00:00:00 2001 From: Kai Vehmanen Date: Fri, 21 Mar 2025 14:35:43 +0200 Subject: [PATCH 06/11] cmake/zephyr: unify cmake rules for src/audio/google Adding all source files in a single, giant zephyr/CMakeLists.txt is inconvenient and does not scale. Modify Zephyr rules to use definitions in src/audio/google instead to build Google CTS and RTC modules. Link: https://github.com/thesofproject/sof/issues/8260 Signed-off-by: Kai Vehmanen --- src/audio/CMakeLists.txt | 2 +- src/audio/google/CMakeLists.txt | 62 +++++++++++++++++++++++++++++++++ zephyr/CMakeLists.txt | 50 -------------------------- 3 files changed, 63 insertions(+), 51 deletions(-) diff --git a/src/audio/CMakeLists.txt b/src/audio/CMakeLists.txt index 9334cfd225b3..71747a375a5d 100644 --- a/src/audio/CMakeLists.txt +++ b/src/audio/CMakeLists.txt @@ -95,6 +95,7 @@ if(NOT CONFIG_COMP_MODULE_SHARED_LIBRARY_BUILD) if(CONFIG_DTS_CODEC) add_subdirectory(codec) endif() + add_subdirectory(google) if(CONFIG_ZEPHYR_NATIVE_DRIVERS) list(APPEND base_files host-zephyr.c) sof_list_append_ifdef(CONFIG_COMP_DAI base_files dai-zephyr.c) @@ -145,7 +146,6 @@ if(NOT CONFIG_COMP_MODULE_SHARED_LIBRARY_BUILD) if(CONFIG_INTEL_ADSP_MIC_PRIVACY) add_subdirectory(mic_privacy_manager) endif() - add_subdirectory(google) return() endif() diff --git a/src/audio/google/CMakeLists.txt b/src/audio/google/CMakeLists.txt index a53374e3a95a..dd6ff653b3ee 100644 --- a/src/audio/google/CMakeLists.txt +++ b/src/audio/google/CMakeLists.txt @@ -1,5 +1,67 @@ # SPDX-License-Identifier: BSD-3-Clause +is_zephyr(zephyr) +if(zephyr) ### Zephyr ### + + set(THIRD_PARTY ${SOF_ROOT_SOURCE_DIRECTORY}/third_party) + if(CONFIG_IPC_MAJOR_3) + set(ipc_suffix ipc3) + elseif(CONFIG_IPC_MAJOR_4) + set(ipc_suffix ipc4) + endif() + + if(CONFIG_COMP_GOOGLE_RTC_AUDIO_PROCESSING STREQUAL "m") + add_subdirectory(llext_rtc + ${PROJECT_BINARY_DIR}/google_rtc_audio_processing_llext) + add_dependencies(app google_rtc_audio_processing) + elseif(CONFIG_COMP_GOOGLE_RTC_AUDIO_PROCESSING) + zephyr_library_sources(google_rtc_audio_processing.c) + + zephyr_library_sources_ifdef(CONFIG_GOOGLE_RTC_AUDIO_PROCESSING_MOCK + google_rtc_audio_processing_mock.c + ) + + if(NOT CONFIG_GOOGLE_RTC_AUDIO_PROCESSING_MOCK) + zephyr_include_directories(${THIRD_PARTY}/include) + target_link_directories(SOF INTERFACE ${THIRD_PARTY}/lib) + target_link_libraries(SOF INTERFACE google_rtc_audio_processing) + target_link_libraries(SOF INTERFACE c++) + target_link_libraries(SOF INTERFACE c++abi) + target_link_libraries(SOF INTERFACE m) + target_link_libraries(SOF INTERFACE c) + target_link_libraries(SOF INTERFACE gcc) + endif() + endif() + + if(CONFIG_COMP_GOOGLE_CTC_AUDIO_PROCESSING STREQUAL "m") + add_subdirectory(llext_ctc + ${PROJECT_BINARY_DIR}/google_ctc_audio_processing_llext) + add_dependencies(app google_ctc_audio_processing) + elseif(CONFIG_COMP_GOOGLE_CTC_AUDIO_PROCESSING) + zephyr_library_sources( + google_ctc_audio_processing.c + google_ctc_audio_processing_${ipc_suffix}.c + ) + zephyr_library_sources_ifdef(CONFIG_GOOGLE_CTC_AUDIO_PROCESSING_MOCK + google_ctc_audio_processing_mock.c + ) + + if(NOT CONFIG_GOOGLE_CTC_AUDIO_PROCESSING_MOCK) + zephyr_include_directories(${THIRD_PARTY}/include) + target_link_directories(SOF INTERFACE ${THIRD_PARTY}/lib) + target_link_libraries(SOF INTERFACE google_ctc_audio_processing) + target_link_libraries(SOF INTERFACE c++) + target_link_libraries(SOF INTERFACE c++abi) + target_link_libraries(SOF INTERFACE m) + target_link_libraries(SOF INTERFACE c) + target_link_libraries(SOF INTERFACE gcc) + endif() + endif() + + return() +endif() + +### XTOS build rules ### if((NOT CONFIG_LIBRARY) OR CONFIG_LIBRARY_STATIC) if(CONFIG_COMP_GOOGLE_HOTWORD_DETECT) add_local_sources(sof diff --git a/zephyr/CMakeLists.txt b/zephyr/CMakeLists.txt index 45377fcca419..a190174462c3 100644 --- a/zephyr/CMakeLists.txt +++ b/zephyr/CMakeLists.txt @@ -538,56 +538,6 @@ zephyr_library_sources_ifdef(CONFIG_MAXIM_DSM_STUB ${SOF_AUDIO_PATH}/smart_amp/maxim_dsm_stub.c ) -if(CONFIG_COMP_GOOGLE_RTC_AUDIO_PROCESSING STREQUAL "m") - add_subdirectory(${SOF_AUDIO_PATH}/google/llext_rtc - ${PROJECT_BINARY_DIR}/google_rtc_audio_processing_llext) - add_dependencies(app google_rtc_audio_processing) -elseif(CONFIG_COMP_GOOGLE_RTC_AUDIO_PROCESSING) - zephyr_library_sources( - ${SOF_AUDIO_PATH}/google/google_rtc_audio_processing.c - ) - - zephyr_library_sources_ifdef(CONFIG_GOOGLE_RTC_AUDIO_PROCESSING_MOCK - ${SOF_AUDIO_PATH}/google/google_rtc_audio_processing_mock.c - ) - - if(NOT CONFIG_GOOGLE_RTC_AUDIO_PROCESSING_MOCK) - zephyr_include_directories(../third_party/include) - target_link_directories(SOF INTERFACE ../third_party/lib) - target_link_libraries(SOF INTERFACE google_rtc_audio_processing) - target_link_libraries(SOF INTERFACE c++) - target_link_libraries(SOF INTERFACE c++abi) - target_link_libraries(SOF INTERFACE m) - target_link_libraries(SOF INTERFACE c) - target_link_libraries(SOF INTERFACE gcc) - endif() -endif() - -if(CONFIG_COMP_GOOGLE_CTC_AUDIO_PROCESSING STREQUAL "m") - add_subdirectory(${SOF_AUDIO_PATH}/google/llext_ctc - ${PROJECT_BINARY_DIR}/google_ctc_audio_processing_llext) - add_dependencies(app google_ctc_audio_processing) -elseif(CONFIG_COMP_GOOGLE_CTC_AUDIO_PROCESSING) - zephyr_library_sources( - ${SOF_AUDIO_PATH}/google/google_ctc_audio_processing.c - ${SOF_AUDIO_PATH}/google/google_ctc_audio_processing_${ipc_suffix}.c - ) - - zephyr_library_sources_ifdef(CONFIG_GOOGLE_CTC_AUDIO_PROCESSING_MOCK - ${SOF_AUDIO_PATH}/google/google_ctc_audio_processing_mock.c - ) - - if(NOT CONFIG_GOOGLE_CTC_AUDIO_PROCESSING_MOCK) - zephyr_include_directories(../third_party/include) - target_link_directories(SOF INTERFACE ../third_party/lib) - target_link_libraries(SOF INTERFACE google_ctc_audio_processing) - target_link_libraries(SOF INTERFACE c++) - target_link_libraries(SOF INTERFACE c++abi) - target_link_libraries(SOF INTERFACE m) - target_link_libraries(SOF INTERFACE c) - target_link_libraries(SOF INTERFACE gcc) - endif() -endif() if(CONFIG_COMP_IGO_NR STREQUAL "m") add_subdirectory(${SOF_AUDIO_PATH}/igo_nr/llext From 08524b3c3d04bdb1f1922a53a04d990389031984 Mon Sep 17 00:00:00 2001 From: Kai Vehmanen Date: Fri, 21 Mar 2025 16:07:01 +0200 Subject: [PATCH 07/11] cmake/zephyr: unify cmake rules for src/audio/smart_amp Adding all source files in a single, giant zephyr/CMakeLists.txt is inconvenient and does not scale. Modify Zephyr rules to use definitions in src/audio/smart_amp instead. Link: https://github.com/thesofproject/sof/issues/8260 Signed-off-by: Kai Vehmanen --- src/audio/CMakeLists.txt | 6 +++--- src/audio/smart_amp/CMakeLists.txt | 34 ++++++++++++++++++++++++------ zephyr/CMakeLists.txt | 15 ------------- 3 files changed, 30 insertions(+), 25 deletions(-) diff --git a/src/audio/CMakeLists.txt b/src/audio/CMakeLists.txt index 71747a375a5d..470d3725ab11 100644 --- a/src/audio/CMakeLists.txt +++ b/src/audio/CMakeLists.txt @@ -75,6 +75,9 @@ if(NOT CONFIG_COMP_MODULE_SHARED_LIBRARY_BUILD) if(CONFIG_COMP_SEL) add_subdirectory(selector) endif() + if(CONFIG_COMP_SMART_AMP) + add_subdirectory(smart_amp) + endif() if(CONFIG_COMP_SRC) add_subdirectory(src) endif() @@ -134,9 +137,6 @@ if(NOT CONFIG_COMP_MODULE_SHARED_LIBRARY_BUILD) dai-legacy.c ) endif() - if(CONFIG_COMP_SMART_AMP) - add_subdirectory(smart_amp) - endif() if(CONFIG_COMP_IGO_NR) add_subdirectory(igo_nr) endif() diff --git a/src/audio/smart_amp/CMakeLists.txt b/src/audio/smart_amp/CMakeLists.txt index 387381057804..22d23b2820f9 100644 --- a/src/audio/smart_amp/CMakeLists.txt +++ b/src/audio/smart_amp/CMakeLists.txt @@ -3,13 +3,33 @@ add_local_sources(sof smart_amp.c smart_amp_generic.c) if(CONFIG_MAXIM_DSM) -add_local_sources(sof smart_amp_maxim_dsm.c) -if(CONFIG_MAXIM_DSM_STUB) -add_local_sources(sof maxim_dsm_stub.c) + add_local_sources(sof smart_amp_maxim_dsm.c) + if(CONFIG_MAXIM_DSM_STUB) + add_local_sources(sof maxim_dsm_stub.c) + endif() else() -sof_add_static_library(dsm ${CMAKE_CURRENT_LIST_DIR}/lib/release/dsm_lib/libdsm.a) + add_local_sources(sof smart_amp_passthru.c) endif() -target_include_directories(sof PUBLIC ${CMAKE_CURRENT_LIST_DIR}/include/dsm_api/inc) -else() -add_local_sources(sof smart_amp_passthru.c) + +is_zephyr(zephyr) +if(zephyr) ### Zephyr ### + + if(CONFIG_MAXIM_DSM) + if(NOT CONFIG_MAXIM_DSM_STUB) + zephyr_library_import(dsm ${CMAKE_CURRENT_LIST_DIR}/lib/release/dsm_lib/libdsm.a) + endif() + + zephyr_include_directories(CONFIG_MAXIM_DSM ${CMAKE_CURRENT_LIST_DIR}/include/dsm_api/inc/) + endif() + +else() ### XTOS + + if(CONFIG_MAXIM_DSM) + if(NOT CONFIG_MAXIM_DSM_STUB) + sof_add_static_library(dsm ${CMAKE_CURRENT_LIST_DIR}/lib/release/dsm_lib/libdsm.a) + endif() + + target_include_directories(sof PUBLIC ${CMAKE_CURRENT_LIST_DIR}/include/dsm_api/inc) + endif() + endif() diff --git a/zephyr/CMakeLists.txt b/zephyr/CMakeLists.txt index a190174462c3..83ddfff3303f 100644 --- a/zephyr/CMakeLists.txt +++ b/zephyr/CMakeLists.txt @@ -524,21 +524,6 @@ zephyr_library_sources_ifdef(CONFIG_LIBRARY_MANAGER ) endif() -zephyr_library_sources_ifdef(CONFIG_MAXIM_DSM - ${SOF_AUDIO_PATH}/smart_amp/smart_amp.c - ${SOF_AUDIO_PATH}/smart_amp/smart_amp_generic.c - ${SOF_AUDIO_PATH}/smart_amp/smart_amp_maxim_dsm.c -) - -zephyr_include_directories_ifdef(CONFIG_MAXIM_DSM - ${SOF_AUDIO_PATH}/smart_amp/include/dsm_api/inc/ -) - -zephyr_library_sources_ifdef(CONFIG_MAXIM_DSM_STUB - ${SOF_AUDIO_PATH}/smart_amp/maxim_dsm_stub.c -) - - if(CONFIG_COMP_IGO_NR STREQUAL "m") add_subdirectory(${SOF_AUDIO_PATH}/igo_nr/llext ${PROJECT_BINARY_DIR}/igo_nr_llext) From e232f7caba94cae7f0f1be0f2e9f67670774a24d Mon Sep 17 00:00:00 2001 From: Kai Vehmanen Date: Fri, 21 Mar 2025 18:30:52 +0200 Subject: [PATCH 08/11] cmake/zephyr: unify cmake rules for src/audio/igo_nr Adding all source files in a single, giant zephyr/CMakeLists.txt is inconvenient and does not scale. Modify Zephyr rules to use definitions in src/audio/igo_nr instead. Link: https://github.com/thesofproject/sof/issues/8260 Signed-off-by: Kai Vehmanen --- src/audio/CMakeLists.txt | 6 +++--- src/audio/igo_nr/CMakeLists.txt | 22 ++++++++++++++++++---- zephyr/CMakeLists.txt | 14 -------------- 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/audio/CMakeLists.txt b/src/audio/CMakeLists.txt index 470d3725ab11..19516f4762f9 100644 --- a/src/audio/CMakeLists.txt +++ b/src/audio/CMakeLists.txt @@ -46,6 +46,9 @@ if(NOT CONFIG_COMP_MODULE_SHARED_LIBRARY_BUILD) if(CONFIG_COMP_FIR) add_subdirectory(eq_fir) endif() + if(CONFIG_COMP_IGO_NR) + add_subdirectory(igo_nr) + endif() if(CONFIG_COMP_IIR) add_subdirectory(eq_iir) endif() @@ -137,9 +140,6 @@ if(NOT CONFIG_COMP_MODULE_SHARED_LIBRARY_BUILD) dai-legacy.c ) endif() - if(CONFIG_COMP_IGO_NR) - add_subdirectory(igo_nr) - endif() if(CONFIG_COMP_RTNR) add_subdirectory(rtnr) endif() diff --git a/src/audio/igo_nr/CMakeLists.txt b/src/audio/igo_nr/CMakeLists.txt index 49f9af9a2003..8ee1709ff5d6 100644 --- a/src/audio/igo_nr/CMakeLists.txt +++ b/src/audio/igo_nr/CMakeLists.txt @@ -1,8 +1,22 @@ # SPDX-License-Identifier: BSD-3-Clause +if(CONFIG_COMP_IGO_NR STREQUAL "m") + add_subdirectory(llext ${PROJECT_BINARY_DIR}/igo_nr_llext) + add_dependencies(app igo_nr) + return() +endif() + add_local_sources(sof igo_nr.c) + if (CONFIG_COMP_IGO_NR_STUB) -add_local_sources(sof igo_nr_stub.c) -else () -sof_add_static_library(IGOChrome ${CMAKE_CURRENT_LIST_DIR}/libigonr.a) -endif () + add_local_sources(sof igo_nr_stub.c) + +else() + is_zephyr(zephyr) + if(zephyr) ### Zephyr ### + zephyr_library_import(IGOChrome ${CMAKE_CURRENT_LIST_DIR}/libigonr.a) + else() + sof_add_static_library(IGOChrome ${CMAKE_CURRENT_LIST_DIR}/libigonr.a) + endif() + +endif() diff --git a/zephyr/CMakeLists.txt b/zephyr/CMakeLists.txt index 83ddfff3303f..f378767cb51d 100644 --- a/zephyr/CMakeLists.txt +++ b/zephyr/CMakeLists.txt @@ -524,20 +524,6 @@ zephyr_library_sources_ifdef(CONFIG_LIBRARY_MANAGER ) endif() -if(CONFIG_COMP_IGO_NR STREQUAL "m") - add_subdirectory(${SOF_AUDIO_PATH}/igo_nr/llext - ${PROJECT_BINARY_DIR}/igo_nr_llext) - add_dependencies(app igo_nr) -elseif(CONFIG_COMP_IGO_NR) - zephyr_library_sources( - ${SOF_AUDIO_PATH}/igo_nr/igo_nr.c - ) - - zephyr_library_sources_ifdef(CONFIG_COMP_IGO_NR_STUB - ${SOF_AUDIO_PATH}/igo_nr/igo_nr_stub.c - ) -endif() - if(CONFIG_COMP_RTNR STREQUAL "m") add_subdirectory(${SOF_AUDIO_PATH}/rtnr/llext ${PROJECT_BINARY_DIR}/rtnr_llext) From 738c5f9c1a961d5d82f0742dac5dac096d50caca Mon Sep 17 00:00:00 2001 From: Kai Vehmanen Date: Fri, 21 Mar 2025 18:34:04 +0200 Subject: [PATCH 09/11] cmake/zephyr: unify cmake rules for google_hotword_detect Adding all source files in a single, giant zephyr/CMakeLists.txt is inconvenient and does not scale. Modify Zephyr rules to use definitions in src/audio/google/ instead. Link: https://github.com/thesofproject/sof/issues/8260 Signed-off-by: Kai Vehmanen --- src/audio/google/CMakeLists.txt | 4 ++++ zephyr/CMakeLists.txt | 4 ---- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/audio/google/CMakeLists.txt b/src/audio/google/CMakeLists.txt index dd6ff653b3ee..d4d89ec8778a 100644 --- a/src/audio/google/CMakeLists.txt +++ b/src/audio/google/CMakeLists.txt @@ -10,6 +10,10 @@ if(zephyr) ### Zephyr ### set(ipc_suffix ipc4) endif() + zephyr_library_sources_ifdef(CONFIG_COMP_GOOGLE_HOTWORD_DETECT + google_hotword_detect.c + ) + if(CONFIG_COMP_GOOGLE_RTC_AUDIO_PROCESSING STREQUAL "m") add_subdirectory(llext_rtc ${PROJECT_BINARY_DIR}/google_rtc_audio_processing_llext) diff --git a/zephyr/CMakeLists.txt b/zephyr/CMakeLists.txt index f378767cb51d..0efce01b5cf3 100644 --- a/zephyr/CMakeLists.txt +++ b/zephyr/CMakeLists.txt @@ -548,10 +548,6 @@ elseif(CONFIG_SAMPLE_SMART_AMP) ) endif() -zephyr_library_sources_ifdef(CONFIG_COMP_GOOGLE_HOTWORD_DETECT - ${SOF_AUDIO_PATH}/google/google_hotword_detect.c -) - if(CONFIG_PROBE STREQUAL "m") add_subdirectory(${SOF_SRC_PATH}/probe/llext ${PROJECT_BINARY_DIR}/probe_llext) From 8bbe7c68c5fa9437dab1e1c271469ab83daa7bbd Mon Sep 17 00:00:00 2001 From: Kai Vehmanen Date: Fri, 21 Mar 2025 18:40:18 +0200 Subject: [PATCH 10/11] cmake/zephyr: unify cmake rules for src/audio/rtnr Adding all source files in a single, giant zephyr/CMakeLists.txt is inconvenient and does not scale. Modify Zephyr rules to use definitions in src/audio/rtnr instead. Link: https://github.com/thesofproject/sof/issues/8260 Signed-off-by: Kai Vehmanen --- src/audio/CMakeLists.txt | 6 +++--- src/audio/rtnr/CMakeLists.txt | 31 +++++++++++++++++++++++-------- zephyr/CMakeLists.txt | 14 -------------- 3 files changed, 26 insertions(+), 25 deletions(-) diff --git a/src/audio/CMakeLists.txt b/src/audio/CMakeLists.txt index 19516f4762f9..f927949174bc 100644 --- a/src/audio/CMakeLists.txt +++ b/src/audio/CMakeLists.txt @@ -75,6 +75,9 @@ if(NOT CONFIG_COMP_MODULE_SHARED_LIBRARY_BUILD) if(CONFIG_COMP_MUX) add_subdirectory(mux) endif() + if(CONFIG_COMP_RTNR) + add_subdirectory(rtnr) + endif() if(CONFIG_COMP_SEL) add_subdirectory(selector) endif() @@ -140,9 +143,6 @@ if(NOT CONFIG_COMP_MODULE_SHARED_LIBRARY_BUILD) dai-legacy.c ) endif() - if(CONFIG_COMP_RTNR) - add_subdirectory(rtnr) - endif() if(CONFIG_INTEL_ADSP_MIC_PRIVACY) add_subdirectory(mic_privacy_manager) endif() diff --git a/src/audio/rtnr/CMakeLists.txt b/src/audio/rtnr/CMakeLists.txt index dc396d5d9035..034bd339a9ae 100644 --- a/src/audio/rtnr/CMakeLists.txt +++ b/src/audio/rtnr/CMakeLists.txt @@ -1,11 +1,26 @@ # SPDX-License-Identifier: BSD-3-Clause -add_local_sources(sof rtnr.c) - -if (CONFIG_COMP_RTNR_STUB) - add_local_sources(sof rtnr_stub.c) -elseif(CONFIG_TIGERLAKE) - add_subdirectory(rtklib/tgl) -elseif(CONFIG_MT8195) - add_subdirectory(rtklib/mt8195) +if(CONFIG_COMP_RTNR STREQUAL "m") + add_subdirectory(llext ${PROJECT_BINARY_DIR}/rtnr_llext) + add_dependencies(app rtnr) + return() +endif() + +is_zephyr(zephyr) +if(zephyr) ### Zephyr ### + + zephyr_library_sources(rtnr.c) + zephyr_library_sources_ifdef(CONFIG_COMP_RTNR_STUB rtnr_stub.c) + +else() ### XTOS ### + + add_local_sources(sof rtnr.c) + if (CONFIG_COMP_RTNR_STUB) + add_local_sources(sof rtnr_stub.c) + elseif(CONFIG_TIGERLAKE) + add_subdirectory(rtklib/tgl) + elseif(CONFIG_MT8195) + add_subdirectory(rtklib/mt8195) + endif() + endif() diff --git a/zephyr/CMakeLists.txt b/zephyr/CMakeLists.txt index 0efce01b5cf3..eb74c989126e 100644 --- a/zephyr/CMakeLists.txt +++ b/zephyr/CMakeLists.txt @@ -524,20 +524,6 @@ zephyr_library_sources_ifdef(CONFIG_LIBRARY_MANAGER ) endif() -if(CONFIG_COMP_RTNR STREQUAL "m") - add_subdirectory(${SOF_AUDIO_PATH}/rtnr/llext - ${PROJECT_BINARY_DIR}/rtnr_llext) - add_dependencies(app rtnr) -elseif(CONFIG_COMP_RTNR) - zephyr_library_sources( - ${SOF_AUDIO_PATH}/rtnr/rtnr.c - ) - - zephyr_library_sources_ifdef(CONFIG_COMP_RTNR_STUB - ${SOF_AUDIO_PATH}/rtnr/rtnr_stub.c - ) -endif() - if(CONFIG_SAMPLE_SMART_AMP STREQUAL "m") add_subdirectory(${SOF_SAMPLES_PATH}/audio/smart_amp_test_llext ${PROJECT_BINARY_DIR}/smart_amp_test_llext) From 191abcf30a2b061202fe395bf5cbd2e0226644cc Mon Sep 17 00:00:00 2001 From: Kai Vehmanen Date: Fri, 21 Mar 2025 18:42:25 +0200 Subject: [PATCH 11/11] cmake/zephyr: unify cmake rules for src/audio/mic_privacy Adding all source files in a single, giant zephyr/CMakeLists.txt is inconvenient and does not scale. Modify Zephyr rules to use definitions in src/audio/mic_privacy instead. Link: https://github.com/thesofproject/sof/issues/8260 Signed-off-by: Kai Vehmanen --- src/audio/CMakeLists.txt | 6 +++--- zephyr/CMakeLists.txt | 5 ----- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/src/audio/CMakeLists.txt b/src/audio/CMakeLists.txt index f927949174bc..53626f45419d 100644 --- a/src/audio/CMakeLists.txt +++ b/src/audio/CMakeLists.txt @@ -105,6 +105,9 @@ if(NOT CONFIG_COMP_MODULE_SHARED_LIBRARY_BUILD) add_subdirectory(codec) endif() add_subdirectory(google) + if(CONFIG_INTEL_ADSP_MIC_PRIVACY) + add_subdirectory(mic_privacy_manager) + endif() if(CONFIG_ZEPHYR_NATIVE_DRIVERS) list(APPEND base_files host-zephyr.c) sof_list_append_ifdef(CONFIG_COMP_DAI base_files dai-zephyr.c) @@ -143,9 +146,6 @@ if(NOT CONFIG_COMP_MODULE_SHARED_LIBRARY_BUILD) dai-legacy.c ) endif() - if(CONFIG_INTEL_ADSP_MIC_PRIVACY) - add_subdirectory(mic_privacy_manager) - endif() return() endif() diff --git a/zephyr/CMakeLists.txt b/zephyr/CMakeLists.txt index eb74c989126e..9f485cdae8c0 100644 --- a/zephyr/CMakeLists.txt +++ b/zephyr/CMakeLists.txt @@ -134,7 +134,6 @@ cmake_path(SET sof_top_dir NORMALIZE "${CMAKE_CURRENT_SOURCE_DIR}/..") set(SOF_SRC_PATH "${sof_top_dir}/src") set(SOF_PLATFORM_PATH "${SOF_SRC_PATH}/platform") -set(SOF_AUDIO_PATH "${SOF_SRC_PATH}/audio") set(SOF_SAMPLES_PATH "${SOF_SRC_PATH}/samples") set(SOF_LIB_PATH "${SOF_SRC_PATH}/lib") set(SOF_DRIVERS_PATH "${SOF_SRC_PATH}/drivers") @@ -571,10 +570,6 @@ zephyr_library_sources_ifdef(CONFIG_SHELL sof_shell.c ) -zephyr_library_sources_ifdef(CONFIG_INTEL_ADSP_MIC_PRIVACY - ${SOF_AUDIO_PATH}/mic_privacy_manager/mic_privacy_manager_intel.c -) - zephyr_library_link_libraries(SOF) target_link_libraries(SOF INTERFACE zephyr_interface)