Commit Graph

9898 Commits

Author SHA1 Message Date
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
Seppo Ingalsuo c399624fcf Audio: Mux: Convert mux and demux to module adapter
This patch converts the components from legacy interface to
module adapter.

The binary control is also changed to use model handler.
The config is changed to be a pointer instead of a struct
inside component data.

Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
2023-03-09 13:33:26 +02:00
Liam Girdwood 470b703eee component: module name: stringify module name to be unique
Some modules have multiple types and init()s, support this with
unique names per type.

Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
2023-03-09 13:33:26 +02:00
Seppo Ingalsuo 7026802227 Audio: Mux: Remove unused parameter dev from functions
The comp_dev struct is not used in these functions so it can be
removed.

Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
2023-03-09 13:33:26 +02:00
Seppo Ingalsuo bca7bf436e Audio: Mux: Code formatting changes
These style changes improve code readability.

Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
2023-03-09 13:33:26 +02:00
Seppo Ingalsuo 84ecf46a90 Audio: Simplify volume ramp functions
This patch saves about 15% of processing time or about 0.9 MCPS
during volume ramp.

The volume_ramp() functions are inlined to volume_process() function.
The other use of function in idle is replaced by volume_ramp_check().

In ramp calculation the division in ramp time calculation is
converted to faster multiplication with inverse of sample rate.

The unnecessary checks for vol greater than vol_max or vol_min are
eliminated by ensuring that tvolume[] is limited to vol_min and vol_max.

The clear of ramp_coef[] at ramp finish is unnecessary. It's
internal for linear ramp and is not used by the other ramp type.

The other optimization is to pass to ramp math functions struct
vol_data pointer instead of processing_module pointer to direct
access to needed state variables.

Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
2023-03-09 13:07:47 +02:00
Adrian Bonislawski d7da25fc25 platform: ace: enable Zephyr counter drivers
This will allow to build and enable ace art and rtc
counter drivers

Signed-off-by: Adrian Bonislawski <adrian.bonislawski@intel.com>
2023-03-08 14:36:57 +00:00
Piotr Makaruk d850d94b0c hda: enable xrun handling in chain dma
Enable detection of under/overruns and report it by sending notification.

Signed-off-by: Piotr Makaruk <piotr.makaruk@intel.com>
2023-03-08 15:07:37 +01:00
Keqiao Zhang 634c65fa47 west.yml: upgrade rimage to d32db50
Pull in following rimage changes:

d32db50 mtl: add Aria module to extended manifest
5bc2010 rimage: fix build error
35bc644 mtl: add eq-iir and fir support
6fad356 rimage: Removed hash context from image structure
6c7a151 hash: Remove old hash functions
d258ea2 manifest: pkcs1_5: Use new hash functions
2bd8be3 hash: New hash functions
93c5e8b misc_utils: Move byte_swap function to new misc_utils.c file
9ce1cc8 ext_manifest: Fix fw_ext_man_cavs_header version
a4ca53c toml_utils: Adding support for decimal numbers in hex parser
5ebbd65 rimage: use hex number
36c0c90 elf: Use the get_file_size function
98c7f7b manifest: Use the get_file_size function
6a64cb9 file_utils: Add a new get_file_size function
055ea7e file_utils: manifest: ext_manifest: Add new create_file_name function
fed69d4 toml_utils: adsp_config: Moved generic parser functions to toml_utils
0931d9c main: heap_adsp release fix
3aa199f config: mtl: set init_config for micsel
d48ad6b adsp_config: add dump for init_config
ffd0542 adsp_config: make the default value zero for init_config
cb9c880 config: tgl-cavs: add kpb, selector and kd support
bf23b5e config: mtl: set KDTEST module_type to 8

Signed-off-by: Keqiao Zhang <keqiao.zhang@intel.com>
2023-03-08 14:12:06 +02:00
Guennadi Liakhovetski b637889efb platform: remove support for cAVS 2.0 platforms
Remove all support for cAVS 2.0 platformsm including Ice Lake and
Jasper Lake, they aren't supported any more.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
2023-03-07 14:02:18 +02:00
Guennadi Liakhovetski 5cbbde7986 clock: replace per-clock locks with a global one
select_cpu_clock() on cAVS currently takes all the clock locks while
adjusting them. And that function is called from clock_set_freq()
which also takes one of those locks, which leads to a recursive
spin-lock. To fix that remove per-clock spin-locks and use a global
clock lock instead.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
2023-03-07 13:37:56 +02:00
Peter Ujfalusi c9343dd4f1 ipc4: copier: Clarify the log and return value when the dai_copier is not found
We are always returning 0 if the dai_copier is not found and never an error
code. Make it clear by returning 0.

With that out of the way, it is clear that this is not an error, it is
something which can happen.
Firmware log is a proof of that since it is flooded with
<err> copier: comp:X 0xSOMEHEX failed to find dai comp or sink pipeline not running.

prints. Drop the log level to info and add a comment as explanation.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
2023-03-07 13:37:23 +02:00
Baofeng Tian 15d18cdc13 copier: remove the host component and endpoint buffer creation
With previous commits, copier can perform DMA copy without host
endpoint buffer and host device, so remove host device and endpoint buffer
creation, accordinlgy, related state settings are all removed.

Signed-off-by: Baofeng Tian <baofeng.tian@intel.com>
2023-03-07 10:59:51 +00:00
Baofeng Tian 9bca4369da copier: replace host dev with copier dev
Replace params and copy host dev with copier dev, after this change,
host dev and endpoint buffer are no longer useful for copier, next
step can remove host device and its endpoint buffer.

Simplified host_zephyr_params parameters, since all parameters changed
to copier dev aligned.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Signed-off-by: Baofeng Tian <baofeng.tian@intel.com>
2023-03-07 10:59:51 +00:00
Baofeng Tian 2edea177a5 copier: change DMA callback register from host to copier
Current host dma call back register on host device,
With this optimization, move this call back function from host
to copier device, create a new copier_dma_cb for copier usage.

Signed-off-by: Baofeng Tian <baofeng.tian@intel.com>
2023-03-07 10:59:51 +00:00
Baofeng Tian c488851def host-zephyr: Expose common functions for host DMA copy
Create and expose a couple of functions for host DMA copy
along with struct host_data,these functions will be shared by both
host and copier component.
This is in preparation to remove the creation of a host component and
endpoint buffer in create_host().

Signed-off-by: Baofeng Tian <baofeng.tian@intel.com>
2023-03-07 10:59:51 +00:00