diff --git a/scripts/cmake/misc.cmake b/scripts/cmake/misc.cmake index 77ae05ee2754..647b69c8c478 100644 --- a/scripts/cmake/misc.cmake +++ b/scripts/cmake/misc.cmake @@ -58,6 +58,14 @@ macro(add_local_sources_ifdef condition target) endif() endmacro() +# helper macro used similarly as add_local_sources_ifdef +# Zephyr duplicate in sof/zephyr/CMakeLists.txt; keep in sync +macro(sof_list_append_ifdef feature_toggle list) + if(${${feature_toggle}}) + list(APPEND ${list} ${ARGN}) + endif() +endmacro() + # Adds sources to target like target_sources, but assumes that # paths are relative to subdirectory. # Works like: diff --git a/src/audio/CMakeLists.txt b/src/audio/CMakeLists.txt index 0ef1083e3ae8..2810a0e452de 100644 --- a/src/audio/CMakeLists.txt +++ b/src/audio/CMakeLists.txt @@ -1,23 +1,24 @@ # SPDX-License-Identifier: BSD-3-Clause -if(NOT CONFIG_COMP_MODULE_SHARED_LIBRARY_BUILD) - add_local_sources(sof - host-legacy.c - component.c - source_api_helper.c - sink_api_helper.c - sink_source_utils.c - audio_stream.c - channel_map.c - ) +set(base_files + channel_map.c + component.c + source_api_helper.c + sink_api_helper.c + sink_source_utils.c + audio_stream.c + channel_map.c +) +### Common actions for Zephyr/XTOS ### +if(NOT CONFIG_COMP_MODULE_SHARED_LIBRARY_BUILD) add_subdirectory(buffers) - - if(CONFIG_COMP_BLOB) - add_local_sources(sof data_blob.c) + add_subdirectory(pipeline) + if(CONFIG_COMP_ASRC) + add_subdirectory(asrc) endif() - if(CONFIG_COMP_SRC) - add_subdirectory(src) + if(CONFIG_COMP_DCBLOCK) + add_subdirectory(dcblock) endif() if(CONFIG_COMP_FIR) add_subdirectory(eq_fir) @@ -25,9 +26,47 @@ if(NOT CONFIG_COMP_MODULE_SHARED_LIBRARY_BUILD) if(CONFIG_COMP_IIR) add_subdirectory(eq_iir) endif() - if(CONFIG_COMP_DCBLOCK) - add_subdirectory(dcblock) + if(CONFIG_COMP_KPB AND NOT CONFIG_LIBRARY_STATIC) + add_local_sources(sof + kpb.c + ) + endif() + if(CONFIG_COMP_SEL) + add_subdirectory(selector) + endif() + if(CONFIG_COMP_SRC) + add_subdirectory(src) + 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) + else() + list(APPEND base_files host-legacy.c) + sof_list_append_ifdef(CONFIG_COMP_DAI base_files dai-legacy.c) endif() +endif() + +sof_list_append_ifdef(CONFIG_COMP_BLOB base_files data_blob.c) + +is_zephyr(it_is) +if(it_is) ### Zephyr ### + + zephyr_library_sources( + ${base_files} + ) + + return() +endif() + +### XTOS normal build (not shared library) ### + +if(NOT CONFIG_COMP_MODULE_SHARED_LIBRARY_BUILD) + add_local_sources(sof + host-legacy.c + ${base_files} + ) + if(CONFIG_COMP_CROSSOVER) add_subdirectory(crossover) endif() @@ -59,21 +98,10 @@ if(NOT CONFIG_COMP_MODULE_SHARED_LIBRARY_BUILD) dai-legacy.c ) endif() - if(CONFIG_COMP_KPB AND NOT CONFIG_LIBRARY_STATIC) - add_local_sources(sof - kpb.c - ) - endif() - if(CONFIG_COMP_SEL) - add_subdirectory(selector) - endif() if(CONFIG_COMP_SMART_AMP) add_subdirectory(smart_amp) endif() add_subdirectory(pcm_converter) - if(CONFIG_COMP_ASRC) - add_subdirectory(asrc) - endif() if(CONFIG_COMP_MODULE_ADAPTER) add_subdirectory(module_adapter) endif() @@ -106,7 +134,6 @@ if(NOT CONFIG_COMP_MODULE_SHARED_LIBRARY_BUILD) if(CONFIG_INTEL_ADSP_MIC_PRIVACY) add_subdirectory(mic_privacy_manager) endif() - subdirs(pipeline) add_subdirectory(google) if(CONFIG_COMP_CHAIN_DMA) add_local_sources(sof chain_dma.c) @@ -118,6 +145,8 @@ if(NOT CONFIG_COMP_MODULE_SHARED_LIBRARY_BUILD) return() endif() +### Shared library build (CONFIG_COMP_MODULE_SHARED_LIBRARY_BUILD) ### + subdirs(pipeline) if(CONFIG_COMP_MODULE_ADAPTER) @@ -125,15 +154,10 @@ if(CONFIG_COMP_MODULE_ADAPTER) endif() add_local_sources(sof - component.c data_blob.c buffers/comp_buffer.c buffers/audio_buffer.c - source_api_helper.c - sink_api_helper.c - sink_source_utils.c - audio_stream.c - channel_map.c + ${base_files} ) # Audio Modules with various optimizaitons diff --git a/src/audio/asrc/CMakeLists.txt b/src/audio/asrc/CMakeLists.txt index 44f68d3c902c..51fa3565c65d 100644 --- a/src/audio/asrc/CMakeLists.txt +++ b/src/audio/asrc/CMakeLists.txt @@ -1,10 +1,16 @@ # SPDX-License-Identifier: BSD-3-Clause +if(CONFIG_COMP_ASRC STREQUAL "m") + add_subdirectory(llext ${PROJECT_BINARY_DIR}/asrc_llext) + add_dependencies(app asrc) + return() +endif() + add_local_sources(sof asrc.c asrc_farrow.c asrc_farrow_generic.c - asrc_farrow_hifi3.c asrc_farrow_hifi5.c) + asrc_farrow_hifi3.c asrc_farrow_hifi5.c) if(CONFIG_IPC_MAJOR_3) - add_local_sources(sof asrc_ipc3.c) + add_local_sources(sof asrc_ipc3.c) elseif(CONFIG_IPC_MAJOR_4) - add_local_sources(sof asrc_ipc4.c) + add_local_sources(sof asrc_ipc4.c) endif() diff --git a/src/audio/buffers/CMakeLists.txt b/src/audio/buffers/CMakeLists.txt index 944a84dedb7e..b035b055b449 100644 --- a/src/audio/buffers/CMakeLists.txt +++ b/src/audio/buffers/CMakeLists.txt @@ -1,8 +1,5 @@ # SPDX-License-Identifier: BSD-3-Clause -add_local_sources(sof audio_buffer.c) -add_local_sources(sof comp_buffer.c) +add_local_sources(sof audio_buffer.c comp_buffer.c) -if(CONFIG_PIPELINE_2_0) - add_local_sources(sof ring_buffer.c) -endif() +add_local_sources_ifdef(CONFIG_PIPELINE_2_0 sof ring_buffer.c) diff --git a/src/audio/dcblock/CMakeLists.txt b/src/audio/dcblock/CMakeLists.txt index a433b0629eeb..c97b957552ab 100644 --- a/src/audio/dcblock/CMakeLists.txt +++ b/src/audio/dcblock/CMakeLists.txt @@ -1,10 +1,16 @@ +if(CONFIG_COMP_DCBLOCK STREQUAL "m") + add_subdirectory(llext ${PROJECT_BINARY_DIR}/dcblock_llext) + add_dependencies(app dcblock) + return() +endif() + add_local_sources(sof dcblock.c) add_local_sources(sof dcblock_generic.c) add_local_sources(sof dcblock_hifi3.c) add_local_sources(sof dcblock_hifi4.c) if(CONFIG_IPC_MAJOR_3) - add_local_sources(sof dcblock_ipc3.c) + add_local_sources(sof dcblock_ipc3.c) elseif(CONFIG_IPC_MAJOR_4) - add_local_sources(sof dcblock_ipc4.c) + add_local_sources(sof dcblock_ipc4.c) endif() diff --git a/src/audio/eq_fir/CMakeLists.txt b/src/audio/eq_fir/CMakeLists.txt index 250ca910658c..aaaabe9812bb 100644 --- a/src/audio/eq_fir/CMakeLists.txt +++ b/src/audio/eq_fir/CMakeLists.txt @@ -1,9 +1,18 @@ # SPDX-License-Identifier: BSD-3-Clause -add_local_sources(sof eq_fir.c eq_fir_generic.c eq_fir_hifi2ep.c eq_fir_hifi3.c) -if(CONFIG_IPC_MAJOR_3) - add_local_sources(sof eq_fir_ipc3.c) -elseif(CONFIG_IPC_MAJOR_4) - add_local_sources(sof eq_fir_ipc4.c) -endif() +if(CONFIG_COMP_FIR STREQUAL "m") + + add_subdirectory(llext ${PROJECT_BINARY_DIR}/eq_fir_llext) + add_dependencies(app eq_fir) + +else() + add_local_sources(sof eq_fir.c eq_fir_generic.c eq_fir_hifi2ep.c eq_fir_hifi3.c) + + if(CONFIG_IPC_MAJOR_3) + add_local_sources(sof eq_fir_ipc3.c) + elseif(CONFIG_IPC_MAJOR_4) + add_local_sources(sof eq_fir_ipc4.c) + endif() + +endif() diff --git a/src/audio/eq_iir/CMakeLists.txt b/src/audio/eq_iir/CMakeLists.txt index 0c9853540ad5..7519ec77b0c8 100644 --- a/src/audio/eq_iir/CMakeLists.txt +++ b/src/audio/eq_iir/CMakeLists.txt @@ -1,8 +1,18 @@ # SPDX-License-Identifier: BSD-3-Clause -add_local_sources(sof eq_iir.c eq_iir_generic.c) -if(CONFIG_IPC_MAJOR_3) - add_local_sources(sof eq_iir_ipc3.c) -elseif(CONFIG_IPC_MAJOR_4) - add_local_sources(sof eq_iir_ipc4.c) +if(CONFIG_COMP_IIR STREQUAL "m") + + add_subdirectory(llext ${PROJECT_BINARY_DIR}/eq_iir_llext) + add_dependencies(app eq_iir) + +else() + + add_local_sources(sof eq_iir.c eq_iir_generic.c) + + if(CONFIG_IPC_MAJOR_3) + add_local_sources(sof eq_iir_ipc3.c) + elseif(CONFIG_IPC_MAJOR_4) + add_local_sources(sof eq_iir_ipc4.c) + endif() + endif() diff --git a/src/audio/pipeline/CMakeLists.txt b/src/audio/pipeline/CMakeLists.txt index 242ace4b2a69..cb26dc3214bd 100644 --- a/src/audio/pipeline/CMakeLists.txt +++ b/src/audio/pipeline/CMakeLists.txt @@ -1,9 +1,9 @@ # SPDX-License-Identifier: BSD-3-Clause add_local_sources(sof - pipeline-graph.c - pipeline-stream.c - pipeline-params.c - pipeline-xrun.c - pipeline-schedule.c + pipeline-graph.c + pipeline-stream.c + pipeline-params.c + pipeline-xrun.c + pipeline-schedule.c ) diff --git a/src/audio/selector/CMakeLists.txt b/src/audio/selector/CMakeLists.txt index 1c7e9a43ad44..eb92a8c29510 100644 --- a/src/audio/selector/CMakeLists.txt +++ b/src/audio/selector/CMakeLists.txt @@ -1,3 +1,9 @@ # SPDX-License-Identifier: BSD-3-Clause +if(CONFIG_COMP_SEL STREQUAL "m") + add_subdirectory(llext ${PROJECT_BINARY_DIR}/selector_llext) + add_dependencies(app selector) + return() +endif() + add_local_sources(sof selector_generic.c selector.c) diff --git a/src/audio/src/CMakeLists.txt b/src/audio/src/CMakeLists.txt index 111b2484b4da..aab97633a2c1 100644 --- a/src/audio/src/CMakeLists.txt +++ b/src/audio/src/CMakeLists.txt @@ -1,9 +1,31 @@ # SPDX-License-Identifier: BSD-3-Clause -add_local_sources(sof src_generic.c src_hifi2ep.c src_hifi3.c src_hifi4.c src_hifi5.c src_common.c src.c) +set(base_files src_generic.c src_hifi2ep.c src_hifi3.c src_hifi4.c src_hifi5.c src_common.c src.c) if(CONFIG_IPC_MAJOR_3) - add_local_sources(sof src_ipc3.c) + list(APPEND base_files src_ipc3.c) elseif(CONFIG_IPC_MAJOR_4) - add_local_sources(sof src_ipc4.c) + list(APPEND base_files src_ipc4.c) +endif() + +sof_list_append_ifdef(CONFIG_COMP_SRC_LITE base_files src_lite.c) + +is_zephyr(it_is) +if(it_is) ### Zephyr ### + + if(CONFIG_COMP_SRC STREQUAL "m") + + add_subdirectory(llext ${PROJECT_BINARY_DIR}/src_llext) + add_dependencies(app src) + + else() + + zephyr_library_sources(${base_files}) + + endif() + +else() ### XTOS ### + + add_local_sources(sof ${base_files}) + endif() diff --git a/src/include/sof/audio/component.h b/src/include/sof/audio/component.h index 9c9a411fd6eb..ff06f8bec419 100644 --- a/src/include/sof/audio/component.h +++ b/src/include/sof/audio/component.h @@ -869,6 +869,7 @@ void sys_comp_module_asrc_interface_init(void); void sys_comp_module_rtnr_interface_init(void); void sys_comp_module_selector_interface_init(void); void sys_comp_module_src_interface_init(void); +void sys_comp_module_src_lite_interface_init(void); void sys_comp_module_tdfb_interface_init(void); void sys_comp_module_volume_interface_init(void); void sys_comp_module_tester_interface_init(void); diff --git a/zephyr/CMakeLists.txt b/zephyr/CMakeLists.txt index aa6a67e754a1..7a3c92f9ce64 100644 --- a/zephyr/CMakeLists.txt +++ b/zephyr/CMakeLists.txt @@ -197,7 +197,13 @@ macro(add_local_sources_ifdef condition target) endif() zephyr_library_sources_ifdef(${condition} ${ARGN}) endmacro() +macro(sof_list_append_ifdef feature_toggle list) + if(${${feature_toggle}}) + list(APPEND ${list} ${ARGN}) + endif() +endmacro() +add_subdirectory(../src/audio/ audio_unused_install/) add_subdirectory(../src/debug/debug_stream/ debug_stream_unused_install/) add_subdirectory(../src/debug/telemetry/ telemetry_unused_install/) add_subdirectory(../src/debug/tester/ debug_tester_unused_install/) @@ -455,21 +461,6 @@ zephyr_library_sources( ${SOF_LIB_PATH}/dma.c ${SOF_LIB_PATH}/dai.c - # SOF mandatory audio processing - ${SOF_AUDIO_PATH}/channel_map.c - ${SOF_AUDIO_PATH}/buffers/comp_buffer.c - ${SOF_AUDIO_PATH}/buffers/audio_buffer.c - ${SOF_AUDIO_PATH}/source_api_helper.c - ${SOF_AUDIO_PATH}/sink_api_helper.c - ${SOF_AUDIO_PATH}/sink_source_utils.c - ${SOF_AUDIO_PATH}/audio_stream.c - ${SOF_AUDIO_PATH}/component.c - ${SOF_AUDIO_PATH}/pipeline/pipeline-graph.c - ${SOF_AUDIO_PATH}/pipeline/pipeline-params.c - ${SOF_AUDIO_PATH}/pipeline/pipeline-schedule.c - ${SOF_AUDIO_PATH}/pipeline/pipeline-stream.c - ${SOF_AUDIO_PATH}/pipeline/pipeline-xrun.c - # SOF core infrastructure - runs on top of Zephyr ${SOF_SRC_PATH}/arch/xtensa/drivers/cache_attr.c @@ -498,27 +489,6 @@ zephyr_library_sources_ifdef(CONFIG_KCPS_DYNAMIC_CLOCK_CONTROL # SOF module interface functions add_subdirectory(../src/module module_unused_install/) -if(CONFIG_PIPELINE_2_0) - zephyr_library_sources(${SOF_AUDIO_PATH}/buffers/ring_buffer.c) -endif() - -if(CONFIG_COMP_BLOB) - zephyr_library_sources( - ${SOF_AUDIO_PATH}/data_blob.c - ) -endif() - -if(CONFIG_ZEPHYR_NATIVE_DRIVERS) - zephyr_library_sources( - ${SOF_AUDIO_PATH}/host-zephyr.c - ) -else() - zephyr_library_sources( - ${SOF_AUDIO_PATH}/host-legacy.c - ) -endif() - - zephyr_library_sources_ifdef(CONFIG_TRACE ${SOF_SRC_PATH}/trace/dma-trace.c ${SOF_SRC_PATH}/trace/trace.c) @@ -536,76 +506,6 @@ elseif(CONFIG_IPC_MAJOR_4) set(ipc_suffix ipc4) endif() -if(CONFIG_COMP_FIR STREQUAL "m") - add_subdirectory(${SOF_AUDIO_PATH}/eq_fir/llext - ${PROJECT_BINARY_DIR}/eq_fir_llext) - add_dependencies(app eq_fir) -elseif(CONFIG_COMP_FIR) - zephyr_library_sources( - ${SOF_AUDIO_PATH}/eq_fir/eq_fir_hifi3.c - ${SOF_AUDIO_PATH}/eq_fir/eq_fir_hifi2ep.c - ${SOF_AUDIO_PATH}/eq_fir/eq_fir_generic.c - ${SOF_AUDIO_PATH}/eq_fir/eq_fir.c - ${SOF_AUDIO_PATH}/eq_fir/eq_fir_${ipc_suffix}.c - ) -endif() - -if(CONFIG_COMP_IIR STREQUAL "m") - add_subdirectory(${SOF_AUDIO_PATH}/eq_iir/llext - ${PROJECT_BINARY_DIR}/eq_iir_llext) - add_dependencies(app eq_iir) -elseif(CONFIG_COMP_IIR) - zephyr_library_sources( - ${SOF_AUDIO_PATH}/eq_iir/eq_iir.c - ${SOF_AUDIO_PATH}/eq_iir/eq_iir_${ipc_suffix}.c - ${SOF_AUDIO_PATH}/eq_iir/eq_iir_generic.c - ) -endif() - -if(CONFIG_COMP_ASRC STREQUAL "m") - add_subdirectory(${SOF_AUDIO_PATH}/asrc/llext - ${PROJECT_BINARY_DIR}/asrc_llext) - add_dependencies(app asrc) -elseif(CONFIG_COMP_ASRC) - zephyr_library_sources( - ${SOF_AUDIO_PATH}/asrc/asrc.c - ${SOF_AUDIO_PATH}/asrc/asrc_farrow_hifi5.c - ${SOF_AUDIO_PATH}/asrc/asrc_farrow_hifi3.c - ${SOF_AUDIO_PATH}/asrc/asrc_farrow.c - ${SOF_AUDIO_PATH}/asrc/asrc_farrow_generic.c - ${SOF_AUDIO_PATH}/asrc/asrc_${ipc_suffix}.c - ) -endif() - -if(CONFIG_COMP_DCBLOCK STREQUAL "m") - add_subdirectory(${SOF_AUDIO_PATH}/dcblock/llext - ${PROJECT_BINARY_DIR}/dcblock_llext) - add_dependencies(app dcblock) -elseif(CONFIG_COMP_DCBLOCK) - zephyr_library_sources( - ${SOF_AUDIO_PATH}/dcblock/dcblock_generic.c - ${SOF_AUDIO_PATH}/dcblock/dcblock.c - ${SOF_AUDIO_PATH}/dcblock/dcblock_hifi3.c - ${SOF_AUDIO_PATH}/dcblock/dcblock_hifi4.c - ${SOF_AUDIO_PATH}/dcblock/dcblock_${ipc_suffix}.c - ) -endif() - -if(CONFIG_COMP_SEL STREQUAL "m") - add_subdirectory(${SOF_AUDIO_PATH}/selector/llext - ${PROJECT_BINARY_DIR}/selector_llext) - add_dependencies(app selector) -elseif(CONFIG_COMP_SEL) - zephyr_library_sources( - ${SOF_AUDIO_PATH}/selector/selector_generic.c - ${SOF_AUDIO_PATH}/selector/selector.c - ) -endif() - -zephyr_library_sources_ifdef(CONFIG_COMP_KPB - ${SOF_AUDIO_PATH}/kpb.c -) - zephyr_library_sources_ifdef(CONFIG_COMP_MIXER ${SOF_AUDIO_PATH}/mixer/mixer.c ${SOF_AUDIO_PATH}/mixer/mixer_generic.c @@ -629,16 +529,6 @@ zephyr_library_sources_ifdef(CONFIG_COMP_TONE ${SOF_AUDIO_PATH}/tone.c ) -if(CONFIG_ZEPHYR_NATIVE_DRIVERS) - zephyr_library_sources_ifdef(CONFIG_COMP_DAI - ${SOF_AUDIO_PATH}/dai-zephyr.c -) -else() - zephyr_library_sources_ifdef(CONFIG_COMP_DAI - ${SOF_AUDIO_PATH}/dai-legacy.c -) -endif() - zephyr_library_sources_ifdef(CONFIG_IPC4_GATEWAY ${SOF_AUDIO_PATH}/copier/copier_ipcgtw.c ) @@ -727,27 +617,6 @@ zephyr_library_sources_ifdef(CONFIG_COMP_CHAIN_DMA ${SOF_AUDIO_PATH}/chain_dma.c ) -if(CONFIG_COMP_SRC STREQUAL "m") - add_subdirectory(${SOF_AUDIO_PATH}/src/llext - ${PROJECT_BINARY_DIR}/src_llext) - add_dependencies(app src) -elseif(CONFIG_COMP_SRC) - zephyr_library_sources_ifdef(CONFIG_COMP_SRC - ${SOF_AUDIO_PATH}/src/src_hifi2ep.c - ${SOF_AUDIO_PATH}/src/src_generic.c - ${SOF_AUDIO_PATH}/src/src_hifi3.c - ${SOF_AUDIO_PATH}/src/src_hifi4.c - ${SOF_AUDIO_PATH}/src/src_hifi5.c - ${SOF_AUDIO_PATH}/src/src_common.c - ${SOF_AUDIO_PATH}/src/src.c - ${SOF_AUDIO_PATH}/src/src_${ipc_suffix}.c - ) - - zephyr_library_sources_ifdef(CONFIG_COMP_SRC_LITE - ${SOF_AUDIO_PATH}/src/src_lite.c - ) -endif() - zephyr_library_sources_ifdef(CONFIG_COMP_BASEFW_IPC4 ${SOF_AUDIO_PATH}/base_fw.c )