Commit Graph

355 Commits

Author SHA1 Message Date
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
Guennadi Liakhovetski e7dc749abb dai: add support for initialisation delay
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>
2021-08-31 21:14:37 +01:00
Guennadi Liakhovetski 1103860a8d pipeline: add two new trigger commands and a new state
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>
2021-08-31 21:14:37 +01:00
ShriramShastry 14e7993979 WIP: Add cmocka tests for trigonometry function
Added cmocka tests for trigonometry asin,acos and
     complex exponential functions . cmocka tests verifies
     32 and 16 bit accuracy.

Signed-off-by: ShriramShastry <malladi.sastry@intel.com>
2021-08-18 13:08:32 +01:00
Rander Wang 23c0839e4a ipc: share some utility functions for ipc4 path
Ipc3 & Ipc4 will share some component operations.

Signed-off-by: Rander Wang <rander.wang@intel.com>
2021-08-03 15:17:37 +01:00
Pierre-Louis Bossart 158bb9e454 Revert "trace: move CONFIG_TRACEM implementation up a couple levels"
This reverts commit 0def905630.

Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
2021-07-30 15:25:09 -05:00
Marc Herbert 0def905630 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-07-26 19:41:55 +01:00
Marc Herbert b63b8e992b .github: run unit tests with -DBUILD_UNIT_TESTS_HOST=ON
Because we can.

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2021-07-26 09:19:50 +01:00
Marc Herbert 3ac8906097 unit tests: skip 'alloc' test when compiled on host
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>
2021-07-26 09:19:50 +01:00
Marc Herbert c8b226b86f cmocka/cmake: add $SIMULATOR to fix "make test" on host
Before this it was required to find and run the executables one by one

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2021-07-26 09:19:50 +01:00
Marc Herbert 589f035ad4 common_mocks.c: fix !CONFIG_TRACE build
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>
2021-07-26 09:19:50 +01:00
Seppo Ingalsuo 99ebc324f4 test: cmocka: Add exit to function __panic()
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>
2021-07-16 14:19:41 +01:00
Liam Girdwood 1ab68bfc00 mocks: enable allocator tests in host mocks with valgrind
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>
2021-06-29 11:05:02 +01:00
Ranjani Sridharan 7b06921b6b pipeline_graph: no need to free pipeline components during pipeline_free()
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>
2021-06-27 20:15:44 +01:00
Marc Herbert 29b1a9fc92 trace: rename trace_flush() to trace_flush_dma_to_mbox()
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>
2021-06-10 15:50:21 +01:00
Liam Girdwood d62e9267f6 ipc: split IPC major code into IPC specific directories
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>
2021-05-31 13:08:20 +01:00
Guennadi Liakhovetski c15c43e9fe clock: add a function to convert microseconds to ticks
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>
2021-05-24 11:17:22 +01:00
ShriramShastry 845c278ed6 Math: Trignometry: Added cordic sin cos function
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>
2021-05-19 11:00:27 +01:00
Liam Girdwood 80666b7cc7 ipc: component: abstract the component creation API
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>
2021-05-10 15:36:07 +01:00
Ranjani Sridharan cbf0a1e359 pipeline: fix pipeline's scheduling comp setting
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>
2021-05-08 14:34:19 +01:00
Ranjani Sridharan 71ac0f97e9 component: do not reset component status in the case of xrun
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>
2021-04-23 14:54:50 +01:00
Liam Girdwood 2f270ea3c6 cmocka: add support to build mocks on xtensa GCC
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>
2021-04-20 15:35:18 +01:00
Liam Girdwood 4d6da60931 cmocka: add support to run mocks on host architecture
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>
2021-04-20 15:35:18 +01:00
Liam Girdwood 16842868d9 cmocka: reduce number of mocked functions and increase test coverage
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>
2021-04-19 14:29:37 +01:00
Liam Girdwood 1931168185 pipeline: decouple IPC major from pipeline_new().
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>
2021-04-19 14:29:37 +01:00
Liam Girdwood d10eefc199 ipc: move IPC buffer logic to IPC helper.
buffer_new() is IPC specific so move to IPC helper.
No code changes only moves.

Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
2021-04-19 14:29:37 +01:00
Keyon Jie d2cfa10f50 cmocka: add cmocka unit test for fft library
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>
2021-04-15 17:30:48 +08:00
Liam Girdwood 517ad95d51 ipc: split ipc headers per function.
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>
2021-04-12 19:30:11 +01:00
Liam Girdwood 0f2c9d1230 cleanup: remove double blanks lines.
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>
2021-04-12 16:58:51 +01:00
Liam Girdwood 4875c44609 pipeline: split pipeline up by function.
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>
2021-04-01 21:46:29 +01:00
Bartosz Kokoszko ce4cd06405 demux: fix demux look up table preparation
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>
2021-02-17 10:31:55 +00:00
Jaska Uimonen 71a4e98a27 mux: fix input and output channel setting
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>
2021-02-03 15:58:24 +00:00
Artur Kloniecki b07f2674cc trace: Rename trace_log() function to trace_log_filtered()
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>
2020-11-27 15:10:46 +00:00
Karol Trzcinski 137c90bbc6 buffer: Move functions using trace system to buffer.c
Then trace location in output trace file is correct.

Signed-off-by: Karol Trzcinski <karolx.trzcinski@linux.intel.com>
2020-11-03 16:47:02 +00:00
Karol Trzcinski fb838de413 buffer: Move buffer_params_match() implementation to buffer.c file
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>
2020-11-03 16:47:02 +00:00
Karol Trzcinski 43124daf39 alloc: Define new memory zone, shared
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>
2020-10-21 14:57:09 +01:00
Artur Kloniecki 996ffefed4 test: pcm converter: Utilize comp_buffer implementation instead of mocking
Currently pcm converter unit tests use mocked-up audio_stream
implementation which should be replaced with real FW implementation.

Signed-off-by: Artur Kloniecki <arturx.kloniecki@linux.intel.com>
2020-09-15 10:49:24 +02:00
Guennadi Liakhovetski 047f08f20e uuid: use a pointer instead of casting it to an integer
UUID objects are represented by struct sof_uuid_entry instances in SOF.
Instead of casting pointers to them to integers for passing around,
carry them as pointers until they have to be cast to integers for
packing into data structures. This also fixes printing UUID, using a
"%pU" format.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
2020-09-15 09:33:29 +01:00
Artur Kloniecki a5b1d51b80 test: selector: Utilize real buffer implementation instead of mocking.
Currently selector unit tests mock audio_stream by hand, which
adds maintenance overhead in case of changes in audio_stream
implementation, which are under way.

Signed-off-by: Artur Kloniecki <arturx.kloniecki@linux.intel.com>
2020-09-08 12:38:57 +02:00
Artur Kloniecki 4f952a3868 test: volume: Utilize real buffer implementation instead of mocking.
Currently volume unit tests mock buffer components by hand, which
adds maintenance overhead in case of changes in buffer implementation,
which are under way.

Signed-off-by: Artur Kloniecki <arturx.kloniecki@linux.intel.com>
2020-09-08 12:38:57 +02:00
Artur Kloniecki 2d1b17a55e test: buffer: read and write to buffer byte by byte.
Currently buffer is filled by memcpy_s and verified by memcmp, which
would require more UT maintenance during upcoming buffer changes.
With this change, usage of the buffer better reflects real-life usage.

Signed-off-by: Artur Kloniecki <arturx.kloniecki@linux.intel.com>
2020-09-08 12:38:57 +02:00
Artur Kloniecki 238cd1457d treewide: Remove references to .free and .avail members of audio_stream.
All audio_stream clients should use provided audio_stream_get_avail*/free*
API, instead of directly accessing .avail and .free member fields.

Signed-off-by: Artur Kloniecki <arturx.kloniecki@linux.intel.com>
2020-08-03 21:53:14 +01:00
Andy Ross fd506970cc zephyr: kconfig: rename CONFIG_SMP -> CONFIG_MULTICORE
This kconfig collides with one of the same name in Zephyr.  Rename it
for clarity ("MULTICORE" was picked for symmetry with the existing
"CORE_COUNT", though it's admittedly a little long...).

Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
2020-07-24 19:55:05 +01:00
Bartosz Kokoszko 5d763d6349 mux: simplifies mux processing functions
This commit simplifies mux processing functions and
does not allow mux to mix channels.

Signed-off-by: Bartosz Kokoszko <bartoszx.kokoszko@linux.intel.com>
2020-07-14 16:35:21 +01:00
Karol Trzcinski adc8cc22cc sof: Unify hex dixplay style
Consistency should be kept so usage the same HEX case throughout the FW
is advised.

Signed-off-by: Karol Trzcinski <karolx.trzcinski@linux.intel.com>
2020-07-07 15:48:43 +01:00
Karol Trzcinski f4bb9fe079 ipc: Extract pipeline id dereference from ipc_comp_dev structure
Mechanism of comparison pipe_id from ipc_comp_dev will be used in
trace filtering, so this part should be moved to separate function
and allow code reusability.
Moreover function usage is compact and descriptive method to define
what given block of code should do, so after such a refactor code
readability is improved.
Include from pipeline.h is removed to omit circular reference.

Signed-off-by: Karol Trzcinski <karolx.trzcinski@linux.intel.com>
2020-06-24 09:43:54 +01:00
Bartosz Kokoszko a2d1e1efdc component: add set of helper functions for large config configuration
This commit rewrites functions responsible for large config configuration
from detect_test component and puts them in component.c file as
generic ones - as a result they can be used by other components.

Signed-off-by: Bartosz Kokoszko <bartoszx.kokoszko@linux.intel.com>
2020-06-17 11:33:23 +02:00
Karol Trzcinski c419fadc3e trace: Filter messages in runtime
Ability to change log level per UUID component improve user
experience during debugging firmware. Threshold trace level
defined in log message with value from trace context, where
trece context is related with component instance (local or
global instance).

Signed-off-by: Karol Trzcinski <karolx.trzcinski@linux.intel.com>
2020-06-10 11:51:41 +01:00
Karol Trzcinski c939302194 trace: Pass trace context to logging function
UUID key is too detailed information for logging function to allow
easy functionality extension in future. Trace context structure is
designed to work directly with logging function, so there is no
reason to unpack values from this struct in trace macro-functions
and pass them as separate arguments to trace_log().

Signed-off-by: Karol Trzcinski <karolx.trzcinski@linux.intel.com>
2020-05-27 17:02:46 +02:00
Karol Trzcinski ed5ac2ff48 trace: buffer: Use trace context in buffer logs
Each trace function should refer to trace context, where are
stored information like uuid and runtime editable logs level,
to unify trace API and allow trace filtering in future.
Remove buf_cl_* functions, as no longer supported.

Signed-off-by: Karol Trzcinski <karolx.trzcinski@linux.intel.com>
2020-05-27 11:53:53 +02:00
Karol Trzcinski 56a660be28 pcm_converter: HiFi3 implementation of conversion between float and fixed
Used method need floating point unit in DSP core.
Vectorized conversion functions are inaccessible for used cores.

Signed-off-by: Karol Trzcinski <karolx.trzcinski@linux.intel.com>
2020-05-25 09:48:01 +01:00
Karol Trzcinski a264e77011 pcm_converter: Normalize floats value during conversion
Respect fixed point data format as Q1.X instead of QX.
After change values in float will be in range <-1;1)
what will correspnd to fixed point data MAX/MIN value
in Q1.X format.

Signed-off-by: Karol Trzcinski <karolx.trzcinski@linux.intel.com>
2020-05-25 09:48:01 +01:00
Karol Trzcinski b1eb29d62d pcm_converter: Add unit tests for conversion float to fixed
Implement mocks, cmake modification and unit test architecture.

Signed-off-by: Karol Trzcinski <karolx.trzcinski@linux.intel.com>
2020-05-25 09:48:01 +01:00
Marcin Maka 6ce635aa82 trace: replace TRACE_CLASS_ by uuids
All trace entries are identified by uuids only now.
Previous TRACE_CLASS_ identification removed completely.

UUIDs are passed to the tracing subsystem inside a trace
context. Each trace context defines run-time log level.
The level is initialized to LOG_LEVEL_INFO (this may be
change per instance is needed) and may be re-configured
at run-time.

Signed-off-by: Marcin Maka <marcin.maka@linux.intel.com>
2020-04-30 11:39:37 +02:00
Tomasz Lauda 8d9e61f698 notifier: add flags
Adds possibility of defining flags, when performing
notifier registration.

Signed-off-by: Tomasz Lauda <tomasz.lauda@linux.intel.com>
2020-04-23 10:30:34 +02:00
Marcin Maka 8a7875d5e4 comp: run default params handler if not defined by target comp
Actions perfomed by the default handler are required to keep
the component device state consistent (e.g. dev->frames are
initialized). While the current comp_params() silently skips
the component if params are not defined.

New simple components will not be required to define a handler
if no extra steps are needed.

It is also an opportunity to reduce the code of existing components
Note that most of the extra steps are moved to prepare() in many
implementations already (like volume), others may follow and remove
their params() handlers once reduced to a single call to the default
handler (like mux recently did).

Signed-off-by: Marcin Maka <marcin.maka@linux.intel.com>
2020-04-15 14:55:54 +02:00
Karol Trzcinski b12a6626c5 trace: Remove metaprogramming from trace implementation
Functions written with metaprogramming are hard to read and debug,
so newly introduced version should be easier to understand for
new developers. Moreover introduced version is more generic and
compact because of usage single logging function implementation
regardless of given parameters number and usage of atomic or
mbox version.
There is no longer a need to heavy test logging function under
UT with different number of arguments, because of it singular
implementation.

Signed-off-by: Karol Trzcinski <karolx.trzcinski@linux.intel.com>
2020-04-10 19:28:37 +01:00
Marcin Maka 245f5aa8a8 alloc: remove unused rrealloc
rrealloc function is no longer in use, so it is better
to remove it. Unused code is no longer tested so its
quality is unknown.

The current implementation is simple but expensive since
extra calls to malloc/free requires time and risky since
at some point requires double allocation of potentially
large object. Please consider re-implementation instead
of restoring.

Signed-off-by: Marcin Maka <marcin.maka@linux.intel.com>
2020-04-10 20:00:05 +03:00
Tomasz Lauda 1c2f3c0ce5 schedule: return status of operations
Changes schedule operations to return error in case
chosen scheduler is not found or scheduler doesn't
support mandatory operation.

Signed-off-by: Tomasz Lauda <tomasz.lauda@linux.intel.com>
2020-04-10 14:45:49 +02:00
Marcin Maka e306d1293e alloc: fix potential oob in rbrealloc
Previous memcpy of bytes is unsafe if new object is larger
then old one.

Typically realloc retrieves the old size internally and does
not need this information passed as argument but sof heap
implementation does not store the exact size of the allocated
memory buffer.

Signed-off-by: Marcin Maka <marcin.maka@linux.intel.com>
2020-04-08 10:51:37 +01:00
Marcin Maka 75b8c1e8f8 alloc: fix potential oob in rrealloc
Previous memcpy of bytes is unsafe if new object is larger
then old one (which is probably most popular realloc use).

Typically realloc retrieves the old size internally and does
not need this information passed as argument but sof heap
implementation does not store the exact size of the allocated
memory buffer.

Signed-off-by: Marcin Maka <marcin.maka@linux.intel.com>
2020-04-08 10:51:37 +01:00
Sam Muhammed de085f22f5 sof: Avoid comparison with NULL
Use (!x) instead of comparison with NULL.

Signed-off-by: Sam Muhammed <jane.pnx9@gmail.com>
2020-04-07 12:07:59 +03:00
Artur Kloniecki e20cd2811e muxdemux: Remove obsolete references to config->num_channels.
Few artifacts of the past were left after dependency removal. This patch
is there to address that.

Signed-off-by: Artur Kloniecki <arturx.kloniecki@linux.intel.com>
2020-04-02 10:12:28 +01:00
Artur Kloniecki a0c9aebe05 muxdemux: Remove dependency on config->num_channels.
In the past, when parameters were held by components, it was impossible
to manage input/output streams with different channels' count.
Now, after params were moved to buffers, we can properly handle such
scenario, which in turn allows for more flexible approach in terms of
runtime configurability.

Signed-off-by: Artur Kloniecki <arturx.kloniecki@linux.intel.com>
2020-04-02 10:12:28 +01:00
Artur Kloniecki 8d76846ba8 muxdemux: Remove dependency on config->frame_format.
(de)mux_get_processing_function() call depended on config->frame_format
being properly configured, which was obsolete from the very beginning.
This patch removed that dependency in favor of reading frame_fmt from
downstream buffer during the call, rendering that field completely
obsolete.

Signed-off-by: Artur Kloniecki <arturx.kloniecki@linux.intel.com>
2020-04-02 10:12:28 +01:00
Sam Muhammed 288b8f3ade test: cmocka: Use ARRAY_SIZE
Instead of computing array size, use the ARRAY_SIZE
macro defined in <sof/common.h>.

Signed-off-by: Sam Muhammed <jane.pnx9@gmail.com>
2020-03-31 15:01:14 +01:00
Marc Herbert 8dbbbf0329 test: fix mixer_test.c:comp_register() 'uninitialized err' -Werror
Fixes:

  error: 'err' may be used uninitialized in this function
                           [-Werror=maybe-uninitialized]
  if (err)
     ^

As I found nothing in the entire code base checking the return value of
comp_register() (the real function seems to always succeed), I also
simplify the main path and pass through the value returned by
memcpy_s().

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2020-03-30 14:56:26 +01:00
Payal Kshirsagar 22be53b98a test: cmocka: src: avoid NULL comparison
Replace NULL comparison with boolean negation. Issue found using
Coccinelle.

Signed-off-by: Payal Kshirsagar <payalskshirsagar1234@gmail.com>
2020-03-27 10:50:52 +01:00
Marcin Maka 36e58d279b alloc: replace r- macros with renamed functions
Once the debug version of allocation functions are removed,
macros may be replaced with functions declared without leading
_ which makes the documentation (and the header) more readable,
the defines section does not need to contain doubled documentation
of alloc api.

bzero macro is not esasily removable due to include deps which
bring earlier declaration of non-inline prototype.

Signed-off-by: Marcin Maka <marcin.maka@linux.intel.com>
2020-03-27 10:43:23 +01:00
Iulian Olaru 303ed59e87 test: Add extra tests fot gcd
This patch adds extra tests for the gcd of
(0, 0), (a, 0), (0, b), (-a, -b), (-a, b), (a, -b)

Signed-off-by: Iulian Olaru <iulianolaru249@yahoo.com>
2020-03-26 12:12:55 +00:00
Marcin Maka 0f88be3e1a mm: separate alloc api and heap mgmt api
All clients that just wants to allocate and free memory
does not need to know all the heap management api
and internals.

Signed-off-by: Marcin Maka <marcin.maka@linux.intel.com>
2020-03-26 10:09:32 +00:00
Marcin Maka 8d350a3eff test: move timer mocks to the common part
Previously used by kpb tests only and defined locally.
New pieces of the code, like perf macros need them
globally.

Signed-off-by: Marcin Maka <marcin.maka@linux.intel.com>
2020-03-25 15:02:37 +01:00
Marcin Maka 415906e822 comp: rename private field to priv_data
Another cpp keyword that confuses documentation generation
process.

Signed-off-by: Marcin Maka <marcin.maka@linux.intel.com>
2020-03-25 11:04:15 +01:00
Marcin Maka 23d0eae9e2 comp: ops: rename new as create
New is c++ keyword which causes errors while generating
the documentation for component api with sphinx and breathe.

Signed-off-by: Marcin Maka <marcin.maka@linux.intel.com>
2020-03-25 11:04:15 +01:00
Janusz Jankowski 9da1fce247 test: audio: remove kpb
KPB tests don't work and it's better to remove it,
than keeping here disabled code.

Signed-off-by: Janusz Jankowski <janusz.jankowski@linux.intel.com>
2020-03-20 16:36:44 +01:00
Marc Herbert ff88cd03b7 test/kpb: fix tests[1] array out of bounds
As reported by gcc.

Fixes: 0b279e06bc. This is a partial, one-line revert of that commit
that decreased the size of this array for no obvious reason.

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2020-03-20 12:14:52 +00:00
Marc Herbert 726dd545d6 cmocka/cmake: don't re-fetch (and change) cmocka.git on every build
Add "UPDATE_DISCONNECTED True" property in ExternalProject_Add() so:

- Unit tests can be rebuilt without a network connection
- The code can't change from one build to the next without the developer
  being aware.

Found by chance thanks to some network issue.

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2020-03-20 12:07:44 +00:00
Janusz Jankowski 162ca407eb test: fix pipeline tests
Initialize global objects that are required by pipelines
logic - pipeline_posn.

Signed-off-by: Janusz Jankowski <janusz.jankowski@linux.intel.com>
2020-03-19 11:30:03 +01:00
Tomasz Lauda b144a02bdc cmocka: fix ut building
We don't support section .shared in unit tests,
so add appropriate flags to make files.

Signed-off-by: Tomasz Lauda <tomasz.lauda@linux.intel.com>
2020-03-18 21:25:56 +00:00
Marcin Maka ac01040efe comp: api: advanced and internal functions separated
The current content of component.h is a mix of basic api, common
basic helpers for every component developers as well as advanced
functions and macros used by infrastructure and very specialized
components like host, dai, kpb etc.

This patch moves the advanced part to component_ext.h and keeps
only basic part in component.h to avoid overloading effects
component developers with declarations and code they do not use.

Signed-off-by: Marcin Maka <marcin.maka@linux.intel.com>
2020-03-17 16:13:29 +01:00
Marcin Maka 0529c141f4 tasks: add uuid based identification for tasks
Tasks activities may be traced and analysed easier if they
are identified by uuids and named.

Signed-off-by: Marcin Maka <marcin.maka@linux.intel.com>
2020-03-17 15:11:42 +02:00
Marcin Maka 322e150080 trace: add uuid to trace entry and remove trace ids
New trace entry parameter is defined: uuid of the source.
Technically, this is an address of uuid entry linked
inside a special section in elf.

Has_ids is removed from the static log entry since eventually
all entries will use uuids and -1 detection is good enough
detection for those who still do not provide ids.

Note: both changes are done in a single patch to avoid two
major dbg-abi version bumps.

Signed-off-by: Marcin Maka <marcin.maka@linux.intel.com>
2020-03-06 10:15:04 +01:00
Marcin Maka 3100546463 uuid: add simple static uuids linked to ldc section
Unique identification in form of Guid is much more
scalable for fw parts (components, dais, ...) then
existing ids and trace class ids.

Signed-off-by: Marcin Maka <marcin.maka@linux.intel.com>
2020-03-06 10:15:04 +01:00
Tomasz Lauda 3609fa6fc6 ipc: use notifications allocated by sources
Changes implementation of notifications allocation.
Instead of using common empty list of messages let's
switch to allocating message per source of notification.
This way we won't have problem with memory and lack of
empty messages and also we will be able to optimize memory.

Signed-off-by: Tomasz Lauda <tomasz.lauda@linux.intel.com>
2020-03-02 13:28:52 +01:00
Bartosz Kokoszko 6b250ff8a9 mux: move fetching proc function from prepare() to set_values()
This commit moves fetching mux/demux processing functions from
mux_prepare() to mux_set_values(). It insures us against
situation when we fetch proc_func in mux_prepare() and
after that comes mux_set_values() with new mux config.

Signed-off-by: Bartosz Kokoszko <bartoszx.kokoszko@linux.intel.com>
2020-02-28 16:21:59 +00:00
Tomasz Lauda 46a1db20a8 component: add operations for remote components
Implements remote operations for params, prepare, trigger
and reset calls. If the target component is running on
different core, we should send IDC in order to execute
appropriate operation.

Signed-off-by: Tomasz Lauda <tomasz.lauda@linux.intel.com>
2020-02-26 16:14:28 +00:00
Tomasz Lauda e3a6efd8e7 buffer: use locks for inter-core buffers
Implements locking and cache synchronization for buffers,
which are connecting components running on different cores.
We need to explicitly use cache here (if platform supports it),
so the shared API cannot be used in this particular case.
Shared is going through uncached area on cAVS platforms,
but it's too slow in the case of frequent buffer accesses.
Also loop in pipeline_set_params has been changed to avoid
unnecessary cache accesses after unlocking the buffer.

Signed-off-by: Tomasz Lauda <tomasz.lauda@linux.intel.com>
2020-02-26 16:14:28 +00:00