Commit Graph

8029 Commits

Author SHA1 Message Date
Chao Song 5eb94a8a80 audio: comp_ext: workaround XCC compatibility with zephyr logging
Multiple use of static inline functions that call Zephyr logging
API across different C files will result in same symbol names
defined in all of the corresponding object files with XCC,
because XCC compiler emits the same symbol names based on the
source file for those static variables inside functions.

If Zephyr logging is used in SOF, we will have log context
redefinition issue with XCC due to above reason.

This patch workarounds the issue by removing the log calls
in static inline functions that are used across multiple C
files if Zephyr is used.

BugLink: https://github.com/zephyrproject-rtos/zephyr/issues/43786

Signed-off-by: Chao Song <chao.song@linux.intel.com>
2022-04-08 13:43:17 +01:00
Krzysztof Frydryk 27e9635227 ipc4: fix pipeline reset trigger from paused state
When pipeline reset was called from paused state, it was not stopped
beforehand. This resulted in improper device turn-off sequence.

Signed-off-by: Krzysztof Frydryk <krzysztofx.frydryk@intel.com>
2022-04-08 13:36:34 +01:00
Vamshi Krishna 39f2626c47 topology1: sof-adl-rt1019-rt5682: add new topology
for amplifier rt1019 SSP1 link is used
for headset rt5682 SSP0 link is used

Signed-off-by: Vamshi Krishna <vamshi.krishna.gopal@intel.com>
2022-04-08 13:20:13 +01:00
Marc Herbert c9ee109296 xtensa-build-zephyr.py: add cavstool.py to staging directory
This is required to read Zephyr logs.

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2022-04-08 13:15:38 +01:00
Marc Herbert f9c461009a xtensa-build-zephyr.py: add for loop to install files into staging
Preparation to copy multiple files. Zero functional change.

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2022-04-08 13:15:38 +01:00
Adrian Bonislawski 5243f0c4ee buffer: dereference before null check fix
This will fix null dereference issue reported by KW

Signed-off-by: Adrian Bonislawski <adrian.bonislawski@intel.com>
2022-04-07 13:49:45 +01:00
Chunxu Li 7b5aa72813 drivers: mtk: refine afe_remove return value
the afe_remove return value is no used, so
change afe_remove return value from int to void

Signed-off-by: Chunxu Li <chunxu.li@mediatek.com>
2022-04-05 12:23:39 -07:00
Chunxu Li 492821a9f7 platform: mtk: add platform dai build support for mt8186
Add platform dai build support
Add platform dai_init

Signed-off-by: Chunxu Li <chunxu.li@mediatek.com>
2022-04-05 12:23:39 -07:00
Chunxu Li eba5396499 platform: mtk: add platform driver support for mt8186
Add support for dai, dma platform driver.

Signed-off-by: Chunxu Li <chunxu.li@mediatek.com>
2022-04-05 12:23:39 -07:00
Chunxu Li 63312ced76 drivers: mtk: add driver compile support for mt8186
compile mt8186 drivers

Signed-off-by: Chunxu Li <chunxu.li@mediatek.com>
2022-04-05 12:23:39 -07:00
Chunxu Li 0a03bef10e drivers: mtk: add afe driver for mt8186
Add AFE driver for memif/sinegen
Add afe-dai.c/afe-drv.c/afe-memif.c for AFE common driver

AFE: Audio Front End

The audio front-end essentially consists of voice and audio data paths.

frontend (memory interface):
 UL (uplink for capture)
 DL (downlink for playback)
backend:
 I2S In/Out etc
interconn:
 inter-connection, connect frontends and backends as DSP path

Note:
TEST_SGEN macro define is just for test

Signed-off-by: Chunxu Li <chunxu.li@mediatek.com>
2022-04-05 12:23:39 -07:00
Chunxu Li b5563511d6 platform: mtk: add afe-platform compile support for mt8186
Add afe-platform compile support for mt8186

Signed-off-by: Chunxu Li <chunxu.li@mediatek.com>
2022-04-05 12:23:39 -07:00
Chunxu Li 529b1d0cc2 platform: mtk: add afe-platform support for mt8186
Add memif data for AFE
Add common and regs header for AFE
Add AFE platform for mt8186 audio/dsp

AFE: the abbreviation for Audio Front End

Signed-off-by: Chunxu Li <chunxu.li@mediatek.com>
2022-04-05 12:23:39 -07:00
Jyri Sarha ad0d4fb3f8 data_blob: Add single buffer mode to save memory with big configurations
The single blob mode keeps only one configuration blob available at
one time and saves the memory otherwise consumed by the second
blob. The down side of this behaviour is that the audio pipeline must
be stopped for the configuration to be updated.

Signed-off-by: Jyri Sarha <jyri.sarha@intel.com>
2022-04-05 17:47:18 +01:00
Jyri Sarha b81c76f854 component: Split data_blob.[ch] out of component.[ch]
The data blob handler functionality is quite independent from the rest
of the generic component code. The component.c and component.h are
already too big so it is better to split the data blob handler
functionality out before adding more features to it.

Signed-off-by: Jyri Sarha <jyri.sarha@intel.com>
2022-04-05 17:47:18 +01:00
Marc Herbert 791efe2094 .github: build again single-threaded and verbose on failure
Building in parallel is much faster but it makes logs unreadable and
build failures impossible to understand. This is especially true when
building with recent ALSA that produces of deprecation warnings.

To show what actually fails, try to build again with a single thread.

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2022-04-05 14:37:28 +01:00
Marc Herbert bde4858625 topologies: docker --env USE_XARGS, NO_PROCESSORS and VERBOSE
Building in parallel is much faster but it makes logs unreadable and
build failures impossible to understand. This is especially true when
building with recent ALSA that produces of deprecation warnings, see
examples below. For test topologies the problem is even worse: its
XARGS parallel build provides no log at all.

To find what actually fails, it is required to fall back on a single
threaded and verbose build and this is achieved with the variables
USE_XARGS, NO_PROCESSORS and VERBOSE. Pass these through docker-run.sh
and CMake.

Examples from #5608
https://github.com/thesofproject/sof/runs/5717553555?check_suite_focus=true
https://sof-ci.01.org/sofpr/PR5608/build12556/build/tools.txt

ALSA pcm.c:1523:(parse_hw_config) deprecated fsync value 'codec_slave',...
ALSA pcm.c:1471:(parse_hw_config) deprecated bclk value 'codec_slave',...
ALSA pcm.c:1523:(parse_hw_config) deprecated fsync value 'codec_slave',...
ALSA pcm.c:1471:(parse_hw_config) deprecated bclk value 'codec_slave',...
ALSA pcm.c:1523:(parse_hw_config) deprecated fsync value 'codec_slave',...

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2022-04-05 14:37:28 +01:00
Ranjani Sridharan 3b0fd1e203 topology2: abi: fix size of ABI bytes
The major/minor/patch values are represented with u16 in the FW. So,
change the numbers of bytes to match that of the FW when adding the
ABI to the topology manifest for IPC4. For IPC3, we still only use 3
bytes as there's no clean way to increase the number of bytes without
breaking backwards compatibility with the older kernel. There are no
topologies using topology2 for IPC3 today but it is possible in the
future.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
2022-04-05 14:37:05 +01:00
Kai Vehmanen 3fdf92c37b mixer: remove unused code from mixer_trigger_common()
Function returns "ret" in any case, so the additional
check on direction is not needed.

Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
2022-04-05 14:34:44 +01:00
Kai Vehmanen 69db9c8715 ipc: run buffer free in context of active pipeline
BUFFER_FREE IPC returns an error if buffer is connected to
two active components.

However it is allowed to free a buffer in the case where either the sink
or the source is no longer active. This happens for example with buffers
that connect two pipelines. If one pipeline is stopped and freed,
the connecting buffer will be also freed.

This does mean pipeline_disconnect() may be run in context
of a pipeline that is running on a different core. This is
fundamentally unsafe and can lead to undefined behaviour
when two cores access the pipeline bsource_list/bsink_list
at the same time on two different cores.

Fix this issue by checking for this case, and running
the BUFFER_FREE on the active core.

The change is not sufficient on its own, but is part of the fixes
to address: https://github.com/thesofproject/sof/issues/5469

Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
2022-04-05 14:34:28 +01:00
Marc Herbert 93f20d577c xtensa-build-zephyr.py: forbid shell=True
The entire purpose of replacing the older shell script with Python was
to achieve cross platform compatibility. shell=True would lose that.

See also
https://docs.python.org/3/library/subprocess.html#security-considerations

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2022-04-04 16:24:43 +01:00
Kai Vehmanen e4e3dd96fc pipeline: do not reschedule pipe task if already in target state
When processing a trigger action in pipeline_task_cmd(), do
not return SOF_TASK_STATE_RESCHEDULE if the pipeline is already
in requested ACTIVE state.

The unnecessary reschedule can cause scheduling bubbles in
topologies with mixer fed by multiple source pipelines. When
the frontend pipelines are released from pause or started,
the connected pipelines that are already running, need to keep
running. A reschedule will cause a gap in scheduling in
of the downstream pipeline(s) mixer feeds.

This fix is not sufficient on its own, but is part of the fixes
to address: https://github.com/thesofproject/sof/issues/5469

Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
2022-04-04 16:19:57 +01:00
Peter Ujfalusi 1a8cea9b69 ipc4: handler: Perform platform context save before primary core shutdown
Run the platform_context_save() before we shut down the primary core.
As an implementation detail: the context save implements the code to
prepare for IMR boot on platforms where it is supported.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
2022-04-02 17:53:43 +01:00
Marc Herbert 0bbdbb111f test/topology: make tplg-build.sh callable from anywhere
This removes two layers of indirection when trying to find what fails.
The lack of this proved especially painful when working on #5632 and
similar backports.

Also move outputs to a subdirectory by default. No change when invoked
from CMake which does not use the default output directory.

Also show the exact m4 and alsatplg commands run when not using XARGS
parallelization. Again this is critical when something fails.

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
2022-04-02 17:51:04 +01:00
Peter Ujfalusi e043503158 ipc4: handler: Fix compilation with gcc in ipc4_set_pipeline_state()
gcc fails with the following warning (treated as error):
sof/src/ipc/ipc4/handler.c: In function 'ipc_cmd':
sof/src/ipc/ipc4/handler.c:471:5: error: 'status' may be used uninitialized in this function [-Werror=maybe-uninitialized]
  471 |  if (status == COMP_STATE_READY)
      |     ^
sof/src/ipc/ipc4/handler.c:439:11: note: 'status' was declared here
  439 |  uint32_t status;
      |           ^~~~~~
cc1: all warnings being treated as errors
make[2]: *** [CMakeFiles/sof.dir/build.make:380: CMakeFiles/sof.dir/src/ipc/ipc4/handler.c.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:2042: CMakeFiles/sof.dir/all] Error 2
make: *** [Makefile:136: all] Error 2

Based on the code, this is a false warning since ppl_count should never be
0 (unless ppl_data->pipelines_count is 0), but never the less, the firmware
does not compile with gcc.

Fixes: 72394a62de ("ipc4: update component direction when pipeline is complete")
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
2022-03-31 11:38:26 +01:00
Ming Jen Tai a5fd52ec43 [RTNR] Fix buffer size calculation
The correct frame length should be calculated by
FRAME_LEN = SAMPLING_RATE * PERIODS / 1000000

The macro COMP_PERIOD_FRAMES does the thing.

Signed-off-by: Curtis Malainey <cujomalainey@chromium.org>
Signed-off-by: Ming Jen Tai <mingjen_tai@realtek.com>
2022-03-30 14:00:16 +01:00
Peter Ujfalusi 3e6fd30aa6 ipc4: base_fw: Simplify firmware version type in basefw_get_dsp_properties
Use the sizeof on the fw_version array to remove the magic number for the
size calculation and drop the address modifier for the data pointer.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
2022-03-30 13:58:47 +01:00
Mark Barton b55a2168f2 audio: codec adapter: remove unused variable from dts codec
Enables dts codec to compile cleanly

Signed-off-by: Mark Barton <mark.barton@xperi.com>
2022-03-30 00:05:28 +03:00
Ben Zhang 992b370c8c google_rtc_audio_processing: Make control write reliable
Userspace may write the config control repeatedly in quick succession.
Accept the new config in cmd callback to avoid -EBUSY error and ensure
the last successful control write before prepare/copy is applied.

This patch also fixes an edge case during init where the first non-empty
control write happens after prepare. This patch ensures the config is
applied during copy.

Tested:
1) Writes in quick succession
for i in $(seq 1 100); do
    ./sof-ctl -n 92 -t 0 -b -r -s /root/test_blob0.txt &
    ./sof-ctl -n 92 -t 0 -b -r -s /root/test_blob1.txt &
done

2) Large config requiring multiple ipcs
for i in $(seq 1 1000); do
    ./sof-ctl -n 92 -t 0 -b -r -s /root/large_blob.txt
    ./sof-ctl -n 92 -t 0 -b -r -s /root/test_blob1.txt
done

3) Reboot, write before and after arecord starts
4) Suspend/resume

Signed-off-by: Ben Zhang <benzh@chromium.org>
2022-03-28 10:51:29 -07:00
Rander Wang f6d83ba510 ipc4: skip component in the incomplete pipeline
Fix a error found by ipc4 Linux driver. Some component
pipeline may be incomplete, so the pipeline is not
updated to the component. Skip this pipeline and
return dai of null.

Signed-off-by: Rander Wang <rander.wang@intel.com>
2022-03-28 16:25:49 +01:00
Rander Wang 421f3b6006 ipc4: mixer: refine path stop logic for ipc4
In ipc4 pipeline can't be reset when the source
and current component is in the same pipeline
and it is active. This is different with ipc3.

Signed-off-by: Rander Wang <rander.wang@intel.com>
2022-03-28 16:25:49 +01:00
Rander Wang c6574f9c0d ipc4: use correct log for pipeline state change
Currently error is reported for both active and paused state when
pipeline is set to reset. For ipc4 case, it is good to switch from
pause to reset. The switch from active to reset is not permitted for
both ipc3 and ipc4. This patch uses different log for active and paused
state.

Signed-off-by: Rander Wang <rander.wang@intel.com>
2022-03-28 16:25:49 +01:00
Rander Wang eb674d1dac ipc4: check direction to choose pcm format conversion function
For alh, link dma and host gateway, the conversion function is
based on direction. For example to convert s24c32 to s32c32 with
alh, it should be function of convert_s24_to_s32 for playback,
but it is a simple copy function for capture since the valid
sample bits are set in msb 24bits like 0xdddddd00 for alh gateway.

The combination of all conditions is very huge but only part
of them are used in real case. This patch only supports some
patterns in our test case and is not complete. It will be enhanced
in future.

Signed-off-by: Rander Wang <rander.wang@intel.com>
2022-03-28 16:25:49 +01:00
Rander Wang 72394a62de ipc4: update component direction when pipeline is complete
In ipc3 path, host driver sends pcm_hw_param message to fw and
direction is included. The direction is set to each component
after pipeline is complete. There is no such ipc message for
ipc4 path and direction can only be figured out from dai gateway
type if there is one. Ipc4 path gets direction from dai component
and set it to each component after connected pipeline are complete.
We skip the host copier to host copier case.

Signed-off-by: Rander Wang <rander.wang@intel.com>
2022-03-28 16:25:49 +01:00
Peter Ujfalusi 5cdabe5b76 ipc4: base_fw: Fix firmware version type in basefw_config IPC
The firmware version numbers should use u16 type, not u32.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
2022-03-28 16:21:07 +01:00
Peter Ujfalusi 9a39672f8f volume: ipc4: Fix compilation due to unused gain_uuid_ldc
Fixes the following compilation failure with gcc:

In file included from src/include/sof/audio/buffer.h:18,
                 from src/include/sof/audio/component.h:19,
                 from src/include/sof/audio/component_ext.h:19,
                 from src/audio/volume/volume.c:18:
src/audio/volume/volume.c:60:29: error: 'gain_uuid_ldc' defined but not used [-Werror=unused-const-variable=]
   60 | DECLARE_SOF_RT_UUID("gain", gain_uuid, 0x61bca9a8, 0x18d0, 0x4a18,
      |                             ^~~~~~~~~
src/include/sof/lib/uuid.h:94:37: note: in definition of macro 'DECLARE_SOF_UUID'
   94 |  static const struct sof_uuid_entry uuid_name ## _ldc = { \
      |                                     ^~~~~~~~~
src/audio/volume/volume.c:60:1: note: in expansion of macro 'DECLARE_SOF_RT_UUID'
   60 | DECLARE_SOF_RT_UUID("gain", gain_uuid, 0x61bca9a8, 0x18d0, 0x4a18,
      | ^~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
make[2]: *** [CMakeFiles/sof.dir/build.make:534: CMakeFiles/sof.dir/src/audio/volume/volume.c.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:2042: CMakeFiles/sof.dir/all] Error 2
make: *** [Makefile:136: all] Error 2

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
2022-03-28 16:15:00 +01:00
Peter Ujfalusi d5aa222e5d ipc4: helper: Remove unused sink_cfg from ipc4_create_buffer()
Compilation fails with gcc:

src/ipc/ipc4/helper.c: In function 'ipc4_create_buffer':
src/ipc/ipc4/helper.c:210:41: error: variable 'sink_cfg' set but not used [-Werror=unused-but-set-variable]
  210 |  struct ipc4_base_module_cfg *src_cfg, *sink_cfg;
      |                                         ^~~~~~~~
cc1: all warnings being treated as errors
make[2]: *** [CMakeFiles/sof.dir/build.make:394: CMakeFiles/sof.dir/src/ipc/ipc4/helper.c.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:2042: CMakeFiles/sof.dir/all] Error 2
make: *** [Makefile:136: all] Error 2

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
2022-03-28 16:15:00 +01:00
Joe.Cheng 04ff2f99e2 config:ADL:Add DTS config
Enable DTS SDK and SOF EQ IIR on ADL platform

Signed-off-by: Joe.Cheng <joe.cheng@xperi.com>
2022-03-28 16:14:04 +01:00
Joe.Cheng 64378c57f0 topology1:ADL:add DTS topology
The DTS Codec can be conditionally added to the sof-adl-nau8825 topology
on those pipelines intended for headphone and speaker output.

Signed-off-by: Joe.Cheng <joe.cheng@xperi.com>
2022-03-28 16:14:04 +01:00
Kai Vehmanen 6a8b2e89ed zephyr: ll-scheduler: k_sem handle must be in coherent memory
Allocate "struct zephyr_ll_pdata" in shared/coherent memory as it embeds
a "struct k_sem" object. Zephyr kernel code assumes the object to be in
cache coherent memory, so incorrect operation may result if condition is
not met.

Long test runs of all-core capture stress test on Intel cAVS2.5
platform show failures that are fixed with this change.

Discovered via runtime assert in zephyr/kernel/sched.c:pend() that
is hit without this patch.

BugLink: https://github.com/thesofproject/sof/issues/5556
Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
2022-03-28 15:25:10 +01:00
Jairaj Arava 95c53eafc7 topology1: add DMIC 48K Core ID flag to CMake for RTNR
For builds with no Hotword on DSP, generic dmic m4 is used.
RTNR is running on DMIC CORE ID 1. Hence adding the flag.

Signed-off-by: Jairaj Arava <jairaj.arava@intel.com>
2022-03-24 13:39:06 -07:00
Liam Girdwood 0db4a82964 tplg parser: refactor and cleanup part 1
No functional change.

Move some common testbench code into the topology parser and group
feature parsing by file name.

Add a tplg_ prefix to external APIs without a prefix, others with an
existing prefix to follow this change.

Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
2022-03-24 16:54:40 +00:00
Andrula Song fcc891ef9b audio: crossover: fix the mistake of sink stream pointer
to fix the mistake of using audio_stream_read_frag* while
getting output sink buffer pointer.

Signed-off-by: Andrula Song <xiaoyuan.song@intel.com>
2022-03-24 15:00:24 +00:00
Andrula Song f8934a9e22 audio: dcblock: fix mistakes of sink stream pointer
to fix the mistakes of using audio_stream_read_frag*
while geeting output sink buffer pointer.

Signed-off-by: Andrula Song <xiaoyuan.song@intel.com>
2022-03-23 13:39:05 -07:00
Iris Wu 8ebb7478b8 overlays:tgl: Configure format converter for IPC4
Enable format converters when building tgl firmware with Zephyr
and IPC4.

Signed-off-by: Iris Wu <xiaoyun.wu@intel.com>
2022-03-23 14:27:55 +00:00
Jyri Sarha ece6d76b8a ll_schedule: Update DSP load tracker to provide per task numbers
Calculates average and records the maximum execution cycles taken by
each execution round and prints the results out once every 1024 round,
e.g. roughly once per second with a typical 1ms tick configuration. The
output is mimicked from the Zephyr side scheduler output. There is a
Kconfig menu option under debug menu to disable this feature. Currently
the default is on.

Signed-off-by: Jyri Sarha <jyri.sarha@intel.com>
2022-03-23 14:24:31 +00:00
Ranjani Sridharan 09ec53876c codec_adapter: return if copy_bytes is 0
Return is copy_bytes is 0 before calling copy/writeback which will do
nothing anyway.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
2022-03-23 13:58:27 +00:00
Ranjani Sridharan f63951832f codec_adapter: Remove the status variable in module_set_configuration()
Remove the static variable that holds the total config size and use
the new field, new_cfg_size in struct module_data to store the size of
the config data.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
2022-03-23 13:58:27 +00:00
Rafal Redzimski a0e55830a0 idc: modify idc payload size and align to cache line size
Modify IDC payload size to be cache aligned and have size of 2 cache
lines.

Signed-off-by: Rafal Redzimski <rafal.f.redzimski@intel.com>
Signed-off-by: Liam Girdwood <liam.r.girdwood@linux.intel.com>
2022-03-23 13:48:31 +00:00
Rafal Redzimski efd6d4a3e4 zephyr: correct the idc payload initialization
For zephyr case remove the dynamic allocation of per-core
idc elements since these are already statically allocated
in a form of idc array in zephyr/wrapper.c.
The payload pointer initialization need to use idc entries
which are returned by the get_idc() call.

Signed-off-by: Rafal Redzimski <rafal.f.redzimski@intel.com>
2022-03-23 13:48:31 +00:00