Commit Graph

9913 Commits

Author SHA1 Message Date
Kai Vehmanen fd31818931 coherent: fix cache flush logic if coherent is not the first member
If coherent object is at non-zero offset, the init call ends
up invalidating data cache outside the allocated buffer.

All current users of "struct coherent" have the object as
the first member, so nothing is broken with current code.

Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
2023-03-20 20:36:41 +02:00
Seppo Ingalsuo e0d8078fa7 Tools: Testbench: Avoid need linux kernel headers in build
This patch adds simplified linux/types.h into testbench headers
to enable include of ALSA asoc.h to build without other difficult
kernel headers content.

The CMakeLists.txt files are updated to make a build time copy of
asoc.h to subdirectory include of the build directories. The new
directory is added to headers path.

This change avoids build fail with xcc toolchain that can't use the
gcc toolchain headers from the system where the ALSA headers are
located.

Suggested-by: Marc Herbert <marc.herbert@intel.com>
Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
2023-03-20 19:33:55 +02:00
Ranjani Sridharan a6a80ec97a dai-zephyr: Fix the ordering of DAI and DMA triggers
During start trigger, the DMA is be started first followed by the DAI. The
same order should also apply for the release triggers. Conversely, during
stop/pause the DAI must be stopped first before the DMA.

But some platforms cannot handle the conventional ordering during the
stop/pause triggers. Add a new config,
COMP_DAI_STOP_TRIGGER_ORDER_REVERSE, that will be used to reverse the
DMA and DAI trigger order during stop/pause. Also, fix the stop case to
use the new config to reverse the ordering instead of
COMP_DMA_SUSPEND_DRAIN.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
2023-03-20 19:33:33 +02:00
Ranjani Sridharan 56abcade56 boards: intel_adsp_ace15_mtpm: Enable dw_dma_suspend_drain for ACE
It is recommended to suspend and drain before stop.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
2023-03-17 16:06:06 +00:00
Serhiy Katsyuba ebfe717f66 ipc4: Remove duplicate ALH_MULTI_GTW_BASE declaration
In ipc4/alh.h we have:
 #define IPC4_ALH_MULTI_GTW_BASE 0x50
In ipc4/gateway.h:
 #define ALH_MULTI_GTW_BASE 0x50

These were added almost simultaneously by two separate pull-requests.
No need to have them both.

Signed-off-by: Serhiy Katsyuba <serhiy.katsyuba@intel.com>
2023-03-17 12:37:48 +00:00
Chao Song 34ea694a83 schedule: fix address space mismatches
Fix below sparse warnings:

zephyr_dp_schedule.c:134:20: warning: incorrect type in argument 1
(different address spaces)

zephyr_dp_schedule.c:348:36: warning: incorrect type in assignment
(different address spaces)

introduced by 3ee1d787

Signed-off-by: Chao Song <chao.song@linux.intel.com>
2023-03-17 12:24:45 +00:00
Przemyslaw Blaszkowski 8541d68b50 ipc4: update comp direction on pipeline complete
Current pipeline implementation assumes that modules are bound one by
one from input to output gateway (Host to DAI or DAI to Host). If
neighbor module does not have direction configured, FW returns error.

This assumption is incorrect. Driver can bind modules that are not yet
bound to any gateway. FW should check connections only when driver
finish binding all modules and set pipeline state.

Signed-off-by: Przemyslaw Blaszkowski <przemyslaw.blaszkowski@intel.com>
2023-03-17 12:18:11 +00:00
Andy Ross 85a2e6dd9e platform: mt8195: Support C++ linkage with native/vendor xcc
At least some versions of the Cadence toolchain for this platform are
built with a slightly variant libc (vs. the newlib build which seems
more common for other SOF devices).  That's fine in principle, SOF
doesn't call anything out of the libc anyway.  But when linking with
the C++ standard libraries, it pulls symbols out that need to go in
otherwise-unrecognized linker sections.  And it wants to see an
_unlink_r() function (the reentrant worker underneath unlink())
defined for reasons that completely escape me.

Signed-off-by: Andy Ross <andyross@google.com>
2023-03-17 12:11:10 +00:00
Seppo Ingalsuo 5ac5b6b84c Tools: Tplg_parser: Fix void pointer arithmetic
Pointer arithmetic with void pointer is not allowed. Functions
get_token_uint32_t() and get_token_comp_format() are updated
to handle correctly the bytes offset.

Functions get_token_dai_type() and get_token_process_type() are
updated to similar pointer arithmetic style as previous.

Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
2023-03-17 12:02:34 +00:00
Bard Liao 7b66c30263 topology2: cavs-sdw: set capture host in_valid_bit_depth = 32
For some reason the input valid bit depth was 16. But the output
valid bit depth of the previous widget is 32. Fix it to 32 now.

Signed-off-by: Bard Liao <yung-chuan.liao@linux.intel.com>
2023-03-17 12:00:51 +00:00
Guennadi Liakhovetski d7cef08f05 iadk: (cosmetic) use an existing pointer
iadk_modules_init() already has a pointer for mod->priv, use it.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
2023-03-17 11:59:53 +00:00
Seppo Ingalsuo da9344a6ad Tools: Testbench/tplg_parser: Check -Wimplicit-fallthrough support
The xt-xcc compiler RG-2017.8 does not support -Wimplicit-fallthrough
option. Add to CMakeLists.txt files check for the option and use it if
it is supported.

Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
2023-03-17 11:08:58 +00:00
Guennadi Liakhovetski 2d8ad0c25a tgl: remove deprecated and unused overlay
The ipc4_native_drivers_overlay.conf overlay is deprecated and isn't
used any more, the default ipc4_overlay.conf configures native
drivers itself. Remove the deprecated version.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
2023-03-17 09:02:06 +02:00
Adrian Bonislawski 1319163ea2 ipc4: fix NULL dereference
This will fix NULL dereference in ipc4_process_chain_dma()

Signed-off-by: Adrian Bonislawski <adrian.bonislawski@intel.com>
2023-03-15 17:12:07 +02:00
Seppo Ingalsuo fce4f9c9f0 Tools: Testbench: Avoid build fail with crossover that uses IIR DF2T
This patch adds for testbench CONFIG_MATH_IIR_DF2T. The issue was
triggered by add of IIR DF1 as default. Crossover component is
still using DF2T.

Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
2023-03-15 13:24:34 +00:00
Liam Girdwood 6b03dde9fd tplg_parser: tokens: print a helpful error for invalid data
Print out error data when invalid private data is found.

Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
2023-03-15 13:23:42 +00:00
Liam Girdwood ce37e802f4 tools: tplg_parser: parse topology in memory and not in file.
Reduce complexity by parsing all topology objects in memory rather than
by seeking file, reading into allocated memory and then freeing memory.

Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
2023-03-15 13:23:42 +00:00
Liam Girdwood 97414e12a8 fuzzer: remove old fuzzer
The original fuzzer has been deprecated for some time now. Remove it.

All fuzzing now done by OSS-fuzz

Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
2023-03-15 13:23:42 +00:00
Marc Herbert 3aeb2bfd99 xtensa-build-xephyr: fix xt-objcopy failure when default-params missing
Fixes recent commit 8aab18351f ("xtensa-build-zephyr: fix
DEFAULT_TOOLCHAIN_VARIANT spill on next platf")

Some XtensaTools installation are missing this `default-params` symbolic
link:

```
XtensaTools/config/
|-- X4H3I16w2D48w3a_2017_8-params
|-- X6H3CNL_2017_8-params
|-- cavs2x_LX6HiFi3_2017_8-params
`-- default-params -> cavs2x_LX6HiFi3_2017_8-params
```

Maybe it's missing when installing with the graphical interface?

This symbolic link is surprisingly enough to make `xt-objcopy` work
_without_ the XTENSA_ variables. But when the variables _and_ the link
are both missing, then `xt-objcopy` fails with the usual error:

```
in current dir: work/current/sof; running command:
 XtDevTools/install/tools/RG-2017.8-linux/XtensaTools/bin/xt-objcopy
 --remove-section .comment sof/build-tgl/zephyr/zephyr.strip
       build-sof-staging/sof-info/tgl/stripped-zephyr.elf
Error: there is no Xtensa core registered as the default.

You need to either specify the name of a registered Xtensa core (with
the --xtensa-core option or the XTENSA_CORE environment variable) or
specify a different registry of Xtensa cores (with the --xtensa-system
option or the XTENSA_SYSTEM environment variable).

The following Xtensa cores are available:
	hifiep_bd5
	cavs2x_LX6HiFi3_2017_8
	sample_config
	sample_flix
	...
```

Fix this failure by simply passing the XTENSA_ variables to xt-objcopy.

Kudos to Seppo Ingalsuo for the interactive debugging session that
allowed root-causing this problem extremely quickly.

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2023-03-15 13:10:31 +00:00
Johnson Wang a2b3f612dd platform: mtk: fixup the wrong register definitions for mtk mt8188
Fixup the wrong register definition of Timer and
remove some unnecessary ones for mt8188.

Signed-off-by: Johnson Wang <johnson.wang@mediatek.com>
2023-03-15 13:11:44 +02:00
Kai Vehmanen 82ae105de9 dai-zephyr: possible division-by-zero if max_block_count is zero
If the max_block_count attribute is zero, this may lead to
division by zero error. Handle this explicitly but reporting
error if max_block_count is zero.

Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
2023-03-15 12:03:20 +02:00
Kai Vehmanen e5767217d5 volume: add validity check on number of channels
Volume has multiple data arrays sized to SOF_IPC_MAX_CHANNELS
and code that uses these arrays without bounds checks (like
volume_ramp()).

Add a sanity check to volume_prepare() to ensure channels
count is never set to a higher value.

Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
2023-03-15 12:02:25 +02:00
Kai Vehmanen e4dca888da ams: handle alloc failures in ams_init()
Current code may end up dereferencing null pointers in case
memory allocations fail in ams_init(). Handle this with proper
error handling.

Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
2023-03-15 12:01:15 +02:00
Marcin Szkudlinski ada31dbd1b IPC4: Workaround: Lock DP modules to same core as pipeline
This commit prevents DP modueles from run on different cores than
the pipleine LL modules. This limitation is enforced because of
possible cache races in pipeline_for_each_comp()
To be removed till safe implementation is ready

Signed-off-by: Marcin Szkudlinski <marcin.szkudlinski@intel.com>
2023-03-14 14:00:28 +00:00
Marcin Szkudlinski eeeec95c98 IPC4: add DP domain modules to pipeline scheduling
Pipeline creation
 - create a task for each DP module when started
   on primary or secondary core
 - delete a task for each DP module when stopped
 - don't call comp_copy in LL context for DP modules

Signed-off-by: Marcin Szkudlinski <marcin.szkudlinski@intel.com>
2023-03-14 14:00:28 +00:00
Marcin Szkudlinski 343b0ab47e IPC4: add processing domain - LL or DP to component context
A component need to keep an information about how it need to be
scheduled - as LowLatency or DataProcessing. The information comes
from IPC4 init instance message

Signed-off-by: Marcin Szkudlinski <marcin.szkudlinski@intel.com>
2023-03-14 14:00:28 +00:00
Marcin Szkudlinski 3ee1d78738 scheduling: add Data Processing scheduler type
The DP scheduler is a scheduler based on Zephyr preemptible
threads. It will start each SOF task as a separate Zephyr
thread.
At current implementation the scheduler can trigger each
task/thread periodically or on demand.
TODO: more sophisticated scheduling decisions, with deadline
and task budgets calculations.

Signed-off-by: Marcin Szkudlinski <marcin.szkudlinski@intel.com>
2023-03-14 14:00:28 +00:00
Marcin Szkudlinski 62e358231e kconfig: add DP_SCHEDULER kconfig def
some platforms don't use Zephyr, therefore they can't
use DP scheduler. Add a config option

Signed-off-by: Marcin Szkudlinski <marcin.szkudlinski@intel.com>
2023-03-14 14:00:28 +00:00
Marc Herbert 2a402ff6d5 topology2: extract new "tplg-targets.cmake" files from CMakeList.txt
The CMakeList.txt files in tools/topology/ have always confused two
different things:

- the list of .tplg files to generate, and
- the CMake logic used to invoke alsatplg and generate them.

Separate the two at last thanks a dead-simple `include()` command.  If I
had knew it was so easy I would have done this much sooner.

The `tools/build_tools/` directory is identical before versus after this
commit.

This will make it much faster to identify what actually changes in
future commits and pull requests.  This will also make CODEOWNERS
smarter and reduce Github notification noise.

Don't do it for topology1 to minimize churn and git disruption in
backports. Topology1 is not very active any more whereas topology2 has
never been released yet.

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2023-03-14 12:59:20 +00:00
Marc Herbert 66b7489032 topology2: copy CMakeLists.txt files as is to new tplg-targets.cmake
Decompose the split in the next commit into two steps to maximize git's
similarity index and facilitate git blame, cherry-pick/rebase, merge,
etc.

The new files are unused in this first commit so git bisect is not
affected.

Changing one-character in the source files also helps: compare git show
-C with git show -C -C. It's also a good clue for the reader when not
using -C.

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2023-03-14 12:59:20 +00:00
Marc Herbert ad8b54f095 xtensa-build-zephyr.py: add new PlatformConfig dataclass
Reduces duplication and provides more flexibility.

Also switch the list of platforms to a dict.

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2023-03-14 12:54:32 +00:00
Iuliana Prodan ffa8cad7ae mixer: skip inactive source
In case one of the sources is inactive, the avail_frames
for that source is 0 and the frames = 0.
So, later on, there is nothing to copy, even if, at least
one source is still active.
In this case, we get a "write error: Input/output error".

To fix this, allow mixer to process data from at least one
source, if that is active.
Or, in other words, if any source is inactive, skip it.

Signed-off-by: Iuliana Prodan <iuliana.prodan@nxp.com>
2023-03-14 12:49:57 +00:00
Chao Song b2ac05f04d smart_amp_test: fix wrong config size in config get
The config to get for smart_amp_test module is
struct sof_smart_amp_config, instead of the bigger
wrapper struct smart_amp_data, so the config size
should be the size of struct sof_smart_amp_config.

Signed-off-by: Chao Song <chao.song@linux.intel.com>
2023-03-14 14:45:07 +02:00
Guennadi Liakhovetski afb1a0d6a3 compile: use flexible arrays to use compiler checks
We use zero-size arrays throughout the code in place of flexible
arrays. There are only two cases where flexible arrays cannot be
used: inside unions and where such an array is the only member of the
structure. In all other cases we can switch to flexible arrays to let
the compiler warn us of any improper use.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
2023-03-13 22:17:32 +00:00
Guennadi Liakhovetski b541e415e0 ipc4: module: remove unused variable size structures
struct ipc4_module_init_instance contains 4 structures at the end,
that aren't currently used in the firmware. Some of them like
struct ipc4_module_init_ext_data have a flexible array at the end
but can have further structures following them. Remove these
structures until any of them are needed, at which point they can be
re-added with proper size accounting.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
2023-03-13 22:17:32 +00:00
Marc Herbert 11441d8540 zephyr/docker-run.sh: hardcode zephyr-build img to Zephyr SDK 0.15.2
Windows has always been hardcoded to 0.15.2 in .github Actions.

Fixes the compare-linux-windows check that just started to fail in daily
build https://github.com/thesofproject/sof/actions/runs/4400264770

The ":latest" zephyr-build image was just upgraded to the Zephyr SDK
0.16.0-rc1
https://hub.docker.com/layers/zephyrprojectrtos/zephyr-build/latest/images/sha256-91ef9e556aa2a6b5ee5397536e6c441b87fbaef82b9dfc0d12287c39d884d0af?context=explore

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2023-03-13 21:59:42 +00:00
Marc Herbert 8aab18351f xtensa-build-zephyr: fix DEFAULT_TOOLCHAIN_VARIANT spill on next platf
xtensa-build-zephyr.py has always defined XTENSA_ and other environment
variables in the current environment shared by all platforms. This was
always bad but apparently never a problem until the addition of the new
DEFAULT_TOOLCHAIN_VARIANT (xcc or clang) variable.

Before DEFAULT_TOOLCHAIN_VARIANT, each platform's environment would
simply override the previous one. However with the new
DEFAULT_TOOLCHAIN_VARIANT, the current environment has precedence for
more flexibility. This makes each platform "spill" onto the next one and
`xtensa-build-zephyr.py -p tgl mtl` fail like this:

```
-- Board: intel_adsp_ace15_mtpm
-- Found toolchain: xcc (/home/XCC/install/tools)
CMake Error at zephyr/cmake/compiler/xcc/generic.cmake:9 (message):
  Zephyr was unable to find the toolchain.  Is the environment
  misconfigured?

  User-configuration:

  ZEPHYR_TOOLCHAIN_VARIANT: xcc

  Internal variables:

  CROSS_COMPILE:
  /home/XCC/install/tools/RI-2022.10-linux/XtensaTools/bin/xt-
```

To fix this, stop modifying the current os.environ and use a new, fresh
os.environ.copy() for each platform instead.

Fixes commit 309fa264e2 ("xtensa-build-zephyr.py: upgraded Xtensa
toolchain for MTL")

History repeats itself: commit 6bedd8e742 ("xtensa-build-zephyr: fix
RIMAGE_KEY when building multiple platforms") fixed the same logical
error months ago in a different script.

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2023-03-13 14:19:49 +02:00
Seppo Ingalsuo f73055aa71 Tools: Testbench: Change struct of struct zeros initialize
The simple {0} is not accepted by xt-xcc compiler. It gives
"warning: missing braces around initializer".

Adding sufficient number of braces to match the struct definition
fixes the build.

Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
2023-03-13 10:00:48 +02:00
Guennadi Liakhovetski 8a48c78704 topology2: add a mixin-mixout level to nocodec
Add a second level of mixin-mixout mixing and a PCM to the nocodec
topology.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
2023-03-13 09:59:21 +02:00
Kai Vehmanen 528c7ebce0 platform: cannonlake: remove unused file idc.h
Remove one file that was missed in commit "platform: support for cAVS
1.8 platforms".

Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
2023-03-10 22:03:55 +00:00
Chao Song 4fa38d9b53 topology2: add cpc value for gain
The missing cpc in gain component results in wrong
calculation for clock selection, and causes capture
issues.

Link: https://github.com/thesofproject/sof/issues/7228
Link: https://github.com/thesofproject/sof/issues/7230

Signed-off-by: Chao Song <chao.song@linux.intel.com>
2023-03-10 16:09:11 +02:00
Andrula Song 802cffad0d Audio: Dcblock: Add HiFi4 implementation of dcblock
Add HiFi4 implementation of dcblock processing functions.
Compared with generic C version, the 16 bit format can save
about 54.8% cycles, and 53.1% for 24 bit format and 49.1%
for 32 bit.

Signed-off-by: Andrula Song <andrula.song@intel.com>
2023-03-10 11:37:45 +02:00
Guennadi Liakhovetski 29f3ac656b pipeline: fix a potential divizion by zero
If a component doesn't implement .get_attribute(),
pipeline_get_dai_comp_latency() will divide by uninitialised values,
possibly zero. To fix that initialise those fields to 0 and check
that they have been changed to non-zero before division.

Suggested-by: Rander Wang <rander.wang@intel.com>
Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
2023-03-10 11:16:30 +02:00
Guennadi Liakhovetski 53c6bac4b8 host: fix processed data reporting
In component's .get_total_data_processed() method the "input"
parameter means "calculate the direction where I am input." I.e. if
it's true, the method should return processed data on its output, and
if false - on its input. Since the host has only one direction, it
should only return data when the direction matches, i.e. when input
== true for playback and false for capture. The current
implementation has that check inverted. Fix both Zephyr and legacy
versions.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
2023-03-10 11:16:30 +02:00
Guennadi Liakhovetski e1e5fd0e7b pipeline: handle failed latency calculation
copier_comp_trigger() calls pipeline_get_dai_comp_latency() for
playback pipelines to obtain the pipeline DAI copier, if there is
one, and to calculate the pipeline latency. The latency is
calculated using the .get_total_data_processed() component
operation, but that operation is only available for DAI, host and
copier components. SOF pipelines often have other components at one
of the pipeline ends, so the latency calculation fails. However, that
shouldn't prevent pipeline_get_dai_comp_latency() from finding the
DAI component.
This fixes the notorious "failed to find dai comp or sink pipeline
not running." error message.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
2023-03-10 11:16:30 +02:00
Przemyslaw Blaszkowski 85367b73b9 mtl: add Aria module to build
Add Aria module to MTL build.

Signed-off-by: Przemyslaw Blaszkowski <przemyslaw.blaszkowski@intel.com>
2023-03-09 13:54:32 +00:00
Przemyslaw Blaszkowski 4d3bd81c02 aria: add generic processing functions
Add non-HIFI processing functions for non-Xtensa configurations.

Signed-off-by: Przemyslaw Blaszkowski <przemyslaw.blaszkowski@intel.com>
2023-03-09 13:54:32 +00:00
Seppo Ingalsuo ac1a63a5a0 Audio: Build testbench audio modules library for mux
This allows to run mux and demux components in testbench.

Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
2023-03-09 13:33:26 +02:00
Seppo Ingalsuo 0ca1ddcf80 Test: Cmocka: Convert mux to module adapter
This patch converts the demux_copy, mux_copy, and
mux_get_processing_function tests to module adapter API.
The main change is in component new preparations with
UUID reference.

Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
2023-03-09 13:33:26 +02:00
Seppo Ingalsuo 75f6bc6dc6 Audio: Mux: Simplify helper functions for mux/demux
This patch simplifies functions mux_prepare_actitive_look_up() and
demux_prepare_active_look_up().

Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
2023-03-09 13:33:26 +02:00