summaryrefslogtreecommitdiff
path: root/sound/soc/intel/avs/path.c
AgeCommit message (Collapse)Author
2025-06-02ASoC: Intel: avs: Verify kcalloc() status when setting constraintsCezary Rojewski
All memory operations shall be checked. Fixes: f2f847461fb7 ("ASoC: Intel: avs: Constrain path based on BE capabilities") Reviewed-by: Amadeusz Sławiński <amadeuszx.slawinski@linux.intel.com> Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com> Link: https://patch.msgid.link/20250530141025.2942936-7-cezary.rojewski@intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
2025-05-01ASoC: Intel: avs: Fix kcalloc() sizesThorsten Blum
rlist, clist, and slist are allocated using sizeof(pointer) instead of sizeof(*pointer). Fix the allocations by using sizeof(*pointer) and avoid overallocating memory on 64-bit systems. Fixes: f2f847461fb7 ("ASoC: Intel: avs: Constrain path based on BE capabilities") Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev> Reviewed-by: Amadeusz Sławiński <amadeuszx.slawinski@linux.intel.com> Link: https://patch.msgid.link/20250426141342.94134-2-thorsten.blum@linux.dev Signed-off-by: Mark Brown <broonie@kernel.org>
2025-04-24ASoC: Merge up fixesMark Brown
They have build/application dependencies for some new changes coming in.
2025-04-08ASoC: Intel: avs: 16 channels supportMark Brown
Merge series from Cezary Rojewski <cezary.rojewski@intel.com>: Relatively small delta-wise patchset which raises max channels supported from 8 to 16. The existing limitation is software-based, not hardware based. The hardware, as per HDAudio specification, section 1.2.2, (relevant register at SDnFMT, section 3.3.41) supports the configurations for years. The avs-driver becomes the first consumer of that configuration on the Linux kernel side. Set starts off with update to string_helpers so that functionality added with parse_int_array_user() can be utilized in kernel-kernel interactions. Follow up is rasing the cap on HDAudio-library side. The format selection procedure found in the library is good-to-go as is. Everything that follows these two patches is avs-driver specific: - raise channels_max for every DAI-driver template - provide i2s_test module parameter for testing purposes. When combined with I2S loopback card, allows to test 16ch on most Intel hardware post Broadwell era - adjust TDM masks to reflect the 8 -> 16 channels change
2025-04-08ASoC: Intel: avs: Constrain path based on BE capabilitiesAmadeusz Sławiński
For i2s and DMIC copiers constraint stream capabilities based on available NHLT configuration. This allows topology to provide generic configuration that handles more hardware, while filtering unavailable ones at runtime. Signed-off-by: Amadeusz Sławiński <amadeuszx.slawinski@linux.intel.com> Link: https://patch.msgid.link/20250407130851.1726800-1-amadeuszx.slawinski@linux.intel.com Reviewed-by: Cezary Rojewski <cezary.rojewski@intel.com> Signed-off-by: Mark Brown <broonie@kernel.org>
2025-04-07ASoC: Intel: avs: Rename AVS_CHANNELS_MAX defineAmadeusz Sławiński
It is used for coefficient table in updown mixer module, which supports maximum of 8 channels. However it does not represent HW capability. Reviewed-by: Cezary Rojewski <cezary.rojewski@intel.com> Signed-off-by: Amadeusz Sławiński <amadeuszx.slawinski@linux.intel.com> Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com> Link: https://patch.msgid.link/20250404090337.3564117-4-cezary.rojewski@intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
2025-04-07ASoC: Intel: avs: Conditionally add DMA config when creating CopierCezary Rojewski
Starting from LunarLake (LNL) platform, non-HDAudio transfers e.g.: I2S/DMIC utilize HDAudio LINK DMA instead of GPDMA for the data transfer. Implement avs_append_dma_cfg() to account for the changes made in LNL timeframe. The handler checks the platform and transfer type before appending the DMA configuration to the module's payload so it can safely be called within the common initialization flow for Copier/WHM modules. Reviewed-by: Amadeusz Sławiński <amadeuszx.slawinski@linux.intel.com> Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com> Acked-by: Liam Girdwood <liam.r.girdwood@linux.intel.com> Link: https://patch.msgid.link/20250407112352.3720779-9-cezary.rojewski@intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
2025-02-24ASoC: Intel: avs: Support multi-channel PEAKVOL instantiationCezary Rojewski
The PEAKVOL module initialization procedure allows for specifying default configuration for all individual channels. To reflect that in the code, first update avs_get_module_control() to allow for selecting Volume or Mute control based on needs and then apply the settings with newly added avs_peakvol_set_volume() and avs_peakvol_set_mute(). Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com> Link: https://patch.msgid.link/20250217102115.3539427-11-cezary.rojewski@intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
2025-02-24ASoC: Intel: avs: Add support for mute for PEAKVOL and GAINAmadeusz Sławiński
With recent updates to AudioDSP firmware, mute functionality has been added to PEAKVOL and GAIN modules. The operation occurs over IPC similarly to how volume is configured. Wire it up to kcontrol infrastructure present in the avs-driver. Signed-off-by: Amadeusz Sławiński <amadeuszx.slawinski@linux.intel.com> Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com> Link: https://patch.msgid.link/20250217102115.3539427-9-cezary.rojewski@intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
2025-02-24ASoC: Intel: avs: Move to the new control operationsCezary Rojewski
Allow for multi-channel volume controls to be utilized by an application by moving over to the new implementation. Drop all unused code in the process. Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com> Link: https://patch.msgid.link/20250217102115.3539427-8-cezary.rojewski@intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
2025-02-24ASoC: Intel: avs: New volume control operationsCezary Rojewski
To provide multi-channel - more than 2 - capability to volume controls implement operations that honor the num_channels of a mixer control. As mc->num_channels can be 0 and is in fact the default behavior, the new functions decide between ALL_CHANNELS_MASK and individual channels based on the field value. To avoid hard-to-review delta when refactoring the code, first implement the new behavior with follow up changes cleaning things up. Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com> Link: https://patch.msgid.link/20250217102115.3539427-7-cezary.rojewski@intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
2025-02-24ASoC: Intel: avs: Make PEAKVOL configurable from topologyCezary Rojewski
The driver exposes volume kcontrols if PEAKVOL/GAIN module is present in the streaming path. Currently there is no control over their default values including the effect that may accompany the volume change event. Add template for PEAKVOL/GAIN module which holds all the information needed to address the limitation. Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com> Link: https://patch.msgid.link/20250217102115.3539427-4-cezary.rojewski@intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
2025-02-03ASoC: Intel: avs: Add WHM module supportCezary Rojewski
WovHostModule (WHM) is used in wake-on-voice scenarios to optimize power consumption. It combines capabilities of Copier, KeyPhraseBuffer, WakeOnVoice and Muxer modules. Signed-off-by: Piotr Maziarz <piotrx.maziarz@linux.intel.com> Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com> Link: https://patch.msgid.link/20250203141051.2361323-11-cezary.rojewski@intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
2025-02-03ASoC: Intel: avs: Remove unused gateway configuration codeCezary Rojewski
Switch to new copier module constructor and remove code that becomes unused because of that. Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com> Link: https://patch.msgid.link/20250203141051.2361323-10-cezary.rojewski@intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
2025-02-03ASoC: Intel: avs: New gateway configuration mechanismCezary Rojewski
Creation of a module which contains gateway configuration consists of few additional steps, namely: - assigning ID (node_id) for the gateway - attaching hardware configuration from the NHLT table (optional) By splitting the steps into separate functions code becomes easier to read and understand. Any redundancy created by this patch will be addressed by follow up changes. Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com> Link: https://patch.msgid.link/20250203141051.2361323-9-cezary.rojewski@intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
2024-05-06ASoC: Intel: avs: clarify Copyright informationPierre-Louis Bossart
For some reason a number of files included the "All rights reserved" statement. Good old copy-paste made sure this mistake proliferated. Remove the "All rights reserved" in all Intel-copyright to align with internal guidance. Acked-by: Cezary Rojewski <cezary.rojewski@intel.com> Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> Reviewed-by: Bard Liao <yung-chuan.liao@linux.intel.com> Reviewed-by: Péter Ujfalusi <peter.ujfalusi@linux.intel.com> Link: https://lore.kernel.org/r/20240503140359.259762-7-pierre-louis.bossart@linux.intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
2024-04-22ASoC: Intel: avs: Switch to acpi-nhltMark Brown
Merge series from Cezary Rojewski <cezary.rojewski@intel.com>: The change is based on rafael/acpi-nhlt [1] immutable branch which Rafael kindly prepared for me. Without the topmost changes to ACPI/NHLT, the patches present will fail to compile. Recent changes for the ACPI tree [2] refactored interfaces of the NHLT table. Currently we have two implementations - one found in acpi subsystem (unused) and one in sound/hda/. As NHLT is part of ACPI, idea is to make the former useful and then switch all users of existing sound/hda/intel-nhlt.c to this new interface over time and remove the duplicate afterward. [1]: https://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm.git/?h=acpi-nhlt [2]: https://lore.kernel.org/linux-acpi/20240319083018.3159716-1-cezary.rojewski@intel.com/
2024-04-21ASoC: Intel: avs: Switch to ACPI NHLTAmadeusz Sławiński
Now that NHLT support in ACPI framework was introduced, migrate avs driver to new API. Signed-off-by: Amadeusz Sławiński <amadeuszx.slawinski@linux.intel.com> Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com> Link: https://lore.kernel.org/r/20240419084307.2718881-3-cezary.rojewski@intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
2024-04-05ASoC: Intel: avs: Remove dead codeCezary Rojewski
The result of list_next_entry()/list_last_entry() is never null. Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com> Link: https://msgid.link/r/20240405090929.1184068-10-cezary.rojewski@intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
2024-04-05ASoC: Intel: avs: Fix ASRC module initializationCezary Rojewski
The ASRC module configuration consists of several reserved fields. Zero them out when initializing the module to avoid sending invalid data. Fixes: 274d79e51875 ("ASoC: Intel: avs: Configure modules according to their type") Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com> Link: https://msgid.link/r/20240405090929.1184068-6-cezary.rojewski@intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
2024-04-05ASoC: Intel: avs: Fix config_length for config-less copiersCezary Rojewski
Copier's config_length shall always be at least one even if there is no configuration payload to carry. While the firmware treats config_length=0 or 1 in the same manner, the driver shall initialize the module properly. Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com> Link: https://msgid.link/r/20240405090929.1184068-5-cezary.rojewski@intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
2024-04-05ASoC: Intel: avs: Silence false-positive memcpy() warningsCezary Rojewski
Commit df8fc4e934c1 ("kbuild: Enable -fstrict-flex-arrays=3") enforced strict flex array declarations. This generates false-positive in form of: "memcpy: detected field-spanning write". Avoid it by utilizing the DECLARE_FLEX_ARRAY() macro. Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com> Link: https://msgid.link/r/20240405090929.1184068-4-cezary.rojewski@intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
2024-02-08ASoC: Intel: avs: Send initial config to module if presentAmadeusz Sławiński
If there are initial configs to send to module on init do send them. Reviewed-by: Cezary Rojewski <cezary.rojewski@intel.com> Signed-off-by: Amadeusz Sławiński <amadeuszx.slawinski@linux.intel.com> Link: https://lore.kernel.org/r/20240208102400.2497791-4-amadeuszx.slawinski@linux.intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
2023-11-27ASoC: Intel: avs: Switch to new stream-format interfaceCezary Rojewski
To provide option for selecting different bit-per-sample than just the maximum one, use the new format calculation mechanism. Acked-by: Mark Brown <broonie@kernel.org> Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com> Acked-by: Jaroslav Kysela <perex@perex.cz> Link: https://lore.kernel.org/r/20231117120610.1755254-14-cezary.rojewski@intel.com Signed-off-by: Takashi Iwai <tiwai@suse.de>
2023-09-29ASoC: Intel: avs: Preallocate memory for module configurationAmadeusz Sławiński
In order to instantiate modules on the firmware side, the driver sends payload with module configuration. In some case size of this information is not known before hand, so driver allocates temporary memory during module creation and frees it after use. Optimize the flow a bit, by preallocating maximum buffer. This removes the time spend on allocating memory, as well as potential OOM errors during module initialization. Handlers for modules, where configuration data fits on stack, are left as is. Reviewed-by: Cezary Rojewski <cezary.rojewski@intel.com> Signed-off-by: Amadeusz Sławiński <amadeuszx.slawinski@linux.intel.com> Link: https://lore.kernel.org/r/20230929112436.787058-4-amadeuszx.slawinski@linux.intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
2023-03-05ASoC: Intel: avs: Use struct_size for struct avs_modcfg_ext sizeJacob Keller
The struct avs_modcfg_ext structure has a flexible array member for the pin_fmts array, and the size should be calculated using struct_size to prevent the potential for overflow with the allocation. Reviewed-by: Cezary Rojewski <cezary.rojewski@intel.com> Reviewed-by: "Amadeusz Sławiński" <amadeuszx.slawinski@linux.intel.com> Signed-off-by: Jacob Keller <jacob.e.keller@intel.com> Link: https://lore.kernel.org/r/20230303180457.2457069-1-jacob.e.keller@intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
2022-12-25ASoC: Intel: avs: Peakvol module configurationAmadeusz Sławiński
Handle creation of peakvol module in FW. When peakvol module is created it retrieves actual value from kcontrol and sends it to FW as part of configuration data. Co-authored-by: Cezary Rojewski <cezary.rojewski@intel.com> Signed-off-by: Amadeusz Sławiński <amadeuszx.slawinski@linux.intel.com> Link: https://lore.kernel.org/r/20221214185500.3896902-5-amadeuszx.slawinski@linux.intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
2022-07-22ASoC: Intel: avs: Use lookup table to create modulesAmadeusz Sławiński
As reported by Nathan, when building avs driver using clang with: CONFIG_COMPILE_TEST=y CONFIG_FORTIFY_SOURCE=y CONFIG_KASAN=y CONFIG_PCI=y CONFIG_SOUND=y CONFIG_SND=y CONFIG_SND_SOC=y CONFIG_SND_SOC_INTEL_AVS=y there are reports of too big stack use, like: sound/soc/intel/avs/path.c:815:18: error: stack frame size (2176) exceeds limit (2048) in 'avs_path_create' [-Werror,-Wframe-larger-than] struct avs_path *avs_path_create(struct avs_dev *adev, u32 dma_id, ^ 1 error generated. This is apparently caused by inlining many calls to guid_equal which inlines fortified memcpy, using 2 size_t variables. Instead of hardcoding many calls to guid_equal, use lookup table with one call, this improves stack usage. Link: https://lore.kernel.org/alsa-devel/YtlzY9aYdbS4Y3+l@dev-arch.thelio-3990X/T/ Link: https://github.com/ClangBuiltLinux/linux/issues/1642 Signed-off-by: Amadeusz Sławiński <amadeuszx.slawinski@linux.intel.com> Reported-by: Nathan Chancellor <nathan@kernel.org> Build-tested-by: Nathan Chancellor <nathan@kernel.org> Reviewed-by: Cezary Rojewski <cezary.rojewski@intel.com> Link: https://lore.kernel.org/r/20220722111959.2588597-1-amadeuszx.slawinski@linux.intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
2022-04-19ASoC: Intel: avs: Configure modules according to their typeCezary Rojewski
Each module on DSP side serves a processing purpose. Depending on its purpose, it needs different information during its initialization. Add functions responsible for creating instances of specific module types given the information coming from the topology file. Signed-off-by: Amadeusz Sławiński <amadeuszx.slawinski@linux.intel.com> Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com> Link: https://lore.kernel.org/r/20220331135246.993089-15-cezary.rojewski@intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
2022-04-19ASoC: Intel: avs: Prepare modules before bindings themCezary Rojewski
When binding modules to pins other than pin0, sometimes additional preparations need to be made, depending on the module type. Add function that prepares modules when necessary before binding them. Signed-off-by: Amadeusz Sławiński <amadeuszx.slawinski@linux.intel.com> Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com> Link: https://lore.kernel.org/r/20220331135246.993089-14-cezary.rojewski@intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
2022-04-19ASoC: Intel: avs: Arm paths after creating themCezary Rojewski
Creating the pipelines and instantiating the modules alone is insufficient to have a fully operational stream. Before it can be run, stream components need to be bound. Add arming functions to ensure all necessary operations are completed before path is yielded back to the avs_path_create() caller. Signed-off-by: Amadeusz Sławiński <amadeuszx.slawinski@linux.intel.com> Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com> Link: https://lore.kernel.org/r/20220331135246.993089-13-cezary.rojewski@intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
2022-04-19ASoC: Intel: avs: Path state managementCezary Rojewski
Add functions to ease with state changing of all objects found in the path. Each represents either a BIND/UNBIND or SET_PIPELINE_STATE IPC. DSP pipelines follow simple state machine scheme: CREATE -> RESET -> PAUSE -> RUNNING -> PAUSE -> RESET -> DELETE There is no STOP, PAUSE serves that purpose instead. Signed-off-by: Amadeusz Sławiński <amadeuszx.slawinski@linux.intel.com> Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com> Link: https://lore.kernel.org/r/20220331135246.993089-12-cezary.rojewski@intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
2022-04-19ASoC: Intel: avs: Path creation and freeingCezary Rojewski
To implement ASoC PCM operations, DSP path handling is needed. With path template concept present, information carried by topology file can be converted into runtime path representation. Each may be composed of several pipelines and each pipeline can contain a number of processing modules inside. Number of templates and variants found within topology may vastly outnumber the total amount of pipelines and modules supported by AudioDSP firmware simultaneously (in runtime) so none of the IDs are specified in the topology. These are assigned dynamically when needed and account for limitations described by FIRMWARE_CONFIG and HARDWARE_CONFIG basefw parameters. Paths are created on ->hw_params() and are freed on ->hw_free() ALSA PCM operations. This choice is based on firmware expectations - need for complete set of information when attempting to instantiate pipelines and modules on AudioDSP side. With DMA and audio format provided, search mechanism tests all path variants available in given path template until a matching variant is found. Once found, information already available is combined with all avs_tplg_* pieces pointed by matching path variant. This finally allows to begin a cascade of IPCs which goal is to reserve resources and prepare DSP for upcoming audio streaming. Signed-off-by: Amadeusz Sławiński <amadeuszx.slawinski@linux.intel.com> Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com> Link: https://lore.kernel.org/r/20220331135246.993089-11-cezary.rojewski@intel.com Signed-off-by: Mark Brown <broonie@kernel.org>