From a3d5016078f2e1e5d272b7e3da18fe1040afcaf2 Mon Sep 17 00:00:00 2001 From: Peter Ujfalusi Date: Mon, 29 Sep 2025 14:12:59 +0300 Subject: [PATCH 001/436] Tools: Topology2: cavs-rt5682: Add ADL platform support Include platform/intel/tgl.conf fro ADL platform Signed-off-by: Peter Ujfalusi --- tools/topology/topology2/cavs-rt5682.conf | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/topology/topology2/cavs-rt5682.conf b/tools/topology/topology2/cavs-rt5682.conf index d8e028775aeb..ce6d160680d4 100644 --- a/tools/topology/topology2/cavs-rt5682.conf +++ b/tools/topology/topology2/cavs-rt5682.conf @@ -128,6 +128,7 @@ Define { # override defaults with platform-specific config IncludeByKey.PLATFORM { + "adl" "platform/intel/tgl.conf" "mtl" "platform/intel/mtl.conf" "lnl" "platform/intel/lnl.conf" "ptl" "platform/intel/ptl.conf" From de8883c7b0f09a41b5fb6c17192738b0431db51d Mon Sep 17 00:00:00 2001 From: Peter Ujfalusi Date: Mon, 29 Sep 2025 14:15:55 +0300 Subject: [PATCH 002/436] Tools: Topology2: development: Add topology for sof-adl-max98357a-rt5682 Enable building topology for adl-max98357a-rt5682 which is used by Google Brya devices. The PCM list is aligned with other max98357a-rt5682 IPC4 devices and _not_ with the IPC3 sound card. Signed-off-by: Peter Ujfalusi --- tools/topology/topology2/development/tplg-targets.cmake | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tools/topology/topology2/development/tplg-targets.cmake b/tools/topology/topology2/development/tplg-targets.cmake index 5c20ef592806..28881828295e 100644 --- a/tools/topology/topology2/development/tplg-targets.cmake +++ b/tools/topology/topology2/development/tplg-targets.cmake @@ -372,4 +372,10 @@ DEEP_BUF_SPK=true,PLAYBACK_PIPELINE_SRC=ctc,SSP_SPK_FMT_24=true,SSP_HS_FMT_24=tr # CS35L56 SSP2 "cavs-cs35l56\;sof-tgl-cs35l56-ssp2\;PLATFORM=tgl,PREPROCESS_PLUGINS=nhlt,\ NHLT_BIN=nhlt-sof-tgl-cs35l56-ssp2.bin" + +# Topology for Google Brya +"cavs-rt5682\;sof-adl-max98357a-rt5682\;PLATFORM=adl,NUM_DMICS=4,PDM1_MIC_A_ENABLE=1,\ +PDM1_MIC_B_ENABLE=1,DMIC0_PCM_ID=99,PREPROCESS_PLUGINS=nhlt,NUM_HDMIS=4,\ +NHLT_BIN=nhlt-sof-adl-max98357a-rt5682.bin,SPK_ID=7,DEEPBUFFER_FW_DMA_MS=10,INCLUDE_ECHO_REF=true,\ +INCLUDE_BT_OFFLOAD=false,DEEP_BUF_SPK=true,SPEAKER_CODEC_NAME=SSP2-Codec,SPEAKER_SSP_DAI_INDEX=2" ) From ab8ffc5f5d3a979e87f96341d1d2445ea5498a96 Mon Sep 17 00:00:00 2001 From: Adrian Warecki Date: Wed, 1 Oct 2025 13:21:35 +0200 Subject: [PATCH 003/436] module: tester: Ensure tester module is only built when explicitly selected Prevent the tester module from being built into the image unless explicitly configured, especially when it's configured as a loadable module and llext support is disabled. Signed-off-by: Adrian Warecki --- src/debug/tester/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/debug/tester/CMakeLists.txt b/src/debug/tester/CMakeLists.txt index e207a0547f6d..85bf026b5ed3 100644 --- a/src/debug/tester/CMakeLists.txt +++ b/src/debug/tester/CMakeLists.txt @@ -14,7 +14,7 @@ if(zephyr) ### Zephyr ### add_subdirectory(llext ${PROJECT_BINARY_DIR}/tester_llext) add_dependencies(app tester) - elseif(CONFIG_COMP_TESTER) + elseif(CONFIG_COMP_TESTER STREQUAL "y") zephyr_library_sources(${base_files}) From 37ac744aa90c8a28b7f6a0d7e2837cdbeea79d8a Mon Sep 17 00:00:00 2001 From: Mateusz Redzynia Date: Tue, 30 Sep 2025 13:54:39 +0000 Subject: [PATCH 004/436] zephyr-lite: update base to zephyr-build v0.28.4 Update base to zephyr-build v0.28.4 and: - Remove python3.12 installation as it's already supplied by new docker base - Remove sysroots from toolchains to free up space - Install jsonschema, cmake - Update SDK to 0.17.4 - Use python venv for packages Signed-off-by: Mateusz Redzynia --- scripts/docker_build/zephyr_lite/Dockerfile | 35 ++++++++++----------- 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/scripts/docker_build/zephyr_lite/Dockerfile b/scripts/docker_build/zephyr_lite/Dockerfile index 0c52b1f668f4..fb891468e5e9 100644 --- a/scripts/docker_build/zephyr_lite/Dockerfile +++ b/scripts/docker_build/zephyr_lite/Dockerfile @@ -2,36 +2,26 @@ # Copyright(c) 2025 Intel Corporation. All rights reserved. # Use zephyr-build as base image -FROM ghcr.io/zephyrproject-rtos/zephyr-build:v0.27.4 as base +FROM ghcr.io/zephyrproject-rtos/zephyr-build:v0.28.4 as base # Remove additional toolchains. # As this is not ideal solution there is a plan to build docker image without zephyr-build as the base -# and install only needeed toolchains in the future. -RUN cd /opt/toolchains/zephyr-sdk-0.17.0 && \ - sudo rm -rvf arc* \ +# and install only needed toolchains in the future. +USER root + +RUN cd /opt/toolchains/zephyr-sdk-0.17.4 && \ + rm -rvf arc* \ micro* \ mips* \ nios* \ risc* \ sparc* \ + sysroots \ x86* \ xtensa-espressif* \ xtensa-sample* \ xtensa-dc233c* -# Some of tests require python 3.12 - instll it from source -RUN cd /tmp && wget -q --show-progress --progress=bar:force:noscroll --no-check-certificate https://www.python.org/ftp/python/3.12.9/Python-3.12.9.tgz && \ - tar -xf Python-3.12.9.tgz && \ - cd Python-3.12.9 && \ - ./configure && \ - sudo make -j$(nproc) && \ - sudo make install && \ - sudo rm -rf /tmp/Python-3* - -# Reinstall python3.10 packages with python3.12 -RUN python3.10 -m pip freeze > /tmp/python3.10.pip.txt && \ - cat /tmp/python3.10.pip.txt | xargs -n 1 python3.12 -m pip install || true - # Use ubuntu24.04 as base for zephyr-lite FROM ubuntu:24.04 as zephyr-lite @@ -39,9 +29,11 @@ FROM ubuntu:24.04 as zephyr-lite # /opt for toolchains and sdk # /usr for binaries and libs # /home for libs installed in .local +# /etc/ssl for ssl certs for python packages COPY --from=base /opt /opt COPY --from=base /usr /usr COPY --from=base /home /home +COPY --from=base /etc/ssl /etc/ssl USER root @@ -49,10 +41,17 @@ USER root # Add user to dialout and sudo group RUN useradd -ms /bin/bash user && \ chown -R user:user /home/user && \ + chown -R user:user /opt/python && \ usermod -a -G dialout,sudo user USER user +# Install cmake and jsonschema in venv +RUN /opt/python/venv/bin/pip install 'cmake>=3.21' jsonschema + # Set zephyr env variables -ENV ZEPHYR_SDK_INSTALL_DIR=/opt/toolchains/zephyr-sdk-0.17.0 +ENV PATH="/opt/python/venv/bin/:$PATH" +ENV ZEPHYR_SDK_INSTALL_DIR=/opt/toolchains/zephyr-sdk-0.17.4 ENV ZEPHYR_TOOLCHAIN_VARIANT=zephyr + +CMD ["/bin/bash", "-l"] From ae3d2de7de7ff9d998b37e9ad9ea32505ae4fea5 Mon Sep 17 00:00:00 2001 From: Mateusz Redzynia Date: Tue, 30 Sep 2025 13:59:05 +0000 Subject: [PATCH 005/436] docker-run: update zephyr-lite version to v0.28.4 Update zephyr-lite to v0.28.4 version with sdk 0.17.4 and jsonschema installed. Signed-off-by: Mateusz Redzynia --- zephyr/docker-run.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/zephyr/docker-run.sh b/zephyr/docker-run.sh index 8cc27df65a21..c8a4af7fd38e 100755 --- a/zephyr/docker-run.sh +++ b/zephyr/docker-run.sh @@ -54,8 +54,8 @@ main() run_command() { - # zephyr-lite:v0.27.4 has /opt/toolchains/zephyr-sdk-0.17.0 - # zephyr-lite:v0.27.4 is based on zephyr-build:v0.27.4 + # zephyr-lite:v0.28.4 has /opt/toolchains/zephyr-sdk-0.17.4 + # zephyr-lite:v0.28.4 is based on zephyr-build:v0.28.4 # https://hub.docker.com/r/zephyrprojectrtos/zephyr-build/tags # https://hub.docker.com/r/thesofproject/zephyr-lite/tags # @@ -65,7 +65,7 @@ run_command() --workdir /zep_workspace \ $SOF_DOCKER_RUN \ --env REAL_CC --env http_proxy --env https_proxy \ - thesofproject/zephyr-lite:v0.27.4 \ + thesofproject/zephyr-lite:v0.28.4 \ ./sof/scripts/sudo-cwd.sh "$@" } From f7f5362ec169acae8724e9d1b1ed81a6f2a8bf02 Mon Sep 17 00:00:00 2001 From: Mateusz Redzynia Date: Wed, 1 Oct 2025 09:18:32 +0000 Subject: [PATCH 006/436] docker-build: remove cmake installation from script Cmake is now shipped with zephyr-lite dockerimage, there is no need to install it again. Signed-off-by: Mateusz Redzynia --- zephyr/docker-build.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/zephyr/docker-build.sh b/zephyr/docker-build.sh index 161ab896c389..fa54fe318d87 100755 --- a/zephyr/docker-build.sh +++ b/zephyr/docker-build.sh @@ -50,8 +50,6 @@ unset ZEPHYR_SDK_INSTALL_DIR # CMake v3.21 changed the order object files are passed to the linker. # This makes builds before that version not reproducible. # To save time don't install if recent enough. -pip install 'cmake>=3.21' -PATH="$HOME"/.local/bin:"$PATH" if test -e .west || test -e zephyr; then init_update='' From 5e37b7a3f5ee09b11f34892ad90a4390f921b1b5 Mon Sep 17 00:00:00 2001 From: Mateusz Redzynia Date: Wed, 1 Oct 2025 11:42:39 +0000 Subject: [PATCH 007/436] llext: rework llext workflow Drop usage of docker-run.sh in favor of using runs-on: container: image: which is the correct approach for github workflows. Signed-off-by: Mateusz Redzynia --- .github/workflows/llext.yml | 45 ++++++++++++++++++++----------------- 1 file changed, 24 insertions(+), 21 deletions(-) diff --git a/.github/workflows/llext.yml b/.github/workflows/llext.yml index 21b812b47600..a2888b75f2f4 100644 --- a/.github/workflows/llext.yml +++ b/.github/workflows/llext.yml @@ -7,9 +7,15 @@ name: Zephyr LLEXT # yamllint disable-line rule:truthy on: [pull_request, workflow_dispatch] +defaults: + run: + shell: bash + jobs: build: runs-on: ubuntu-22.04 + container: + image: thesofproject/zephyr-lite:v0.28.4 strategy: fail-fast: false @@ -17,33 +23,30 @@ jobs: platform: [mtl, lnl] steps: - - name: free space - run: | - sudo rm -rf /usr/share/dotnet - sudo rm -rf /opt/ghc - - - name: git clone sof + - name: checkout uses: actions/checkout@v4 with: - path: ./workspace/sof + path: sof fetch-depth: 0 # fix git describe filter: 'tree:0' - - name: west clones - run: pip3 install west && cd workspace/sof/ && west init -l && - west update --narrow --fetch-opt=--depth=5 + - name: west update + working-directory: sof + run: | + west init -l + west update --narrow --fetch-opt=--depth=5 - - name: Download docker image && ls /opt/toolchains/ - run: cd workspace && ./sof/zephyr/docker-run.sh ls -l /opt/toolchains/ + - name: print all available sdks in /opt/toolchains/ + run: | + ls -l /opt/toolchains/ - name: llext build run: | - cd workspace && ./sof/zephyr/docker-run.sh /bin/sh -c \ - "ln -s /opt/toolchains/zephyr-sdk-* ~/; - python sof/scripts/xtensa-build-zephyr.py \ - --cmake-args=-DEXTRA_CFLAGS=-Werror \ - --cmake-args=-DEXTRA_CXXFLAGS=-Werror \ - --cmake-args=-DEXTRA_AFLAGS='-Werror -Wa,--fatal-warnings' \ - --cmake-args=--warn-uninitialized \ - --overlay=sof/app/configs/${{ matrix.platform }}/modules.conf \ - ${{ matrix.platform }}" + ln -s /opt/toolchains/zephyr-sdk-* ~/ + python sof/scripts/xtensa-build-zephyr.py \ + --cmake-args=-DEXTRA_CFLAGS=-Werror \ + --cmake-args=-DEXTRA_CXXFLAGS=-Werror \ + --cmake-args=-DEXTRA_AFLAGS='-Werror -Wa,--fatal-warnings' \ + --cmake-args=--warn-uninitialized \ + --overlay=sof/app/configs/${{ matrix.platform }}/modules.conf \ + ${{ matrix.platform }} From 52f6edfffdb47672607e7a75b1f200c9cabfb6c5 Mon Sep 17 00:00:00 2001 From: Mateusz Redzynia Date: Wed, 1 Oct 2025 12:53:58 +0000 Subject: [PATCH 008/436] zephyr: rework zephyr workflow Drop usage of docker-run.sh in favor of using runs-on: container: image: which is the correct approach for github workflows. Signed-off-by: Mateusz Redzynia --- .github/workflows/zephyr.yml | 118 ++++++++++++++++------------------- 1 file changed, 55 insertions(+), 63 deletions(-) diff --git a/.github/workflows/zephyr.yml b/.github/workflows/zephyr.yml index d02d67861560..89235c2a1ff2 100644 --- a/.github/workflows/zephyr.yml +++ b/.github/workflows/zephyr.yml @@ -15,18 +15,22 @@ concurrency: cancel-in-progress: true jobs: - manifest-check: runs-on: ubuntu-latest + defaults: + run: + shell: bash + container: + image: thesofproject/zephyr-lite:v0.28.4 steps: - uses: actions/checkout@v4 with: - path: ./workspace/sof + path: sof filter: 'tree:0' - name: plain west update + working-directory: sof run: | - : This plain 'west update' does not provide 100% certainty that : all the manifest revisions make sense but it is quick and : will catch many revision problems. Other jobs typically @@ -35,8 +39,6 @@ jobs: : is useful for testing unmerged Zephyr commits but risks : accepting "invalid" ones, this will not. - pip3 install west - cd workspace/sof/ west init -l west update --fetch-opt=--filter=tree:0 @@ -45,9 +47,8 @@ jobs: # XTOS submodules and... temporarily break every CI, which is why # it hasn't been done yet. - name: git submodules consistency + working-directory: sof run: | - - cd workspace/sof git submodule update --init --recursive west update @@ -66,40 +67,42 @@ jobs: # job will be disappear, folded back in the regular build-* jobs below. LP64-WIP: runs-on: ubuntu-22.04 + defaults: + run: + shell: bash + container: + image: thesofproject/zephyr-lite:v0.28.4 steps: - uses: actions/checkout@v4 with: - path: ./workspace/sof + path: sof filter: 'tree:0' - - name: free space + - name: west update + working-directory: sof run: | - sudo rm -rf /usr/share/dotnet - sudo rm -rf /opt/ghc - - - name: west clones - run: pip3 install west && cd workspace/sof/ && west init -l && - west update --narrow --fetch-opt=--filter=tree:0 + west init -l + west update --narrow --fetch-opt=--filter=tree:0 - # Not strictly necessary but saves a lot of scrolling in the next step - # Caching a 12G image is unfortunately not possible: - # https://github.com/ScribeMD/docker-cache/issues/304 - # For faster builds we would have to pay for some persistent runners. - - name: Download docker image && ls /opt/toolchains/ - run: cd workspace && ./sof/zephyr/docker-run.sh ls -l /opt/toolchains/ + - name: print all available sdks in /opt/toolchains/ + run: | + ls -l /opt/toolchains/ - name: 64 bits build run: | - cd workspace && ./sof/zephyr/docker-run.sh /bin/sh -c \ - 'ln -s /opt/toolchains/zephyr-sdk-* ~/; - west build --board imx93_evk/mimx9352/a55 sof/app \ - -- -DEXTRA_CFLAGS=-Werror -DEXTRA_CXXFLAGS=-Werror \ - -DEXTRA_AFLAGS=-Werror' - + ln -s /opt/toolchains/zephyr-sdk-* ~/ + west build --board imx93_evk/mimx9352/a55 sof/app \ + -- -DEXTRA_CFLAGS=-Werror -DEXTRA_CXXFLAGS=-Werror \ + -DEXTRA_AFLAGS=-Werror build-linux: runs-on: ubuntu-22.04 + defaults: + run: + shell: bash + container: + image: thesofproject/zephyr-lite:v0.28.4 strategy: fail-fast: false matrix: @@ -143,20 +146,15 @@ jobs: with: fetch-depth: 0 filter: 'tree:0' - path: ./workspace/sof + path: sof - - name: free space + - name: west update + working-directory: sof run: | - sudo rm -rf /usr/share/dotnet - sudo rm -rf /opt/ghc - - - name: west clones - - run: pip3 install west && cd workspace/sof/ && west init -l && - time west update --narrow --fetch-opt=--filter=tree:0 + west init -l + west update --narrow --fetch-opt=--filter=tree:0 - name: select zephyr revision - working-directory: ${{ github.workspace }}/workspace run: | if [ 'mnfst' = '${{ matrix.zephyr_revision }}' ]; then rem_rev=$(git -C zephyr rev-parse HEAD) @@ -175,7 +173,7 @@ jobs: # Get some tags to fix `git describe` hence BUILD_VERSION, etc. # Keep in sync with build-windows below - name: Fetch tags for git describe - working-directory: ${{ github.workspace }}/workspace/zephyr + working-directory: zephyr run: | # Because we used git tricks to speed things up, we now have two git # problems: @@ -205,25 +203,19 @@ jobs: git describe --long --always --dirty git describe --long --always --dirty --tags - # Not strictly necessary but saves a lot of scrolling in the next step - # Caching a 12G image is unfortunately not possible: - # https://github.com/ScribeMD/docker-cache/issues/304 - # For faster builds we would have to pay for some persistent runners. - - name: Download docker image && ls /opt/toolchains/ - run: cd workspace && ./sof/zephyr/docker-run.sh ls -l /opt/toolchains/ + - name: print all available sdks in /opt/toolchains/ + run: | + ls -l /opt/toolchains/ - # https://github.com/zephyrproject-rtos/docker-image - # Note: env variables can be passed to the container with - # -e https_proxy=... - name: build - run: cd workspace && ./sof/zephyr/docker-run.sh - ./sof/zephyr/docker-build.sh --cmake-args=-DEXTRA_CFLAGS=-Werror - --cmake-args=-DEXTRA_CXXFLAGS=-Werror - --cmake-args=-DEXTRA_AFLAGS='-Werror -Wa,--fatal-warnings' - --cmake-args=--warn-uninitialized - --overlay=sof/app/configs/repro-build.conf - --no-tarball - ${{ matrix.build_opts }} ${{ matrix.IPC_platforms }} + run: | + ./sof/zephyr/docker-build.sh --cmake-args=-DEXTRA_CFLAGS=-Werror \ + --cmake-args=-DEXTRA_CXXFLAGS=-Werror \ + --cmake-args=-DEXTRA_AFLAGS='-Werror -Wa,--fatal-warnings' \ + --cmake-args=--warn-uninitialized \ + --overlay=sof/app/configs/repro-build.conf \ + --no-tarball \ + ${{ matrix.build_opts }} ${{ matrix.IPC_platforms }} - name: Upload build artifacts uses: actions/upload-artifact@v4 @@ -232,8 +224,8 @@ jobs: name: linux-build ${{ matrix.build_opts }} ${{ matrix.IPC_platforms }} if-no-files-found: error path: | - ${{ github.workspace }}/workspace/build-sof-staging - ${{ github.workspace }}/workspace/**/compile_commands.json + build-sof-staging + ./**/compile_commands.json build-windows: runs-on: windows-latest @@ -285,12 +277,12 @@ jobs: # Keep this SDK version identical to the one in # sof/zephyr/docker-run.sh - - name: Cache Zephyr SDK 0.17.0 + - name: Cache Zephyr SDK 0.17.4 id: cache-zephyr-sdk uses: actions/cache@v4 with: - path: zephyr-sdk-0.17.0_windows-x86_64.7z - key: ${{ runner.os }}-cache-zephyr-sdk-0-17-0 + path: zephyr-sdk-0.17.4_windows-x86_64.7z + key: ${{ runner.os }}-cache-zephyr-sdk-0-17-4 # Wget is needed by Zephyr SDK setup.cmd installation script - name: Download wget @@ -298,11 +290,11 @@ jobs: run: | curl -L -O http://downloads.sourceforge.net/gnuwin32/wget-1.11.4-1-bin.zip - - name: Download Zephyr SDK 0.17.0 + - name: Download Zephyr SDK 0.17.4 if: ${{ steps.cache-zephyr-sdk.outputs.cache-hit != 'true' }} run: | # yamllint disable-line rule:line-length curl -L -O ` - https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v0.17.0/zephyr-sdk-0.17.0_windows-x86_64.7z + https://github.com/zephyrproject-rtos/sdk-ng/releases/download/v0.17.4/zephyr-sdk-0.17.4_windows-x86_64.7z # Unzips every .zip package to directory matching its name without extension - name: Unzip downloaded packages @@ -325,7 +317,7 @@ jobs: # setup.cmd may not be called in from msys shell as it does not parse # forward slash script input arguments correctly. - name: Install Zephyr SDK - run: zephyr-sdk-0.17.0_windows-x86_64/zephyr-sdk-0.17.0/setup.cmd /t all /h /c + run: zephyr-sdk-0.17.4_windows-x86_64/zephyr-sdk-0.17.4/setup.cmd /t all /h /c - name: Setup Python uses: actions/setup-python@v5 From e9625498423c4a9d8209f140d0e089153fbc8a5d Mon Sep 17 00:00:00 2001 From: Mateusz Redzynia Date: Wed, 1 Oct 2025 13:18:03 +0000 Subject: [PATCH 009/436] sparse-zephyr: rework sparse-zephyr workflow Drop usage of docker-run.sh in favor of using runs-on: container: image: which is the correct approach for github workflows. Signed-off-by: Mateusz Redzynia --- .github/workflows/sparse-zephyr.yml | 50 ++++++++++++++--------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/.github/workflows/sparse-zephyr.yml b/.github/workflows/sparse-zephyr.yml index edb484c42a50..15eba1dca2a7 100644 --- a/.github/workflows/sparse-zephyr.yml +++ b/.github/workflows/sparse-zephyr.yml @@ -7,6 +7,10 @@ name: Sparse Zephyr # yamllint disable-line rule:truthy on: [push, pull_request, workflow_dispatch, workflow_call] +defaults: + run: + shell: bash + jobs: # As of sparse commit ce1a6720f69e / Sept 2022, the exit status of # sparse.c is an unusable mess and always zero in practice. Moreover @@ -18,6 +22,8 @@ jobs: # We're sharing the sparse binary with the zephyr-build container so keep # this in sync with it. runs-on: ubuntu-24.04 + container: + image: thesofproject/zephyr-lite:v0.28.4 strategy: fail-fast: false @@ -25,43 +31,39 @@ jobs: platform: [tgl, mtl, lnl] steps: - - name: free space - run: | - sudo rm -rf /usr/share/dotnet - sudo rm -rf /opt/ghc - - name: git clone sparse analyzer uses: actions/checkout@v4 with: repository: thesofproject/sparse fetch-depth: 0 filter: 'tree:0' - path: workspace/sparse + path: sparse # As of its 2023 commit 98b203419679, sparse-llvm.c uses symbols # (LLVMConstGEP, LLVMBuildLoad, LLVMBuildCall,...) which are: # - -Wdeprecated in LLVM v14 # - Removed in LLVM v16 - name: build sparse analyzer - run: cd workspace/sparse && make -j4 # HAVE_LLVM=no + working-directory: sparse + run: | + make -j4 # HAVE_LLVM=no - name: git clone sof uses: actions/checkout@v4 with: - path: ./workspace/sof + path: sof fetch-depth: 0 # fix git describe filter: 'tree:0' - - name: west clones - run: pip3 install west && cd workspace/sof/ && west init -l && - west update --narrow --fetch-opt=--depth=5 + - name: west update + working-directory: sof + run: | + west init -l + west update --narrow --fetch-opt=--depth=5 - # Not strictly necessary but saves a lot of scrolling in the next step - # Caching a 12G image is unfortunately not possible: - # https://github.com/ScribeMD/docker-cache/issues/304 - # For faster builds we would have to pay for some persistent runners. - - name: Download docker image && ls /opt/toolchains/ - run: cd workspace && ./sof/zephyr/docker-run.sh ls -l /opt/toolchains/ + - name: print all available sdks in /opt/toolchains/ + run: | + ls -l /opt/toolchains/ # --pristine is important to reproduce _warnings_. It makes no # difference for github but it's useful for anyone trying to @@ -69,13 +71,11 @@ jobs: # "sparse" is currently incompatible with PICOLIBC (the new Zephyr default), # see https://github.com/zephyrproject-rtos/zephyr/issues/63003 - name: analyze zephyr - working-directory: ./workspace run: | - ./sof/zephyr/docker-run.sh \ - ./sof/zephyr/docker-build.sh ${{ matrix.platform }} \ - --cmake-args=-DZEPHYR_SCA_VARIANT=sparse --cmake-args=-DCONFIG_LOG_USE_VLA=n \ - --cmake-args=-DCONFIG_MINIMAL_LIBC=y \ - --pristine 2>&1 | tee _.log + ./sof/zephyr/docker-build.sh ${{ matrix.platform }} \ + --cmake-args=-DZEPHYR_SCA_VARIANT=sparse --cmake-args=-DCONFIG_LOG_USE_VLA=n \ + --cmake-args=-DCONFIG_MINIMAL_LIBC=y \ + --pristine 2>&1 | tee _.log - printf '\n\n\t\t\t ---- Messages below are treated as sparse errors --- \n\n\n' - (set -x; ./sof/scripts/parse_sparse_output.sh ${{ matrix.platforms.platform }} <_.log) + printf '\n\n\t\t\t ---- Messages below are treated as sparse errors --- \n\n\n' + (set -x; ./sof/scripts/parse_sparse_output.sh ${{ matrix.platforms.platform }} <_.log) From bafb96b9a07a3d21f4bace9b8f79e2ec55837daa Mon Sep 17 00:00:00 2001 From: Adrian Bonislawski Date: Thu, 25 Sep 2025 11:03:52 +0200 Subject: [PATCH 010/436] platform: ace40: add support for cold data and code Required changes to enable CONFIG_COLD_STORE_EXECUTE_DRAM for ACE 4.0 nvl.toml.h -> add COLD module.entry novalake memory.h -> add __cold define support Signed-off-by: Adrian Bonislawski --- .../novalake/include/platform/lib/memory.h | 6 ++++++ tools/rimage/config/nvl.toml.h | 14 ++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/src/platform/novalake/include/platform/lib/memory.h b/src/platform/novalake/include/platform/lib/memory.h index 19ade62dfb2b..666c4fc9eb89 100644 --- a/src/platform/novalake/include/platform/lib/memory.h +++ b/src/platform/novalake/include/platform/lib/memory.h @@ -56,6 +56,12 @@ */ #define HEAPMEM_SIZE CONFIG_SOF_ZEPHYR_HEAP_SIZE +#if CONFIG_COLD_STORE_EXECUTE_DRAM && \ + (CONFIG_LLEXT_TYPE_ELF_RELOCATABLE || !defined(LL_EXTENSION_BUILD)) +#define __cold __section(".cold") +#define __cold_rodata __section(".coldrodata") +#endif + #endif /* __PLATFORM_LIB_MEMORY_H__ */ #else diff --git a/tools/rimage/config/nvl.toml.h b/tools/rimage/config/nvl.toml.h index eafe7501ac8d..80e28916f827 100644 --- a/tools/rimage/config/nvl.toml.h +++ b/tools/rimage/config/nvl.toml.h @@ -12,6 +12,20 @@ auto_start = "0" index = __COUNTER__ +#if CONFIG_COLD_STORE_EXECUTE_DRAM +[[module.entry]] +name = "COLD" +uuid = UUIDREG_STR_COLD +affinity_mask = "3" +instance_count = "1" +domain_types = "0" +load_type = "0" +module_type = "0" +auto_start = "0" + +index = __COUNTER__ +#endif + [[module.entry]] name = "BASEFW" uuid = "0E398C32-5ADE-BA4B-93B1-C50432280EE4" From 771d6747b384c47eba020a241c3e1f727f40c943 Mon Sep 17 00:00:00 2001 From: Adrian Bonislawski Date: Thu, 25 Sep 2025 08:52:39 +0200 Subject: [PATCH 011/436] boards: ace40: enable cold store DRAM execution Enable CONFIG_COLD_STORE_EXECUTE_DRAM for ACE 4.0 Signed-off-by: Adrian Bonislawski --- app/boards/intel_adsp_ace40_nvl.conf | 1 + app/boards/intel_adsp_ace40_nvls.conf | 1 + 2 files changed, 2 insertions(+) diff --git a/app/boards/intel_adsp_ace40_nvl.conf b/app/boards/intel_adsp_ace40_nvl.conf index 55a6628959e1..34175a8b6b9b 100644 --- a/app/boards/intel_adsp_ace40_nvl.conf +++ b/app/boards/intel_adsp_ace40_nvl.conf @@ -15,6 +15,7 @@ CONFIG_FORMAT_CONVERT_HIFI3=n # SOF / infrastructure CONFIG_PROBE=y CONFIG_PROBE_DMA_MAX=2 +CONFIG_COLD_STORE_EXECUTE_DRAM=y # SOF / loadable modules CONFIG_INTEL_MODULES=y diff --git a/app/boards/intel_adsp_ace40_nvls.conf b/app/boards/intel_adsp_ace40_nvls.conf index 55a6628959e1..34175a8b6b9b 100644 --- a/app/boards/intel_adsp_ace40_nvls.conf +++ b/app/boards/intel_adsp_ace40_nvls.conf @@ -15,6 +15,7 @@ CONFIG_FORMAT_CONVERT_HIFI3=n # SOF / infrastructure CONFIG_PROBE=y CONFIG_PROBE_DMA_MAX=2 +CONFIG_COLD_STORE_EXECUTE_DRAM=y # SOF / loadable modules CONFIG_INTEL_MODULES=y From 1117d0b69da5a8d4643f8b1de1f8774070034ae8 Mon Sep 17 00:00:00 2001 From: Kai Vehmanen Date: Tue, 30 Sep 2025 18:52:39 +0300 Subject: [PATCH 012/436] versions.json: set version to 2.14.99 Open mainline for development and set version to 2.14.99 as stable-v2.14 has branched out. Signed-off-by: Kai Vehmanen --- versions.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/versions.json b/versions.json index 47679041789a..89bebab40c35 100644 --- a/versions.json +++ b/versions.json @@ -1,7 +1,7 @@ { "SOF": { "MAJOR": "2", - "MINOR": "13", + "MINOR": "14", "MICRO": "99" } } From 5bd5a4bf5dcc2a71a9434f22ececa5655a40c151 Mon Sep 17 00:00:00 2001 From: Tomasz Leman Date: Tue, 5 Aug 2025 12:47:11 +0200 Subject: [PATCH 013/436] test: ztest: Add math basic trigonometry unit tests converted from CMock This patch converts 9 existing math trigonometry unit tests from CMock/Unity to Zephyr's Ztest framework, maintaining the same test coverage and functionality: - test_sin_32b_fixed: 32-bit fixed-point sine function - test_sin_16b_fixed: 16-bit fixed-point sine function - test_cos_32b_fixed: 32-bit fixed-point cosine function - test_cos_16b_fixed: 16-bit fixed-point cosine function - test_asin_32b_fixed: 32-bit fixed-point arcsine function - test_asin_16b_fixed: 16-bit fixed-point arcsine function - test_acos_32b_fixed: 32-bit fixed-point arccosine function - test_acos_16b_fixed: 16-bit fixed-point arccosine function - test_sin_lut_16b_fixed: 16-bit sine lookup table function Original tests converted from sof/test/cmocka/src/math/trig/ authored by: - Slawomir Blauciak - Shriram Shastry - Seppo Ingalsuo The converted tests validate the same trigonometric functions from src/math/trig.c and src/math/lut_trig.c as the original CMock tests, ensuring no regression in test coverage during the migration to Ztest framework. Reference tables and tolerance values are preserved to maintain identical test accuracy and validation criteria. This is part of the broader SOF unit test migration from CMock to Zephyr Ztest framework, establishing the foundation for math/basic/trigonometry tests in the new directory structure. Signed-off-by: Tomasz Leman --- .../math/basic/trigonometry/CMakeLists.txt | 28 ++ .../unit/math/basic/trigonometry/prj.conf | 1 + .../math/basic/trigonometry/testcase.yaml | 24 ++ .../math/basic/trigonometry/trig_tables.h | 371 ++++++++++++++++++ .../unit/math/basic/trigonometry/trig_test.c | 225 +++++++++++ 5 files changed, 649 insertions(+) create mode 100644 test/ztest/unit/math/basic/trigonometry/CMakeLists.txt create mode 100644 test/ztest/unit/math/basic/trigonometry/prj.conf create mode 100644 test/ztest/unit/math/basic/trigonometry/testcase.yaml create mode 100644 test/ztest/unit/math/basic/trigonometry/trig_tables.h create mode 100644 test/ztest/unit/math/basic/trigonometry/trig_test.c diff --git a/test/ztest/unit/math/basic/trigonometry/CMakeLists.txt b/test/ztest/unit/math/basic/trigonometry/CMakeLists.txt new file mode 100644 index 000000000000..b5387a998aee --- /dev/null +++ b/test/ztest/unit/math/basic/trigonometry/CMakeLists.txt @@ -0,0 +1,28 @@ +cmake_minimum_required(VERSION 3.20.0) + +find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE}) +project(test_math_trigonometry) + +set(SOF_ROOT "${PROJECT_SOURCE_DIR}/../../../../../..") + +target_include_directories(app PRIVATE + ${SOF_ROOT}/zephyr/include + ${SOF_ROOT}/src/include +) + +# Define SOF-specific configurations for unit testing +target_compile_definitions(app PRIVATE + -DCONFIG_SOF_LOG_LEVEL=CONFIG_LOG_DEFAULT_LEVEL + -DCONFIG_ZEPHYR_POSIX=1 + -DCONFIG_LIBRARY=1 + -DUNIT_TEST=1 +) + +target_sources(app PRIVATE + trig_test.c + ${SOF_ROOT}/src/math/trig.c + ${SOF_ROOT}/src/math/lut_trig.c +) + +# Link math library for standard math functions +target_link_libraries(app PRIVATE m) diff --git a/test/ztest/unit/math/basic/trigonometry/prj.conf b/test/ztest/unit/math/basic/trigonometry/prj.conf new file mode 100644 index 000000000000..9467c2926896 --- /dev/null +++ b/test/ztest/unit/math/basic/trigonometry/prj.conf @@ -0,0 +1 @@ +CONFIG_ZTEST=y diff --git a/test/ztest/unit/math/basic/trigonometry/testcase.yaml b/test/ztest/unit/math/basic/trigonometry/testcase.yaml new file mode 100644 index 000000000000..037fbcaac456 --- /dev/null +++ b/test/ztest/unit/math/basic/trigonometry/testcase.yaml @@ -0,0 +1,24 @@ +# SPDX-License-Identifier: BSD-3-Clause +# +# Copyright(c) 2025 Intel Corporation. All rights reserved. +# +# Math basic trigonometry unit tests converted from CMock to Ztest +# +# These contents may have been developed with support from one or more Intel-operated +# generative artificial intelligence solutions. +# + +common: + tags: + - SOF + - unit_test + - math + - trigonometry + integration_platforms: + - native_sim + arch_exclude: xtensa # Test is for host builds only + +tests: + sof.unit.math.trigonometry: + platform_allow: + - native_sim diff --git a/test/ztest/unit/math/basic/trigonometry/trig_tables.h b/test/ztest/unit/math/basic/trigonometry/trig_tables.h new file mode 100644 index 000000000000..33405231cf48 --- /dev/null +++ b/test/ztest/unit/math/basic/trigonometry/trig_tables.h @@ -0,0 +1,371 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * + * Copyright(c) 2025 Intel Corporation. All rights reserved. + */ + +#ifndef __SOF_ZTEST_TRIG_TABLES_H__ +#define __SOF_ZTEST_TRIG_TABLES_H__ + +/* Reference table generated by sin(), gcc-4.3.2 */ +static const float sin_ref_table[] = { + 0.0000000000, 0.0174524064, 0.0348994967, 0.0523359562, + 0.0697564737, 0.0871557427, 0.1045284633, 0.1218693434, + 0.1391731010, 0.1564344650, 0.1736481777, 0.1908089954, + 0.2079116908, 0.2249510543, 0.2419218956, 0.2588190451, + 0.2756373558, 0.2923717047, 0.3090169944, 0.3255681545, + 0.3420201433, 0.3583679495, 0.3746065934, 0.3907311285, + 0.4067366431, 0.4226182617, 0.4383711468, 0.4539904997, + 0.4694715628, 0.4848096202, 0.5000000000, 0.5150380749, + 0.5299192642, 0.5446390350, 0.5591929035, 0.5735764364, + 0.5877852523, 0.6018150232, 0.6156614753, 0.6293203910, + 0.6427876097, 0.6560590290, 0.6691306064, 0.6819983601, + 0.6946583705, 0.7071067812, 0.7193398003, 0.7313537016, + 0.7431448255, 0.7547095802, 0.7660444431, 0.7771459615, + 0.7880107536, 0.7986355100, 0.8090169944, 0.8191520443, + 0.8290375726, 0.8386705679, 0.8480480962, 0.8571673007, + 0.8660254038, 0.8746197071, 0.8829475929, 0.8910065242, + 0.8987940463, 0.9063077870, 0.9135454576, 0.9205048535, + 0.9271838546, 0.9335804265, 0.9396926208, 0.9455185756, + 0.9510565163, 0.9563047560, 0.9612616959, 0.9659258263, + 0.9702957263, 0.9743700648, 0.9781476007, 0.9816271834, + 0.9848077530, 0.9876883406, 0.9902680687, 0.9925461516, + 0.9945218954, 0.9961946981, 0.9975640503, 0.9986295348, + 0.9993908270, 0.9998476952, 1.0000000000, 0.9998476952, + 0.9993908270, 0.9986295348, 0.9975640503, 0.9961946981, + 0.9945218954, 0.9925461516, 0.9902680687, 0.9876883406, + 0.9848077530, 0.9816271834, 0.9781476007, 0.9743700648, + 0.9702957263, 0.9659258263, 0.9612616959, 0.9563047560, + 0.9510565163, 0.9455185756, 0.9396926208, 0.9335804265, + 0.9271838546, 0.9205048535, 0.9135454576, 0.9063077870, + 0.8987940463, 0.8910065242, 0.8829475929, 0.8746197071, + 0.8660254038, 0.8571673007, 0.8480480962, 0.8386705679, + 0.8290375726, 0.8191520443, 0.8090169944, 0.7986355100, + 0.7880107536, 0.7771459615, 0.7660444431, 0.7547095802, + 0.7431448255, 0.7313537016, 0.7193398003, 0.7071067812, + 0.6946583705, 0.6819983601, 0.6691306064, 0.6560590290, + 0.6427876097, 0.6293203910, 0.6156614753, 0.6018150232, + 0.5877852523, 0.5735764364, 0.5591929035, 0.5446390350, + 0.5299192642, 0.5150380749, 0.5000000000, 0.4848096202, + 0.4694715628, 0.4539904997, 0.4383711468, 0.4226182617, + 0.4067366431, 0.3907311285, 0.3746065934, 0.3583679495, + 0.3420201433, 0.3255681545, 0.3090169944, 0.2923717047, + 0.2756373558, 0.2588190451, 0.2419218956, 0.2249510543, + 0.2079116908, 0.1908089954, 0.1736481777, 0.1564344650, + 0.1391731010, 0.1218693434, 0.1045284633, 0.0871557427, + 0.0697564737, 0.0523359562, 0.0348994967, 0.0174524064, + 0.0000000000, -0.0174524064, -0.0348994967, -0.0523359562, + -0.0697564737, -0.0871557427, -0.1045284633, -0.1218693434, + -0.1391731010, -0.1564344650, -0.1736481777, -0.1908089954, + -0.2079116908, -0.2249510543, -0.2419218956, -0.2588190451, + -0.2756373558, -0.2923717047, -0.3090169944, -0.3255681545, + -0.3420201433, -0.3583679495, -0.3746065934, -0.3907311285, + -0.4067366431, -0.4226182617, -0.4383711468, -0.4539904997, + -0.4694715628, -0.4848096202, -0.5000000000, -0.5150380749, + -0.5299192642, -0.5446390350, -0.5591929035, -0.5735764364, + -0.5877852523, -0.6018150232, -0.6156614753, -0.6293203910, + -0.6427876097, -0.6560590290, -0.6691306064, -0.6819983601, + -0.6946583705, -0.7071067812, -0.7193398003, -0.7313537016, + -0.7431448255, -0.7547095802, -0.7660444431, -0.7771459615, + -0.7880107536, -0.7986355100, -0.8090169944, -0.8191520443, + -0.8290375726, -0.8386705679, -0.8480480962, -0.8571673007, + -0.8660254038, -0.8746197071, -0.8829475929, -0.8910065242, + -0.8987940463, -0.9063077870, -0.9135454576, -0.9205048535, + -0.9271838546, -0.9335804265, -0.9396926208, -0.9455185756, + -0.9510565163, -0.9563047560, -0.9612616959, -0.9659258263, + -0.9702957263, -0.9743700648, -0.9781476007, -0.9816271834, + -0.9848077530, -0.9876883406, -0.9902680687, -0.9925461516, + -0.9945218954, -0.9961946981, -0.9975640503, -0.9986295348, + -0.9993908270, -0.9998476952, -1.0000000000, -0.9998476952, + -0.9993908270, -0.9986295348, -0.9975640503, -0.9961946981, + -0.9945218954, -0.9925461516, -0.9902680687, -0.9876883406, + -0.9848077530, -0.9816271834, -0.9781476007, -0.9743700648, + -0.9702957263, -0.9659258263, -0.9612616959, -0.9563047560, + -0.9510565163, -0.9455185756, -0.9396926208, -0.9335804265, + -0.9271838546, -0.9205048535, -0.9135454576, -0.9063077870, + -0.8987940463, -0.8910065242, -0.8829475929, -0.8746197071, + -0.8660254038, -0.8571673007, -0.8480480962, -0.8386705679, + -0.8290375726, -0.8191520443, -0.8090169944, -0.7986355100, + -0.7880107536, -0.7771459615, -0.7660444431, -0.7547095802, + -0.7431448255, -0.7313537016, -0.7193398003, -0.7071067812, + -0.6946583705, -0.6819983601, -0.6691306064, -0.6560590290, + -0.6427876097, -0.6293203910, -0.6156614753, -0.6018150232, + -0.5877852523, -0.5735764364, -0.5591929035, -0.5446390350, + -0.5299192642, -0.5150380749, -0.5000000000, -0.4848096202, + -0.4694715628, -0.4539904997, -0.4383711468, -0.4226182617, + -0.4067366431, -0.3907311285, -0.3746065934, -0.3583679495, + -0.3420201433, -0.3255681545, -0.3090169944, -0.2923717047, + -0.2756373558, -0.2588190451, -0.2419218956, -0.2249510543, + -0.2079116908, -0.1908089954, -0.1736481777, -0.1564344650, + -0.1391731010, -0.1218693434, -0.1045284633, -0.0871557427, + -0.0697564737, -0.0523359562, -0.0348994967, -0.0174524064 +}; + +/* Reference table generated by cos(), gcc-4.3.2 */ +static const float cos_ref_table[] = { + 1.000000000000000, 0.999847695156391, 0.999390827019096, 0.998629534754574, + 0.997564050259824, 0.996194698091746, 0.994521895368273, 0.992546151641322, + 0.99026806874157, 0.987688340595138, 0.984807753012208, 0.981627183447664, + 0.978147600733806, 0.974370064785235, 0.970295726275996, 0.965925826289068, + 0.961261695938319, 0.956304755963035, 0.951056516295154, 0.945518575599317, + 0.939692620785908, 0.933580426497202, 0.927183854566787, 0.92050485345244, + 0.913545457642601, 0.90630778703665, 0.898794046299167, 0.891006524188368, + 0.882947592858927, 0.874619707139396, 0.866025403784439, 0.857167300702112, + 0.848048096156426, 0.838670567945424, 0.829037572555042, 0.819152044288992, + 0.809016994374947, 0.798635510047293, 0.788010753606722, 0.777145961456971, + 0.766044443118978, 0.754709580222772, 0.743144825477394, 0.731353701619171, + 0.719339800338651, 0.707106781186548, 0.694658370458997, 0.681998360062498, + 0.669130606358858, 0.656059028990507, 0.642787609686539, 0.629320391049838, + 0.615661475325658, 0.601815023152048, 0.587785252292473, 0.573576436351046, + 0.559192903470747, 0.544639035015027, 0.529919264233205, 0.515038074910054, + 0.500000000000000, 0.484809620246337, 0.469471562785891, 0.453990499739547, + 0.438371146789077, 0.422618261740699, 0.4067366430758, 0.390731128489274, + 0.374606593415912, 0.3583679495453, 0.342020143325669, 0.325568154457157, + 0.309016994374947, 0.292371704722737, 0.275637355816999, 0.258819045102521, + 0.241921895599668, 0.224951054343865, 0.207911690817759, 0.190808995376545, + 0.17364817766693, 0.156434465040231, 0.139173100960066, 0.121869343405147, + 0.104528463267653, 0.0871557427476581, 0.0697564737441255, 0.052335956242944, + 0.0348994967025011, 0.0174524064372834, 6.12323399573677e-17, -0.0174524064372835, + -0.0348994967025007, -0.0523359562429436, -0.0697564737441253, -0.0871557427476582, + -0.104528463267653, -0.121869343405147, -0.139173100960065, -0.156434465040231, + -0.17364817766693, -0.190808995376545, -0.207911690817759, -0.224951054343865, + -0.241921895599668, -0.258819045102521, -0.275637355816999, -0.292371704722737, + -0.309016994374947, -0.325568154457156, -0.342020143325669, -0.3583679495453, + -0.374606593415912, -0.390731128489274, -0.4067366430758, -0.422618261740699, + -0.438371146789078, -0.453990499739547, -0.469471562785891, -0.484809620246337, + -0.500000000000000, -0.515038074910054, -0.529919264233205, -0.544639035015027, + -0.559192903470747, -0.573576436351046, -0.587785252292473, -0.601815023152048, + -0.615661475325658, -0.629320391049837, -0.642787609686539, -0.656059028990507, + -0.669130606358858, -0.681998360062498, -0.694658370458997, -0.707106781186547, + -0.719339800338651, -0.73135370161917, -0.743144825477394, -0.754709580222772, + -0.766044443118978, -0.777145961456971, -0.788010753606722, -0.798635510047293, + -0.809016994374947, -0.819152044288992, -0.829037572555042, -0.838670567945424, + -0.848048096156426, -0.857167300702112, -0.866025403784439, -0.874619707139396, + -0.882947592858927, -0.891006524188368, -0.898794046299167, -0.90630778703665, + -0.913545457642601, -0.92050485345244, -0.927183854566787, -0.933580426497202, + -0.939692620785908, -0.945518575599317, -0.951056516295154, -0.956304755963035, + -0.961261695938319, -0.965925826289068, -0.970295726275996, -0.974370064785235, + -0.978147600733806, -0.981627183447664, -0.984807753012208, -0.987688340595138, + -0.99026806874157, -0.992546151641322, -0.994521895368273, -0.996194698091746, + -0.997564050259824, -0.998629534754574, -0.999390827019096, -0.999847695156391, + -1.000000000000000, -0.999847695156391, -0.999390827019096, -0.998629534754574, + -0.997564050259824, -0.996194698091746, -0.994521895368273, -0.992546151641322, + -0.99026806874157, -0.987688340595138, -0.984807753012208, -0.981627183447664, + -0.978147600733806, -0.974370064785235, -0.970295726275997, -0.965925826289068, + -0.961261695938319, -0.956304755963036, -0.951056516295154, -0.945518575599317, + -0.939692620785908, -0.933580426497202, -0.927183854566787, -0.92050485345244, + -0.913545457642601, -0.90630778703665, -0.898794046299167, -0.891006524188368, + -0.882947592858927, -0.874619707139396, -0.866025403784439, -0.857167300702112, + -0.848048096156426, -0.838670567945424, -0.829037572555042, -0.819152044288992, + -0.809016994374947, -0.798635510047293, -0.788010753606722, -0.777145961456971, + -0.766044443118978, -0.754709580222772, -0.743144825477394, -0.731353701619171, + -0.719339800338651, -0.707106781186548, -0.694658370458997, -0.681998360062499, + -0.669130606358858, -0.656059028990508, -0.642787609686539, -0.629320391049837, + -0.615661475325658, -0.601815023152048, -0.587785252292473, -0.573576436351046, + -0.559192903470747, -0.544639035015027, -0.529919264233205, -0.515038074910054, + -0.500000000000000, -0.484809620246337, -0.469471562785891, -0.453990499739547, + -0.438371146789078, -0.4226182617407, -0.4067366430758, -0.390731128489274, + -0.374606593415912, -0.358367949545301, -0.342020143325669, -0.325568154457157, + -0.309016994374948, -0.292371704722737, -0.275637355816999, -0.258819045102521, + -0.241921895599668, -0.224951054343865, -0.20791169081776, -0.190808995376545, + -0.17364817766693, -0.156434465040231, -0.139173100960065, -0.121869343405147, + -0.104528463267653, -0.0871557427476582, -0.0697564737441256, -0.0523359562429443, + -0.0348994967025016, -0.0174524064372835, -1.83697019872103e-16, 0.0174524064372831, + 0.0348994967025013, 0.0523359562429439, 0.0697564737441252, 0.0871557427476579, + 0.104528463267653, 0.121869343405148, 0.139173100960065, 0.156434465040231, + 0.17364817766693, 0.190808995376544, 0.207911690817759, 0.224951054343865, + 0.241921895599667, 0.258819045102521, 0.275637355816999, 0.292371704722737, + 0.309016994374947, 0.325568154457156, 0.342020143325668, 0.3583679495453, + 0.374606593415912, 0.390731128489273, 0.406736643075801, 0.4226182617407, + 0.438371146789077, 0.453990499739547, 0.46947156278589, 0.484809620246337, + 0.500000000000000, 0.515038074910054, 0.529919264233205, 0.544639035015027, + 0.559192903470746, 0.573576436351046, 0.587785252292473, 0.601815023152048, + 0.615661475325659, 0.629320391049838, 0.642787609686539, 0.656059028990507, + 0.669130606358858, 0.681998360062498, 0.694658370458997, 0.707106781186547, + 0.719339800338651, 0.731353701619171, 0.743144825477394, 0.754709580222772, + 0.766044443118978, 0.777145961456971, 0.788010753606722, 0.798635510047293, + 0.809016994374947, 0.819152044288992, 0.829037572555041, 0.838670567945424, + 0.848048096156425, 0.857167300702112, 0.866025403784438, 0.874619707139396, + 0.882947592858927, 0.891006524188368, 0.898794046299167, 0.90630778703665, + 0.913545457642601, 0.92050485345244, 0.927183854566787, 0.933580426497202, + 0.939692620785908, 0.945518575599317, 0.951056516295154, 0.956304755963036, + 0.961261695938319, 0.965925826289068, 0.970295726275996, 0.974370064785235, + 0.978147600733806, 0.981627183447664, 0.984807753012208, 0.987688340595138, + 0.99026806874157, 0.992546151641322, 0.994521895368273, 0.996194698091746, + 0.997564050259824, 0.998629534754574, 0.999390827019096, 0.999847695156391, + 1 +}; + +/* Reference table generated by asin(), gcc-4.3.2 */ +static const float asin_ref_table[] = { + -1.5707963258028030, -1.4292567726224661, -1.3704614471644163, -1.3252307642251253, + -1.2870021797716618, -1.2532358597964048, -1.2226302791386843, -1.1944128256291151, + -1.1680804640054703, -1.1432840377092361, -1.1197695024311543, -1.0973451361060143, + -1.0758621711283922, -1.0552022922784090, -1.0352696590125561, -1.0159852746874094, + -0.9972832072526217, -0.9791076704859734, -0.9614110030233860, -0.9441520925611258, + -0.9272952042520046, -0.9108089841902256, -0.8946658074855804, -0.8788411282002926, + -0.8633130993694067, -0.8480620700865984, -0.8330703470855951, -0.8183219302445650, + -0.8038023039698601, -0.7894981894642115, -0.7753974795341492, -0.7614890411496162, + -0.7477626111358404, -0.7342087719589472, -0.7208187356591225, -0.7075844295322895, + -0.6944982521235943, -0.6815531998872757, -0.6687426939606667, -0.6560605876147747, + -0.6435010936111212, -0.6310588326305151, -0.6187286712229252, -0.6065058410167694, + -0.5943857878446579, -0.5823642127215862, -0.5704370923340321, -0.5586005486547947, + -0.5468509383499622, -0.5351847745478153, -0.5235987640917301, -0.5120897386223078, + -0.5006546974182129, -0.4892907701432705, -0.4779951833188534, -0.4667653329670429, + -0.4555986635386944, -0.4444927759468555, -0.4334453158080578, -0.4224540572613478, + -0.4115168377757072, -0.4006315693259239, -0.3897962793707848, -0.3790090084075928, + -0.3682678826153278, -0.3575710840523243, -0.3469168916344643, -0.3363035582005978, + -0.3257294744253159, -0.3151930235326290, -0.3046926259994507, -0.2942268401384354, + -0.2837941013276577, -0.2733930107206106, -0.2630221955478191, -0.2526802383363247, + -0.2423658333718777, -0.2320776768028736, -0.2218144722282887, -0.2115749418735504, + -0.2013579159975052, -0.1911621354520321, -0.1809864528477192, -0.1708296611905098, + -0.1606906354427338, -0.1505682766437531, -0.1404614131897688, -0.1303689777851105, + -0.1202898658812046, -0.1102230437099934, -0.1001674197614193, -0.0901219304651022, + -0.0800855793058872, -0.0700572803616524, -0.0600360594689846, -0.0500208474695683, + -0.0400106683373451, -0.0300045013427734, -0.0200013294816017, -0.0100001543760300, + 0.0000000000000000, 0.0100001543760300, 0.0200013294816017, 0.0300045013427734, + 0.0400106683373451, 0.0500208474695683, 0.0600360594689846, 0.0700572803616524, + 0.0800855793058872, 0.0901219304651022, 0.1001674197614193, 0.1102230437099934, + 0.1202898658812046, 0.1303689777851105, 0.1404614131897688, 0.1505682766437531, + 0.1606906354427338, 0.1708296611905098, 0.1809864528477192, 0.1911621354520321, + 0.2013579159975052, 0.2115749418735504, 0.2218144722282887, 0.2320776768028736, + 0.2423658333718777, 0.2526802383363247, 0.2630221955478191, 0.2733930107206106, + 0.2837941013276577, 0.2942268401384354, 0.3046926259994507, 0.3151930235326290, + 0.3257294744253159, 0.3363035582005978, 0.3469168916344643, 0.3575710840523243, + 0.3682678826153278, 0.3790090084075928, 0.3897962793707848, 0.4006315693259239, + 0.4115168377757072, 0.4224540572613478, 0.4334453158080578, 0.4444927759468555, + 0.4555986635386944, 0.4667653329670429, 0.4779951833188534, 0.4892907701432705, + 0.5006546974182129, 0.5120897386223078, 0.5235987640917301, 0.5351847745478153, + 0.5468509383499622, 0.5586005486547947, 0.5704370923340321, 0.5823642127215862, + 0.5943857878446579, 0.6065058410167694, 0.6187286712229252, 0.6310588326305151, + 0.6435010936111212, 0.6560605876147747, 0.6687426939606667, 0.6815531998872757, + 0.6944982521235943, 0.7075844295322895, 0.7208187356591225, 0.7342087719589472, + 0.7477626111358404, 0.7614890411496162, 0.7753974795341492, 0.7894981894642115, + 0.8038023039698601, 0.8183219302445650, 0.8330703470855951, 0.8480620700865984, + 0.8633130993694067, 0.8788411282002926, 0.8946658074855804, 0.9108089841902256, + 0.9272952042520046, 0.9441520925611258, 0.9614110030233860, 0.9791076704859734, + 0.9972832072526217, 1.0159852746874094, 1.0352696590125561, 1.0552022922784090, + 1.0758621711283922, 1.0973451361060143, 1.1197695024311543, 1.1432840377092361, + 1.1680804640054703, 1.1944128256291151, 1.2226302791386843, 1.2532358597964048, + 1.2870021797716618, 1.3252307642251253, 1.3704614471644163, 1.4292567726224661, + 1.5707963258028030, +}; + +/* Reference table generated by acos(), gcc-4.3.2 */ +static const float acos_ref_table[] = { + 3.1415926534682512, 3.0000531002879143, 2.9412577748298645, 2.8960270918905735, + 2.8577985074371099, 2.8240321874618530, 2.7934266068041325, 2.7652091532945633, + 2.7388767916709185, 2.7140803653746843, 2.6905658300966024, 2.6681414637714624, + 2.6466584987938404, 2.6259986199438572, 2.6060659866780043, 2.5867816023528576, + 2.5680795349180698, 2.5499039981514215, 2.5322073306888342, 2.5149484202265739, + 2.4980915319174528, 2.4816053118556738, 2.4654621351510286, 2.4496374558657408, + 2.4341094270348549, 2.4188583977520466, 2.4038666747510433, 2.3891182579100132, + 2.3745986316353083, 2.3602945171296597, 2.3461938071995974, 2.3322853688150644, + 2.3185589388012886, 2.3050050996243954, 2.2916150633245707, 2.2783807571977377, + 2.2652945797890425, 2.2523495275527239, 2.2395390216261148, 2.2268569152802229, + 2.2142974212765694, 2.2018551602959633, 2.1895249988883734, 2.1773021686822176, + 2.1651821155101061, 2.1531605403870344, 2.1412334199994802, 2.1293968763202429, + 2.1176472660154104, 2.1059811022132635, 2.0943950917571783, 2.0828860662877560, + 2.0714510250836611, 2.0600870978087187, 2.0487915109843016, 2.0375616606324911, + 2.0263949912041426, 2.0152891036123037, 2.0042416434735060, 1.9932503849267960, + 1.9823131654411554, 1.9714278969913721, 1.9605926070362329, 1.9498053360730410, + 1.9390642102807760, 1.9283674117177725, 1.9177132192999125, 1.9070998858660460, + 1.8965258020907640, 1.8859893511980772, 1.8754889536648989, 1.8650231678038836, + 1.8545904289931059, 1.8441893383860588, 1.8338185232132673, 1.8234765660017729, + 1.8131621610373259, 1.8028740044683218, 1.7926107998937368, 1.7823712695389986, + 1.7721542436629534, 1.7619584631174803, 1.7517827805131674, 1.7416259888559580, + 1.7314869631081820, 1.7213646043092012, 1.7112577408552170, 1.7011653054505587, + 1.6910861935466528, 1.6810193713754416, 1.6709637474268675, 1.6609182581305504, + 1.6508819069713354, 1.6408536080271006, 1.6308323871344328, 1.6208171751350164, + 1.6108069960027933, 1.6008008290082216, 1.5907976571470499, 1.5807964820414782, + 1.5707963258028030, 1.5607961714267731, 1.5507949963212013, 1.5407918244600296, + 1.5307856574654579, 1.5207754783332348, 1.5107602663338184, 1.5007390454411507, + 1.4907107464969158, 1.4806743953377008, 1.4706289060413837, 1.4605732820928097, + 1.4505064599215984, 1.4404273480176926, 1.4303349126130342, 1.4202280491590500, + 1.4101056903600693, 1.3999666646122932, 1.3898098729550838, 1.3796341903507710, + 1.3694384098052979, 1.3592213839292526, 1.3489818535745144, 1.3387186489999294, + 1.3284304924309254, 1.3181160874664783, 1.3077741302549839, 1.2974033150821924, + 1.2870022244751453, 1.2765694856643677, 1.2661036998033524, 1.2556033022701740, + 1.2450668513774872, 1.2344927676022053, 1.2238794341683388, 1.2132252417504787, + 1.2025284431874752, 1.1917872473952103, 1.1810000464320183, 1.1701647564768791, + 1.1592794880270958, 1.1483422685414553, 1.1373510099947453, 1.1263035498559475, + 1.1151976622641087, 1.1040309928357601, 1.0928011424839497, 1.0815055556595325, + 1.0701416283845901, 1.0587065871804953, 1.0471975617110729, 1.0356115512549877, + 1.0239453874528408, 1.0121957771480083, 1.0003592334687710, 0.9884321130812168, + 0.9764105379581451, 0.9642904847860336, 0.9520676545798779, 0.9397374931722879, + 0.9272952321916819, 0.9147357381880283, 0.9020536318421364, 0.8892431259155273, + 0.8762980736792088, 0.8632118962705135, 0.8499775901436806, 0.8365875538438559, + 0.8230337146669626, 0.8093072846531868, 0.7953988462686539, 0.7812981363385916, + 0.7669940218329430, 0.7524743955582380, 0.7377259787172079, 0.7227342557162046, + 0.7074832264333963, 0.6919551976025105, 0.6761305183172226, 0.6599873416125774, + 0.6435011215507984, 0.6266442332416773, 0.6093853227794170, 0.5916886553168297, + 0.5735131185501814, 0.5548110511153936, 0.5355266667902470, 0.5155940335243940, + 0.4949341546744108, 0.4734511896967888, 0.4510268233716488, 0.4275122880935669, + 0.4027158617973328, 0.3763835001736879, 0.3481660466641188, 0.3175604660063982, + 0.2837941460311413, 0.2455655615776777, 0.2003348786383867, 0.1415395531803370, + 0.0000000000000000 +}; + +/* Reference degree table generated for acos(),asin() in range of [-1:1e-2:1]*/ +static const double degree_table[] = { + -57.2957795262336731, -56.7228217124938965, -56.1498639285564423, -55.5769061148166656, + -55.0039483308792114, -54.4309905469417572, -53.8580327332019806, -53.2850749492645264, + -52.7121171653270721, -52.1391593515872955, -51.5662015676498413, -50.9932437539100647, + -50.4202859699726105, -49.8473281860351562, -49.2743703722953796, -48.7014125883579254, + -48.1284548044204712, -47.5554969906806946, -46.9825392067432404, -46.4095813930034637, + -45.8366236090660095, -45.2636658251285553, -44.6907080113887787, -44.1177502274513245, + -43.5447924435138702, -42.9718346297740936, -42.3988768458366394, -41.8259190320968628, + -41.2529612481594086, -40.6800034642219543, -40.1070456504821777, -39.5340878665447235, + -38.9611300826072693, -38.3881722688674927, -37.8152144849300385, -37.2422566711902618, + -36.6692988872528076, -36.0963411033153534, -35.5233832895755768, -34.9504255056381226, + -34.3774677217006683, -33.8045099079608917, -33.2315521240234375, -32.6585943102836609, + -32.0856365263462067, -31.5126787424087524, -30.9397209286689758, -30.3667631447315216, + -29.7938053607940674, -29.2208475470542908, -28.6478897631168365, -28.0749319493770599, + -27.5019741654396057, -26.9290163815021515, -26.3560585677623749, -25.7831007838249207, + -25.2101429998874664, -24.6371851861476898, -24.0642274022102356, -23.4912695884704590, + -22.9183118045330048, -22.3453540205955505, -21.7723962068557739, -21.1994384229183197, + -20.6264806389808655, -20.0535228252410889, -19.4805650413036346, -18.9076072275638580, + -18.3346494436264038, -17.7616916596889496, -17.1887338459491730, -16.6157760620117188, + -16.0428182780742645, -15.4698604643344879, -14.8969026803970337, -14.3239448666572571, + -13.7509870827198029, -13.1780292987823486, -12.6050714850425720, -12.0321137011051178, + -11.4591559171676636, -10.8861981034278870, -10.3132403194904327, -9.7402825057506561, + -9.1673247218132019, -8.5943669378757477, -8.0214091241359711, -7.4484513401985168, + -6.8754935562610626, -6.3025357425212860, -5.7295779585838318, -5.1566201448440552, + -4.5836623609066010, -4.0107045769691467, -3.4377467632293701, -2.8647889792919159, + -2.2918311953544617, -1.7188733816146851, -1.1459155976772308, -0.5729577839374542, + 0.0000000000000000, 0.5729577839374542, 1.1459155976772308, 1.7188733816146851, + 2.2918311953544617, 2.8647889792919159, 3.4377467632293701, 4.0107045769691467, + 4.5836623609066010, 5.1566201448440552, 5.7295779585838318, 6.3025357425212860, + 6.8754935562610626, 7.4484513401985168, 8.0214091241359711, 8.5943669378757477, + 9.1673247218132019, 9.7402825057506561, 10.3132403194904327, 10.8861981034278870, + 11.4591559171676636, 12.0321137011051178, 12.6050714850425720, 13.1780292987823486, + 13.7509870827198029, 14.3239448666572571, 14.8969026803970337, 15.4698604643344879, + 16.0428182780742645, 16.6157760620117188, 17.1887338459491730, 17.7616916596889496, + 18.3346494436264038, 18.9076072275638580, 19.4805650413036346, 20.0535228252410889, + 20.6264806389808655, 21.1994384229183197, 21.7723962068557739, 22.3453540205955505, + 22.9183118045330048, 23.4912695884704590, 24.0642274022102356, 24.6371851861476898, + 25.2101429998874664, 25.7831007838249207, 26.3560585677623749, 26.9290163815021515, + 27.5019741654396057, 28.0749319493770599, 28.6478897631168365, 29.2208475470542908, + 29.7938053607940674, 30.3667631447315216, 30.9397209286689758, 31.5126787424087524, + 32.0856365263462067, 32.6585943102836609, 33.2315521240234375, 33.8045099079608917, + 34.3774677217006683, 34.9504255056381226, 35.5233832895755768, 36.0963411033153534, + 36.6692988872528076, 37.2422566711902618, 37.8152144849300385, 38.3881722688674927, + 38.9611300826072693, 39.5340878665447235, 40.1070456504821777, 40.6800034642219543, + 41.2529612481594086, 41.8259190320968628, 42.3988768458366394, 42.9718346297740936, + 43.5447924435138702, 44.1177502274513245, 44.6907080113887787, 45.2636658251285553, + 45.8366236090660095, 46.4095813930034637, 46.9825392067432404, 47.5554969906806946, + 48.1284548044204712, 48.7014125883579254, 49.2743703722953796, 49.8473281860351562, + 50.4202859699726105, 50.9932437539100647, 51.5662015676498413, 52.1391593515872955, + 52.7121171653270721, 53.2850749492645264, 53.8580327332019806, 54.4309905469417572, + 55.0039483308792114, 55.5769061148166656, 56.1498639285564423, 56.7228217124938965, + 57.2957795262336731 +}; + +#define CMP_TOLERANCE_32B 0.0000000611175871f +#define CMP_TOLERANCE_16B 0.000065f +#define CMP_TOLERANCE_ASIN_32B 0.000000068141916f +#define CMP_TOLERANCE_ACOS_32B 0.000000060077032f +#define CMP_TOLERANCE_ASIN_16B 0.0001152158f +#define CMP_TOLERANCE_ACOS_16B 0.0001196862f +#define CMP_TOLERANCE_SIN 3.1e-5f + +#endif /* __SOF_ZTEST_TRIG_TABLES_H__ */ diff --git a/test/ztest/unit/math/basic/trigonometry/trig_test.c b/test/ztest/unit/math/basic/trigonometry/trig_test.c new file mode 100644 index 000000000000..61cb19ef6142 --- /dev/null +++ b/test/ztest/unit/math/basic/trigonometry/trig_test.c @@ -0,0 +1,225 @@ +// SPDX-License-Identifier: BSD-3-Clause +// +// Copyright(c) 2025 Intel Corporation. All rights reserved. +// +// These contents may have been developed with support from one or more Intel-operated +// generative artificial intelligence solutions. +// +// Converted from CMock to Ztest +// +// Original tests from sof/test/cmocka/src/math/trig/: +// - sin_32b_fixed.c (Author: Slawomir Blauciak ) +// - sin_16b_fixed.c (Author: Shriram Shastry ) +// - cos_32b_fixed.c (Author: Shriram Shastry ) +// - cos_16b_fixed.c (Author: Shriram Shastry ) +// - asin_32b_fixed.c (Author: Shriram Shastry ) +// - asin_16b_fixed.c (Author: Shriram Shastry ) +// - acos_32b_fixed.c (Author: Shriram Shastry ) +// - acos_16b_fixed.c (Author: Shriram Shastry ) +// - lut_sin_16b_fixed.c (Authors: Slawomir Blauciak , +// Seppo Ingalsuo ) + +#define _USE_MATH_DEFINES +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "trig_tables.h" + +/* Define M_PI if not available */ +#ifndef M_PI +#define M_PI 3.14159265358979323846 +#endif + +/* Conversion factor from degrees to radians (PI/180) */ +#define DEGREES_TO_RADIANS 0.017453292519943295 + +/* + * Helper function for rounding double values to nearest integer + * Implements custom rounding: round to 0 if absolute value < 0.5, otherwise round normally + */ +static inline int32_t round_to_nearest_int(double value) +{ + double abs_value = fabs(value); + + return (int32_t) (abs_value >= 0.5) ? floor(value + 0.5) : 0.0; +} + +/* Test sin_32b_fixed function */ +ZTEST(trigonometry, test_sin_32b_fixed) +{ + int theta; + float delta; + double rad; + int32_t sin_val; + + for (theta = 0; theta < ARRAY_SIZE(sin_ref_table); ++theta) { + rad = M_PI * ((double)theta / 180.0); + sin_val = sin_fixed_32b(Q_CONVERT_FLOAT(rad, 28)); + delta = fabsf(sin_ref_table[theta] - Q_CONVERT_QTOF(sin_val, 31)); + zassert_true(delta <= CMP_TOLERANCE_32B, + "sin_32b_fixed failed for angle %d", theta); + } +} + +/* Test sin_16b_fixed function */ +ZTEST(trigonometry, test_sin_16b_fixed) +{ + int theta; + float delta; + double rad; + int16_t sin_val; + + for (theta = 0; theta < ARRAY_SIZE(sin_ref_table); ++theta) { + rad = M_PI * ((double)theta / 180.0); + sin_val = sin_fixed_16b(Q_CONVERT_FLOAT(rad, 28)); + delta = fabsf(sin_ref_table[theta] - Q_CONVERT_QTOF(sin_val, 15)); + zassert_true(delta <= CMP_TOLERANCE_16B, + "sin_16b_fixed failed for angle %d", theta); + } +} + +/* Test cos_32b_fixed function */ +ZTEST(trigonometry, test_cos_32b_fixed) +{ + int theta; + float delta; + double rad; + int32_t cos_val; + + for (theta = 0; theta < ARRAY_SIZE(cos_ref_table); ++theta) { + rad = M_PI * ((double)theta / 180.0); + cos_val = cos_fixed_32b(Q_CONVERT_FLOAT(rad, 28)); + delta = fabsf(cos_ref_table[theta] - Q_CONVERT_QTOF(cos_val, 31)); + zassert_true(delta <= CMP_TOLERANCE_32B, + "cos_32b_fixed failed for angle %d", theta); + } +} + +/* Test cos_16b_fixed function */ +ZTEST(trigonometry, test_cos_16b_fixed) +{ + int theta; + float delta; + double rad; + int16_t cos_val; + + for (theta = 0; theta < ARRAY_SIZE(cos_ref_table); ++theta) { + rad = M_PI * ((double)theta / 180.0); + cos_val = cos_fixed_16b(Q_CONVERT_FLOAT(rad, 28)); + delta = fabsf(cos_ref_table[theta] - Q_CONVERT_QTOF(cos_val, 15)); + zassert_true(delta <= CMP_TOLERANCE_16B, + "cos_16b_fixed failed for angle %d", theta); + } +} + +/* Test asin_32b_fixed function */ +ZTEST(trigonometry, test_asin_32b_fixed) +{ + int index; + float delta; + double u; + int32_t asin_val, input_val; + + for (index = 0; index < ARRAY_SIZE(degree_table); ++index) { + /* Convert degree to input value in Q2.30 format like original test */ + /* angleInRadians = PI/180 * angleInDegrees & const Q2.30 format */ + u = (DEGREES_TO_RADIANS * degree_table[index] * 0x40000000); + input_val = round_to_nearest_int(u); + + asin_val = asin_fixed_32b(input_val); + delta = fabsf(asin_ref_table[index] - Q_CONVERT_QTOF(asin_val, 29)); + zassert_true(delta <= CMP_TOLERANCE_ASIN_32B, + "asin_32b_fixed failed for index %d", index); + } +} + +/* Test asin_16b_fixed function */ +ZTEST(trigonometry, test_asin_16b_fixed) +{ + int index; + float delta; + double u; + int16_t asin_val; + int32_t input_val; + + for (index = 0; index < ARRAY_SIZE(degree_table); ++index) { + /* Convert degree to input value in Q2.30 format like original test */ + /* angleInRadians = PI/180 * angleInDegrees & const Q2.30 format */ + u = (DEGREES_TO_RADIANS * degree_table[index] * 0x40000000); + input_val = round_to_nearest_int(u); + + asin_val = asin_fixed_16b(input_val); + delta = fabsf(asin_ref_table[index] - Q_CONVERT_QTOF(asin_val, 13)); + zassert_true(delta <= CMP_TOLERANCE_ASIN_16B, + "asin_16b_fixed failed for index %d", index); + } +} + +/* Test acos_32b_fixed function */ +ZTEST(trigonometry, test_acos_32b_fixed) +{ + int index; + float delta; + double u; + int32_t acos_val, input_val; + + for (index = 0; index < ARRAY_SIZE(degree_table); ++index) { + /* Convert degree to input value in Q2.30 format like original test */ + /* angleInRadians = PI/180 * angleInDegrees & const Q2.30 format */ + u = (DEGREES_TO_RADIANS * degree_table[index] * 0x40000000); + input_val = round_to_nearest_int(u); + + acos_val = acos_fixed_32b(input_val); + delta = fabsf(acos_ref_table[index] - Q_CONVERT_QTOF(acos_val, 29)); + zassert_true(delta <= CMP_TOLERANCE_ACOS_32B, + "acos_32b_fixed failed for index %d", index); + } +} + +/* Test acos_16b_fixed function */ +ZTEST(trigonometry, test_acos_16b_fixed) +{ + int index; + float delta; + double u; + int16_t acos_val; + int32_t input_val; + + for (index = 0; index < ARRAY_SIZE(degree_table); ++index) { + /* Convert degree to input value in Q2.30 format like original test */ + /* angleInRadians = PI/180 * angleInDegrees & const Q2.30 format */ + u = (DEGREES_TO_RADIANS * degree_table[index] * 0x40000000); + input_val = round_to_nearest_int(u); + + acos_val = acos_fixed_16b(input_val); + delta = fabsf(acos_ref_table[index] - Q_CONVERT_QTOF(acos_val, 13)); + zassert_true(delta <= CMP_TOLERANCE_ACOS_16B, + "acos_16b_fixed failed for index %d", index); + } +} + +/* Test sin lookup table function */ +ZTEST(trigonometry, test_sin_lut_16b_fixed) +{ + int theta; + float delta; + double rad; + int16_t sin_val; + + for (theta = 0; theta < ARRAY_SIZE(sin_ref_table); ++theta) { + rad = M_PI * (double)theta / 180.0; + sin_val = sofm_lut_sin_fixed_16b(Q_CONVERT_FLOAT(rad, 28)); + delta = fabsf(sin_ref_table[theta] - Q_CONVERT_QTOF(sin_val, 15)); + zassert_true(delta <= CMP_TOLERANCE_SIN, + "sin_lut_16b_fixed failed for angle %d", theta); + } +} + +ZTEST_SUITE(trigonometry, NULL, NULL, NULL, NULL, NULL); From b6ff255ffdaa91d9294f41f691a215007949acdf Mon Sep 17 00:00:00 2001 From: Tomasz Leman Date: Thu, 25 Sep 2025 15:13:49 +0200 Subject: [PATCH 014/436] copier: fix queue ID extraction using correct IPC4 macro Fix NULL pointer dereference crash in copier module by using the correct IPC4 macro to extract queue IDs from buffer IDs. The issue occurred in do_conversion_copy() and copier_module_copy() when accessing cd->converter[i] where i was extracted using IPC4_SINK_QUEUE_ID(). This was incorrect because buffer IDs are constructed as: IPC4_COMP_ID(src_queue, dst_queue) From the buffer's perspective, the copier's sink is actually the source, so IPC4_SRC_QUEUE_ID() should be used to get the correct copier sink index. Using IPC4_SINK_QUEUE_ID() extracted the dst_queue (upper 16 bits) instead of src_queue (lower 16 bits), leading to wrong array indices and NULL pointer crashes when the converter array wasn't initialized for those indices. This resolves crashes in RTC AEC topologies where internal module copiers have buffer IDs that map to non-zero queue IDs. Signed-off-by: Tomasz Leman --- src/audio/copier/copier.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/audio/copier/copier.c b/src/audio/copier/copier.c index 9aab0858a305..0e1db840db67 100644 --- a/src/audio/copier/copier.c +++ b/src/audio/copier/copier.c @@ -540,7 +540,12 @@ static int do_conversion_copy(struct comp_dev *dev, comp_get_copy_limits(src, sink, processed_data); - i = IPC4_SINK_QUEUE_ID(buf_get_id(sink)); + /* + * Buffer ID is constructed as IPC4_COMP_ID(src_queue, dst_queue). + * From the buffer's perspective, copier's sink is the source, + * so we use IPC4_SRC_QUEUE_ID() to get the correct copier sink index. + */ + i = IPC4_SRC_QUEUE_ID(buf_get_id(sink)); if (i >= IPC4_COPIER_MODULE_OUTPUT_PINS_COUNT) return -EINVAL; buffer_stream_invalidate(src, processed_data->source_bytes); @@ -617,7 +622,12 @@ static int copier_module_copy(struct processing_module *mod, uint32_t source_samples; int sink_queue_id; - sink_queue_id = IPC4_SINK_QUEUE_ID(buf_get_id(sink_c)); + /* + * Buffer ID is constructed as IPC4_COMP_ID(src_queue, dst_queue). + * From the buffer's perspective, copier's sink is the source, + * so we use IPC4_SRC_QUEUE_ID() to get the correct copier sink index. + */ + sink_queue_id = IPC4_SRC_QUEUE_ID(buf_get_id(sink_c)); if (sink_queue_id >= IPC4_COPIER_MODULE_OUTPUT_PINS_COUNT) return -EINVAL; From 9a6ee49c742fd4c3c82ad13d1a6876047da9214f Mon Sep 17 00:00:00 2001 From: Peter Ujfalusi Date: Tue, 23 Sep 2025 16:45:49 +0300 Subject: [PATCH 015/436] base_fw: Extend fw_config with information about the host buffer size The host buffer default or minimum size can be platform dependent and it is not know by the host. It is in sole discretion of the firmware and the hardware where it is running and can be changed by recompiling the firmware. Add new tlv item to fw_config with ID 33 and store the host DMA default period size, which is the indication of the default, minimum size of the host buffer in ms. Signed-off-by: Peter Ujfalusi --- src/audio/base_fw.c | 26 ++++++++++++++++++++++++++ src/include/ipc4/base_fw.h | 2 ++ 2 files changed, 28 insertions(+) diff --git a/src/audio/base_fw.c b/src/audio/base_fw.c index ed7f131d04e4..2d8655af163b 100644 --- a/src/audio/base_fw.c +++ b/src/audio/base_fw.c @@ -44,6 +44,27 @@ DECLARE_TR_CTX(basefw_comp_tr, SOF_UUID(basefw_uuid), LOG_LEVEL_INFO); static struct ipc4_system_time_info global_system_time_info; static uint64_t global_cycle_delta; +__cold static uint32_t get_host_buffer_size(void) +{ + struct sof_dma *dma_host; + uint32_t periods; + + assert_can_be_cold(); + + dma_host = sof_dma_get(SOF_DMA_DIR_HMEM_TO_LMEM, 0, SOF_DMA_DEV_HOST, + SOF_DMA_ACCESS_SHARED); + if (!dma_host) { + LOG_WRN("Failed to get host DMA channel"); + return 0; + } + + periods = dma_host->plat_data.period_count; + + sof_dma_put(dma_host); + + return periods; +} + __cold static int basefw_config(uint32_t *data_offset, char *data) { uint16_t version[4] = {SOF_MAJOR, SOF_MINOR, SOF_MICRO, SOF_BUILD}; @@ -124,6 +145,11 @@ __cold static int basefw_config(uint32_t *data_offset, char *data) tuple = tlv_next(tuple); + tlv_value_uint32_set(tuple, IPC4_FW_MIN_HOST_BUFFER_PERIODS, + get_host_buffer_size()); + + tuple = tlv_next(tuple); + /* add platform specific tuples */ basefw_vendor_fw_config(&plat_data_offset, (char *)tuple); diff --git a/src/include/ipc4/base_fw.h b/src/include/ipc4/base_fw.h index 25601b1209f0..86ee5f72a588 100644 --- a/src/include/ipc4/base_fw.h +++ b/src/include/ipc4/base_fw.h @@ -373,6 +373,8 @@ enum ipc4_fw_config_params { IPC4_DMI_FORCE_L1_EXIT = 28, /* FW context save on D3 entry */ IPC4_FW_CONTEXT_SAVE = 29, + /* Minimum size of host buffer in ms */ + IPC4_FW_MIN_HOST_BUFFER_PERIODS = 33, /* Total number of FW config parameters */ IPC4_FW_CFG_PARAMS_COUNT, /* Max config parameter id */ From d15670dd22982f28839f6e75909858dc4fd5749e Mon Sep 17 00:00:00 2001 From: Jyri Sarha Date: Thu, 4 Sep 2025 15:50:43 +0300 Subject: [PATCH 016/436] alloc: Add rmalloc_align() function Add rmalloc_align() function. The alignment is present in all alloc implementations used by rmalloc() so there is no reason not to provide it in the API. Signed-off-by: Jyri Sarha --- posix/include/rtos/alloc.h | 7 +++++++ zephyr/include/rtos/alloc.h | 6 ++++++ zephyr/lib/alloc.c | 15 +++++++++++---- 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/posix/include/rtos/alloc.h b/posix/include/rtos/alloc.h index 7927f17394e5..7dbf070259ff 100644 --- a/posix/include/rtos/alloc.h +++ b/posix/include/rtos/alloc.h @@ -61,8 +61,15 @@ * Allocates memory block. * @param flags Flags, see SOF_MEM_FLAG_... * @param bytes Size in bytes. + * @param alignment Alignment in bytes. * @return Pointer to the allocated memory or NULL if failed. */ +void *rmalloc_align(uint32_t flags, size_t bytes, + uint32_t alignment); + +/** + * Similar to rmalloc_align(), but no alignment can be specified. + */ void *rmalloc(uint32_t flags, size_t bytes); /** diff --git a/zephyr/include/rtos/alloc.h b/zephyr/include/rtos/alloc.h index 0cf885ffe2ad..2738a0ac230b 100644 --- a/zephyr/include/rtos/alloc.h +++ b/zephyr/include/rtos/alloc.h @@ -52,9 +52,15 @@ * Allocates memory block. * @param flags Flags, see SOF_MEM_FLAG_.... * @param bytes Size in bytes. + * @param alignment Alignment in bytes. * @return Pointer to the allocated memory or NULL if failed. * */ +void *rmalloc_align(uint32_t flags, size_t bytes, uint32_t alignment); + +/** + * Similar to rmalloc_align(), but no alignment can be specified. + */ void *rmalloc(uint32_t flags, size_t bytes); /** diff --git a/zephyr/lib/alloc.c b/zephyr/lib/alloc.c index 2af0eb83397d..17d8d1a20af5 100644 --- a/zephyr/lib/alloc.c +++ b/zephyr/lib/alloc.c @@ -439,7 +439,7 @@ static void heap_free(struct k_heap *h, void *mem) } -void *rmalloc(uint32_t flags, size_t bytes) +void *rmalloc_align(uint32_t flags, size_t bytes, uint32_t alignment) { void *ptr; struct k_heap *heap; @@ -453,7 +453,7 @@ void *rmalloc(uint32_t flags, size_t bytes) tr_err(&zephyr_tr, "L3_HEAP available for cached addresses only!"); return NULL; } - ptr = (__sparse_force void *)l3_heap_alloc_aligned(heap, 0, bytes); + ptr = (__sparse_force void *)l3_heap_alloc_aligned(heap, alignment, bytes); return ptr; #else @@ -468,17 +468,24 @@ void *rmalloc(uint32_t flags, size_t bytes) } if (!(flags & SOF_MEM_FLAG_COHERENT)) { - ptr = (__sparse_force void *)heap_alloc_aligned_cached(heap, 0, bytes); + ptr = (__sparse_force void *)heap_alloc_aligned_cached(heap, alignment, bytes); } else { /* * XTOS alloc implementation has used dcache alignment, * so SOF application code is expecting this behaviour. */ - ptr = heap_alloc_aligned(heap, PLATFORM_DCACHE_ALIGN, bytes); + alignment = MAX(PLATFORM_DCACHE_ALIGN, alignment); + ptr = heap_alloc_aligned(heap, alignment, bytes); } return ptr; } +EXPORT_SYMBOL(rmalloc_align); + +void *rmalloc(uint32_t flags, size_t bytes) +{ + return rmalloc_align(flags, bytes, 0); +} EXPORT_SYMBOL(rmalloc); void *rbrealloc_align(void *ptr, uint32_t flags, size_t bytes, From 6ab1c30b44bf9ebcdb6e260e52ac20fc17d506ff Mon Sep 17 00:00:00 2001 From: Jyri Sarha Date: Thu, 4 Sep 2025 21:09:04 +0300 Subject: [PATCH 017/436] cmocka: Prepare cmocka tests for rmalloc and rmalloc_align Prepare cmocka tests for rmalloc() and rmalloc_align(). Signed-off-by: Jyri Sarha --- test/cmocka/src/common_mocks.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/test/cmocka/src/common_mocks.c b/test/cmocka/src/common_mocks.c index cb116c5f8908..1450af20ddfd 100644 --- a/test/cmocka/src/common_mocks.c +++ b/test/cmocka/src/common_mocks.c @@ -63,10 +63,26 @@ void WEAK *rbrealloc_align(void *ptr, uint32_t flags, { (void)flags; (void)old_bytes; + (void)alignment; return realloc(ptr, bytes); } +void WEAK *rmalloc_align(uint32_t flags, size_t bytes, uint32_t alignment) +{ + (void)flags; + (void)alignment; + + return malloc(bytes); +} + +void WEAK *rmalloc(uint32_t flags, size_t bytes) +{ + (void)flags; + + return malloc(bytes); +} + void WEAK rfree(void *ptr) { free(ptr); From fb67c051119a19c6fe89c481178ab19efb74fa43 Mon Sep 17 00:00:00 2001 From: Jyri Sarha Date: Thu, 4 Sep 2025 21:33:09 +0300 Subject: [PATCH 018/436] testbench: library: Prepare for rmalloc_align() usage Prepare for rmalloc_align() usage. Signed-off-by: Jyri Sarha --- src/platform/library/lib/alloc.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/platform/library/lib/alloc.c b/src/platform/library/lib/alloc.c index ec7667b351be..1a5b96b68d64 100644 --- a/src/platform/library/lib/alloc.c +++ b/src/platform/library/lib/alloc.c @@ -16,6 +16,11 @@ /* testbench mem alloc definition */ +void *rmalloc_align(uint32_t flags, size_t bytes, uint32_t alignment) +{ + return malloc(bytes); +} + void *rmalloc(uint32_t flags, size_t bytes) { return malloc(bytes); From 864ce1d83ada3ca34f054a1d2ecefbf366246355 Mon Sep 17 00:00:00 2001 From: Jyri Sarha Date: Wed, 3 Sep 2025 18:44:32 +0300 Subject: [PATCH 019/436] modules: alloc API: Use rmalloc() instead of rbmalloc() Forward mod_alloc() calls to rmalloc() instead of rbmalloc(). rballoc() calls are forwarded to virtual heap if it is enabled, but rmalloc() calls are not. The commit also removes if (alignment) condition, as rmalloc() will eventually end up to rmalloc_align() with zero alignment. Signed-off-by: Jyri Sarha --- src/audio/module_adapter/module/generic.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/audio/module_adapter/module/generic.c b/src/audio/module_adapter/module/generic.c index f95299f952d8..c79f4759380d 100644 --- a/src/audio/module_adapter/module/generic.c +++ b/src/audio/module_adapter/module/generic.c @@ -185,10 +185,7 @@ void *mod_alloc_align(struct processing_module *mod, uint32_t size, uint32_t ali } /* Allocate memory for module */ - if (alignment) - ptr = rballoc_align(SOF_MEM_FLAG_USER, size, alignment); - else - ptr = rballoc(SOF_MEM_FLAG_USER, size); + ptr = rmalloc_align(SOF_MEM_FLAG_USER, size, alignment); if (!ptr) { comp_err(mod->dev, "failed to allocate memory."); From befa16548b289ac0cb8fd47ed01f1a689159ac7e Mon Sep 17 00:00:00 2001 From: Jyri Sarha Date: Tue, 2 Sep 2025 17:23:52 +0300 Subject: [PATCH 020/436] modules: Better mod_alloc_align() failure prints Remove the remains of function name from the prints and in case of heap allocation failure, print all available related parameters. Signed-off-by: Jyri Sarha --- src/audio/module_adapter/module/generic.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/audio/module_adapter/module/generic.c b/src/audio/module_adapter/module/generic.c index c79f4759380d..6546a5ec4781 100644 --- a/src/audio/module_adapter/module/generic.c +++ b/src/audio/module_adapter/module/generic.c @@ -188,7 +188,8 @@ void *mod_alloc_align(struct processing_module *mod, uint32_t size, uint32_t ali ptr = rmalloc_align(SOF_MEM_FLAG_USER, size, alignment); if (!ptr) { - comp_err(mod->dev, "failed to allocate memory."); + comp_err(mod->dev, "Failed to alloc %d bytes %d alignment for comp %x.", + size, alignment, dev_comp_id(mod->dev)); container_put(mod, container); return NULL; } From 27012d1db0cdfc76beb045ca6a1070e3828f53ed Mon Sep 17 00:00:00 2001 From: Jyri Sarha Date: Tue, 2 Sep 2025 11:58:01 +0300 Subject: [PATCH 021/436] ipc4: helper: Print module IDs as hex Print all module IDs hex for better readability. Signed-off-by: Jyri Sarha --- src/ipc/ipc4/helper.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/ipc/ipc4/helper.c b/src/ipc/ipc4/helper.c index 511917ceb768..c35fc41ba364 100644 --- a/src/ipc/ipc4/helper.c +++ b/src/ipc/ipc4/helper.c @@ -581,7 +581,7 @@ __cold int ipc_comp_connect(struct ipc *ipc, ipc_pipe_comp_connect *_connect) buffer = ipc4_create_buffer(source, cross_core_bind, buf_size, bu->extension.r.src_queue, bu->extension.r.dst_queue); if (!buffer) { - tr_err(&ipc_tr, "failed to allocate buffer to bind %d to %d", src_id, sink_id); + tr_err(&ipc_tr, "failed to allocate buffer to bind %#x to %#x", src_id, sink_id); return IPC4_OUT_OF_MEMORY; } @@ -646,14 +646,14 @@ __cold int ipc_comp_connect(struct ipc *ipc, ipc_pipe_comp_connect *_connect) ret = comp_buffer_connect(source, source->ipc_config.core, buffer, PPL_CONN_DIR_COMP_TO_BUFFER); if (ret < 0) { - tr_err(&ipc_tr, "failed to connect src %d to internal buffer", src_id); + tr_err(&ipc_tr, "failed to connect src %#x to internal buffer", src_id); goto free; } ret = comp_buffer_connect(sink, sink->ipc_config.core, buffer, PPL_CONN_DIR_BUFFER_TO_COMP); if (ret < 0) { - tr_err(&ipc_tr, "failed to connect internal buffer to sink %d", sink_id); + tr_err(&ipc_tr, "failed to connect internal buffer to sink %#x", sink_id); goto e_sink_connect; } @@ -1043,7 +1043,7 @@ __cold const struct comp_driver *ipc4_get_comp_drv(uint32_t module_id) mod = lib_manager_get_module_manifest(module_id); if (!mod) { - tr_err(&comp_tr, "Error: Couldn't find loadable module with id %d.", + tr_err(&comp_tr, "Error: Couldn't find loadable module with id %#x.", module_id); return NULL; } From 6dd0917675bfd0684d3f2a951e2897cebbb1c443 Mon Sep 17 00:00:00 2001 From: Jyri Sarha Date: Fri, 12 Sep 2025 16:10:13 +0300 Subject: [PATCH 022/436] modules: mod_alloc: mod_alloc size and alignment parameter to size_t Change mod_alloc_align and friends size and alignment parameters type to size_t. Signed-off-by: Jyri Sarha --- src/audio/module_adapter/module/generic.c | 8 ++++---- src/include/sof/audio/module_adapter/module/generic.h | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/audio/module_adapter/module/generic.c b/src/audio/module_adapter/module/generic.c index 6546a5ec4781..38d17ea2426a 100644 --- a/src/audio/module_adapter/module/generic.c +++ b/src/audio/module_adapter/module/generic.c @@ -168,7 +168,7 @@ static void container_put(struct processing_module *mod, struct module_resource * * The allocated memory is automatically freed when the module is unloaded. */ -void *mod_alloc_align(struct processing_module *mod, uint32_t size, uint32_t alignment) +void *mod_alloc_align(struct processing_module *mod, size_t size, size_t alignment) { struct module_resource *container = container_get(mod); struct module_resources *res = &mod->priv.resources; @@ -188,7 +188,7 @@ void *mod_alloc_align(struct processing_module *mod, uint32_t size, uint32_t ali ptr = rmalloc_align(SOF_MEM_FLAG_USER, size, alignment); if (!ptr) { - comp_err(mod->dev, "Failed to alloc %d bytes %d alignment for comp %x.", + comp_err(mod->dev, "Failed to alloc %zu bytes %zu alignment for comp %#x.", size, alignment, dev_comp_id(mod->dev)); container_put(mod, container); return NULL; @@ -216,7 +216,7 @@ EXPORT_SYMBOL(mod_alloc_align); * Like mod_alloc_align() but the alignment can not be specified. However, * rballoc() will always aligns the memory to PLATFORM_DCACHE_ALIGN. */ -void *mod_alloc(struct processing_module *mod, uint32_t size) +void *mod_alloc(struct processing_module *mod, size_t size) { return mod_alloc_align(mod, size, 0); } @@ -230,7 +230,7 @@ EXPORT_SYMBOL(mod_alloc); * * Like mod_alloc() but the allocated memory is initialized to zero. */ -void *mod_zalloc(struct processing_module *mod, uint32_t size) +void *mod_zalloc(struct processing_module *mod, size_t size) { void *ret = mod_alloc(mod, size); diff --git a/src/include/sof/audio/module_adapter/module/generic.h b/src/include/sof/audio/module_adapter/module/generic.h index 97e5d9b35520..e322632a653f 100644 --- a/src/include/sof/audio/module_adapter/module/generic.h +++ b/src/include/sof/audio/module_adapter/module/generic.h @@ -188,9 +188,9 @@ struct module_processing_data { /*****************************************************************************/ int module_load_config(struct comp_dev *dev, const void *cfg, size_t size); int module_init(struct processing_module *mod); -void *mod_alloc_align(struct processing_module *mod, uint32_t size, uint32_t alignment); -void *mod_alloc(struct processing_module *mod, uint32_t size); -void *mod_zalloc(struct processing_module *mod, uint32_t size); +void *mod_alloc_align(struct processing_module *mod, size_t size, size_t alignment); +void *mod_alloc(struct processing_module *mod, size_t size); +void *mod_zalloc(struct processing_module *mod, size_t size); int mod_free(struct processing_module *mod, const void *ptr); #if CONFIG_COMP_BLOB struct comp_data_blob_handler *mod_data_blob_handler_new(struct processing_module *mod); From 9288b27bfa3c722164dc28b5f4af1fd26f7493a9 Mon Sep 17 00:00:00 2001 From: Jyri Sarha Date: Mon, 29 Sep 2025 00:01:52 +0300 Subject: [PATCH 023/436] module: Add mod_balloc() and mod_balloc_aling() functions Add mod_balloc() and mod_balloc_aling() to enable also automatically freed buffer memory allocations. The difference at the moment is that "buffers" are allocated from virtual heap, using rballoc() as a back-end, and other things are allocated from Zephyr heap assigned for user space shared memory, using rmalloc() as a back-end. Signed-off-by: Jyri Sarha --- src/audio/module_adapter/module/generic.c | 68 ++++++++++++++++++- .../sof/audio/module_adapter/module/generic.h | 2 + 2 files changed, 68 insertions(+), 2 deletions(-) diff --git a/src/audio/module_adapter/module/generic.c b/src/audio/module_adapter/module/generic.c index 38d17ea2426a..ba476e856dff 100644 --- a/src/audio/module_adapter/module/generic.c +++ b/src/audio/module_adapter/module/generic.c @@ -159,6 +159,71 @@ static void container_put(struct processing_module *mod, struct module_resource list_item_append(&container->list, &res->free_cont_list); } +/** + * Allocates aligned buffer memory block for module. + * @param mod Pointer to the module this memory block is allocatd for. + * @param bytes Size in bytes. + * @param alignment Alignment in bytes. + * @return Pointer to the allocated memory or NULL if failed. + * + * The allocated memory is automatically freed when the module is + * unloaded. The back-end, rballoc(), always aligns the memory to + * PLATFORM_DCACHE_ALIGN at the minimum. + */ +void *mod_balloc_align(struct processing_module *mod, size_t size, size_t alignment) +{ + struct module_resource *container = container_get(mod); + struct module_resources *res = &mod->priv.resources; + void *ptr; + + MEM_API_CHECK_THREAD(res); + if (!container) + return NULL; + + if (!size) { + comp_err(mod->dev, "requested allocation of 0 bytes."); + container_put(mod, container); + return NULL; + } + + /* Allocate buffer memory for module */ + ptr = rballoc_align(SOF_MEM_FLAG_USER, size, alignment); + + if (!ptr) { + comp_err(mod->dev, "Failed to alloc %zu bytes %zu alignment for comp %#x.", + size, alignment, dev_comp_id(mod->dev)); + container_put(mod, container); + return NULL; + } + /* Store reference to allocated memory */ + container->ptr = ptr; + container->size = size; + container->type = MOD_RES_HEAP; + list_item_prepend(&container->list, &res->res_list); + + res->heap_usage += size; + if (res->heap_usage > res->heap_high_water_mark) + res->heap_high_water_mark = res->heap_usage; + + return ptr; +} +EXPORT_SYMBOL(mod_balloc_align); + +/** + * Allocates buffer memory block for module. + * @param mod Pointer to module this memory block is allocated for. + * @param bytes Size in bytes. + * @return Pointer to the allocated memory or NULL if failed. + * + * Like mod_balloc_align() but the alignment can not be specified. However, + * rballoc() always aligns the memory to PLATFORM_DCACHE_ALIGN. + */ +void *mod_balloc(struct processing_module *mod, size_t size) +{ + return mod_balloc_align(mod, size, 0); +} +EXPORT_SYMBOL(mod_balloc); + /** * Allocates aligned memory block for module. * @param mod Pointer to the module this memory block is allocatd for. @@ -213,8 +278,7 @@ EXPORT_SYMBOL(mod_alloc_align); * @param bytes Size in bytes. * @return Pointer to the allocated memory or NULL if failed. * - * Like mod_alloc_align() but the alignment can not be specified. However, - * rballoc() will always aligns the memory to PLATFORM_DCACHE_ALIGN. + * Like mod_alloc_align() but the alignment can not be specified. */ void *mod_alloc(struct processing_module *mod, size_t size) { diff --git a/src/include/sof/audio/module_adapter/module/generic.h b/src/include/sof/audio/module_adapter/module/generic.h index e322632a653f..adb7005b0a9f 100644 --- a/src/include/sof/audio/module_adapter/module/generic.h +++ b/src/include/sof/audio/module_adapter/module/generic.h @@ -188,6 +188,8 @@ struct module_processing_data { /*****************************************************************************/ int module_load_config(struct comp_dev *dev, const void *cfg, size_t size); int module_init(struct processing_module *mod); +void *mod_balloc_align(struct processing_module *mod, size_t size, size_t alignment); +void *mod_balloc(struct processing_module *mod, size_t size); void *mod_alloc_align(struct processing_module *mod, size_t size, size_t alignment); void *mod_alloc(struct processing_module *mod, size_t size); void *mod_zalloc(struct processing_module *mod, size_t size); From 62625355d451412a8aaac5a20329a386c6d83fc3 Mon Sep 17 00:00:00 2001 From: Jyri Sarha Date: Tue, 30 Sep 2025 16:43:38 +0300 Subject: [PATCH 024/436] module: Move container_get() after MEM_API_CHECK_THREAD() Move container_get() after MEM_API_CHECK_THREAD(). This change may help debugging if container_get() crashes when memory API functions are called from wrong thread. Signed-off-by: Jyri Sarha --- src/audio/module_adapter/module/generic.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/audio/module_adapter/module/generic.c b/src/audio/module_adapter/module/generic.c index ba476e856dff..b6a0b2276255 100644 --- a/src/audio/module_adapter/module/generic.c +++ b/src/audio/module_adapter/module/generic.c @@ -172,11 +172,13 @@ static void container_put(struct processing_module *mod, struct module_resource */ void *mod_balloc_align(struct processing_module *mod, size_t size, size_t alignment) { - struct module_resource *container = container_get(mod); struct module_resources *res = &mod->priv.resources; + struct module_resource *container; void *ptr; MEM_API_CHECK_THREAD(res); + + container = container_get(mod); if (!container) return NULL; @@ -235,11 +237,13 @@ EXPORT_SYMBOL(mod_balloc); */ void *mod_alloc_align(struct processing_module *mod, size_t size, size_t alignment) { - struct module_resource *container = container_get(mod); struct module_resources *res = &mod->priv.resources; + struct module_resource *container; void *ptr; MEM_API_CHECK_THREAD(res); + + container = container_get(mod); if (!container) return NULL; @@ -317,10 +321,12 @@ struct comp_data_blob_handler * mod_data_blob_handler_new(struct processing_module *mod) { struct module_resources *res = &mod->priv.resources; - struct module_resource *container = container_get(mod); struct comp_data_blob_handler *bhp; + struct module_resource *container; MEM_API_CHECK_THREAD(res); + + container = container_get(mod); if (!container) return NULL; @@ -351,10 +357,12 @@ EXPORT_SYMBOL(mod_data_blob_handler_new); const void *mod_fast_get(struct processing_module *mod, const void * const dram_ptr, size_t size) { struct module_resources *res = &mod->priv.resources; - struct module_resource *container = container_get(mod); + struct module_resource *container; const void *ptr; MEM_API_CHECK_THREAD(res); + + container = container_get(mod); if (!container) return NULL; From 64879dde16255ebe7988b725b4678640a3be387f Mon Sep 17 00:00:00 2001 From: Jyri Sarha Date: Tue, 30 Sep 2025 17:01:42 +0300 Subject: [PATCH 025/436] module: Make mod_balloc() and mod_alloc() inline functions Make mod_balloc() and mod_alloc() inline functions. Signed-off-by: Jyri Sarha --- src/audio/module_adapter/module/generic.c | 29 ------------------- .../sof/audio/module_adapter/module/generic.h | 12 ++++++-- 2 files changed, 10 insertions(+), 31 deletions(-) diff --git a/src/audio/module_adapter/module/generic.c b/src/audio/module_adapter/module/generic.c index b6a0b2276255..b4b72264cd54 100644 --- a/src/audio/module_adapter/module/generic.c +++ b/src/audio/module_adapter/module/generic.c @@ -211,21 +211,6 @@ void *mod_balloc_align(struct processing_module *mod, size_t size, size_t alignm } EXPORT_SYMBOL(mod_balloc_align); -/** - * Allocates buffer memory block for module. - * @param mod Pointer to module this memory block is allocated for. - * @param bytes Size in bytes. - * @return Pointer to the allocated memory or NULL if failed. - * - * Like mod_balloc_align() but the alignment can not be specified. However, - * rballoc() always aligns the memory to PLATFORM_DCACHE_ALIGN. - */ -void *mod_balloc(struct processing_module *mod, size_t size) -{ - return mod_balloc_align(mod, size, 0); -} -EXPORT_SYMBOL(mod_balloc); - /** * Allocates aligned memory block for module. * @param mod Pointer to the module this memory block is allocatd for. @@ -276,20 +261,6 @@ void *mod_alloc_align(struct processing_module *mod, size_t size, size_t alignme } EXPORT_SYMBOL(mod_alloc_align); -/** - * Allocates memory block for module. - * @param mod Pointer to module this memory block is allocated for. - * @param bytes Size in bytes. - * @return Pointer to the allocated memory or NULL if failed. - * - * Like mod_alloc_align() but the alignment can not be specified. - */ -void *mod_alloc(struct processing_module *mod, size_t size) -{ - return mod_alloc_align(mod, size, 0); -} -EXPORT_SYMBOL(mod_alloc); - /** * Allocates memory block for module and initializes it to zero. * @param mod Pointer to module this memory block is allocated for. diff --git a/src/include/sof/audio/module_adapter/module/generic.h b/src/include/sof/audio/module_adapter/module/generic.h index adb7005b0a9f..9ee0656b0ee7 100644 --- a/src/include/sof/audio/module_adapter/module/generic.h +++ b/src/include/sof/audio/module_adapter/module/generic.h @@ -189,9 +189,17 @@ struct module_processing_data { int module_load_config(struct comp_dev *dev, const void *cfg, size_t size); int module_init(struct processing_module *mod); void *mod_balloc_align(struct processing_module *mod, size_t size, size_t alignment); -void *mod_balloc(struct processing_module *mod, size_t size); +static inline void *mod_balloc(struct processing_module *mod, size_t size) +{ + return mod_balloc_align(mod, size, 0); +} + void *mod_alloc_align(struct processing_module *mod, size_t size, size_t alignment); -void *mod_alloc(struct processing_module *mod, size_t size); +static inline void *mod_alloc(struct processing_module *mod, size_t size) +{ + return mod_alloc_align(mod, size, 0); +} + void *mod_zalloc(struct processing_module *mod, size_t size); int mod_free(struct processing_module *mod, const void *ptr); #if CONFIG_COMP_BLOB From 4da059eef9e2acceb6aded3c7fcec3aa74f1fdc9 Mon Sep 17 00:00:00 2001 From: Jyri Sarha Date: Tue, 30 Sep 2025 17:55:24 +0300 Subject: [PATCH 026/436] module: Make mod_zalloc() inline function Make mod_zalloc() inline function. Signed-off-by: Jyri Sarha --- src/audio/module_adapter/module/generic.c | 19 ------------------- .../sof/audio/module_adapter/module/generic.h | 11 ++++++++++- 2 files changed, 10 insertions(+), 20 deletions(-) diff --git a/src/audio/module_adapter/module/generic.c b/src/audio/module_adapter/module/generic.c index b4b72264cd54..f77377a54cea 100644 --- a/src/audio/module_adapter/module/generic.c +++ b/src/audio/module_adapter/module/generic.c @@ -261,25 +261,6 @@ void *mod_alloc_align(struct processing_module *mod, size_t size, size_t alignme } EXPORT_SYMBOL(mod_alloc_align); -/** - * Allocates memory block for module and initializes it to zero. - * @param mod Pointer to module this memory block is allocated for. - * @param bytes Size in bytes. - * @return Pointer to the allocated memory or NULL if failed. - * - * Like mod_alloc() but the allocated memory is initialized to zero. - */ -void *mod_zalloc(struct processing_module *mod, size_t size) -{ - void *ret = mod_alloc(mod, size); - - if (ret) - memset(ret, 0, size); - - return ret; -} -EXPORT_SYMBOL(mod_zalloc); - /** * Creates a blob handler and releases it when the module is unloaded * @param mod Pointer to module this memory block is allocated for. diff --git a/src/include/sof/audio/module_adapter/module/generic.h b/src/include/sof/audio/module_adapter/module/generic.h index 9ee0656b0ee7..82430a017204 100644 --- a/src/include/sof/audio/module_adapter/module/generic.h +++ b/src/include/sof/audio/module_adapter/module/generic.h @@ -200,7 +200,16 @@ static inline void *mod_alloc(struct processing_module *mod, size_t size) return mod_alloc_align(mod, size, 0); } -void *mod_zalloc(struct processing_module *mod, size_t size); +static inline void *mod_zalloc(struct processing_module *mod, size_t size) +{ + void *ret = mod_alloc(mod, size); + + if (ret) + memset(ret, 0, size); + + return ret; +} + int mod_free(struct processing_module *mod, const void *ptr); #if CONFIG_COMP_BLOB struct comp_data_blob_handler *mod_data_blob_handler_new(struct processing_module *mod); From 788861804ed08485496e979dd9c467c1a21b30c5 Mon Sep 17 00:00:00 2001 From: Tomasz Leman Date: Thu, 31 Jul 2025 23:23:42 +0200 Subject: [PATCH 027/436] boards: ace: power: disable unused asynchronous runtime PM This patch removes the `CONFIG_PM_DEVICE_RUNTIME_ASYNC` configuration from the Intel ADSP board files, including ACE15 MTPM, ACE20 LNL, ACE30 PTL, ACE30 WCL ACE40 NVL and ACE40 NVLS. The asynchronous runtime power management feature is not utilized by any device drivers in our project, rendering it unnecessary. By excluding this configuration, we prevent the compilation of dead code related to power management, optimizing the build process and reducing potential overhead. Signed-off-by: Tomasz Leman --- app/boards/intel_adsp_ace15_mtpm.conf | 1 + app/boards/intel_adsp_ace20_lnl.conf | 1 + app/boards/intel_adsp_ace30_ptl.conf | 1 + app/boards/intel_adsp_ace30_wcl.conf | 1 + app/boards/intel_adsp_ace40_nvl.conf | 1 + app/boards/intel_adsp_ace40_nvls.conf | 1 + 6 files changed, 6 insertions(+) diff --git a/app/boards/intel_adsp_ace15_mtpm.conf b/app/boards/intel_adsp_ace15_mtpm.conf index 4ebf4498375d..5266f38386d3 100644 --- a/app/boards/intel_adsp_ace15_mtpm.conf +++ b/app/boards/intel_adsp_ace15_mtpm.conf @@ -77,6 +77,7 @@ CONFIG_SYS_CLOCK_TICKS_PER_SEC=12000 CONFIG_ADSP_IDLE_CLOCK_GATING=y CONFIG_ADSP_IMR_CONTEXT_SAVE=n CONFIG_PM_PREWAKEUP_CONV_MODE_CEIL=y +CONFIG_PM_DEVICE_RUNTIME_ASYNC=n # Zephyr / logging CONFIG_LOG_BACKEND_ADSP=n diff --git a/app/boards/intel_adsp_ace20_lnl.conf b/app/boards/intel_adsp_ace20_lnl.conf index bc716dbf293d..abf6d1537330 100644 --- a/app/boards/intel_adsp_ace20_lnl.conf +++ b/app/boards/intel_adsp_ace20_lnl.conf @@ -56,6 +56,7 @@ CONFIG_SYS_CLOCK_TICKS_PER_SEC=12000 CONFIG_ADSP_IDLE_CLOCK_GATING=y CONFIG_ADSP_IMR_CONTEXT_SAVE=y CONFIG_PM_PREWAKEUP_CONV_MODE_CEIL=y +CONFIG_PM_DEVICE_RUNTIME_ASYNC=n # Zephyr / logging CONFIG_LOG_BACKEND_ADSP=n diff --git a/app/boards/intel_adsp_ace30_ptl.conf b/app/boards/intel_adsp_ace30_ptl.conf index c8305fa33b35..48a923ab7870 100644 --- a/app/boards/intel_adsp_ace30_ptl.conf +++ b/app/boards/intel_adsp_ace30_ptl.conf @@ -58,6 +58,7 @@ CONFIG_SYS_CLOCK_TICKS_PER_SEC=12000 # Zephyr / power settings CONFIG_ADSP_IMR_CONTEXT_SAVE=y CONFIG_PM_PREWAKEUP_CONV_MODE_CEIL=y +CONFIG_PM_DEVICE_RUNTIME_ASYNC=n # Zephyr / logging CONFIG_LOG_BACKEND_ADSP=n diff --git a/app/boards/intel_adsp_ace30_wcl.conf b/app/boards/intel_adsp_ace30_wcl.conf index faa20dd97a9b..0b3abe5a3868 100644 --- a/app/boards/intel_adsp_ace30_wcl.conf +++ b/app/boards/intel_adsp_ace30_wcl.conf @@ -45,6 +45,7 @@ CONFIG_SYS_CLOCK_TICKS_PER_SEC=12000 # Zephyr / power settings CONFIG_ADSP_IMR_CONTEXT_SAVE=y CONFIG_PM_PREWAKEUP_CONV_MODE_CEIL=y +CONFIG_PM_DEVICE_RUNTIME_ASYNC=n # Zephyr / logging CONFIG_LOG_BACKEND_ADSP=n diff --git a/app/boards/intel_adsp_ace40_nvl.conf b/app/boards/intel_adsp_ace40_nvl.conf index 34175a8b6b9b..560dc8b5b85e 100644 --- a/app/boards/intel_adsp_ace40_nvl.conf +++ b/app/boards/intel_adsp_ace40_nvl.conf @@ -42,6 +42,7 @@ CONFIG_ADSP_IMR_CONTEXT_SAVE=y CONFIG_PM_POLICY_CUSTOM=y CONFIG_PM_PREWAKEUP_CONV_MODE_CEIL=y CONFIG_SRAM_RETENTION_MODE=n +CONFIG_PM_DEVICE_RUNTIME_ASYNC=n # Zephyr / logging CONFIG_LOG_BACKEND_ADSP=n diff --git a/app/boards/intel_adsp_ace40_nvls.conf b/app/boards/intel_adsp_ace40_nvls.conf index 34175a8b6b9b..560dc8b5b85e 100644 --- a/app/boards/intel_adsp_ace40_nvls.conf +++ b/app/boards/intel_adsp_ace40_nvls.conf @@ -42,6 +42,7 @@ CONFIG_ADSP_IMR_CONTEXT_SAVE=y CONFIG_PM_POLICY_CUSTOM=y CONFIG_PM_PREWAKEUP_CONV_MODE_CEIL=y CONFIG_SRAM_RETENTION_MODE=n +CONFIG_PM_DEVICE_RUNTIME_ASYNC=n # Zephyr / logging CONFIG_LOG_BACKEND_ADSP=n From 2608ccf61f52ab348a34a887a5a3ffc7b83f41a4 Mon Sep 17 00:00:00 2001 From: Seppo Ingalsuo Date: Fri, 3 Oct 2025 15:50:34 +0300 Subject: [PATCH 028/436] Tools: Topology: Enable pre-processing in DMIC function tplgs This patch adds DMIC0_ENHANCED_CAPTURE=true to function topologies for PCH DMIC. The function topology is used in a SDW platform if there is a PCH DMIC in use instead of SDW codec connected microphone. The microphone pre-processing adds the multi-microphone beamformer (TDFB) and dynamic range compressor (DRC) components. Signed-off-by: Seppo Ingalsuo --- .../production/tplg-targets-ace1.cmake | 48 ++++++++++++------- .../production/tplg-targets-ace2.cmake | 24 ++++++---- .../production/tplg-targets-ace3.cmake | 24 ++++++---- 3 files changed, 64 insertions(+), 32 deletions(-) diff --git a/tools/topology/topology2/production/tplg-targets-ace1.cmake b/tools/topology/topology2/production/tplg-targets-ace1.cmake index c00e2e1d746d..8c4b4ee2944d 100644 --- a/tools/topology/topology2/production/tplg-targets-ace1.cmake +++ b/tools/topology/topology2/production/tplg-targets-ace1.cmake @@ -169,67 +169,83 @@ EFX_DMIC0_TDFB_PARAMS=line2_generic_pm10deg,EFX_DMIC0_DRC_PARAMS=dmic_default" # Split topologies "cavs-sdw\;sof-arl-dmic-2ch-id2\;PLATFORM=mtl,SDW_JACK=false,NUM_HDMIS=0,NUM_DMICS=2,\ PDM1_MIC_A_ENABLE=0,PDM1_MIC_B_ENABLE=0,DMIC0_ID=2,DMIC1_ID=3,PREPROCESS_PLUGINS=nhlt,\ -NHLT_BIN=nhlt-sof-arl-dmic-2ch-id2.bin" +NHLT_BIN=nhlt-sof-arl-dmic-2ch-id2.bin,DMIC0_ENHANCED_CAPTURE=true,\ +EFX_DMIC0_TDFB_PARAMS=line2_generic_pm10deg,EFX_DMIC0_DRC_PARAMS=dmic_default" "cavs-sdw\;sof-arl-dmic-2ch-id3\;PLATFORM=mtl,SDW_JACK=false,NUM_HDMIS=0,NUM_DMICS=2,\ PDM1_MIC_A_ENABLE=0,PDM1_MIC_B_ENABLE=0,DMIC0_ID=3,DMIC1_ID=4,PREPROCESS_PLUGINS=nhlt,\ -NHLT_BIN=nhlt-sof-arl-dmic-2ch-id3.bin" +NHLT_BIN=nhlt-sof-arl-dmic-2ch-id3.bin,DMIC0_ENHANCED_CAPTURE=true,\ +EFX_DMIC0_TDFB_PARAMS=line2_generic_pm10deg,EFX_DMIC0_DRC_PARAMS=dmic_default" "cavs-sdw\;sof-arl-dmic-2ch-id4\;PLATFORM=mtl,SDW_JACK=false,NUM_HDMIS=0,NUM_DMICS=2,\ PDM1_MIC_A_ENABLE=0,PDM1_MIC_B_ENABLE=0,DMIC0_ID=4,DMIC1_ID=5,PREPROCESS_PLUGINS=nhlt,\ -NHLT_BIN=nhlt-sof-arl-dmic-2ch-id4.bin" +NHLT_BIN=nhlt-sof-arl-dmic-2ch-id4.bin,DMIC0_ENHANCED_CAPTURE=true,\ +EFX_DMIC0_TDFB_PARAMS=line2_generic_pm10deg,EFX_DMIC0_DRC_PARAMS=dmic_default" "cavs-sdw\;sof-arl-dmic-2ch-id5\;PLATFORM=mtl,SDW_JACK=false,NUM_HDMIS=0,NUM_DMICS=2,\ PDM1_MIC_A_ENABLE=0,PDM1_MIC_B_ENABLE=0,DMIC0_ID=5,DMIC1_ID=6,PREPROCESS_PLUGINS=nhlt,\ -NHLT_BIN=nhlt-sof-arl-dmic-2ch-id5.bin" +NHLT_BIN=nhlt-sof-arl-dmic-2ch-id5.bin,DMIC0_ENHANCED_CAPTURE=true,\ +EFX_DMIC0_TDFB_PARAMS=line2_generic_pm10deg,EFX_DMIC0_DRC_PARAMS=dmic_default" "cavs-sdw\;sof-arl-dmic-4ch-id2\;PLATFORM=mtl,SDW_JACK=false,NUM_HDMIS=0,NUM_DMICS=4,\ PDM1_MIC_A_ENABLE=1,PDM1_MIC_B_ENABLE=1,DMIC0_ID=2,DMIC1_ID=3,PREPROCESS_PLUGINS=nhlt,\ -NHLT_BIN=nhlt-sof-arl-dmic-4ch-id2.bin" +NHLT_BIN=nhlt-sof-arl-dmic-4ch-id2.bin,DMIC0_ENHANCED_CAPTURE=true,\ +EFX_DMIC0_TDFB_PARAMS=line4_pass,EFX_DMIC0_DRC_PARAMS=dmic_default" "cavs-sdw\;sof-arl-dmic-4ch-id3\;PLATFORM=mtl,SDW_JACK=false,NUM_HDMIS=0,NUM_DMICS=4,\ PDM1_MIC_A_ENABLE=1,PDM1_MIC_B_ENABLE=1,DMIC0_ID=3,DMIC1_ID=4,PREPROCESS_PLUGINS=nhlt,\ -NHLT_BIN=nhlt-sof-arl-dmic-4ch-id3.bin" +NHLT_BIN=nhlt-sof-arl-dmic-4ch-id3.bin,DMIC0_ENHANCED_CAPTURE=true,\ +EFX_DMIC0_TDFB_PARAMS=line4_pass,EFX_DMIC0_DRC_PARAMS=dmic_default" "cavs-sdw\;sof-arl-dmic-4ch-id4\;PLATFORM=mtl,SDW_JACK=false,NUM_HDMIS=0,NUM_DMICS=4,\ PDM1_MIC_A_ENABLE=1,PDM1_MIC_B_ENABLE=1,DMIC0_ID=4,DMIC1_ID=5,PREPROCESS_PLUGINS=nhlt,\ -NHLT_BIN=nhlt-sof-arl-dmic-4ch-id4.bin" +NHLT_BIN=nhlt-sof-arl-dmic-4ch-id4.bin,DMIC0_ENHANCED_CAPTURE=true,\ +EFX_DMIC0_TDFB_PARAMS=line4_pass,EFX_DMIC0_DRC_PARAMS=dmic_default" "cavs-sdw\;sof-arl-dmic-4ch-id5\;PLATFORM=mtl,SDW_JACK=false,NUM_HDMIS=0,NUM_DMICS=4,\ PDM1_MIC_A_ENABLE=1,PDM1_MIC_B_ENABLE=1,DMIC0_ID=5,DMIC1_ID=6,PREPROCESS_PLUGINS=nhlt,\ -NHLT_BIN=nhlt-sof-arl-dmic-4ch-id5.bin" +NHLT_BIN=nhlt-sof-arl-dmic-4ch-id5.bin,DMIC0_ENHANCED_CAPTURE=true,\ +EFX_DMIC0_TDFB_PARAMS=line4_pass,EFX_DMIC0_DRC_PARAMS=dmic_default" "cavs-sdw\;sof-mtl-dmic-2ch-id2\;PLATFORM=mtl,SDW_JACK=false,NUM_HDMIS=0,NUM_DMICS=2,\ PDM1_MIC_A_ENABLE=0,PDM1_MIC_B_ENABLE=0,DMIC0_ID=2,DMIC1_ID=3,PREPROCESS_PLUGINS=nhlt,\ -NHLT_BIN=nhlt-sof-mtl-dmic-2ch-id2.bin" +NHLT_BIN=nhlt-sof-mtl-dmic-2ch-id2.bin,DMIC0_ENHANCED_CAPTURE=true,\ +EFX_DMIC0_TDFB_PARAMS=line2_generic_pm10deg,EFX_DMIC0_DRC_PARAMS=dmic_default" "cavs-sdw\;sof-mtl-dmic-2ch-id3\;PLATFORM=mtl,SDW_JACK=false,NUM_HDMIS=0,NUM_DMICS=2,\ PDM1_MIC_A_ENABLE=0,PDM1_MIC_B_ENABLE=0,DMIC0_ID=3,DMIC1_ID=4,PREPROCESS_PLUGINS=nhlt,\ -NHLT_BIN=nhlt-sof-mtl-dmic-2ch-id3.bin" +NHLT_BIN=nhlt-sof-mtl-dmic-2ch-id3.bin,DMIC0_ENHANCED_CAPTURE=true,\ +EFX_DMIC0_TDFB_PARAMS=line2_generic_pm10deg,EFX_DMIC0_DRC_PARAMS=dmic_default" "cavs-sdw\;sof-mtl-dmic-2ch-id4\;PLATFORM=mtl,SDW_JACK=false,NUM_HDMIS=0,NUM_DMICS=2,\ PDM1_MIC_A_ENABLE=0,PDM1_MIC_B_ENABLE=0,DMIC0_ID=4,DMIC1_ID=5,PREPROCESS_PLUGINS=nhlt,\ -NHLT_BIN=nhlt-sof-mtl-dmic-2ch-id4.bin" +NHLT_BIN=nhlt-sof-mtl-dmic-2ch-id4.bin,DMIC0_ENHANCED_CAPTURE=true,\ +EFX_DMIC0_TDFB_PARAMS=line2_generic_pm10deg,EFX_DMIC0_DRC_PARAMS=dmic_default" "cavs-sdw\;sof-mtl-dmic-2ch-id5\;PLATFORM=mtl,SDW_JACK=false,NUM_HDMIS=0,NUM_DMICS=2,\ PDM1_MIC_A_ENABLE=0,PDM1_MIC_B_ENABLE=0,DMIC0_ID=5,DMIC1_ID=6,PREPROCESS_PLUGINS=nhlt,\ -NHLT_BIN=nhlt-sof-mtl-dmic-2ch-id5.bin" +NHLT_BIN=nhlt-sof-mtl-dmic-2ch-id5.bin,DMIC0_ENHANCED_CAPTURE=true,\ +EFX_DMIC0_TDFB_PARAMS=line2_generic_pm10deg,EFX_DMIC0_DRC_PARAMS=dmic_default" "cavs-sdw\;sof-mtl-dmic-4ch-id2\;PLATFORM=mtl,SDW_JACK=false,NUM_HDMIS=0,NUM_DMICS=4,\ PDM1_MIC_A_ENABLE=1,PDM1_MIC_B_ENABLE=1,DMIC0_ID=2,DMIC1_ID=3,PREPROCESS_PLUGINS=nhlt,\ -NHLT_BIN=nhlt-sof-mtl-dmic-4ch-id2.bin" +NHLT_BIN=nhlt-sof-mtl-dmic-4ch-id2.bin,DMIC0_ENHANCED_CAPTURE=true,\ +EFX_DMIC0_TDFB_PARAMS=line4_pass,EFX_DMIC0_DRC_PARAMS=dmic_default" "cavs-sdw\;sof-mtl-dmic-4ch-id3\;PLATFORM=mtl,SDW_JACK=false,NUM_HDMIS=0,NUM_DMICS=4,\ PDM1_MIC_A_ENABLE=1,PDM1_MIC_B_ENABLE=1,DMIC0_ID=3,DMIC1_ID=4,PREPROCESS_PLUGINS=nhlt,\ -NHLT_BIN=nhlt-sof-mtl-dmic-4ch-id3.bin" +NHLT_BIN=nhlt-sof-mtl-dmic-4ch-id3.bin,DMIC0_ENHANCED_CAPTURE=true,\ +EFX_DMIC0_TDFB_PARAMS=line4_pass,EFX_DMIC0_DRC_PARAMS=dmic_default" "cavs-sdw\;sof-mtl-dmic-4ch-id4\;PLATFORM=mtl,SDW_JACK=false,NUM_HDMIS=0,NUM_DMICS=4,\ PDM1_MIC_A_ENABLE=1,PDM1_MIC_B_ENABLE=1,DMIC0_ID=4,DMIC1_ID=5,PREPROCESS_PLUGINS=nhlt,\ -NHLT_BIN=nhlt-sof-mtl-dmic-4ch-id4.bin" +NHLT_BIN=nhlt-sof-mtl-dmic-4ch-id4.bin,DMIC0_ENHANCED_CAPTURE=true,\ +EFX_DMIC0_TDFB_PARAMS=line4_pass,EFX_DMIC0_DRC_PARAMS=dmic_default" "cavs-sdw\;sof-mtl-dmic-4ch-id5\;PLATFORM=mtl,SDW_JACK=false,NUM_HDMIS=0,NUM_DMICS=4,\ PDM1_MIC_A_ENABLE=1,PDM1_MIC_B_ENABLE=1,DMIC0_ID=5,DMIC1_ID=6,PREPROCESS_PLUGINS=nhlt,\ -NHLT_BIN=nhlt-sof-mtl-dmic-4ch-id5.bin" +NHLT_BIN=nhlt-sof-mtl-dmic-4ch-id5.bin,DMIC0_ENHANCED_CAPTURE=true,\ +EFX_DMIC0_TDFB_PARAMS=line4_pass,EFX_DMIC0_DRC_PARAMS=dmic_default" # Below topologies are used on Chromebooks diff --git a/tools/topology/topology2/production/tplg-targets-ace2.cmake b/tools/topology/topology2/production/tplg-targets-ace2.cmake index 7c066ad27cc1..169e2ab2d527 100644 --- a/tools/topology/topology2/production/tplg-targets-ace2.cmake +++ b/tools/topology/topology2/production/tplg-targets-ace2.cmake @@ -37,35 +37,43 @@ EFX_DMIC0_TDFB_PARAMS=line2_generic_pm10deg,EFX_DMIC0_DRC_PARAMS=dmic_default" # Split topologies "cavs-sdw\;sof-lnl-dmic-2ch-id2\;PLATFORM=lnl,SDW_JACK=false,NUM_HDMIS=0,NUM_DMICS=2,\ PDM1_MIC_A_ENABLE=0,PDM1_MIC_B_ENABLE=0,DMIC0_ID=2,DMIC1_ID=3,PREPROCESS_PLUGINS=nhlt,\ -NHLT_BIN=nhlt-sof-lnl-dmic-2ch-id2.bin" +NHLT_BIN=nhlt-sof-lnl-dmic-2ch-id2.bin,DMIC0_ENHANCED_CAPTURE=true,\ +EFX_DMIC0_TDFB_PARAMS=line2_generic_pm10deg,EFX_DMIC0_DRC_PARAMS=dmic_default" "cavs-sdw\;sof-lnl-dmic-2ch-id3\;PLATFORM=lnl,SDW_JACK=false,NUM_HDMIS=0,NUM_DMICS=2,\ PDM1_MIC_A_ENABLE=0,PDM1_MIC_B_ENABLE=0,DMIC0_ID=3,DMIC1_ID=4,PREPROCESS_PLUGINS=nhlt,\ -NHLT_BIN=nhlt-sof-lnl-dmic-2ch-id3.bin" +NHLT_BIN=nhlt-sof-lnl-dmic-2ch-id3.bin,DMIC0_ENHANCED_CAPTURE=true,\ +EFX_DMIC0_TDFB_PARAMS=line2_generic_pm10deg,EFX_DMIC0_DRC_PARAMS=dmic_default" "cavs-sdw\;sof-lnl-dmic-2ch-id4\;PLATFORM=lnl,SDW_JACK=false,NUM_HDMIS=0,NUM_DMICS=2,\ PDM1_MIC_A_ENABLE=0,PDM1_MIC_B_ENABLE=0,DMIC0_ID=4,DMIC1_ID=5,PREPROCESS_PLUGINS=nhlt,\ -NHLT_BIN=nhlt-sof-lnl-dmic-2ch-id4.bin" +NHLT_BIN=nhlt-sof-lnl-dmic-2ch-id4.bin,DMIC0_ENHANCED_CAPTURE=true,\ +EFX_DMIC0_TDFB_PARAMS=line2_generic_pm10deg,EFX_DMIC0_DRC_PARAMS=dmic_default" "cavs-sdw\;sof-lnl-dmic-2ch-id5\;PLATFORM=lnl,SDW_JACK=false,NUM_HDMIS=0,NUM_DMICS=2,\ PDM1_MIC_A_ENABLE=0,PDM1_MIC_B_ENABLE=0,DMIC0_ID=5,DMIC1_ID=6,PREPROCESS_PLUGINS=nhlt,\ -NHLT_BIN=nhlt-sof-lnl-dmic-2ch-id5.bin" +NHLT_BIN=nhlt-sof-lnl-dmic-2ch-id5.bin,DMIC0_ENHANCED_CAPTURE=true,\ +EFX_DMIC0_TDFB_PARAMS=line2_generic_pm10deg,EFX_DMIC0_DRC_PARAMS=dmic_default" "cavs-sdw\;sof-lnl-dmic-4ch-id2\;PLATFORM=lnl,SDW_JACK=false,NUM_HDMIS=0,NUM_DMICS=4,\ PDM1_MIC_A_ENABLE=1,PDM1_MIC_B_ENABLE=1,DMIC0_ID=2,DMIC1_ID=3,PREPROCESS_PLUGINS=nhlt,\ -NHLT_BIN=nhlt-sof-lnl-dmic-4ch-id2.bin" +NHLT_BIN=nhlt-sof-lnl-dmic-4ch-id2.bin,DMIC0_ENHANCED_CAPTURE=true,\ +EFX_DMIC0_TDFB_PARAMS=line4_pass,EFX_DMIC0_DRC_PARAMS=dmic_default" "cavs-sdw\;sof-lnl-dmic-4ch-id3\;PLATFORM=lnl,SDW_JACK=false,NUM_HDMIS=0,NUM_DMICS=4,\ PDM1_MIC_A_ENABLE=1,PDM1_MIC_B_ENABLE=1,DMIC0_ID=3,DMIC1_ID=4,PREPROCESS_PLUGINS=nhlt,\ -NHLT_BIN=nhlt-sof-lnl-dmic-4ch-id3.bin" +NHLT_BIN=nhlt-sof-lnl-dmic-4ch-id3.bin,DMIC0_ENHANCED_CAPTURE=true,\ +EFX_DMIC0_TDFB_PARAMS=line4_pass,EFX_DMIC0_DRC_PARAMS=dmic_default" "cavs-sdw\;sof-lnl-dmic-4ch-id4\;PLATFORM=lnl,SDW_JACK=false,NUM_HDMIS=0,NUM_DMICS=4,\ PDM1_MIC_A_ENABLE=1,PDM1_MIC_B_ENABLE=1,DMIC0_ID=4,DMIC1_ID=5,PREPROCESS_PLUGINS=nhlt,\ -NHLT_BIN=nhlt-sof-lnl-dmic-4ch-id4.bin" +NHLT_BIN=nhlt-sof-lnl-dmic-4ch-id4.bin,DMIC0_ENHANCED_CAPTURE=true,\ +EFX_DMIC0_TDFB_PARAMS=line4_pass,EFX_DMIC0_DRC_PARAMS=dmic_default" "cavs-sdw\;sof-lnl-dmic-4ch-id5\;PLATFORM=lnl,SDW_JACK=false,NUM_HDMIS=0,NUM_DMICS=4,\ PDM1_MIC_A_ENABLE=1,PDM1_MIC_B_ENABLE=1,DMIC0_ID=5,DMIC1_ID=6,PREPROCESS_PLUGINS=nhlt,\ -NHLT_BIN=nhlt-sof-lnl-dmic-4ch-id5.bin" +NHLT_BIN=nhlt-sof-lnl-dmic-4ch-id5.bin,DMIC0_ENHANCED_CAPTURE=true,\ +EFX_DMIC0_TDFB_PARAMS=line4_pass,EFX_DMIC0_DRC_PARAMS=dmic_default" # No SDW Jack. SDW DMIC+SPK "cavs-sdw\;sof-lnl-rt1318-l12-rt714-l0\;PLATFORM=lnl,SDW_JACK=false,SDW_DMIC=1,\ diff --git a/tools/topology/topology2/production/tplg-targets-ace3.cmake b/tools/topology/topology2/production/tplg-targets-ace3.cmake index d83e2e2637d3..f301591a35e9 100644 --- a/tools/topology/topology2/production/tplg-targets-ace3.cmake +++ b/tools/topology/topology2/production/tplg-targets-ace3.cmake @@ -110,33 +110,41 @@ HDMI_IN_1_ID=0,HDMI_IN_2_ID=1" # Split topologies "cavs-sdw\;sof-ptl-dmic-2ch-id2\;PLATFORM=ptl,SDW_JACK=false,NUM_HDMIS=0,NUM_DMICS=2,\ PDM1_MIC_A_ENABLE=0,PDM1_MIC_B_ENABLE=0,DMIC0_ID=2,DMIC1_ID=3,PREPROCESS_PLUGINS=nhlt,\ -NHLT_BIN=nhlt-sof-ptl-dmic-2ch-id2.bin" +NHLT_BIN=nhlt-sof-ptl-dmic-2ch-id2.bin,DMIC0_ENHANCED_CAPTURE=true,\ +EFX_DMIC0_TDFB_PARAMS=line2_generic_pm10deg,EFX_DMIC0_DRC_PARAMS=dmic_default" "cavs-sdw\;sof-ptl-dmic-2ch-id3\;PLATFORM=ptl,SDW_JACK=false,NUM_HDMIS=0,NUM_DMICS=2,\ PDM1_MIC_A_ENABLE=0,PDM1_MIC_B_ENABLE=0,DMIC0_ID=3,DMIC1_ID=4,PREPROCESS_PLUGINS=nhlt,\ -NHLT_BIN=nhlt-sof-ptl-dmic-2ch-id3.bin" +NHLT_BIN=nhlt-sof-ptl-dmic-2ch-id3.bin,DMIC0_ENHANCED_CAPTURE=true,\ +EFX_DMIC0_TDFB_PARAMS=line2_generic_pm10deg,EFX_DMIC0_DRC_PARAMS=dmic_default" "cavs-sdw\;sof-ptl-dmic-2ch-id4\;PLATFORM=ptl,SDW_JACK=false,NUM_HDMIS=0,NUM_DMICS=2,\ PDM1_MIC_A_ENABLE=0,PDM1_MIC_B_ENABLE=0,DMIC0_ID=4,DMIC1_ID=5,PREPROCESS_PLUGINS=nhlt,\ -NHLT_BIN=nhlt-sof-ptl-dmic-2ch-id4.bin" +NHLT_BIN=nhlt-sof-ptl-dmic-2ch-id4.bin,DMIC0_ENHANCED_CAPTURE=true,\ +EFX_DMIC0_TDFB_PARAMS=line2_generic_pm10deg,EFX_DMIC0_DRC_PARAMS=dmic_default" "cavs-sdw\;sof-ptl-dmic-2ch-id5\;PLATFORM=ptl,SDW_JACK=false,NUM_HDMIS=0,NUM_DMICS=2,\ PDM1_MIC_A_ENABLE=0,PDM1_MIC_B_ENABLE=0,DMIC0_ID=5,DMIC1_ID=6,PREPROCESS_PLUGINS=nhlt,\ -NHLT_BIN=nhlt-sof-ptl-dmic-2ch-id5.bin" +NHLT_BIN=nhlt-sof-ptl-dmic-2ch-id5.bin,DMIC0_ENHANCED_CAPTURE=true,\ +EFX_DMIC0_TDFB_PARAMS=line2_generic_pm10deg,EFX_DMIC0_DRC_PARAMS=dmic_default" "cavs-sdw\;sof-ptl-dmic-4ch-id2\;PLATFORM=ptl,SDW_JACK=false,NUM_HDMIS=0,NUM_DMICS=4,\ PDM1_MIC_A_ENABLE=1,PDM1_MIC_B_ENABLE=1,DMIC0_ID=2,DMIC1_ID=3,PREPROCESS_PLUGINS=nhlt,\ -NHLT_BIN=nhlt-sof-ptl-dmic-4ch-id2.bin" +NHLT_BIN=nhlt-sof-ptl-dmic-4ch-id2.bin,DMIC0_ENHANCED_CAPTURE=true,\ +EFX_DMIC0_TDFB_PARAMS=line4_pass,EFX_DMIC0_DRC_PARAMS=dmic_default" "cavs-sdw\;sof-ptl-dmic-4ch-id3\;PLATFORM=ptl,SDW_JACK=false,NUM_HDMIS=0,NUM_DMICS=4,\ PDM1_MIC_A_ENABLE=1,PDM1_MIC_B_ENABLE=1,DMIC0_ID=3,DMIC1_ID=4,PREPROCESS_PLUGINS=nhlt,\ -NHLT_BIN=nhlt-sof-ptl-dmic-4ch-id3.bin" +NHLT_BIN=nhlt-sof-ptl-dmic-4ch-id3.bin,DMIC0_ENHANCED_CAPTURE=true,\ +EFX_DMIC0_TDFB_PARAMS=line4_pass,EFX_DMIC0_DRC_PARAMS=dmic_default" "cavs-sdw\;sof-ptl-dmic-4ch-id4\;PLATFORM=ptl,SDW_JACK=false,NUM_HDMIS=0,NUM_DMICS=4,\ PDM1_MIC_A_ENABLE=1,PDM1_MIC_B_ENABLE=1,DMIC0_ID=4,DMIC1_ID=5,PREPROCESS_PLUGINS=nhlt,\ -NHLT_BIN=nhlt-sof-ptl-dmic-4ch-id4.bin" +NHLT_BIN=nhlt-sof-ptl-dmic-4ch-id4.bin,DMIC0_ENHANCED_CAPTURE=true,\ +EFX_DMIC0_TDFB_PARAMS=line4_pass,EFX_DMIC0_DRC_PARAMS=dmic_default" "cavs-sdw\;sof-ptl-dmic-4ch-id5\;PLATFORM=ptl,SDW_JACK=false,NUM_HDMIS=0,NUM_DMICS=4,\ PDM1_MIC_A_ENABLE=1,PDM1_MIC_B_ENABLE=1,DMIC0_ID=5,DMIC1_ID=6,PREPROCESS_PLUGINS=nhlt,\ -NHLT_BIN=nhlt-sof-ptl-dmic-4ch-id5.bin" +NHLT_BIN=nhlt-sof-ptl-dmic-4ch-id5.bin,DMIC0_ENHANCED_CAPTURE=true,\ +EFX_DMIC0_TDFB_PARAMS=line4_pass,EFX_DMIC0_DRC_PARAMS=dmic_default" ) From 400db36b2ceae231a349d6044d4ad8980a43c7ef Mon Sep 17 00:00:00 2001 From: Kai Vehmanen Date: Mon, 6 Oct 2025 15:28:08 +0300 Subject: [PATCH 029/436] platform: intel: cavs: modify pm_notifier init for older toolchains With Zephyr commit ae1f13149fcd ("pm: Extend pm notifier to be able to report substate"), the pm_notifier struct was changed to include multiple structs within a union. The xcc toolchain used for cAVS targets cannot initialize the struct with the existing code. Modify the code to work with the new pm.h definition and the old compiler used. Signed-off-by: Kai Vehmanen --- src/platform/intel/cavs/platform.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/platform/intel/cavs/platform.c b/src/platform/intel/cavs/platform.c index 366424bae1dd..8a1a7c59c3b5 100644 --- a/src/platform/intel/cavs/platform.c +++ b/src/platform/intel/cavs/platform.c @@ -107,9 +107,7 @@ int platform_boot_complete(uint32_t boot_message) return 0; } -static struct pm_notifier pm_state_notifier = { - .state_exit = cpu_notify_state_exit, -}; +static struct pm_notifier pm_state_notifier; /* Runs on the primary core only */ int platform_init(struct sof *sof) @@ -138,6 +136,7 @@ int platform_init(struct sof *sof) return ret; /* register power states exit notifiers */ + pm_state_notifier.state_exit = cpu_notify_state_exit; pm_notifier_register(&pm_state_notifier); /* initialize the host IPC mechanisms */ From d5d70f1e93fb06e869722022e5a9ad319a907661 Mon Sep 17 00:00:00 2001 From: Ranjani Sridharan Date: Wed, 8 Oct 2025 08:20:55 -0700 Subject: [PATCH 030/436] audio: module_adapter: Set the pipeline pointer during module init Set the pipeline pointer during init for all modules and remove the code from copier init. Signed-off-by: Ranjani Sridharan --- src/audio/copier/copier.c | 20 +++----------------- src/audio/module_adapter/module_adapter.c | 11 +++++++++++ 2 files changed, 14 insertions(+), 17 deletions(-) diff --git a/src/audio/copier/copier.c b/src/audio/copier/copier.c index 0e1db840db67..f3b0a08a05fc 100644 --- a/src/audio/copier/copier.c +++ b/src/audio/copier/copier.c @@ -131,13 +131,10 @@ static void mic_privacy_free(struct copier_data *cd) __cold static int copier_init(struct processing_module *mod) { union ipc4_connector_node_id node_id; - struct ipc_comp_dev *ipc_pipe; - struct ipc *ipc = ipc_get(); struct copier_data *cd; struct comp_dev *dev = mod->dev; struct module_data *md = &mod->priv; struct ipc4_copier_module_cfg *copier = (struct ipc4_copier_module_cfg *)md->cfg.init_data; - struct comp_ipc_config *config = &dev->ipc_config; void *gtw_cfg = NULL; size_t gtw_cfg_size; int i, ret = 0; @@ -186,17 +183,6 @@ __cold static int copier_init(struct processing_module *mod) for (i = 0; i < IPC4_COPIER_MODULE_OUTPUT_PINS_COUNT; i++) cd->out_fmt[i] = cd->config.out_fmt; - ipc_pipe = ipc_get_comp_by_ppl_id(ipc, COMP_TYPE_PIPELINE, - config->pipeline_id, - IPC_COMP_IGNORE_REMOTE); - if (!ipc_pipe) { - comp_err(dev, "pipeline %d is not existed", config->pipeline_id); - ret = -EPIPE; - goto error; - } - - dev->pipeline = ipc_pipe->pipeline; - node_id = copier->gtw_cfg.node_id; /* copier is linked to gateway */ if (node_id.dw != IPC4_INVALID_NODE_ID) { @@ -205,7 +191,7 @@ __cold static int copier_init(struct processing_module *mod) switch (node_id.f.dma_type) { case ipc4_hda_host_output_class: case ipc4_hda_host_input_class: - ret = copier_host_create(dev, cd, copier, ipc_pipe->pipeline); + ret = copier_host_create(dev, cd, copier, dev->pipeline); if (ret < 0) { comp_err(dev, "unable to create host"); goto error; @@ -228,7 +214,7 @@ __cold static int copier_init(struct processing_module *mod) case ipc4_i2s_link_input_class: case ipc4_alh_link_output_class: case ipc4_alh_link_input_class: - ret = copier_dai_create(dev, cd, copier, ipc_pipe->pipeline); + ret = copier_dai_create(dev, cd, copier, dev->pipeline); if (ret < 0) { comp_err(dev, "unable to create dai"); goto error; @@ -246,7 +232,7 @@ __cold static int copier_init(struct processing_module *mod) #if CONFIG_IPC4_GATEWAY case ipc4_ipc_output_class: case ipc4_ipc_input_class: - ret = copier_ipcgtw_create(dev, cd, copier, ipc_pipe->pipeline); + ret = copier_ipcgtw_create(dev, cd, copier, dev->pipeline); if (ret < 0) { comp_err(dev, "unable to create IPC gateway"); goto error; diff --git a/src/audio/module_adapter/module_adapter.c b/src/audio/module_adapter/module_adapter.c index 77777727efba..662b3a51de86 100644 --- a/src/audio/module_adapter/module_adapter.c +++ b/src/audio/module_adapter/module_adapter.c @@ -125,6 +125,17 @@ struct comp_dev *module_adapter_new_ext(const struct comp_driver *drv, else goto err; +#if CONFIG_IPC_MAJOR_4 + struct ipc_comp_dev *ipc_pipe; + struct ipc *ipc = ipc_get(); + + /* set the pipeline pointer if ipc_pipe is valid */ + ipc_pipe = ipc_get_comp_by_ppl_id(ipc, COMP_TYPE_PIPELINE, config->pipeline_id, + IPC_COMP_IGNORE_REMOTE); + if (ipc_pipe) + dev->pipeline = ipc_pipe->pipeline; +#endif + /* Init processing module */ ret = module_init(mod); if (ret) { From b2a138bf90df791eeb7efa545e0286e18baf2958 Mon Sep 17 00:00:00 2001 From: Seppo Ingalsuo Date: Wed, 28 Aug 2024 17:51:59 +0300 Subject: [PATCH 031/436] Scripts: Add testbench build for Intel NVL platform DSP This patch adds to "scripts/rebuild-testbench.sh -p nvl" option to test processing components with NVL DSP build. Signed-off-by: Seppo Ingalsuo --- scripts/set_xtensa_params.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/scripts/set_xtensa_params.sh b/scripts/set_xtensa_params.sh index 92e4d7d384a6..4bdaf93c809d 100644 --- a/scripts/set_xtensa_params.sh +++ b/scripts/set_xtensa_params.sh @@ -66,6 +66,11 @@ case "$platform" in XTENSA_CORE="ace30_LX7HiFi4_PIF" TOOLCHAIN_VER="RI-2022.10-linux" ;; + nvl) + PLATFORM="$platform" + XTENSA_CORE="ace4px_HiFi5MMU_PIF_nlib" + TOOLCHAIN_VER="RI-2022.10-linux" + ;; # NXP imx8) @@ -153,7 +158,7 @@ esac # Pre-zephyr "XTOS" build, testbench,... case "$platform" in - mtl|lnl|ptl|acp_7_0|mt8196) + mtl|lnl|ptl|acp_7_0|mt8196|nvl) SOF_CC_BASE='clang';; *) SOF_CC_BASE='xcc';; From 250c92f3053a7c2f0c884c544398176862ab46dc Mon Sep 17 00:00:00 2001 From: Ranjani Sridharan Date: Mon, 6 Oct 2025 17:19:57 -0700 Subject: [PATCH 032/436] ipc: ipc4: helper: Add a helper for converting audio format to stream params This will be used for converting the input/output audio formats in the base config extension to the stream params format. Signed-off-by: Ranjani Sridharan --- src/include/ipc4/base-config.h | 2 ++ src/ipc/ipc4/helper.c | 35 +++++++++++++++++++++------------- 2 files changed, 24 insertions(+), 13 deletions(-) diff --git a/src/include/ipc4/base-config.h b/src/include/ipc4/base-config.h index b95ecbd3e1f9..0c89d534637a 100644 --- a/src/include/ipc4/base-config.h +++ b/src/include/ipc4/base-config.h @@ -30,6 +30,8 @@ struct sof_ipc_stream_params; void ipc4_base_module_cfg_to_stream_params(const struct ipc4_base_module_cfg *base_cfg, struct sof_ipc_stream_params *params); +void ipc4_audio_format_to_stream_params(const struct ipc4_audio_format *audio_fmt, + struct sof_ipc_stream_params *params); struct comp_buffer; void ipc4_update_buffer_format(struct comp_buffer *buf_c, const struct ipc4_audio_format *fmt); diff --git a/src/ipc/ipc4/helper.c b/src/ipc/ipc4/helper.c index c35fc41ba364..3aee3b69313f 100644 --- a/src/ipc/ipc4/helper.c +++ b/src/ipc/ipc4/helper.c @@ -1152,28 +1152,37 @@ int ipc4_find_dma_config_multiple(struct ipc_config_dai *dai, uint8_t *data_buff return IPC4_INVALID_REQUEST; } -void ipc4_base_module_cfg_to_stream_params(const struct ipc4_base_module_cfg *base_cfg, - struct sof_ipc_stream_params *params) +void ipc4_audio_format_to_stream_params(const struct ipc4_audio_format *audio_fmt, + struct sof_ipc_stream_params *params) { enum sof_ipc_frame frame_fmt, valid_fmt; int i; memset(params, 0, sizeof(struct sof_ipc_stream_params)); - params->channels = base_cfg->audio_fmt.channels_count; - params->rate = base_cfg->audio_fmt.sampling_frequency; - params->sample_container_bytes = base_cfg->audio_fmt.depth / 8; - params->sample_valid_bytes = base_cfg->audio_fmt.valid_bit_depth / 8; - params->buffer_fmt = base_cfg->audio_fmt.interleaving_style; - params->buffer.size = base_cfg->obs * 2; - - audio_stream_fmt_conversion(base_cfg->audio_fmt.depth, - base_cfg->audio_fmt.valid_bit_depth, + params->channels = audio_fmt->channels_count; + params->rate = audio_fmt->sampling_frequency; + params->sample_container_bytes = audio_fmt->depth / 8; + params->sample_valid_bytes = audio_fmt->valid_bit_depth / 8; + params->buffer_fmt = audio_fmt->interleaving_style; + + audio_stream_fmt_conversion(audio_fmt->depth, + audio_fmt->valid_bit_depth, &frame_fmt, &valid_fmt, - base_cfg->audio_fmt.s_type); + audio_fmt->s_type); params->frame_fmt = frame_fmt; for (i = 0; i < SOF_IPC_MAX_CHANNELS; i++) - params->chmap[i] = (base_cfg->audio_fmt.ch_map >> i * 4) & 0xf; + params->chmap[i] = (audio_fmt->ch_map >> i * 4) & 0xf; +} +EXPORT_SYMBOL(ipc4_audio_format_to_stream_params); + +void ipc4_base_module_cfg_to_stream_params(const struct ipc4_base_module_cfg *base_cfg, + struct sof_ipc_stream_params *params) +{ + memset(params, 0, sizeof(struct sof_ipc_stream_params)); + params->buffer.size = base_cfg->obs * 2; + + ipc4_audio_format_to_stream_params(&base_cfg->audio_fmt, params); } EXPORT_SYMBOL(ipc4_base_module_cfg_to_stream_params); From 3598a0bc437947b5a1cbe8a34812666440c9f510 Mon Sep 17 00:00:00 2001 From: Ranjani Sridharan Date: Tue, 16 Sep 2025 17:55:10 -0700 Subject: [PATCH 033/436] audio: module_adapter: Remove use of comp_verify_params for IPC4 comp_verify_params does 3 things, update comp params based on buffer flags, then set buffer params based on comp params and then finally set the component period frames based on buffer frames. In the case of IPC4, buffer flags are unused, so there's no need to update comp params based on these flags. So, move the setting of buffer params during the modules binding call where the buffers are allocated. Finally, set the component period frames based on the module's params and the device period frames during module init Signed-off-by: Ranjani Sridharan --- src/audio/module_adapter/module_adapter.c | 24 ++++++------- .../module_adapter/module_adapter_ipc4.c | 36 +++++++++++++++++++ 2 files changed, 48 insertions(+), 12 deletions(-) diff --git a/src/audio/module_adapter/module_adapter.c b/src/audio/module_adapter/module_adapter.c index 662b3a51de86..c5e6c75ca649 100644 --- a/src/audio/module_adapter/module_adapter.c +++ b/src/audio/module_adapter/module_adapter.c @@ -132,8 +132,13 @@ struct comp_dev *module_adapter_new_ext(const struct comp_driver *drv, /* set the pipeline pointer if ipc_pipe is valid */ ipc_pipe = ipc_get_comp_by_ppl_id(ipc, COMP_TYPE_PIPELINE, config->pipeline_id, IPC_COMP_IGNORE_REMOTE); - if (ipc_pipe) + if (ipc_pipe) { dev->pipeline = ipc_pipe->pipeline; + + /* LL modules have the same period as the pipeline */ + if (dev->ipc_config.proc_domain == COMP_PROCESSING_DOMAIN_LL) + dev->period = ipc_pipe->pipeline->period; + } #endif /* Init processing module */ @@ -166,6 +171,9 @@ struct comp_dev *module_adapter_new_ext(const struct comp_driver *drv, comp_err(dev, "%d: module params failed", ret); goto err; } + + /* set component period frames */ + component_set_nearest_period_frames(dev, params.rate); #endif comp_dbg(dev, "done"); @@ -226,11 +234,7 @@ int module_adapter_prepare(struct comp_dev *dev) comp_dbg(dev, "start"); #if CONFIG_IPC_MAJOR_4 - /* - * if the stream_params are valid, just update the sink/source buffer params. If not, - * retrieve the params from the basecfg, allocate stream_params and then update the - * sink/source buffer params. - */ + /* allocate stream_params and retrieve the params from the basecfg if needed */ if (!mod->stream_params) { struct sof_ipc_stream_params params; @@ -239,12 +243,6 @@ int module_adapter_prepare(struct comp_dev *dev) comp_err(dev, "module_adapter_new() %d: module params failed", ret); return ret; } - } else { - ret = comp_verify_params(dev, mod->verify_params_flags, mod->stream_params); - if (ret < 0) { - comp_err(dev, "comp_verify_params() failed."); - return ret; - } } #endif /* Prepare module */ @@ -535,11 +533,13 @@ int module_adapter_params(struct comp_dev *dev, struct sof_ipc_stream_params *pa module_adapter_set_params(mod, params); +#if CONFIG_IPC_MAJOR_3 ret = comp_verify_params(dev, mod->verify_params_flags, params); if (ret < 0) { comp_err(dev, "comp_verify_params() failed."); return ret; } +#endif /* allocate stream_params each time */ if (mod->stream_params) diff --git a/src/audio/module_adapter/module_adapter_ipc4.c b/src/audio/module_adapter/module_adapter_ipc4.c index 2657e7e2a561..8e1d13661dec 100644 --- a/src/audio/module_adapter/module_adapter_ipc4.c +++ b/src/audio/module_adapter/module_adapter_ipc4.c @@ -320,11 +320,47 @@ static bool module_adapter_multi_sink_source_prepare(struct comp_dev *dev) return false; } +static int module_update_source_buffer_params(struct processing_module *mod, + struct bind_info *bind_data) +{ + struct module_config *dst = &mod->priv.cfg; + struct sof_ipc_stream_params params; + struct comp_buffer *buffer; + int dst_queue_id = bind_data->ipc4_data->extension.r.dst_queue; + + /* only update buffer params for sink components */ + if (bind_data->bind_type != COMP_BIND_TYPE_SOURCE) + return 0; + + comp_dev_for_each_producer(mod->dev, buffer) { + if (IPC4_SINK_QUEUE_ID(buffer->stream.runtime_stream_params.id) != dst_queue_id) + continue; + + /* use base_cfg params for pin 0 or if base config extn is missing */ + if (!dst_queue_id || dst_queue_id >= dst->nb_input_pins) { + buffer_set_params(buffer, mod->stream_params, BUFFER_UPDATE_FORCE); + return 0; + } + + /* otherwise use the respective input pin audio format */ + ipc4_audio_format_to_stream_params(&dst->input_pins[dst_queue_id].audio_fmt, + ¶ms); + buffer_set_params(buffer, ¶ms, BUFFER_UPDATE_FORCE); + return 0; + } + + return 0; +} + int module_adapter_bind(struct comp_dev *dev, struct bind_info *bind_data) { struct processing_module *mod = comp_mod(dev); int ret; + ret = module_update_source_buffer_params(mod, bind_data); + if (ret < 0) + return ret; + ret = module_bind(mod, bind_data); if (ret < 0) return ret; From 1bda34bc39bfae4b3e8e4829e5c431e611333acf Mon Sep 17 00:00:00 2001 From: Guennadi Liakhovetski Date: Thu, 21 Aug 2025 14:44:42 +0200 Subject: [PATCH 034/436] component: split a function into two Split comp_alloc() into two parts - allocation and initialisation to be able to re-use the initialisation code with a different allocation method. Signed-off-by: Guennadi Liakhovetski --- src/include/sof/audio/component.h | 35 +++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/src/include/sof/audio/component.h b/src/include/sof/audio/component.h index 61486e0e2a36..041a40eefb91 100644 --- a/src/include/sof/audio/component.h +++ b/src/include/sof/audio/component.h @@ -849,6 +849,24 @@ static inline enum sof_comp_type dev_comp_type(const struct comp_dev *dev) return dev->ipc_config.type; } +/** + * Initialize common part of a component device + * @param drv Parent component driver. + * @param dev Device. + * @param bytes Size of the component device in bytes. + */ +static inline void comp_init(const struct comp_driver *drv, + struct comp_dev *dev, size_t bytes) +{ + dev->size = bytes; + dev->drv = drv; + dev->state = COMP_STATE_INIT; + list_init(&dev->bsink_list); + list_init(&dev->bsource_list); + memcpy_s(&dev->tctx, sizeof(dev->tctx), + trace_comp_drv_get_tr_ctx(dev->drv), sizeof(struct tr_ctx)); +} + /** * Allocates memory for the component device and initializes common part. * @param drv Parent component driver. @@ -857,23 +875,18 @@ static inline enum sof_comp_type dev_comp_type(const struct comp_dev *dev) */ static inline struct comp_dev *comp_alloc(const struct comp_driver *drv, size_t bytes) { - struct comp_dev *dev = NULL; - /* * Use uncached address everywhere to access components to rule out * multi-core failures. TODO: verify if cached alias may be used in some cases */ - dev = module_driver_heap_rzalloc(drv->user_heap, SOF_MEM_FLAG_USER | SOF_MEM_FLAG_COHERENT, - bytes); + struct comp_dev *dev = module_driver_heap_rzalloc(drv->user_heap, + SOF_MEM_FLAG_USER | SOF_MEM_FLAG_COHERENT, + bytes); + if (!dev) return NULL; - dev->size = bytes; - dev->drv = drv; - dev->state = COMP_STATE_INIT; - list_init(&dev->bsink_list); - list_init(&dev->bsource_list); - memcpy_s(&dev->tctx, sizeof(struct tr_ctx), - trace_comp_drv_get_tr_ctx(dev->drv), sizeof(struct tr_ctx)); + + comp_init(drv, dev, bytes); return dev; } From 733c95ac7d23f3e9fc23d78794e5fea02903d01b Mon Sep 17 00:00:00 2001 From: Guennadi Liakhovetski Date: Thu, 2 Oct 2025 17:34:40 +0200 Subject: [PATCH 035/436] module: add a missing header The private part of struct struct processing_module contains a list head, add the respective header. Signed-off-by: Guennadi Liakhovetski --- src/include/module/module/base.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/include/module/module/base.h b/src/include/module/module/base.h index ed116681afd2..6d7dea657314 100644 --- a/src/include/module/module/base.h +++ b/src/include/module/module/base.h @@ -16,6 +16,10 @@ #include "interface.h" #include "../ipc4/base-config.h" +#ifdef SOF_MODULE_API_PRIVATE +#include +#endif + #define module_get_private_data(mod) ((mod)->priv.private) #define module_set_private_data(mod, data) ((mod)->priv.private = data) From 3d5802113043d0a8bdb94b4fb8c75fa15337e3f9 Mon Sep 17 00:00:00 2001 From: Guennadi Liakhovetski Date: Thu, 2 Oct 2025 17:37:02 +0200 Subject: [PATCH 036/436] probe: fix a variable size structure member Variable size structure members are only allowed at the end. Signed-off-by: Guennadi Liakhovetski --- src/probe/probe.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/probe/probe.c b/src/probe/probe.c index 339935993ef1..b1c095deeda4 100644 --- a/src/probe/probe.c +++ b/src/probe/probe.c @@ -80,11 +80,11 @@ struct probe_dma_ext { * Probe main struct */ struct probe_pdata { + struct task dmap_work; /**< probe task */ struct probe_dma_ext ext_dma; /**< extraction DMA */ struct probe_dma_ext inject_dma[CONFIG_PROBE_DMA_MAX]; /**< injection DMA */ struct probe_point probe_points[CONFIG_PROBE_POINTS_MAX]; /**< probe points */ struct probe_data_packet header; /**< data packet header */ - struct task dmap_work; /**< probe task */ }; /** From 8d44f26809f1fa4360759268098faab3807e5179 Mon Sep 17 00:00:00 2001 From: Guennadi Liakhovetski Date: Wed, 8 Oct 2025 14:18:22 +0200 Subject: [PATCH 037/436] library-manager: (cosmetic) make a function static Make lib_manager_allocate_module() static also for the CONFIG_MM_DRV=n case. Also don't drop the const qualifier needlessly. Signed-off-by: Guennadi Liakhovetski --- src/library_manager/lib_manager.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/library_manager/lib_manager.c b/src/library_manager/lib_manager.c index d45df1493f5e..7cd35af57ad9 100644 --- a/src/library_manager/lib_manager.c +++ b/src/library_manager/lib_manager.c @@ -412,8 +412,8 @@ int lib_manager_free_module(const uint32_t component_id) #define PAGE_SZ 4096 /* equals to MAN_PAGE_SIZE used by rimage */ -uintptr_t lib_manager_allocate_module(const struct comp_ipc_config *ipc_config, - const void *ipc_specific_config, const void **buildinfo) +static uintptr_t lib_manager_allocate_module(const struct comp_ipc_config *ipc_config, + const void *ipc_specific_config, const void **buildinfo) { tr_err(&lib_manager_tr, "Dynamic module allocation is not supported"); return 0; @@ -578,7 +578,7 @@ static struct comp_dev *lib_manager_module_create(const struct comp_driver *drv, const void *spec) { const struct sof_man_fw_desc *const desc = lib_manager_get_library_manifest(config->id); - const struct ipc_config_process *args = (struct ipc_config_process *)spec; + const struct ipc_config_process *args = (const struct ipc_config_process *)spec; const uint32_t entry_index = LIB_MANAGER_GET_MODULE_INDEX(config->id); const struct module_interface *ops = NULL; const struct sof_man_module *mod; From 35625371d605a96ac0d8f076c9e7269fdf5fcc2d Mon Sep 17 00:00:00 2001 From: Adrian Bonislawski Date: Thu, 25 Sep 2025 08:46:20 +0200 Subject: [PATCH 038/436] rimage: config: add nvl to generic platform toml This is required to build single NVL loadable module Signed-off-by: Adrian Bonislawski --- tools/rimage/config/platform.toml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/rimage/config/platform.toml b/tools/rimage/config/platform.toml index 0210477b7f30..1c392355ed50 100644 --- a/tools/rimage/config/platform.toml +++ b/tools/rimage/config/platform.toml @@ -4,4 +4,6 @@ #include "platform-lnl.toml" #elif CONFIG_SOC_INTEL_ACE30 #include "platform-ptl.toml" +#elif CONFIG_SOC_INTEL_ACE40 +#include "platform-nvl.toml" #endif From 0929803a731482c9fd12bf451cb0faad9ecc6976 Mon Sep 17 00:00:00 2001 From: Adrian Bonislawski Date: Thu, 2 Oct 2025 11:46:59 +0200 Subject: [PATCH 039/436] rimage: config: add FORCE_ALL_MODULES macro to nvl.toml.h When this header is then preprocessed with that macro defined, all module TOML files will be included. Signed-off-by: Adrian Bonislawski --- tools/rimage/config/nvl.toml.h | 48 +++++++++++++++++----------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/tools/rimage/config/nvl.toml.h b/tools/rimage/config/nvl.toml.h index 80e28916f827..fd659f5aa475 100644 --- a/tools/rimage/config/nvl.toml.h +++ b/tools/rimage/config/nvl.toml.h @@ -38,35 +38,35 @@ auto_start = "0" index = __COUNTER__ -#if defined(CONFIG_COMP_TESTER) +#if defined(CONFIG_COMP_TESTER) || defined(LLEXT_FORCE_ALL_MODULAR) #include #endif -#ifdef CONFIG_COMP_MIXIN_MIXOUT +#if defined(CONFIG_COMP_MIXIN_MIXOUT) || defined(LLEXT_FORCE_ALL_MODULAR) #include