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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
Some DAI devices need a delay between their PRE_START and START
trigger commands, and similarly between PRE_RELEASE and RELEASE.
Add a DAI driver operation to get that delay time and use it between
the two commands.
Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
We need to split the START trigger command into two commands because
some components have a long delay inside their START handling. This
patch introduces two new trigger commands: PRE_START and
PRE_RELEASE and a new state PRE_ACTIVE to prepare for that split.
For simmetry POST_STOP and POST_PAUSE are also added, however they
aren't used yet.
Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
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>
It is failing and skipped only when compiled on the host, runs fine with
xt-run.
This is temporarily needed to add host-based unit tests to CI now and
catch any regression in any other test now.
Signed-off-by: Marc Herbert <marc.herbert@intel.com>
Fixes 'no previous prototype for trace_log_filtered' -Werr and
redefinition of ‘trace_flush_dma_to_mbox’ error.
Signed-off-by: Marc Herbert <marc.herbert@intel.com>
This change avoids build error:
cc1: warnings being treated as errors
sof/test/cmocka/src/common_mocks.c: In function ‘__panic’:
sof/test/cmocka/src/common_mocks.c💯 warning: ‘noreturn’ function does return
Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
This enables support for running the allocator mocks with valgrind by
building the allocator for the host library target using a similar
heap map to Intel CAVS targets (memory.c is almost identical copy of CAVS
version).
Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Pipeline components will be freed by the host before the
pipeline widget itself is freed. No need to walk the pipeline
and free anything during pipeline_free().
Fix the unit tests to remove the tests that are not relevant anymore.
Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Pure rename, zero functional change.
The very poorly named trace_flush() function sounds like earlier
scheduling of something that would the same later anyway but that's
absolutely not what it does. Instead it copies pending DMA traces to the
shared mailbox.
As an example, in June 2020, PR #3195 commit 6c14e76c0d ("trace: Log
FW ABI and hash numbers") added a tr_info() "banner" immediately after
to make sure tracing works. That included a likely misunderstood
trace_flush() call immediately after the tr_info().
Signed-off-by: Marc Herbert <marc.herbert@intel.com>
Prepare for supporting new IPC major versions by partitioning
IPC code into directories.
This is a code move only, no code changes except Makefiles.
Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Several code paths use the existing clock_ms_to_ticks() function in
some not ideal ways, potentially leading to computation overhead or
to precision loss. The function is often called to calculate ticks
for 1 millisecond, which then is recalculated to the required time
interval. It's better to let the function calculate the number of
ticks for the required time interval directly. E.g. instead of
clock_ms_to_ticks(PLATFORM_DEFAULT_CLOCK, 1) * milliseconds
it's better to call
clock_ms_to_ticks(PLATFORM_DEFAULT_CLOCK, milliseconds)
directly. For microseconds however replacing
clock_ms_to_ticks(PLATFORM_DEFAULT_CLOCK, 1) * microseconds / 1000
with
clock_ms_to_ticks(PLATFORM_DEFAULT_CLOCK, microseconds / 1000)
can lead to a loss of precision. To avoid that a new function
clock_us_to_ticks() is added.
Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
Cordic sin cos input value range is [-2*pi to 2*pi]
and output range is [-1 to +1]
This is common function to calculate trignometric sine
and cosine using separate lookup table size for speeds
and accuracy calculation.
For 32bit sine and cosine
Error (max = 0.000000011175871), THD+N = -170.152933
For 16bit sine and cosine
Error (max = 0.000061), THD+N = -91.518584
Signed-off-by: ShriramShastry <malladi.sastry@intel.com>
Make sure component creation is not tightly coupled to a particular IPC
version. This is mostly a mechanical change of structures being passed
to the comp creation APIs away from IPC specific to general structures.
Highlevel changes
1) Pass a common component data object and a component
specific data object during create().
2) Mark the component IPC derived data as "ipc_config" within the
component device to help developers track the data source origin.
3) Pass component specific data during creation so that componets
can allocate and copy to thier private data.
4) Comp_dev no longer has component specific data appended to it.
Instead we can store all in the comp private data (and hence use the
compiler to access it rather than by developer access methods).
Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Move the code that sets the scheduling comp for
a pipeline to allow setting it in ipc_pipeline_complete().
This removes the restriction that the scheduling comp must
be set up before the pipeline widget and provides the
flexibility in the kernel to set up the widgets in any order
while parsing topology.
Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Do not reset component status in the case of xrun.
An irrecoverable xrun will lead to the pipeline being
stopped by the host and resetting the status will result
in an error stating invalid current state during the STOP
trigger.
Also update the unit test to retain the same state during an xrun.
Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Allows the mocks to be built only for xtensa GCC. i.e a build test only.
Running on qemu requires more work.
Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Allows the mocks to be quickly run on the host with full access to host
debug and development tooling.
Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Reduce the number of functions we mock and use the real functions where
we can. This brings in more runtime code so will increase the test
coverage.
Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Decouple the IPC ABI major version from pipeline creation. This moves
struct sof_ipc_pipe_new from the pipeline and replaces it with it's
members (saving 8 bytes as no header is needed).
Add new feature specific pipeline APIs to configure pipeline at creation.
Additionally align testbench and UTs to API change.
Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Add cmocka unit test for FFT library, including fft with size 1024/256,
fft + ifft with SNR test, fft for 2 channels.
Implement helpers to accept samples put in comp_buffer for both real and
complex FFT, the helper fft_real_2() is implemented to speed up the FFT
for dual channels inputs up to two times. All theses helpers should be
used for unit test only.
Suggested-by: Amery Song <chao.song@intel.com>
Signed-off-by: Keyon Jie <yang.jie@linux.intel.com>
Split IPC APIs out by feature so that the IPC layer to help future
IPC infrastructure changes support more than one IPC ABI MAJOR version.
No code changes here, only code partitioning and Doxygen comments.
Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Several files had multiple blank lines even before the removal of
platform_shared_commit(). Fix them with "cat -s"
Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Split the pipeline logic up into stream, params, graph, scheduling and xrun
so that it easier to follow and understand. This is to help on the TSC work
to integrate the codec adaptor into core logic.
This PR is all mechanical code moves. There are NO functional changes. Some
function that were static are now public.
Followup patches will add more documentation updates alongside.
Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
Array streams represents streams on "many" side i.e. input
for MUX and output for DEMUX.
For DEMUX each stream has masks array - 1 mask per output
channel. Each mask shows, from which input channel data
should be taken.
This commit reverts "demux" part of commit:
"b1b31e7154a5c159d81459634eabd8013b434181"
Signed-off-by: Bartosz Kokoszko <bartoszx.kokoszko@linux.intel.com>
Input and output channel settings from matrix row and column
are in reverse order, so they should be swapped.
Signed-off-by: Jaska Uimonen <jaska.uimonen@intel.com>
Also create trace_log_unfiltered() function, to be used internally
by tracing subsystem to emit information about suppressed trace messages.
The *unfiltered function could be also used as replacement
in _log_message() macro, to disable log filtering for debugging purposes.
Signed-off-by: Artur Kloniecki <arturx.kloniecki@linux.intel.com>
Assertions don't show proper location for functions implemented
in header file.
Before changes, example location of this assert was:
Location: src/audio/pipeline.c:303
Signed-off-by: Karol Trzcinski <karolx.trzcinski@linux.intel.com>
Shared memory shouldn't be connected with any cpu core,
because in general such an resource may be shared between
any number of arbitrary chosen cores.
Connecting it with with core 0 heap, leads to unbalanced
heap usage between core 0 and secondary cores.
Moreover operations like alloc and free may be called from
two different cores, what's not possible in current implementation.
Such an situation is especially possibly during handling resources
describing hardware components, eg. DAI or DMA, from two different
cores.
Moving shared memory management to dedicated heap, allows to easily
use another memory region, what may be needed to fulfill platform
specific demands.
Signed-off-by: Karol Trzcinski <karolx.trzcinski@linux.intel.com>