Commit Graph

341 Commits

Author SHA1 Message Date
Baofeng Tian 47c52ccfe4 Component: move comp_copy from header file to source file an
On sof zephyr ipc4 build, component performance profiling logs can't
be enabled due to current xcc compiler does not support inline
logging in header file, logs as below:

  log_level undeclared (first use in this function)
  log_current_const_data undeclared (first use in this function)

Move comp_copy to component.c can resolve this limitation.
However, this brings another cmocka issue for mixer unit test,
this patch also fixed cmocka mixer unit test issue.

BugLink: https://github.com/zephyrproject-rtos/zephyr/issues/43786
Signed-off-by: Baofeng Tian <baofeng.tian@intel.com>
2022-10-18 13:42:53 +03:00
Adrian Warecki 784bce763c mtl: Added meteorlake platform to the build system
Added new mtl platform to xtensa-build-zephyr.py.
Added ace directories to cmake files.
Added ACE to kconfig.
Add Meteorlake platform to be built with Zephyr under
CONFIG_ACE_VERSION_1_5 flag.

Signed-off-by: Andrey Borisovich <andrey.borisovich@intel.com>
Signed-off-by: Marcin Szkudlinski <marcin.szkudlinski@intel.com>
Signed-off-by: Adrian Warecki <adrian.warecki@intel.com>
Signed-off-by: Konrad Leszczynski <konrad.leszczynski@intel.com>
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Signed-off-by: Tomasz Leman <tomasz.m.leman@intel.com>
Signed-off-by: Rafal Redzimski <rafal.f.redzimski@intel.com>
Signed-off-by: Adrian Bonislawski <adrian.bonislawski@intel.com>
2022-09-21 15:15:26 +02:00
Ranjani Sridharan 21587cee71 test: Add test infrastructure for module adapter
Add the test infrastructure for setting up and freeing a module and use
it in the volume unit test.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
2022-09-15 16:41:55 +01:00
Ranjani Sridharan 68866f2c1f test: volume: remove unused code
Volume component no longer does format conversion. Remove the unused
test code.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
2022-09-15 16:41:55 +01:00
Seppo Ingalsuo d3b58acab9 Test: cmocka: Add shift parameter to Mel filterbank reference
This patch adds to reference Mel filterbank the parameter
shift that is used to compensate in logarithmic power spectrum
the previously applied bitshift for linear spectrum values. The
added parameter is needed to test compatibility with C
implementation of the filterbank.

The test vectors were re-generated to include effect of shift
parameter values 0 - 3. The previous test used only value 0.

Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
2022-09-14 12:06:32 +01:00
Liam Girdwood e8733b4f4c header: rtos: use rtos specific version of clk.h
Code can now include <rtos/clk.h>. API is not yet wrapped to Zephyr.

Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
2022-09-12 11:44:27 +01:00
Liam Girdwood 4843516ab8 header: rtos: use rtos specific version of alloc.h
Code can now include <rtos/alloc.h> and uses thinly wrapped Zephyr
native for most uses. Wrapping can be removed over time.

Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
2022-09-12 11:44:27 +01:00
Liam Girdwood e42f4a6e63 header: rtos: use rtos specific version of timer.h
Code can now include <rtos/timer.h> and uses native Zephyr timer API
for most uses. Some wrapping still exists which can be removed over
time.

Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
2022-09-12 11:44:27 +01:00
Seppo Ingalsuo 957cebf64c Test: cmocka: Add test for DCT library
This patch adds 16 bit DCT matrix generation tests. The reference
DCT matrices are generated with Matlab or Octave with script ref_dct.m.
The test in dct.c compares SOF DCT lib generated matrix to reference
matrix and checks absolute and RMS error.

Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
2022-09-09 13:57:22 +01:00
Seppo Ingalsuo baec9c1b28 Test: cmocka: Add tests for auditory functions library
Add test for psy_hz_to_mel(), psy_mel_to_hz(), psy_get_mel_filterbank(),
and psy_apply_mel_filterbank_16/32(). All the test data in C header
files was created with script ref_auditory.m.

Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
2022-09-06 22:05:03 +01:00
Liam Girdwood c3c94fc515 header: rtos: use rtos specific version of wait.h
Code can now include <rtos/wait.h> and uses native Zephyr 64
cycle API instead of SOF version.

Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
2022-09-06 15:37:21 +01:00
Seppo Ingalsuo 65687d0c6b Test: cmocka: Add unit tests for matrix library
This patch adds four unit tests for 16 bit matrix multiplication.

Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
2022-08-31 14:45:32 +01:00
Liam Girdwood c90055f2f5 header: rtos: use rtos specific version of string.h
No runtime semantic change. Use C library when RTOS uses
C library otherwise use own C library calls.

Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
2022-08-31 12:01:07 +01:00
Liam Girdwood 1629a1f72c header: rtos: decouple headers into rtos specific directories.
No functional runtime change, but changes to rtos partitioning and the
layout of headers .

This patch creates RTOS specifc header paths and updates spinlock.h
and kernel.h to show the new usage. Other headers will incrementally follow.
It reuses the current zephyr topleve directory and creates a new
toplevel xtos directory for xtos specific files.

Due to the mixing of RTOS, driver and library headers at the top level include
directory it was necessary to create rtos specific header directories i.e.

src/include/rtos-xtos
src/include/rtos-zephyr

These RTOS include directories will eventually contain RTOS specific headers
whilst common logic and structures will be placed in non RTOS directories.

This will also mean

"#include <sof/spinlock.h>"

will become

"#include <rtos/spinlock.h>"

and will allow easier visualisation of where and why RTOS headers are being used.
This will help to eliminate cross usage of headers between RTOSes.

Subsequqnt patches will move more headers and rtos specific wrppaer
source files into rtos specific locations.

Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
2022-08-31 12:01:07 +01:00
Seppo Ingalsuo 152c57bb4c Test: cmocka: Add tests for window functions
This patch adds cmocka test cases for window functions library.
The calculated windows are compared with RMS error criteria
to Matlab calculated windows in header files. The header files
are directly generated by script ref_window.m.

Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
2022-08-29 17:07:55 +01:00
Seppo Ingalsuo ef90ee9a40 Test: cmocka: Always build FFt unit tests
There seems to be no reason to avoid add_subdirectory(fft).

Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
2022-08-26 10:46:50 +01:00
Seppo Ingalsuo 213fbf9740 Test: cmocka: Add unit tests for 16 bit FFT and IFFT
This patch adds tests for 16-bit FFT library version. The test SNR
is improved by using sine frequency that matches with length of FFT.
It allows to get highest SNR in transform without need for window
functions in test and attenuation in the signal.

The 32 bit FFT tests are updated to use the same signal generator.
With this criteria the minimum SNRs for 32 bit to pass could be
increased to 95 - 132 dB.

Also tests were added for 512 size FFT in addition to 256 and 1024.

Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
2022-08-26 10:46:50 +01:00
Seppo Ingalsuo 20fb082ecb Math: FFT: Add 16 bit FFT and IFFT version
This patch adds lower RAM and lower MCPS consuming FFT
for 16 bit data. The twiddle factors save from .bss
4096 bytes. For e.g. 512 bin FFT the saving for runtime is
additional 4096 bytes.

The previous fft.c has been split to fft_common.c and fft_32.c for
32 bits version. The new 16 bit version is in fft_16.c. The name
of previous fft_execute() is changed to fft_execute_32(). Common
function fft_plan_new() takes FFT word length 16 or 32 as new
last argument.

Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
2022-08-26 10:46:50 +01:00
Rander Wang 141efbd7b0 ipc4: convert selector to use the new module interface
Now both ipc4 and ipc3 path will switch to module interface
with this patch.

Signed-off-by: Rander Wang <rander.wang@intel.com>
2022-08-24 13:28:02 +01:00
Andrula Song 100144a1d0 Audio: Mixer: Add hifi version processing functions for mixer
Add hifi3 & hifi4 version implementation of mixer processing functions.
The hifi version functions can save at least 47% cycles than C version.

Signed-off-by: Andrula Song <xiaoyuan.song@intel.com>
2022-08-24 12:00:30 +01:00
Anas Nashif e687345a27 kconfig: remove undefined kconfig NUMBERS_GCD
NUMBERS_GCD was removed in commit 9611d126ba. We should not be
selecting or buildign with an undefined Kconfig.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
2022-08-09 11:01:14 +03:00
Ranjani Sridharan 4af7082ad0 Revert "eq_iir: Use the new module interface"
This reverts commit 9d9ba739b3.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
2022-07-19 15:33:29 -05:00
Ranjani Sridharan 9d9ba739b3 eq_iir: Use the new module interface
Use the module interface instead of the comp drv interface for the
EQ IIR component.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
2022-07-18 16:56:40 +01:00
Guennadi Liakhovetski af26534201 volume: fix buffer acquisition
Instead of acquiring and releasing buffers locally multiple times,
do that once for .copy() and .prepare() methods.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
2022-06-21 13:33:31 +01:00
Guennadi Liakhovetski 42eccb306b component: comp_make_shared() only needs to mark the component
comp_make_shared() only makes sense and is only called in multi-core
configurations. In such configurations components are allocated from
uncached memory, from the SOF_MEM_ZONE_RUNTIME_SHARED zone. So they
are always uncached and there is no need to flush cached or relink
lists. We only need to set a flag, indicating, that this component
is used on multiple cores.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
2022-06-13 15:23:37 +01:00
Ranjani Sridharan f7663de1f4 volume: use the new module interface
Move the volume component inside the module_adapter folder and use the
module interface API instead of the component driver interface. Also fix
the volume cmocka tests to use the modified scale_vol function.

Also, add kconfig option for keeping the legacy comp_drv interface for platforms
that are limited in text region memory size, such as
BYT/CHT/APL/JSL/ICL.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
2022-06-10 09:50:08 +01:00
Jyri Sarha b81c76f854 component: Split data_blob.[ch] out of component.[ch]
The data blob handler functionality is quite independent from the rest
of the generic component code. The component.c and component.h are
already too big so it is better to split the data blob handler
functionality out before adding more features to it.

Signed-off-by: Jyri Sarha <jyri.sarha@intel.com>
2022-04-05 17:47:18 +01:00
Adrian Warecki c1e75603b2 timer: Use Zephyr timer API
Replaced sof timer related functions with Zephyr alternative.

Signed-off-by: Adrian Warecki <adrianx.warecki@intel.com>
Signed-off-by: Daniel Baluta <daniel.baluta@nxp.com>
2022-03-16 12:02:29 +00:00
Adrian Warecki 619065f164 timer: Separate xtos timer API and add wrappers for Zephyr timer API
Created a new directory xtos-wrapper for xtos related files. Moved timer
header there.

Signed-off-by: Adrian Warecki <adrianx.warecki@intel.com>
2022-03-16 12:02:29 +00:00
Adrian Warecki 3cbab7ad5b clk: Add new function clock_ns_to_ticks
Added the new function clock_ns_to_ticks which allows conversion from
nanoseconds to ticks.

Signed-off-by: Adrian Warecki <adrianx.warecki@intel.com>
2022-03-16 12:02:29 +00:00
Adrian Warecki 5245c2e5f4 wait: Add functions to wait ms and us
Waiting for a certain time has been simplified by adding a functions
wait_delay_ms and wait_delay_us. Previously now, its required a conversion
between time to ticks using clock_ms_to_ticks.

Signed-off-by: Adrian Warecki <adrianx.warecki@intel.com>
2022-03-16 12:02:29 +00:00
Adrian Warecki 42025e551a ipc: Added const specifier to protect IPC message content in sending functions.
Added the const specifier to protect the message passed to
ipc_platform_send_msg and ipc_prepare_to_send functions. The deletion of
the message from the list has been moved to ipc_send_queued_msg function.

Signed-off-by: Adrian Warecki <adrianx.warecki@intel.com>
2022-02-21 15:42:43 +00:00
Shriram Shastry 10b4c56ed9 math: Add logarithm base E and base 10
fixpoint math log() and log10() function.  logarithm of a
number is the power or exponent by which another value
must be raised to produce an equivalent value of the given number
fix point  log10(x) is a derivative of log2(x)/log2(10)
and loge(x) is log2(x)/log2(e)

Signed-off-by: Shriram Shastry <malladi.sastry@intel.com>
2022-02-10 16:42:00 -08:00
Liam Girdwood 52b33a23b8 zephyr: spinlock: Align spinlock API to use Zephyr API
Align the SOF spinlock API with Zephyr spinlock API.

Currently SOF spinlock has two locking variants: with and without
disabling local IRQs. Since taking a spinlock potentially puts the
CPU into busy-looping, periods of time for holding spinlocks should
be kept as short as possible. This also means, that usually the CPU,
holding a spinlock shouldn't be interrupted. So usually spinlocks
should be taken in atomic contexts. Therefore using the version, not
locking local IRQs should only be done when IRQs are already
disabled. This then saves several CPU cycles, avoiding reading and
writing CPU status again. However, this should be only done with
extreme care and it introduces potential for current and future bugs,
including dead-locks.

Zephyr spinlock API always disables local IRQs. This makes it simpler
and less error prone. Switching to it potentially wastes several CPU
cycles in some locations, but makes the code more robust.

This is first part of work for spinlock Zephyr alignment, subsequent
updates will align headers and associated splinlock dependecies.

Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
2022-02-04 12:09:30 +00:00
Seppo Ingalsuo beb0610148 Math: IIR: Move IIR DF2T initialize helpers to library
The DF2T IIR core has been moved earlier to library but the
helper functions for configuring it were left to EQ component.
This patch eases use of IIR core from other components. The
file src/audio/eq_iir/iir.c is moved to src/math. There are no
changes except of remove iir.h since the contents specific
for DF2T type were merged to iir_df2t.h

Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
2022-02-04 10:02:55 +00:00
Andrula Song 3eaf974081 audio: volume: optimize volume component with HIFI3
Processing continuous data. Asking a 8-byte aligned memory
to store volume gain 4 times, using 2-way or 4-way pipeline
operations of xtensa intrinsics. This method can reduce about
40% MCPS than the original one.

Signed-off-by: Andrula Song <xiaoyuan.song@intel.com>
2022-01-27 12:01:27 +00:00
Chao Song b673d4a3e2 test: improve compatibility for malloc
The C header file malloc.h does not exist on
some Xtensa processor configurations or host OSes,
include stdlib.h instead because they both provide
the prototype for 'malloc' function.

Fixes: #5102

Signed-off-by: Chao Song <chao.song@linux.intel.com>
2021-12-25 20:44:02 +00:00
Seppo Ingalsuo 40046a2d25 Audio: Move audio stream copy inline functions to component.c
This patch moves functions audio_stream_copy(),
audio_stream_copy_from_linear(), and audio_stream_copy_to_linear()
into component.c. The functions are not changed.

There is no measurable code execution time
increase. In a test build this change saved about 800 bytes.

Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
2021-12-22 21:51:46 +00:00
Shriram Shastry 29fa4e1a9c math : Add square root function using lookup table
fix point math square function having positive number y as input and
return the positive number x multiplied by itself (squared)

Signed-off-by: Shriram Shastry <malladi.sastry@intel.com>
2021-12-21 15:30:20 +00:00
Marc Herbert 630b55e40a cmocka/test-all-defconfig.sh: add banners between platforms
Sample output:

[ 97%] Built target acos_32b_fixed
[ 98%] Linking C executable volume_process
[ 98%] Built target volume_process
[100%] Linking C executable strcheck
[100%] Built target strcheck

    =========  Building cmocka tests for broadwell_defconfig ======

+ cmake -DINIT_CONFIG=broadwell_defconfig -S /srv/mherber2/SOFub20/sof
   -B build_ut_defs/broadwell_defconfig -DBUILD_UNIT_TESTS=ON
   -DBUILD_UNIT_TESTS_HOST=ON

-- version.cmake starting SOF build at 2021-12-17T01:09:44Z UTC
-- Building git commit with parent(s):

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2021-12-20 22:34:03 +00:00
Marc Herbert 9005c90f3c cmocka: make test-all-defconfigs.h runnable from anywhere
Make test-all-defconfigs.h runnable from anywhere by merely adding a
cmake -S option.

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2021-12-20 22:34:03 +00:00
Rander Wang 235255bc44 test: add format S24_3LE in volume test
The format is added to make volume test pass.
The implementation will be added later.

Signed-off-by: Rander Wang <rander.wang@intel.com>
2021-12-06 09:55:59 +00:00
ShriramShastry 16002080e0 math: Add power scalar and base 2 log function
fix point math power function having negative and positive values
of base and exponent as function argument. power_int32() support
only integer base and exponential value and it does not support
fractional values for base and exponent.

fix point math base 2 logarithm function using a short lookup
tables

Signed-off-by: ShriramShastry <malladi.sastry@intel.com>
2021-12-01 10:42:10 +00:00
Liam Girdwood a824c1fc7e arch: string.h: use memset_s for all bzero uses.
Safer and fixes the following GCC11 warning

In file included from /home/lrg/work/sof/sof/src/include/sof/string.h:11,
                 from /home/lrg/work/sof/sof/src/include/sof/debug/debug.h:17,
                 from /home/lrg/work/sof/sof/src/platform/baytrail/platform.c:9:
/home/lrg/work/sof/sof/src/platform/baytrail/platform.c: In function 'platform_init':
/home/lrg/work/sof/sof/src/arch/xtensa/include/arch/string.h:22:9: error: 'memset' offset [0, 4095] is out of the bounds [0, 0] [-Werror=array-bounds]
   22 |         memset(ptr, 0, size)
      |         ^~~~~~~~~~~~~~~~~~~~
/home/lrg/work/sof/sof/src/include/sof/lib/alloc.h:160:9: note: in expansion of macro 'arch_bzero'
  160 |         arch_bzero(ptr, size)
      |         ^~~~~~~~~~
/home/lrg/work/sof/sof/src/platform/baytrail/platform.c:198:9: note: in expansion of macro 'bzero'
  198 |         bzero((void *)MAILBOX_BASE, MAILBOX_SIZE);
      |         ^~~~~

Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
2021-11-24 15:28:54 +00:00
Seppo Ingalsuo 132e648280 Math: Build library functions if enabled from Kconfig
This patch adds src/math/Kconfig with items CORDIC_TRIGONOMETRY_FIXED,
NUMBERS_GCD, NUMBERS_NORM, NUMBERS_VECTOR_FIND, MATH_DECIBELS, MATH_FFT,
MATH_FIR, and MATH_IIR_DF2T.

Configuration FIR and FFT were previously in src/audio/Kconfig but they
were moved to new math location for simplicity.

The build of trig.c was simplified by remove of unused UNIT_CORDIC_TEST
and CONFIG_CORDIC_TRIGONOMETRY_FIXED.

All but build details of numbers.c are handled by src/math/CMakeList.txt
if(CONFIG_X) additions. There was need to add "-DCONFIG_NUMBERS_x" into
target_compile_definitions() in test/cmocka/CMakeLists.txt because
the platforms those drop most features e.g. BYT would fail in test
case build.

Tone generator build is disabled for all platforms. It avoids select of
triginometric functions and saves RAM.

Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
2021-11-21 22:41:43 +00:00
Seppo Ingalsuo 3eeda96c0c Test: Add cmocka test case for IIR equalizer
This patch adds for the IIR equalized component a test with
comparison 100 ms of Octave generated output to output of the
component. The test signal is a full scale chirp signal. The
IIR response is both amplifying and attenuating to trigger as
much as possible issues with internal overflows.

All test data was generated by Octave script
cmocka_data_eq_iir.m. Re-run of script updates the used header
files the in cmocka tests directory.

Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
2021-11-08 12:14:43 +00:00
Guennadi Liakhovetski ace6181d4a ipc: (cosmetic) make two functions strongly typed
ipc_platform_complete_cmd() and ipc_platform_do_cmd() aren't called
as callbacks any longer, we can use strong argument types with both.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
2021-11-02 22:26:20 +00:00
Marc Herbert eef56b3988 trace: move CONFIG_TRACEM implementation up a couple levels
From deep down trace.c:va_tracelog() up to the _log_message() level.

Also rename va_tracelog() to the more specific dma_tracelog()

Preparation to support the DMA trace in Zephyr.

The only functional change in this commit is that DMA messages copied to
the shared memory are not de-duplicated any more (a.k.a "adaptive rate
limiting" or CONFIG_TRACE_FILTERING_ADAPTIVE). These are generally
supposed to be high level hence rare enough; otherwise there is probably
a "bigger problem".

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2021-10-26 21:54:11 +01:00
Keyon Jie 9887d2dffb cmocka: alloc: remove the 200KB+ buffer zone case
We have limited buffer zone which can't afford as big as 200KB+
allocation request on platforms like APL, remove the case.

Signed-off-by: Keyon Jie <yang.jie@linux.intel.com>
2021-09-23 12:59:36 +01:00
Keyon Jie ba95d8d306 cmocka: align to the new heap management
Align to the new heap memory map and allocator, smaller SYSTEM and
RUNTIME zones are used on apollolake now.

Signed-off-by: Keyon Jie <yang.jie@linux.intel.com>
2021-09-10 12:07:59 +01:00