Commit Graph

5834 Commits

Author SHA1 Message Date
Pin-chih Lin 984e02ef09 sof: drc: Implement s24 and s32 sample format cases
Implemented s24 and s32 sample format cases of both pass and default
functions.

Because both s24 and s32 cases use 32-bit samples for source/sink stream
while s16 case uses 16-bit, for pre_delay_buffers, it followed as well
(32-bit for s24/s32, 16-bit for s16). One special note is that we <<8 when
storing samples from source to pre_delay_buffers, and >>8 when loading from
pre_delay_buffers. It makes 32-bit samples in pre_delay_buffers are always
Q1.31 in both s24 and s32 cases.

In common functions (e.g. drc_compress_output), sample byte information is
required to pass if the function has the operation of pre_delay_buffers, to
distinguish 16-bit and 32-bit sample cases.

Signed-off-by: Pin-chih Lin <johnylin@google.com>
2020-11-10 18:38:57 -08:00
Pin-chih Lin 8a70f62846 sof: drc: component implemented by fixed-point calculations
In drc_generic.c and drc_math_generic.c, all floating-point math functions
are removed, and all float vaiables are replaced by fixed-point (int32_t)
variables with the appropriate precisions. It is verified that the
fixed-point replacement only lead to quite insignificant MSE errors among
all test patterns.

 - Multiplications are replaced by Q_MULTSR_32X32 with the appropriate
   precisions.

 - Divisions (x/y) are replaced by Q_MULTSR_32X32(x, inv(y)), where inv(y)
   is approximated 1/y by polynomial functions generated by fpminimax of
   Sollya with rexp optimization.

Signed-off-by: Pin-chih Lin <johnylin@google.com>
2020-11-10 18:38:57 -08:00
Pin-chih Lin 91998d7d01 sof: drc: Use one_over_attack_frames in replace of attack_frames
Replaced the config coefficient "attack_frames" by "one_over_attack_frames"
(=1/attack_frames). It is because only "one_over_attack_frames" is used by
firmware and it could save a division operand by the replacement.

Signed-off-by: Pin-chih Lin <johnylin@google.com>
2020-11-10 18:38:57 -08:00
Pin-chih Lin 03b1fba732 sof: drc: More fixed-point approximative functions
Implemented the following fixed-point functions for the approximation of
math calculations in drc_math_generic.c. fpminimax of Sollya is used for
generating a good polynomial approximation of wanted functions.

logf(x)
 - Input is Q6.26: max 32.0
 - Output range ~ (-inf, 3.4657); regulated to Q6.26: (-32.0, 32.0)

linear_to_decibels(x)
 - Input is Q6.26: max 32.0
 - Output range ~ (-inf, 30.1030); regulated to Q11.21: (-1024.0, 1024.0)

asinf(x)
 - Use two-step polynomial approximation among [0, 1] whose pivot point is
   1/sqrt(2)
 - Input is Q2.30: (-2.0, 2.0)
 - Output range: [-1.0, 1.0]; regulated to Q2.30: (-2.0, 2.0)

powf(x, y)
 - Input x is Q6.26: (-32.0, 32.0); y is Q2.30: (-2.0, 2.0)
 - Output is Q12.20: max 2048.0

Signed-off-by: Pin-chih Lin <johnylin@google.com>
2020-11-10 18:38:57 -08:00
Curtis Malainey 9b5ba31938 dma-trace: free buffer on error
We are leaking memory if the host sends bad messages to the firmware
since we are not freeing the buffer.

Signed-off-by: Curtis Malainey <cujomalainey@chromium.org>
2020-11-09 22:20:45 +00:00
Bartosz Kokoszko 85986e1f4f demux: add demux_prepare_active_look_up() function
This commit adds demux_prepare_active_look_up()
function. It contains channel parameter checking.
Look up table should not include elements referring
to channels higher than those actually set in
source/sink buffers.

Signed-off-by: Bartosz Kokoszko <bartoszx.kokoszko@linux.intel.com>
2020-11-09 22:19:08 +00:00
Bartosz Kokoszko acc022b4c4 mux: add channels check in mux_prepare_active_look_up()
This commit adds channel parameter checking in
mux_prepare_active_look_up() function. Look up
table should not include elements referring to
channels higher than those actually set in
source/sink buffers.

Signed-off-by: Bartosz Kokoszko <bartoszx.kokoszko@linux.intel.com>
2020-11-09 22:19:08 +00:00
Bartosz Kokoszko 473d8894f0 mux: change prepare_active_look_up() function name
This commit changes prepare_active_look_up() function
name to be mux specific.

Signed-off-by: Bartosz Kokoszko <bartoszx.kokoszko@linux.intel.com>
2020-11-09 22:19:08 +00:00
Marcin Rajwa a6a11d8e65 topology: add C_CONTROL to codec processing topology
This patch extends codec processing topology with C_CONTROLS
which comprises of SETUP configuration for both SoF component
and CADENCE codec.

Signed-off-by: Marcin Rajwa <marcin.rajwa@linux.intel.com>
2020-11-09 22:14:38 +00:00
Marcin Rajwa aacbe98768 topology: add simple topology with codec processing
This patch adds a processing topology which uses external
codec for processing. This topology comprises of:

HOST -> CODEC_ADAPTER -> DAI

So the only processing component is codec_adapter which can be
configured to work with any codec.

Signed-off-by: Marcin Rajwa <marcin.rajwa@linux.intel.com>
2020-11-09 22:14:38 +00:00
Marcin Rajwa 09dadff771 topology: add codec_adapter component
This patch adds codec_adapter component in the topology
of SoF.

Signed-off-by: Marcin Rajwa <marcin.rajwa@linux.intel.com>
2020-11-09 22:14:38 +00:00
Marcin Rajwa af78d51912 codec_adapter: call middle layer interfaces
This patch calls middle layer interfaces to perform
codec specific operations.

Signed-off-by: Marcin Rajwa <marcin.rajwa@linux.intel.com>
2020-11-09 22:14:38 +00:00
Marcin Rajwa f5f097a715 codec_adapter: export cadence specific functions
This exports cadence interfaces for the middle layer.

Signed-off-by: Marcin Rajwa <marcin.rajwa@linux.intel.com>
2020-11-09 22:14:38 +00:00
Marcin Rajwa bb9254fd27 codec_adapter: add cadence codecs support
This implements ops for cadence codecs.

Signed-off-by: Marcin Rajwa <marcin.rajwa@linux.intel.com>
2020-11-09 22:14:38 +00:00
Marcin Rajwa 9da98fdc7f codec_adapter: cadence: add header files
This adds header files for codecs working with CADENCE
API.

Signed-off-by: Marcin Rajwa <marcin.rajwa@linux.intel.com>
2020-11-09 22:14:38 +00:00
Marcin Rajwa 02e7da03ac codec_adapter: add mapping function for codecs
This implements a middle layer between the SoF component
codec_adapter and specific codec. For example, the SoF component
may receive a prepare request from the driver, so it prepares itself
(assigns sink/source buffers, check states, etc) and then calls this
middle layer which proceed with codec specific preparation. The exact
same scenario happens for any other interface as well.

Signed-off-by: Marcin Rajwa <marcin.rajwa@linux.intel.com>
2020-11-09 22:14:38 +00:00
Marcin Rajwa 969d008f78 component: add "codec adapter" component
This introduces new SoF component called "codec adapter".
It provides means to process samples through external codec
libraries. This part implements only the SoF component.

Signed-off-by: Marcin Rajwa <marcin.rajwa@linux.intel.com>
2020-11-09 22:14:38 +00:00
Keyon Jie b20d86f2ce host-testbench.sh: update comment for testbench building
The host-build-all.sh is deprecated, update to the recommended
'rebuild-testbench.sh'.

Signed-off-by: Keyon Jie <yang.jie@linux.intel.com>
2020-11-09 22:08:30 +00:00
Bartosz Kokoszko c66d5b59ea apl: power_down: move IPC_HOST_BASE literal into register
Before switching off memory, IPC_HOST_BASE literal value should
be moved to register, in order to avoid accessing to disabled
memory.

Signed-off-by: Bartosz Kokoszko <bartoszx.kokoszko@linux.intel.com>
2020-11-09 22:00:00 +00:00
Bartosz Kokoszko 3e8a42bfc0 cavs: power_down: move IPC_HOST_BASE literal into register
Before switching off memory, IPC_HOST_BASE literal value should
be moved to register, in order to avoid accessing to disabled
memory.

Signed-off-by: Bartosz Kokoszko <bartoszx.kokoszko@linux.intel.com>
2020-11-09 22:00:00 +00:00
Karol Trzcinski 1aefc30f37 trace: hda-dma: Lower trace level
Modified traces are quite verbose so should be done
with tr_dbg() function to reduce messaging noise in
non-verbose scenario.

Signed-off-by: Karol Trzcinski <karolx.trzcinski@linux.intel.com>
2020-11-09 21:54:39 +00:00
Marc Herbert 3de29dac2a testbench: make lib_table actually global and stop passing it around
This fixes compilation with:

  CFLAGS=-fno-common ./scripts/rebuild-testbench.sh

  sof/tools/testbench/topology.c:24: multiple definition of `lib_table';
  sof/tools/testbench/testbench.c:39: first defined here

This was detected by Gentoo 10 which uses -fno-common by default, thanks
Guennadi for the report and investigation.

Commit 03067c6c77 ("host: set up shared library table") introduced a
strange "lib_table" symbol that was apparently meant to be global but
was not really because of some confusion between arrays and pointers and
needed to be passed around and "initialized to itself" (!) at run time
as seen in the sample trace below:

topology.c

struct shared_lib_table *lib_table;

parse_topology(..., library_table,...)
{

        printf("DEBUG1 ----- %p, %p, %p\n",
                  &lib_table,     lib_table,      library_table);

        lib_table = library_table;

        printf("DEBUG2 ----- %p, %p, %p\n",
                 &lib_table,      lib_table,      library_table);

}

Log:

    DEBUG1 ----- 0x56298c954040, 0x56298c951183, 0x56298c954040

    DEBUG2 ----- 0x56298c954040, 0x56298c954040, 0x56298c954040

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2020-11-05 23:09:35 +00:00
Pin-chih Lin 51c034c408 tools: tune: Generate ctrl bytes from params for DRC
Used the similar parameter set as the DRC kernel in CRAS to generate ctrl
bytes for DRC component.

Plotted input-output dB response curve with the specific parameter set.

Signed-off-by: Pin-chih Lin <johnylin@google.com>
2020-11-05 11:35:40 -08:00
Karol Trzcinski 9b5f48b3a3 pipeline: Fix spelling error
Changed `coomponents` to `components`

Signed-off-by: Karol Trzcinski <karolx.trzcinski@linux.intel.com>
2020-11-05 09:32:30 +02:00
Marc Herbert 2aa62e1e65 rebuild-testbench.sh: don't build twice with combined "make install"
"make + make install" duplicates many steps, probably because of the
fatal combination of build timestamps + source hash, see PR #3353 for a
similar example.

A single, combined "make install" generates the exact same binary
outputs 30% faster and prints 30% shorter build logs.

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2020-11-03 16:48:02 +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 b72c7ec2df rimage: Update to commit 0d2af68a9e
Included changes:

0d2af68a9e gitignore: Add checkpatch temporary file to gitignore
8249abfa11 toml: Keep available manifest parsers in list
c98a29da14 toml: Extract version parsing to separate function
b9cf1aeb3b pkcs1_5.c: don't pretend everything is fine when failing to sign
e87db0f080 pkcs1_5.c: intermediate named constants in ri_manifest_sign_v1_x()
86754c1389 hash: Assert memory overflow during hash calculation
37323face2 Merge pull request #28 from marc-hb/copy-sram-overflow
7322c02349 manifest.c: assert buffer overflow in man_copy_sram()

Signed-off-by: Karol Trzcinski <karolx.trzcinski@linux.intel.com>
2020-10-30 14:15:32 +00:00
Daniel Baluta 12fdd638de drivers: imx: sdma: Fix SDMA watermark
After experiments I found that current SDMA watermark
causes SDMA to miss SAI DMA requests.

The empirical value was chosen so that watermark is a
divisor of min(bd_count, fifo watermark).

Of course this needs to be revisited, but for now "it just works" (tm).

Signed-off-by: Daniel Baluta <daniel.baluta@nxp.com>
2020-10-30 13:49:37 +00:00
Daniel Baluta 1baececbad drivers: imx: sdma: Cleanup event handling
For handling events we only needs an enable/disable functionalities.
Setting up an event (that means reading the event number and saving
it in dma_pdata is already done at config time).

So, this patch just introduces:
	* smda_enable_event
	* sdma_disable_event

and removes existing sdma_clear_event and sdma_set_event.

Signed-off-by: Daniel Baluta <daniel.baluta@nxp.com>
2020-10-30 13:49:37 +00:00
Daniel Baluta 04d14eeaca drivers: imx: sdma: Cleanup sdma_set_event
Do not touch overrides values in sdma_set_event as they are properly
set at config time.

Signed-off-by: Daniel Baluta <daniel.baluta@nxp.com>
2020-10-30 13:49:37 +00:00
Daniel Baluta 39ff32336c drivers: imx: sdma: Do not override events
A channel will be scheduled when both an event has occurred
and the users have enabled the channel.

This allows us to strictly control channel scheduling.

Signed-off-by: Daniel Baluta <daniel.baluta@nxp.com>
2020-10-30 13:49:37 +00:00
Daniel Baluta 1d19cf43ea drivers: imx: sdma: Set dma channel index
Without this index will always be 0 and we cannot differentiate
between channels for various function calls.

Signed-off-by: Daniel Baluta <daniel.baluta@nxp.com>
2020-10-30 13:49:37 +00:00
Daniel Baluta bae469d8cb drivers: imx: sdma: Enable channel after a BD was processed
Host platform sets HSTART_HE bit to activate the corresponding channel
and the DSP will clear the HE bit when done.

In order, for the channel to be rescheduled we need to start again the
HSTART_HE after we got an interrupt that a BD was processed.

This is done in sdma_copy using sdma_enable_channel.

Signed-off-by: Daniel Baluta <daniel.baluta@nxp.com>
2020-10-30 13:49:37 +00:00
Daniel Baluta 2346622d1a drivers: imx: sdma: Initialize next_bd with zero at config time
During several runs next_bd might not be zero, this means that
when an interrupt arrives we will mark the wrong BD as being ready
to be processed by the DSP.

This causes the DSP to block waiting forever for an available BD.

Signed-off-by: Daniel Baluta <daniel.baluta@nxp.com>
2020-10-30 13:49:37 +00:00
Daniel Baluta 5f022993f6 drivers: imx: sdma: Stop a channel in sdma_stop
We no longer care about setting overrides values at stop
because they are correctly set at config time.

What we need to do instead, is to clear HE bit (SDMA_STOP_STAT).

This patch also introduces sdma_disable_channel function to simmetry
with sdma_enable_channel.

Signed-off-by: Daniel Baluta <daniel.baluta@nxp.com>
2020-10-30 13:49:37 +00:00
Daniel Baluta 30c9eed3cb drivers: imx: sdma: Always manually start a channel
A channel is scheduled when the following condition is true:

(HE[i] or HO[i]) and (EP[i] or EO[i])

In order to strictly control a channel's behavior we allow it to run
only after the users has started the channel in sdma_start and an
event arrives.

For this reason we need to set host override and event override to 0.
This is already done at config time.

Signed-off-by: Daniel Baluta <daniel.baluta@nxp.com>
2020-10-30 13:49:37 +00:00
Daniel Baluta 300e4531aa drivers: imx: sdma: Do not set channel priority at start
Channel priority is set during config time.

Also, notice that only channels will index != 0 will call
sdma_start so it is correct to not check for index != 0 in
sdma_start. This makes code easier to read.

Signed-off-by: Daniel Baluta <daniel.baluta@nxp.com>
2020-10-30 13:49:37 +00:00
Karol Trzcinski 3c9657789d trace: ipc: pipeline: Add logs about ipc_pipeline_complete() errors
A few error paths through ipc_pipeline_complete() didn't send
any error log. Each silent error path is some kind of firmware
malfunction.

Signed-off-by: Karol Trzcinski <karolx.trzcinski@linux.intel.com>
2020-10-30 13:48:31 +00:00
Curtis Malainey 5d871373cb host: don't alloc notifier
Both the fuzzer and the testbench call init_system_notifier which
initializes the struct so there is no need for this check (which causes
a double alloc) in the get function.

Signed-off-by: Curtis Malainey <cujomalainey@chromium.org>
2020-10-30 13:46:52 +00:00
Seppo Ingalsuo 0963d88ba3 Tools: Tune: TDFB: Simplify typical usage of bf_design(), bf_export()
The bf_defaults() now sets the default directory locations for
for bf_export() so it does not need to be set in every script.

Also the defaults for input channels and output mixing are set to
that in typical design they do not need to be set.

The default distance for look direction is set to 5.0m so it is better
guaranteed in far field for even relatively large arrays. The far field
assumes planar sound waves. The design equations do not fully support
near field with spherical waves.

The FFT length is changed to 1024 to enable design of longer filter bank
filters. There's no compromise in performance for for e.g. length 64.

The incorrect use of mic_n (number of microphones) is replaced by
num_filters. It's possible define beamformer that ignores some mic
channels so these are not the same.

The automatic systematic design file names are now created for all array
types, not just line.

The script is made more flexible to run without need to export data and
clutter just to quickly interactively check from plots what kind of
beam pattern and other characteristic some array, e.g. circular with
some radius and mic count gives.

Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
2020-10-30 13:45:29 +00:00
Seppo Ingalsuo db47e28154 Tools: Test: Audio: Cleanup for TDFB component test script
The common array identifier string is brought up for easier edit to
test other array geometries than this default. A typo about 16 kHz
is fixed, the test runs at 48 kHz testbench default rate.

Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
2020-10-30 13:45:29 +00:00
Seppo Ingalsuo d88e36987b Tools: Tune: TDFB: Fix typo in copyright text year
This patch fixes the small mistake.

Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
2020-10-30 13:45:29 +00:00
Seppo Ingalsuo bede56972c Tools: Tune: TDFB: Updates for array geometry helpers and add 3D array
This patch adds the missing XYZ 3D array helper and does minor fixes
for two others. The L-shape microphones orientation is made similar as
in rectangular array by inverting the y-axis. The missing centering
of rectangular array is added.

Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
2020-10-30 13:45:29 +00:00
Curtis Malainey aea7da470c oss-fuzz: add code owner
Add myself as the code owner for the fuzzer

Signed-off-by: Curtis Malainey <cujomalainey@chromium.org>
2020-10-29 15:56:42 +00:00
Curtis Malainey 1d028ab9c1 fuzz_ipc: use calloc instead of malloc for ipc region
The memory sanitzer catches uninitialized value errors on the size check
for small data sizes. Therefore lets us calloc so we can assume the
whole region exists without having the sanitizer get upset.

Signed-off-by: Curtis Malainey <cujomalainey@chromium.org>
2020-10-29 15:55:41 +00:00
Slawomir Blauciak cb6420853d compile: check for __XCC__ flag when defining FW build info
Previously, the __GNUC__ flag was used to differentiate between GCC and XCC.
However, that flag is defined by XCC as well,
as a result, __XCC__ flag should be checked instead.

Signed-off-by: Slawomir Blauciak <slawomir.blauciak@linux.intel.com>
2020-10-29 13:58:21 +00:00
Curtis Malainey 28e5047f03 cmake: fix indentation
Replace spaces with tabs

Signed-off-by: Curtis Malainey <cujomalainey@chromium.org>
2020-10-29 12:11:12 +00:00
Curtis Malainey db09bb8058 dcblock: fix reset handler
Reset state when reset trigger happens and use memset to do it

Signed-off-by: Curtis Malainey <cujomalainey@chromium.org>
2020-10-23 10:44:10 +01:00
Guennadi Liakhovetski b672923809 zephyr: adjust for new location of audio component samples
Audio component samples have been moved to a new location, fix Zephyr
builds to account for it.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
2020-10-23 10:16:55 +01:00