Commit Graph

239 Commits

Author SHA1 Message Date
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
Tomasz Lauda de0a0b85c5 component: add task when scheduled on different core
Adds separate task to components, which are supposed to be scheduled
on different core than the rest of the pipeline. These are so called
shared components. This way components requiring huge processing power
can be offloaded to slave cores.

Signed-off-by: Tomasz Lauda <tomasz.lauda@linux.intel.com>
2020-02-26 16:14:28 +00:00
Tomasz Lauda ec15c0ac38 component: implement component sharing functionality
Implements component reallocation in shared memory. This way
cores can share components, which are part of one core's pipeline,
but runs on other core.

Signed-off-by: Tomasz Lauda <tomasz.lauda@linux.intel.com>
2020-02-26 16:14:28 +00:00
Marcin Maka 247af133b8 comp: init back ptr to driver early in new
Back pointer must be initialized before any instance
level logging is performed by the new() operation since
the instance identification requires access to the uuid
that will be implemented on the component driver level.

Signed-off-by: Marcin Maka <marcin.maka@linux.intel.com>
2020-02-19 20:51:58 +00:00
Marcin Maka 210f907ba2 comp: improve access to component properties
Static inline getters provides better control of use
component properties as L- and R-values.

They also make changes to the common component data defs
easier and transparent for clients (no code changes, just
recompilation required).

Signed-off-by: Marcin Maka <marcin.maka@linux.intel.com>
2020-02-19 14:22:11 +00:00
Marcin Rajwa 53d35e4912 ut: add missing source file to build of KPB
This patch adds missing spinlock.c file to the build of
KPB component.

Signed-off-by: Marcin Rajwa <marcin.rajwa@linux.intel.com>
2020-02-17 20:25:38 +01:00
Bartosz Kokoszko bdc95775af component: add generic comp_verify_params() function
Implements comp_verify_params() function, which can be used in order
to set and update some of sink (playback) or source (capture) buffer
parameters with pcm parameters. There is a possibility to specify
which of parameters won't be overwritten (e.g. SRC component should
not overwrite rate parameter, because it is able to change it).
Commit also adds macros to buffer.h, which can be used in order
to specify which parameter of source/sink buffer should not be
updated.

Signed-off-by: Bartosz Kokoszko <bartoszx.kokoszko@linux.intel.com>
2020-02-17 16:21:57 +00:00
Karol Trzcinski f493e907a1 test: buffer: Replace memcpy to memcpy_s
Introduced change resolve checkpach issue related with edited lines
of code.

Signed-off-by: Karol Trzcinski <karolx.trzcinski@linux.intel.com>
2020-01-23 22:04:42 +02:00
Marcin Rajwa 895b46771c kpb: refactor some of KPBs macros
This patch refactor KPBs macros:

KPB_SAMPLING_WIDTH to KPB_SAMPLES_PER_MS as this is
exactly what this macro stands for - the amount of
samples we take each milisecond.

KPB_NR_OF_CHANNELS to KPB_NUM_OF_CHANNELS as the later
is more meaningful

Signed-off-by: Marcin Rajwa <marcin.rajwa@linux.intel.com>
2020-01-23 10:32:43 +00:00
Karol Trzcinski 9508d2efbd buffer: Create audio stream buffer
When new component will need to process audio data in two steps,
then temporary circular buffer will be needed. Also extra information
about data stream may be needed to choose right algorithm or assert data
compatibility.

Currently only 'comp_buffer' has such a possibility but it is component
defined in topology - with much wider capabilities - and shouldn't be
created inside component just to hold temporary data stream.

Use introduced structure in processing functions, move api responsible
for data processing from buffer to audio_stream module.

Signed-off-by: Karol Trzcinski <karolx.trzcinski@linux.intel.com>
2020-01-22 14:56:22 +00:00
Karol Trzcinski 9a091a1320 test: Use common_mocks in each unit test
Link common_mock to each test by default.
Removed duplicated mocks in component specific folders.
Keep old mocks where implementation differs from
implementation in common_moks.c

Signed-off-by: Karol Trzcinski <karolx.trzcinski@linux.intel.com>
2020-01-22 14:45:29 +00:00
Karol Trzcinski 816f8919db test: Implement common mocks
In unit tests there are a lot of mocks duplication for mocks related
with memory management and panic routine.
As long as implementation doesn't have any module specific routines
and may be reused, it should be mocked in common mock space.

Marked each mock as WEAK to make it possible to overwrite this
implementation in specific test.

To use assert_false in __panic function, added dependence of
universal_mock from cmock.

Signed-off-by: Karol Trzcinski <karolx.trzcinski@linux.intel.com>
2020-01-22 14:45:29 +00:00
Karol Trzcinski b7c92f18e6 test: Rename universal_mocks.c to common_mocks.c
Old name was quite misleading, new one better describes file content

Signed-off-by: Karol Trzcinski <karolx.trzcinski@linux.intel.com>
2020-01-22 14:45:29 +00:00
Tomasz Lauda a3e01c805a test: don't use shared section and uncache for unit tests
SHARED_DATA macros doesn't put shared data into separate section
when unit tests are built and uncached memory region is not used.

Signed-off-by: Tomasz Lauda <tomasz.lauda@linux.intel.com>
2020-01-20 14:37:01 +00:00
Tomasz Lauda 7867944946 component: use comp_driver_info during registration
Changes component driver registration to use comp_driver_info
as an element to be put into the drivers list. This way
comp_driver can be constant and comp_driver_info can be
marked as shared in the future.

Signed-off-by: Tomasz Lauda <tomasz.lauda@linux.intel.com>
2020-01-20 14:37:01 +00:00
Tomasz Lauda 5eea994a3a component: add comp drivers list to sof context
Adds component drivers list to sof context, so it can be
accessed globally. Also adds global getter.

Signed-off-by: Tomasz Lauda <tomasz.lauda@linux.intel.com>
2020-01-20 14:37:01 +00:00
Tomasz Lauda 47917c1f3d component: pass sof context to sys_comp_init()
Passes sof context pointer to sys_comp_init() function.
It will be needed in order to add comp_driver_list to
sof context.

Signed-off-by: Tomasz Lauda <tomasz.lauda@linux.intel.com>
2020-01-20 14:37:01 +00:00