Remove a log-module declaration to eliminate unused static
variables until we return to using the LOH_* Zephyr API.
Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
Move logging code and static data to platform/library and
declare a LOG module properly.
Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
In both native and Zephyr builds schedule_edf_ops and
schedule_ll_ops are only used in one file each, make them
static.
Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
Undefining and re-defining MIN/MAX when already defined is
convoluted. Simply define them if not __ZEPHYR__ instead.
Signed-off-by: Marc Herbert <marc.herbert@intel.com>
If processing format is restricted from Kconfig there's a possibility of
pcm_converter not having proper conversion function. Thus check for NULL
in dai to avoid crashes.
Signed-off-by: Jaska Uimonen <jaska.uimonen@intel.com>
Add support for cs42l42 running on GLK boards. We add a 10 ms BCLK
delay to the SSP_CONFIG_DATA of SSP2 since the codec PLL is locking on
BCLK. Without the delay, there could be noise on TX path.
Signed-off-by: Brent Lu <brent.lu@intel.com>
we are building unused functions if we only enable specific formats,
lets put them with the functions that use them
Signed-off-by: Curtis Malainey <cujomalainey@chromium.org>
For compatibility with Zephyr, MIN and MAX macros are downgraded to the
basic, compile-time, standard compliant and unsafe implementation.
This means the code will now be the same whether it's compiled with Zephyr
versus not.
Fixes https://github.com/zephyrproject-rtos/zephyr/issues/33567 which
means it's now possible to use MIN() or MAX() in either Zephyr's
BUILD_ASSERT() or in SOF's equivalent STATIC_ASSERT() or in C11's
_Static_assert()
This implementation is unsafe because it can evaluate its arguments
twice which is obviously not desired when the argument has side-effects:
https://wiki.sei.cmu.edu/confluence/display/c/PRE31-C.+Avoid+side+effects+in+arguments+to+unsafe+macros
Signed-off-by: Marc Herbert <marc.herbert@intel.com>
For consistency with Zephyr, MIN and MAX macros are "downgraded" to the
basic, compile-time, standard compliant and unsafe implementation that
Zephyr uses. "Unsafe" because it can evaluate its arguments twice which
is obviously not desired when the argument has side-effects:
https://wiki.sei.cmu.edu/confluence/display/c/PRE31-C.+Avoid+side+effects+in+arguments+to+unsafe+macros
I reviewed every single invocation of MIN() and MAX() and found no
increment or assignment but I found a number of function calls in their
arguments. This commit removes them all. Note I did _not_ check for
volatile variables.
Most of these functions do not appear to have side-effects _but_ it's
much simpler and faster for the reader or static analyzer not to even
have to wonder about the possibility of side-effects and it's also more
future-proof; no risk of a function accidentally gaining side effects.
Note the following files are not compiled in the default configurations
and the changes in them were NOT compile-tested locally:
src/audio/codec_adapter/codec_adapter.c
src/audio/drc/drc_generic.c
Signed-off-by: Marc Herbert <marc.herbert@intel.com>
Each type of codec will have its own config option that will point
to the path in build filesystem where library binary is located.
This will make compiling Cadence libraries binaries more flexible.
The libraries will be statically linked with SOF firmware.
Signed-off-by: Daniel Baluta <daniel.baluta@nxp.com>
This patch simplifies codec adapter state machine by removing
redundant state "ca_state" plus extending the other one with
new states like IDLE or PROCESSING.
Signed-off-by: Marcin Rajwa <marcin.rajwa@linux.intel.com>
This patch allows to apply runtime configuration as soon
as codec got created. This is too avoid high load spikes
which may happen when whole, large config blob is being
applied along side codec processing.
Signed-off-by: Marcin Rajwa <marcin.rajwa@linux.intel.com>
Thanks to this change we reset all params to default values
on start, and reset only. The later is because on reset we
call init again due to lack of explicit reset API for cadence
codecs. Now we can apply runtime params earlier, during prepare or
as soon as codec has been instantiated and they won't be reset.
Signed-off-by: Marcin Rajwa <marcin.rajwa@linux.intel.com>
looks like with the new ipc mechanisms we changed the function signature
and moved casting the message from platform code to ipc code.
Signed-off-by: Curtis Malainey <cujomalainey@chromium.org>
This script lives in a sof.git/ clone yet it was systematically cloning
a second sof.git/. Besides the obvious confusion and risk of editing the
wrong files, this meant it was not possible to build code that has not
been merged yet! This was a problem for both CI and developers. Fixed by
using symbolic links to ourselves instead.
Note it is _still_ possible to build from another sof.git clone if
desired, however this script will never git re-clone a second sof.git
itself, that second clone has to be created (e.g.: by west) before this
script runs.
When cloning a brand new zephyrproject, use a shallow zephyr clone and
download only the two zephyr modules we actually use. This speeds up
automation considerably and makes it much faster for non-Zephyr
developers to reproduce Zephyr issues. Developers can always git
unshallow and west update once if they want to.
Rename the default west top to "zephyrproject" to not just match the
zephyr documentation but to also avoid creating a double zephyr/zephyr/
directory.
See the new print_usage() for a few more implementation details.
Signed-off-by: Marc Herbert <marc.herbert@intel.com>
It still looks smart but the \n addition compared to the original
version in xtensa-build-all.sh broke it for more advanced cases:
die '%s %d' str 5
-bash ERROR: -bash: printf: 5\n: invalid number
As reported by shellcheck. shellcheck saves lives.
In scripts/xtensa-build-zephyr.sh line 22:
>&2 printf "$@\n"
^-- SC2145: Argument mixes string and array.
Use * or separate argument.
Signed-off-by: Marc Herbert <marc.herbert@intel.com>
... because the latter does not print on stderr when not found; so IDEs
and CIs don't display this as a warning.
Also remove the "... and ignore set -e" comment that made sense at the
time of commit cad86dc340 ("scripts: xtensa-build: fix alias detection
for bxt/apl gcc") but not anymore.
Signed-off-by: Marc Herbert <marc.herbert@intel.com>
Every log file should have a date.
ktime can be related to the TIMESTAMP column. It is especially useful to
spot logs delayed or stuck.
Some logs use ktime while others use a date and it can be sometimes
difficult to connect them with one another. This header can help.
Before:
TIMESTAMP (us) DELTA C# COMPONENT CONTENT
[ 5120116529] ( 0) c0 dma-trace ERROR FW ABI 0x3012001 ...
After:
TIMESTAMP (us) DELTA C# COMPONENT \
CONTENT ktime=5132.663s @ 2021-04-27 14:36:09 -0700 PDT
[ 5120116529] ( 0) c0 dma-trace ERROR FW ABI 0x3012001 ...
Signed-off-by: Marc Herbert <marc.herbert@intel.com>
After commit 5ca0e9bba3 ("topology: Use generic name for 8qxp/8qm")
installer test is broken as we also need to update the i.MX topology
with the new naming.
So, fix this by replacing imx8qxp naming with imx8. But while we are at
it choose a better (more relevant) random topology, sof-imx8-wm8960.tplg
instead of sof-imx8-nodec.tplg.
Signed-off-by: Daniel Baluta <daniel.baluta@nxp.com>
i.MX8QXP / i.MX8QM have the same configuration w.r.t topology.
But since we firstly added support for 8qxp all the names use
8qxp and then for 8qm we just borrow the files but using the 8qxp
naming.
This sometimes might cause confusion. So, we group under the
umbrella of imx8 naming both i.mx8qxp and i.mx8qm.
Signed-off-by: Daniel Baluta <daniel.baluta@nxp.com>
The asrc_dai_configure_timestamp() caused a DSP panic when called from
asrc_prepare(). The reason is that DAI prepare now happens after ASRC
prepare. Call from trigger start is after pipeline prepare so it
avoids this problem.
Fixes: #4068
Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
This patch adds error handling for case where DAI data pointer
to DMA channel is not set. The situation can happen if ASRC tries
to set up timestamping before DAI has been prepared.
More specifically access to dd->chan->index with NULL in chan
caused a DSP panic.
Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
Learned the hard way. Will help refactoring or duplicated
"reverse-engineering" effort.
Zero code change, pure comments: no functional change.
Signed-off-by: Marc Herbert <marc.herbert@intel.com>
math.h is an external header, provided by libc, whereas SOF
is a stand-alone executable, that must not depend on any system
headers. Particularly math.h isn't available when building with
Zephyr. The only inclusion of math.h in SOF currently is only
needed for the M_PI definition. Define it locally with a
slightly different name to eliminate the dependency and fix
Zephyr builds.
Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
Increase default width from 10 to 12 to stop common misalignment,
especially in relative mode.
New timestamp_width() function to avoid duplication and
divergence.
Signed-off-by: Marc Herbert <marc.herbert@intel.com>
The use of Zephyr LOG_*() API in SOF is breaking compilation.
Replace it with with the native trace logging until a proper
fix is available.
Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
Add a generic header type and update the mailbox and command handler
logic to accept generic headers. Generic header type should also support
the existing compact message API and expand it to other platforms.
Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
We need to make sure that the local buffer has enough room to hold
the output of the processing.
This means that for each type of decoding algorithm we need to know
the maximum possible output size and skip processing if local buffer
size is less than that.
Signed-off-by: Daniel Baluta <daniel.baluta@nxp.com>
This codec_adapter interface will return the number
of samples expected after decoding one compressed input frame.
This is optional. For codecs which do not care, this will return 0.
Do not care means that the number of input samples is equal with the
number of output samples after processing is done.
This will be used in the next patch to determine if the local output
buffer has enough space to copy the decoded samples.
Signed-off-by: Daniel Baluta <daniel.baluta@nxp.com>
The atomic code is implemented in zephyr. When sof is used as
a zephyr module, there is no need to reimplement atomic.
The modification here is to solve the problem of repeated
definition of atomic related content.
Signed-off-by: Yang XiaoHua <yangxiaohuamail@gmail.com>
In some situations the domain clear routine might encounter
a case, when the number of clients is decremented and 0,
as such, a subsequent subdivision will result in an integer underflow.
Signed-off-by: Slawomir Blauciak <slawomir.blauciak@linux.intel.com>
With SDMA2 in place now it is shared by both A and HiFi core
- this breaks 8MP EVK + WM8960 topology. Remove SDMA2 so that
SDMA2 remains assigned to A core and SDMA3 assigned to HiFi core
as it was initially planned.
Suggested-by: Paul Olaru <paul.olaru@nxp.com>
Signed-off-by: Viorel Suman <viorel.suman@nxp.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>
Don't try to pack the ring buffer to the very last byte so we don't
split (and lose!) trace events across the end and start of the
buffer. The logger on the receive side does not support such
re-assembly.
Note this was never noticed because the logger tends to silently (!)
discard garbage like this, addressed in other commit(s).
Also switch to memset() and memcpy_s()
Fixes commit 271c75aa71 ("debugability: Fix potential buffer overflow
in mbox traces")
Signed-off-by: Marc Herbert <marc.herbert@intel.com>
This makes the display of the mailbox ring buffer log much less
confusing. It should not happen with the DMA trace but will behave the
same in case something goes wrong.
Before this commit the only clue that wrapping had happened was a NaN in
the delta column (instead of the negative value).
The "other?" is because the start of the mailbox is sometimes corrupted,
or the timestamp goes sometimes back at boot for no obvious reason. In
other words this new separator is useful to highlight bugs too.
Absolute mode -e 0 with this commit:
TIMESTAMP DELTA C# COMPONENT LOCATION
[22598174808] ( 11) c0 ipc src/ipc/....
[22598174824] ( 15) c0 ipc src/ipc/....
[22598443257] ( 268433) c0 dma-trace src/trace/....
[22598443271] ( 14) c0 dma-trace src/trace/....
[22598443286] ( 14) c0 dma-trace src/trace/....
[22598943257] ( 499971) c0 dma-trace src/trace/....
--- negative DELTA: wrap, IPC_TRACE, other? ---
[22430943257] ( 0) c0 dma-trace src/trace/....
[22530943257] ( 100000000) c0 dma-trace src/trace/....
[22542943257] ( 12000000) c0 dma-trace src/trace/....
[22542943271] ( 14) c0 dma-trace src/trace/....
[22542943285] ( 14) c0 dma-trace src/trace/....
Relative mode -e 1 with this commit:
TIMESTAMP DELTA C# COMPONENT LOCATION
[ 3080783.6] ( 11.4) c0 ipc src/ipc/....
[ 3080799.1] ( 15.5) c0 ipc src/ipc/....
[ 3349232.5] ( 268433.4) c0 dma-trace src/trace/....
[ 3349246.8] ( 14.3) c0 dma-trace src/trace/....
[ 3349261.2] ( 14.4) c0 dma-trace src/trace/....
[ 3849232.4] ( 499971.2) c0 dma-trace src/trace/....
--- negative DELTA: wrap, IPC_TRACE, other? ---
[22430943257.0] ( 0.0) c0 dma-trace src/trace/....
[100000000.0] (100000000.0) c0 dma-trace src/trace/....
[111999999.5] ( 12000000.0) c0 dma-trace src/trace/....
[112000013.9] ( 14.4) c0 dma-trace src/trace/....
[112000028.2] ( 14.3) c0 dma-trace src/trace/....
Signed-off-by: Marc Herbert <marc.herbert@intel.com>
XT_ROUND_S is available only when you include option of
"Xtensa's single precision FPU option (scalar)".
IF current DSP includes optional vector FPU (single precision).
FIROUND.S (with appropriate RoundMode state set) followed by
TRUNC.S can be used to emulate Xtensa scalar FPU’s ROUND.S, CEIL.S and
FLOOR.S instructions."FIROUND.S", does round, but no scaling.Result
still in float format.Use TRUNC.S to scale it and truncate as necessary.
Signed-off-by: Yang XiaoHua <yangxiaohuamail@gmail.com>
This reverts commit cd2444adbf.
Reverting this to unblock the CI runningon tgl-nocodec-ci platform.
Signed-off-by: Keyon Jie <yang.jie@linux.intel.com>