The dai_config_set()/dai_config_update() syscall verifiers copied the
user-space bespoke configuration blob into a fixed stack buffer of
CONFIG_DAI_MAX_BESPOKE_CFG_SIZE bytes and rejected anything larger with
-EINVAL. This turns out to be too limiting and we need to support larger
configuration objects.
Decouple the stack buffer size from the maximum allowed blob size and
change implementation such that objects up to DAI_BESPOKE_CFG_STACK_SIZE
are validated on the stack as before, but for larger objects,
k_malloc'ed kernel buffer is used instead.
Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
The SSP_DMA_TRANSMISSION_START/STOP case fell through into
SSP_DMA_ALWAYS_RUNNING_MODE, overwriting the expected size with
sizeof(struct ssp_intel_run_ctl) (4 bytes) instead of
sizeof(struct ssp_intel_tr_ctl) (24 bytes). A well-formed transmission
control TLV then failed the size != aux_tlv->size check and aborted the
whole config parse. Add the missing break.
Assisted-by: Claude:fable-5
Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
(cherry picked from commit 5072a10a03b10ee5cf7495b2d7c346d96a337675)
Extend the existing TDM DAI driver for ACP 7.X:
- Add tdm_dai.h header with shared struct definitions
(dai_amd_tdm_params, acp_tdm_dai_config) and include guard
- Include ACP 7.X chip headers via #elif for CONFIG_SOC_ACP_7_X
- Add sample_format field to dai_amd_tdm_params for per-format
clock configuration (16/24/32-bit slots)
- Configure tdm_lrclk_div_val/tdm_bclk_div_val per sample_format
under CONFIG_SOC_ACP_7_X
- Use acp_tdm_frmt union for TXFRMT/RXFRMT register access
Signed-off-by: DineshKumar Kalva <DineshKumar.Kalva@amd.com>
Signed-off-by: Sneha Voona <sneha.voona@amd.com>
Move the main property logic to dai_ssp_get_properties_copy() and reuse
it for dai_ssp_get_properties(). This allows to avoid the extra memcpy for
dai_ssp_get_properties_copy().
Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
The current dai_ssp_get_properties() implementation requires additional
layer of locking on user side as the properties object is modified in
the function, but the data is not same for TX and RX directions. If the
DAI is used concurrently for TX and RX, this can lead to a race with
invalid data returned.
Fix the issue and align the ssp driver to other DAI drivers by
separating TX and RX state, and only modifying object for one
direction at a time.
Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Move the main property logic to dai_alh_get_properties_copy() and reuse
it for dai_alh_get_properties(). This allows to avoid the extra memcpy for
dai_alh_get_properties_copy().
Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
The current dai_alh_get_properties() implementation requires additional
layer of locking on user side as the properties object is modified in
the function, but the data is not same for TX and RX directions. If the
DAI is used concurrently for TX and RX, this can lead to a race with
invalid data returned.
Fix the issue and align the alh driver to other DAI drivers by
separating TX and RX state, and only modifying object for one
direction at a time.
Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
dai_alh_get_properties() used the caller-provided stream_id without
any validation. The value is used to index the fixed-size
alh_handshake_map[] array and to compute the FIFO register offset, so
an out-of-range stream_id results in an out-of-bounds read and a bogus
FIFO address.
Reject negative and too-large stream_id values up front and return
NULL. dai_alh_get_properties_copy() already maps a NULL result to
-ENOENT, so the error is propagated cleanly to the caller.
Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Add ACP 7.X support to the AMD ACP SoundWire DAI driver
(drivers/dai/amd/sdw/acp_sdw_dai.c):
- Include ACP 7.X specific register headers (acp7x_chip_offsets.h,
acp7x_chip_reg.h) when CONFIG_ACP_7_X is selected
- Add a 4-instance SoundWire DMA channel map (SDW0-SDW3, 22 pins
each) for ACP 7.X
- Add acp_sdw_get_dma_channel() helper for per-instance channel
resolution, populating dma_hs_id for both DAI_DIR_RX and
DAI_DIR_TX directions
Signed-off-by: Sneha Voona <sneha.voona@amd.com>
Add TDM DAI driver and ACP 7.0 register
definitions for AMD Audio Co-Processor. This includes:
- TDM DAI driver (tdm_dai.c) with support for I2S format
- ACP 7.0 chip register definitions and offset mappings
- Device tree bindings and nodes for TDM DAI instances
- Kconfig and CMake build integration
Signed-off-by: Siva Subramanian Ravi Saravanan <sravisar@amd.com>
Co-authored-by: DineshKumar Kalva <DineshKumar.Kalva@amd.com>
Add SoundWire Digital Audio Interface (DAI) driver for AMD
ACP 7.0 audio DSP. This enables audio streaming configuration
for SoundWire-connected audio peripherals and codecs.
Also adds DAI_AMD_SDW type to the DAI subsystem enum.
Signed-off-by: Siva Subramanian Ravi Saravanan <sravisar@amd.com>
Add a Kconfig CONFIG_DAI_MAX_BESPOKE_CFG_SIZE to configure the maximum
blob size for dai_config_set. This only affects user-space usage via
syscalls when the blob needs to be copied to kernel memory before
validation.
The default is increased to 1024 to make tests pass with upstream
SOF project configurations.
Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Utilize a code spell-checking tool to scan for and correct spelling errors
in all files within:
- `drivers/clock_control`
- `drivers/counter`
- `drivers/crypto`
- `drivers/dai`
- `drivers/debug`
Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
This fixes a regression introduced with commit fc2b1b2f3e.
This ensures that when the UAOL driver is disabled, the DAI UAOL
driver is also disabled.
Signed-off-by: Serhiy Katsyuba <serhiy.katsyuba@intel.com>
This adds a DAI driver for USB Audio Offload Link (UAOL)
individual streams on Intel ACE2.0 and ACE3.0 platforms.
Signed-off-by: Tomasz Lissowski <tomasz.lissowski@intel.com>
Signed-off-by: Serhiy Katsyuba <serhiy.katsyuba@intel.com>
dai_ssp_set_clock_control_ver_1() never reports errors and always
returns 0.
The error check at the call site is therefore dead code.
Make the function void and drop the unused error handling.
Signed-off-by: Gaetan Perrot <gaetan.perrot@spacecubics.com>
dai_dmic_probe() and dai_dmic_probe_wrapper() never reports errors
and always returns 0.
The error check at the call site is therefore dead code.
Make functions void and drop the unused error handling.
Signed-off-by: Gaetan Perrot <gaetan.perrot@spacecubics.com>
Make a in-kernel copy of 'cfg' parameter before passing the struct
to kernel z_impl_dai_config_set() implementation. This ensures
user-space will not have access to the object when kernel part
of the syscall is running.
Also add separate handling for the case where bespoke configuration
object is NULL. While no current driver works without a bespoke
configuration, this is not forbidden in the API and the generic syscall
handler should not assume a bespoke object is passed.
Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
dai_ssp_get_properties() can return NULL if there are no properties
defined for the device. Handle this case correctly in ssp driver's
dai_ssp_get_properties_copy() by returning -ENOENT in this case.
Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Add support for new get_properties_copy() method. This allows to
use ssp driver from user-space threads.
Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
The DAI interface is not used from user-space in all configurations
where Zephyr user-space is enabled, so it is beneficial to have
a build option to contorl whether the DAI syscalls are included or
not.
Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Add a variant of get_properties() method that writes the properties
to a caller provided pointer. Unlike the old variant, this copy
variant can be exported to user-space in a safe way.
Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Add user-space support to the dai.h interface. No functional
impact to builds when CONFIG_USERSPACE is not set.
Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Fix incorrect TLV (Type-Length-Value) data length calculation for
SSP configuration blob version 3.0. The blob30->size field does not
include auxiliary TLV data appended after the main structure, leading
to incorrect parsing boundaries.
Changes:
- Use the total 'size' parameter instead of blob30->size for v3.0
- Pass size parameter through dai_ssp_parse_aux_data() chain
- Ensures correct parsing of auxiliary data (clocks, sync, DMA controls)
Signed-off-by: Adrian Bonislawski <adrian.bonislawski@intel.com>
Add explicit bespoke_cfg_size parameter to the dai_config_set()
function and its underlying driver API to improve configuration
validation and security.
Changes:
- Add 'size_t size' parameter to dai_driver_api.config_set callback
- Update dai_config_set() inline wrapper to pass size parameter
- Update all DAI driver implementations:
- Intel: SSP, DMIC, HDA, ALH
- NXP: SAI, ESAI, MICFIL
- Add documentation for new size parameter
This change enables drivers to validate the size of bespoke
configuration data, preventing buffer overruns and improving
robustness of the DAI configuration interface.
All existing callers must be updated to pass the size of their
bespoke configuration structures.
Signed-off-by: Adrian Bonislawski <adrian.bonislawski@intel.com>
Add handling for SSP_GTW_DMA_CONFIG_ID (0x1000) TLV type in SSP driver's
auxiliary data parsing functions. This TLV type is explicitly ignored as
it does not require any processing by the driver.
Changes:
- Define SSP_GTW_DMA_CONFIG_ID constant (0x1000) in dai-params-intel-ipc4.h
- Add case handling in dai_ssp_check_aux_data() to validate this TLV
- Add case handling in dai_ssp_parse_tlv() to skip processing of this TLV
This allows SSP configuration blobs containing SSP_GTW_DMA_CONFIG_ID
entries to be parsed successfully without triggering errors
for undefined TLV types.
Signed-off-by: Adrian Bonislawski <adrian.bonislawski@intel.com>
Use the "zephyr-keep-sorted-start/stop" comment to have CI check
the alphabetical order of includes, to help reducing the chance
of conflicts while contributing drivers.
Signed-off-by: Josuah Demangeon <me@josuah.net>
After commit 524b72ce40 ("toolchain: llvm: Provide working
BUILD_ASSERT macro") when compiling with clang we have actual
checks and a real assert check using _Static_assert.
Now, when compiling with clang (used by Xtensa internal toolchain)
we get the following error.
$ zephyr/drivers/dai/nxp/sai/sai.c:968:29: error: static_assert expression
is not an integral constant expression
We get this in asserts like this:
BUILD_ASSERT(SAI_DLINE_COUNT(inst) != -1, "...").
This expands to (reduced the macro to easier understand the context):
_Static_assert(((((((I2S_Type *)(uintptr_t)(1493499904U))) ==
((I2S_Type *)(0x59040000u)))
... and clang complains that this is not a constant expression.
So, in order to fix the compile time error remove the compile time
asserts and replace them with runtime checks.
Signed-off-by: Daniel Baluta <daniel.baluta@nxp.com>
Fixes: commit 524b72ce40 ("toolchain: llvm: Provide working
BUILD_ASSERT macro")
The call to k_sleep() is not safe as dai_dmic_probe() is called
from PM dmic_pm_action() and k_can_yield() may be false.
Problem was caught on Intel WCL ADSP platform with SOF as application
and a Zephyr build with asserts enabled.
Fix the issue by using k_busy_wait() instead.
Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Introduce the ACE 4.0 architecture, along with support for the NVL and
NVL-S platforms within the Intel ADSP framework in the Zephyr project.
This update includes:
- Addition of ACE 4.0 architecture configurations in Kconfig and
Kconfig.intel_adsp.
- Inclusion of device tree source files for NVL and NVL-S platforms,
defining CPU, memory, and peripheral configurations.
- Updates to driver files to support ACE 4.0 specific features,
including DMIC and SSP configurations.
- Introduction of new header files for ACE 4.0, detailing boot,
interrupt, IPC, power, and shim functionalities.
- Modifications to the CMakeLists.txt to include ACE 4.0 MMU support.
- Addition of default configurations for NVL and NVL-S platforms in
Kconfig.defconfig.ace40.
The NVL and NVL-S platforms are part of the Nova Lake series, targeting
advanced audio processing capabilities. ACE 4.0 introduces enhanced DSP
capabilities and advanced power management features, improving audio
stream handling and synchronization compared to ACE 3.0.
Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
Signed-off-by: Daniel Leung <daniel.leung@intel.com>
Signed-off-by: Serhiy Katsyuba <serhiy.katsyuba@intel.com>
Signed-off-by: Anas Nashif <anas.nashif@intel.com>
Signed-off-by: Tomasz Leman <tomasz.m.leman@intel.com>
During intensive testing, it was found that the clock should
be set the same way on all ACE platforms
Signed-off-by: Adrian Bonislawski <adrian.bonislawski@intel.com>
This change is assumed to fix the random corruption of 4ch
capture for PDM1 channels 3-4 in PTL platform. There are no
solid facts behind this change but assumption that PDMx
controllers are not in sync if the start sequence for PDM1
is further away from PDM0. The PDM0 internal state may be
different from PDM1
The single for loop to handle the CIC and FIR start sequence
is split into two for loops to handle same registers update
tasks symmetrically for all stereo PDM controllers. E.g. two
PDMs for four microphones.
First loop programs the CIC_CONTROL and MIC_CONTROL registers
of the PDMx controllers. These features belong to the CIC block
in DMIC IP. Second loop programs the FIR_CONTROL registers of
the PDMx controllers.
In a stress test of 100 times repeated commands:
arecord -Dhw:0,6 -fS32_LE -r48000 -c4 -d 10 dmic_test_1.wav; \
sleep 0.5; \
arecord -Dhw:0,6 -fS32_LE -r48000 -c4 -d 10 dmic_test_2.wav; \
sleep 1
The corruption occurrence with xt-clang build was e.g. 87/200
fails in one of wav files giving 43.5% occurrence. The test was
done with Zephyr commit fe29c40a93
("llext: add inspection API test suite").
In a gcc build the occurrence of corruption is lower, around 6%
but it is seen that the channels 3-4 pdm1 are swapping randomly.
With this fix the corruption occurred zero times in xt-clang
and gcc builds with same 100 repeats.
Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
This patch will disable DMIC IRQ handling in DMIC driver
because it is now managed by Mic Privacy driver
Signed-off-by: Adrian Bonislawski <adrian.bonislawski@intel.com>
Introduce new DAI driver used for NXP's PDM MICFIL IP.
This block implements required digital interface to provide
a 24-bits audio signal from a PDM microphone bitstream in a configurable
output sampling rate.
Signed-off-by: Daniel Baluta <daniel.baluta@nxp.com>
Print the register address, mask and value as hexadecimal to be more
intuitive and also print out the actual value from the register to have
some insights.
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
With ACE3 the logging is skipped in dai_ssp_start(), move the code under
the same if cases to preserve them.
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>