ASoC: Intel: avs: Topology and path management
Subsystems (3)
Cezary Rojewski
maintainercover ASoC: Intel: avs: Topology and path management
A continuation of avs-driver initial series [1]. This chapter covers path management and topology parsing part which was ealier path of the main series. The two patches that represented these two subjects in the initial series, have been split into many to allow for easier review and discussion.
AVS topology is split into two major parts: dictionaries - found within ASoC topology manifest - and path templates.
Dictionaries job is to reduce the total amount of memory occupied by topology elements. Rather than having every pipeline and module carry its own information, each refers to specific entry in specific dictionary by provided (from topology file) indexes. In consequence, most struct avs_tplg_xxx are made out of pointers.
Path templates are similar to path descriptions found in skylake-driver and they describe how given path shall look like in runtime - number of modules and pipelines that shape it and how they are laid out. A single path template is tied either to FE or BE and thus at most to a single, user-visible endpoint when speaking of FE.
Path is a software representation of its ADSP firmware equivalent. It's a logical container for pipelines which are themselves containers - this time for modules i.e. processing units.
Depending on the number of audio formats supported, each path template may carry one or more descriptions of given path. During runtime, when audio format is known, description matching said format is selected and used when instantiating path on ADSP firmware side through IPCs.
Changes RFC -> v1:
- Plenty of rewordings and spelling fixes as requested by Pierre
- any sysfs-functionality-related left in RFC dropped, will be part of separate subject in the future
- separated parsing of formatted strings into: "Support link_mask formatted string" patch, increasing series size to 14 patches
[1]: https://lore.kernel.org/alsa-devel/[email protected]/T/#t
Cezary Rojewski (14):
ASoC: Intel: avs: Declare vendor tokens
ASoC: Intel: avs: Add topology parsing infrastructure
ASoC: Intel: avs: Parse module-extension tuples
ASoC: Intel: avs: Parse pplcfg and binding tuples
ASoC: Intel: avs: Parse pipeline and module tuples
ASoC: Intel: avs: Parse path and path templates tuples
ASoC: Intel: avs: Add topology loading operations
ASoC: Intel: avs: Support link_mask formatted string
ASoC: Intel: avs: Declare path and its components
ASoC: Intel: avs: Path creation and freeing
ASoC: Intel: avs: Path state management
ASoC: Intel: avs: Arm paths after creating them
ASoC: Intel: avs: Prepare modules before bindings them
ASoC: Intel: avs: Configure modules according to their type
include/uapi/sound/intel/avs/tokens.h | 126 ++ sound/soc/intel/Kconfig | 2 + sound/soc/intel/avs/Makefile | 3 +- sound/soc/intel/avs/avs.h | 23 + sound/soc/intel/avs/path.c | 1008 ++++++++++++++++ sound/soc/intel/avs/path.h | 72 ++ sound/soc/intel/avs/topology.c | 1600 +++++++++++++++++++++++++ sound/soc/intel/avs/topology.h | 194 +++ 8 files changed, 3027 insertions(+), 1 deletion(-) create mode 100644 include/uapi/sound/intel/avs/tokens.h create mode 100644 sound/soc/intel/avs/path.c create mode 100644 sound/soc/intel/avs/path.h create mode 100644 sound/soc/intel/avs/topology.c create mode 100644 sound/soc/intel/avs/topology.h
Signature · 1 line
2.25.1
Cezary Rojewski
maintainerPATCH 1/14 ASoC: Intel: avs: Declare vendor tokens
Expose all vendor tokens that help shape AVS topology. Parsing helpers introduced in follow up patches make use of these to know which block they are currently dealing with and to verify their correctness.
--- include/uapi/sound/intel/avs/tokens.h | 126 ++++++++++++++++++++++++++ 1 file changed, 126 insertions(+) create mode 100644 include/uapi/sound/intel/avs/tokens.h
include/uapi/sound/intel/avs/tokens.h new file +126 -0
@@ -0,0 +1,126 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +/* +* Copyright(c) 2021 Intel Corporation. All rights reserved. +* +* Authors: Cezary Rojewski <[email protected]> +* Amadeusz Slawinski <[email protected]> +*/ + +#ifndef __UAPI_SOUND_INTEL_AVS_TOKENS_H +#define __UAPI_SOUND_INTEL_AVS_TOKENS_H + +enum avs_tplg_token { +/* struct avs_tplg */ +AVS_TKN_MANIFEST_NAME_STRING =1 , +AVS_TKN_MANIFEST_VERSION_U32 =2 , +AVS_TKN_MANIFEST_NUM_LIBRARIES_U32 =3 , +AVS_TKN_MANIFEST_NUM_AFMTS_U32 =4 , +AVS_TKN_MANIFEST_NUM_MODCFGS_BASE_U32 =5 , +AVS_TKN_MANIFEST_NUM_MODCFGS_EXT_U32 =6 , +AVS_TKN_MANIFEST_NUM_PPLCFGS_U32 =7 , +AVS_TKN_MANIFEST_NUM_BINDINGS_U32 =8 , + +/* struct avs_tplg_library */ +AVS_TKN_LIBRARY_ID_U32 =101 , +AVS_TKN_LIBRARY_NAME_STRING =102 , + +/* struct avs_audio_format */ +AVS_TKN_AFMT_ID_U32 =201 , +AVS_TKN_AFMT_SAMPLE_RATE_U32 =202 , +AVS_TKN_AFMT_BIT_DEPTH_U32 =203 , +AVS_TKN_AFMT_CHANNEL_MAP_U32 =204 , +AVS_TKN_AFMT_CHANNEL_CFG_U32 =205 , +AVS_TKN_AFMT_INTERLEAVING_U32 =206 , +AVS_TKN_AFMT_NUM_CHANNELS_U32 =207 , +AVS_TKN_AFMT_VALID_BIT_DEPTH_U32 =208 , +AVS_TKN_AFMT_SAMPLE_TYPE_U32 =209 , + +/* struct avs_tplg_modcfg_base */ +AVS_TKN_MODCFG_BASE_ID_U32 =301 , +AVS_TKN_MODCFG_BASE_CPC_U32 =302 , +AVS_TKN_MODCFG_BASE_IBS_U32 =303 , +AVS_TKN_MODCFG_BASE_OBS_U32 =304 , +AVS_TKN_MODCFG_BASE_PAGES_U32 =305 , + +/* struct avs_tplg_modcfg_ext */ +AVS_TKN_MODCFG_EXT_ID_U32 =401 , +AVS_TKN_MODCFG_EXT_TYPE_UUID =402 , +AVS_TKN_MODCFG_CPR_OUT_AFMT_ID_U32 =403 , +AVS_TKN_MODCFG_CPR_FEATURE_MASK_U32 =404 , +AVS_TKN_MODCFG_CPR_DMA_TYPE_U32 =405 , +AVS_TKN_MODCFG_CPR_DMABUFF_SIZE_U32 =406 , +AVS_TKN_MODCFG_CPR_VINDEX_U8 =407 , +AVS_TKN_MODCFG_CPR_BLOB_FMT_ID_U32 =408 , +AVS_TKN_MODCFG_MICSEL_OUT_AFMT_ID_U32 =409 , +AVS_TKN_MODCFG_INTELWOV_CPC_LP_MODE_U32 =410 , +AVS_TKN_MODCFG_SRC_OUT_FREQ_U32 =411 , +AVS_TKN_MODCFG_MUX_REF_AFMT_ID_U32 =412 , +AVS_TKN_MODCFG_MUX_OUT_AFMT_ID_U32 =413 , +AVS_TKN_MODCFG_AEC_REF_AFMT_ID_U32 =414 , +AVS_TKN_MODCFG_AEC_OUT_AFMT_ID_U32 =415 , +AVS_TKN_MODCFG_AEC_CPC_LP_MODE_U32 =416 , +AVS_TKN_MODCFG_ASRC_OUT_FREQ_U32 =417 , +AVS_TKN_MODCFG_ASRC_MODE_U8 =418 , +AVS_TKN_MODCFG_ASRC_DISABLE_JITTER_U8 =419 , +AVS_TKN_MODCFG_UPDOWN_MIX_OUT_CHAN_CFG_U32 =420 , +AVS_TKN_MODCFG_UPDOWN_MIX_COEFF_SELECT_U32 =421 , +AVS_TKN_MODCFG_UPDOWN_MIX_COEFF_0_S32 =422 , +AVS_TKN_MODCFG_UPDOWN_MIX_COEFF_1_S32 =423 , +AVS_TKN_MODCFG_UPDOWN_MIX_COEFF_2_S32 =424 , +AVS_TKN_MODCFG_UPDOWN_MIX_COEFF_3_S32 =425 , +AVS_TKN_MODCFG_UPDOWN_MIX_COEFF_4_S32 =426 , +AVS_TKN_MODCFG_UPDOWN_MIX_COEFF_5_S32 =427 , +AVS_TKN_MODCFG_UPDOWN_MIX_COEFF_6_S32 =428 , +AVS_TKN_MODCFG_UPDOWN_MIX_COEFF_7_S32 =429 , +AVS_TKN_MODCFG_UPDOWN_MIX_CHAN_MAP_U32 =430 , +AVS_TKN_MODCFG_EXT_NUM_INPUT_PINS_U16 =431 , +AVS_TKN_MODCFG_EXT_NUM_OUTPUT_PINS_U16 =432 , + +/* struct avs_tplg_pplcfg */ +AVS_TKN_PPLCFG_ID_U32 =1401 , +AVS_TKN_PPLCFG_REQ_SIZE_U16 =1402 , +AVS_TKN_PPLCFG_PRIORITY_U8 =1403 , +AVS_TKN_PPLCFG_LOW_POWER_BOOL =1404 , +AVS_TKN_PPLCFG_ATTRIBUTES_U16 =1405 , +AVS_TKN_PPLCFG_TRIGGER_U32 =1406 , + +/* struct avs_tplg_binding */ +AVS_TKN_BINDING_ID_U32 =1501 , +AVS_TKN_BINDING_TARGET_TPLG_NAME_STRING =1502 , +AVS_TKN_BINDING_TARGET_PATH_TMPL_ID_U32 =1503 , +AVS_TKN_BINDING_TARGET_PPL_ID_U32 =1504 , +AVS_TKN_BINDING_TARGET_MOD_ID_U32 =1505 , +AVS_TKN_BINDING_TARGET_MOD_PIN_U8 =1506 , +AVS_TKN_BINDING_MOD_ID_U32 =1507 , +AVS_TKN_BINDING_MOD_PIN_U8 =1508 , +AVS_TKN_BINDING_IS_SINK_U8 =1509 , + +/* struct avs_tplg_pipeline */ +AVS_TKN_PPL_ID_U32 =1601 , +AVS_TKN_PPL_PPLCFG_ID_U32 =1602 , +AVS_TKN_PPL_NUM_BINDING_IDS_U32 =1603 , +AVS_TKN_PPL_BINDING_ID_U32 =1604 , + +/* struct avs_tplg_module */ +AVS_TKN_MOD_ID_U32 =1701 , +AVS_TKN_MOD_MODCFG_BASE_ID_U32 =1702 , +AVS_TKN_MOD_IN_AFMT_ID_U32 =1703 , +AVS_TKN_MOD_CORE_ID_U8 =1704 , +AVS_TKN_MOD_PROC_DOMAIN_U8 =1705 , +AVS_TKN_MOD_MODCFG_EXT_ID_U32 =1706 , + +/* struct avs_tplg_path_template */ +AVS_TKN_PATH_TMPL_ID_U32 =1801 , + +/* struct avs_tplg_path */ +AVS_TKN_PATH_ID_U32 =1901 , +AVS_TKN_PATH_FE_FMT_ID_U32 =1902 , +AVS_TKN_PATH_BE_FMT_ID_U32 =1903 , + +/* struct avs_tplg_pin_format */ +AVS_TKN_PIN_FMT_INDEX_U32 =2201 , +AVS_TKN_PIN_FMT_IOBS_U32 =2202 , +AVS_TKN_PIN_FMT_AFMT_ID_U32 =2203 , +}; + +#endif
Signature · 1 line
2.25.1
Cezary Rojewski
maintainerPATCH 2/14 ASoC: Intel: avs: Add topology parsing infrastructure
In reply to Cezary RojewskiAVS topology is split into two major parts: dictionaries - found within ASoC topology manifest - and path templates.
Dictionaries job is to reduce the total amount of memory occupied by topology elements. Rather than having every pipeline and module carry its own information, each refers to specific entry in specific dictionary by provided (from topology file) indexes. In consequence, most struct avs_tplg_xxx are made out of pointers.
To support the above, range of parsing helpers for all value-types known to ALSA: uuid, bool, byte, short, word and string are added. Additional handlers help translate pointer-types and more complex objects such as audio formats and module base configs.
Path templates are similar to path descriptions found in skylake-driver and they describe how given path shall look like in runtime - number of modules and pipelines that shape it and how they are laid out.
--- sound/soc/intel/avs/avs.h | 14 + sound/soc/intel/avs/topology.c | 595 +++++++++++++++++++++++++++++++++ sound/soc/intel/avs/topology.h | 44 +++ 3 files changed, 653 insertions(+) create mode 100644 sound/soc/intel/avs/topology.c create mode 100644 sound/soc/intel/avs/topology.h
sound/soc/intel/avs/avs.h +14 -0
@@ -13,10 +13,12 @@#include <linux/firmware.h> #include <sound/hda_codec.h> #include <sound/hda_register.h> +#include <sound/soc-component.h> #include "messages.h" #include "registers.h" struct avs_dev ; +struct avs_tplg ;/* * struct avs_dsp_ops - Platform-specific DSP operations
@@ -244,4 +246,16 @@ int avs_hda_load_library(struct avs_dev *adev, struct firmware *lib, u32 id);int avs_hda_transfer_modules (struct avs_dev *adev,bool load,struct avs_module_entry *mods,u32 num_mods); +/* Soc component members */ + +struct avs_soc_component { +struct snd_soc_component base; +struct avs_tplg *tplg; + +struct list_head node; +}; + +#define to_avs_soc_component (comp) \ + container_of(comp, struct avs_soc_component, base) +#endif /* __SOUND_SOC_INTEL_AVS_H */
sound/soc/intel/avs/topology.c new file +595 -0
595 lines not on this page · raw message
sound/soc/intel/avs/topology.h new file +44 -0
44 lines not on this page · raw message
Signature · 1 line
2.25.1
Cezary Rojewski
maintainerPATCH 3/14 ASoC: Intel: avs: Parse module-extension tuples
In reply to Cezary RojewskiAnything that goes beyond module base config is an extension config. It covers all fields for all specific module types available in ADSP firmware. Add parsing helpers to support loading such information from the topology file.
--- sound/soc/intel/avs/topology.c | 297 +++++++++++++++++++++++++++++++++ sound/soc/intel/avs/topology.h | 59 +++++++ 2 files changed, 356 insertions(+)
sound/soc/intel/avs/topology.c +297 -0
@@ -344,6 +344,7 @@ avs_parse_##name##_ptr(struct snd_soc_component *comp, void *elem, void *object, AVS_DEFINE_PTR_PARSER(audio_format, struct avs_audio_format, fmts); AVS_DEFINE_PTR_PARSER(modcfg_base, struct avs_tplg_modcfg_base, modcfgs_base); +AVS_DEFINE_PTR_PARSER(modcfg_ext, struct avs_tplg_modcfg_ext, modcfgs_ext);static int parse_audio_format_bitfield (struct snd_soc_component *comp,void *elem,void *object,u32 offset)
@@ -593,3 +594,299 @@ static int avs_tplg_parse_modcfgs_base(struct snd_soc_component *comp,AVS_TKN_MODCFG_BASE_ID_U32 , modcfg_base_parsers, ARRAY_SIZE(modcfg_base_parsers)); } + +static const struct avs_tplg_token_parser modcfg_ext_parsers[] = { + { + .token =AVS_TKN_MODCFG_EXT_TYPE_UUID , + .type =SND_SOC_TPLG_TUPLE_TYPE_UUID , + .offset = offsetof(struct avs_tplg_modcfg_ext , type), + .parse = avs_parse_uuid_token, + }, + { + .token =AVS_TKN_MODCFG_CPR_OUT_AFMT_ID_U32 , + .type =SND_SOC_TPLG_TUPLE_TYPE_WORD , + .offset = offsetof(struct avs_tplg_modcfg_ext, copier.out_fmt), + .parse = avs_parse_audio_format_ptr, + }, + { + .token =AVS_TKN_MODCFG_CPR_FEATURE_MASK_U32 , + .type =SND_SOC_TPLG_TUPLE_TYPE_WORD , + .offset = offsetof(struct avs_tplg_modcfg_ext, copier.feature_mask), + .parse = avs_parse_word_token, + }, + { + .token =AVS_TKN_MODCFG_CPR_VINDEX_U8 , + .type =SND_SOC_TPLG_TUPLE_TYPE_BYTE , + .offset = offsetof(struct avs_tplg_modcfg_ext, copier.vindex), + .parse = avs_parse_byte_token, + }, + { + .token =AVS_TKN_MODCFG_CPR_DMA_TYPE_U32 , + .type =SND_SOC_TPLG_TUPLE_TYPE_WORD , + .offset = offsetof(struct avs_tplg_modcfg_ext, copier.dma_type), + .parse = avs_parse_word_token, + }, + { + .token =AVS_TKN_MODCFG_CPR_DMABUFF_SIZE_U32 , + .type =SND_SOC_TPLG_TUPLE_TYPE_WORD , + .offset = offsetof(struct avs_tplg_modcfg_ext, copier.dma_buffer_size), + .parse = avs_parse_word_token, + }, + { + .token =AVS_TKN_MODCFG_CPR_BLOB_FMT_ID_U32 , + .type =SND_SOC_TPLG_TUPLE_TYPE_WORD , + .offset = offsetof(struct avs_tplg_modcfg_ext, copier.blob_fmt), + .parse = avs_parse_audio_format_ptr, + }, + { + .token =AVS_TKN_MODCFG_MICSEL_OUT_AFMT_ID_U32 , + .type =SND_SOC_TPLG_TUPLE_TYPE_WORD , + .offset = offsetof(struct avs_tplg_modcfg_ext, micsel.out_fmt), + .parse = avs_parse_audio_format_ptr, + }, + { + .token =AVS_TKN_MODCFG_INTELWOV_CPC_LP_MODE_U32 , + .type =SND_SOC_TPLG_TUPLE_TYPE_WORD , + .offset = offsetof(struct avs_tplg_modcfg_ext, wov.cpc_lp_mode), + .parse = avs_parse_word_token, + }, + { + .token =AVS_TKN_MODCFG_SRC_OUT_FREQ_U32 , + .type =SND_SOC_TPLG_TUPLE_TYPE_WORD , + .offset = offsetof(struct avs_tplg_modcfg_ext, src.out_freq), + .parse = avs_parse_word_token, + }, + { + .token =AVS_TKN_MODCFG_MUX_REF_AFMT_ID_U32 , + .type =SND_SOC_TPLG_TUPLE_TYPE_WORD , + .offset = offsetof(struct avs_tplg_modcfg_ext, mux.ref_fmt), + .parse = avs_parse_audio_format_ptr, + }, + { + .token =AVS_TKN_MODCFG_MUX_OUT_AFMT_ID_U32 , + .type =SND_SOC_TPLG_TUPLE_TYPE_WORD , + .offset = offsetof(struct avs_tplg_modcfg_ext, mux.out_fmt), + .parse = avs_parse_audio_format_ptr, + }, + { + .token =AVS_TKN_MODCFG_AEC_REF_AFMT_ID_U32 , + .type =SND_SOC_TPLG_TUPLE_TYPE_WORD , + .offset = offsetof(struct avs_tplg_modcfg_ext, aec.ref_fmt), + .parse = avs_parse_audio_format_ptr, + }, + { + .token =AVS_TKN_MODCFG_AEC_OUT_AFMT_ID_U32 , + .type =SND_SOC_TPLG_TUPLE_TYPE_WORD , + .offset = offsetof(struct avs_tplg_modcfg_ext, aec.out_fmt), + .parse = avs_parse_audio_format_ptr, + }, + { + .token =AVS_TKN_MODCFG_AEC_CPC_LP_MODE_U32 , + .type =SND_SOC_TPLG_TUPLE_TYPE_WORD , + .offset = offsetof(struct avs_tplg_modcfg_ext, aec.cpc_lp_mode), + .parse = avs_parse_word_token, + }, + { + .token =AVS_TKN_MODCFG_ASRC_OUT_FREQ_U32 , + .type =SND_SOC_TPLG_TUPLE_TYPE_WORD , + .offset = offsetof(struct avs_tplg_modcfg_ext, asrc.out_freq), + .parse = avs_parse_word_token, + }, + { + .token =AVS_TKN_MODCFG_ASRC_MODE_U8 , + .type =SND_SOC_TPLG_TUPLE_TYPE_BYTE , + .offset = offsetof(struct avs_tplg_modcfg_ext, asrc.mode), + .parse = avs_parse_byte_token, + }, + { + .token =AVS_TKN_MODCFG_ASRC_DISABLE_JITTER_U8 , + .type =SND_SOC_TPLG_TUPLE_TYPE_BYTE , + .offset = offsetof(struct avs_tplg_modcfg_ext, asrc.disable_jitter_buffer), + .parse = avs_parse_byte_token, + }, + { + .token =AVS_TKN_MODCFG_UPDOWN_MIX_OUT_CHAN_CFG_U32 , + .type =SND_SOC_TPLG_TUPLE_TYPE_WORD , + .offset = offsetof(struct avs_tplg_modcfg_ext, updown_mix.out_channel_config), + .parse = avs_parse_word_token, + }, + { + .token =AVS_TKN_MODCFG_UPDOWN_MIX_COEFF_SELECT_U32 , + .type =SND_SOC_TPLG_TUPLE_TYPE_WORD , + .offset = offsetof(struct avs_tplg_modcfg_ext, updown_mix.coefficients_select), + .parse = avs_parse_word_token, + }, + { + .token =AVS_TKN_MODCFG_UPDOWN_MIX_COEFF_0_S32 , + .type =SND_SOC_TPLG_TUPLE_TYPE_WORD , + .offset = offsetof(struct avs_tplg_modcfg_ext, updown_mix.coefficients[0]), + .parse = avs_parse_word_token, + }, + { + .token =AVS_TKN_MODCFG_UPDOWN_MIX_COEFF_1_S32 , + .type =SND_SOC_TPLG_TUPLE_TYPE_WORD , + .offset = offsetof(struct avs_tplg_modcfg_ext, updown_mix.coefficients[1]), + .parse = avs_parse_word_token, + }, + { + .token =AVS_TKN_MODCFG_UPDOWN_MIX_COEFF_2_S32 , + .type =SND_SOC_TPLG_TUPLE_TYPE_WORD , + .offset = offsetof(struct avs_tplg_modcfg_ext, updown_mix.coefficients[2]), + .parse = avs_parse_word_token, + }, + { + .token =AVS_TKN_MODCFG_UPDOWN_MIX_COEFF_3_S32 , + .type =SND_SOC_TPLG_TUPLE_TYPE_WORD , + .offset = offsetof(struct avs_tplg_modcfg_ext, updown_mix.coefficients[3]), + .parse = avs_parse_word_token, + }, + { + .token =AVS_TKN_MODCFG_UPDOWN_MIX_COEFF_4_S32 , + .type =SND_SOC_TPLG_TUPLE_TYPE_WORD , + .offset = offsetof(struct avs_tplg_modcfg_ext, updown_mix.coefficients[4]), + .parse = avs_parse_word_token, + }, + { + .token =AVS_TKN_MODCFG_UPDOWN_MIX_COEFF_5_S32 , + .type =SND_SOC_TPLG_TUPLE_TYPE_WORD , + .offset = offsetof(struct avs_tplg_modcfg_ext, updown_mix.coefficients[5]), + .parse = avs_parse_word_token, + }, + { + .token =AVS_TKN_MODCFG_UPDOWN_MIX_COEFF_6_S32 , + .type =SND_SOC_TPLG_TUPLE_TYPE_WORD , + .offset = offsetof(struct avs_tplg_modcfg_ext, updown_mix.coefficients[6]), + .parse = avs_parse_word_token, + }, + { + .token =AVS_TKN_MODCFG_UPDOWN_MIX_COEFF_7_S32 , + .type =SND_SOC_TPLG_TUPLE_TYPE_WORD , + .offset = offsetof(struct avs_tplg_modcfg_ext, updown_mix.coefficients[7]), + .parse = avs_parse_word_token, + }, + { + .token =AVS_TKN_MODCFG_UPDOWN_MIX_CHAN_MAP_U32 , + .type =SND_SOC_TPLG_TUPLE_TYPE_WORD , + .offset = offsetof(struct avs_tplg_modcfg_ext, updown_mix.channel_map), + .parse = avs_parse_word_token, + }, + { + .token =AVS_TKN_MODCFG_EXT_NUM_INPUT_PINS_U16 , + .type =SND_SOC_TPLG_TUPLE_TYPE_SHORT , + .offset = offsetof(struct avs_tplg_modcfg_ext, generic.num_input_pins), + .parse = avs_parse_short_token, + }, + { + .token =AVS_TKN_MODCFG_EXT_NUM_OUTPUT_PINS_U16 , + .type =SND_SOC_TPLG_TUPLE_TYPE_SHORT , + .offset = offsetof(struct avs_tplg_modcfg_ext, generic.num_output_pins), + .parse = avs_parse_short_token, + }, +}; + +static const struct avs_tplg_token_parser pin_format_parsers[] = { + { + .token =AVS_TKN_PIN_FMT_INDEX_U32 , + .type =SND_SOC_TPLG_TUPLE_TYPE_WORD , + .offset = offsetof(struct avs_tplg_pin_format , pin_index), + .parse = avs_parse_word_token, + }, + { + .token =AVS_TKN_PIN_FMT_IOBS_U32 , + .type =SND_SOC_TPLG_TUPLE_TYPE_WORD , + .offset = offsetof(struct avs_tplg_pin_format , iobs), + .parse = avs_parse_word_token, + }, + { + .token =AVS_TKN_PIN_FMT_AFMT_ID_U32 , + .type =SND_SOC_TPLG_TUPLE_TYPE_WORD , + .offset = offsetof(struct avs_tplg_pin_format , fmt), + .parse = avs_parse_audio_format_ptr, + }, +}; + +static int avs_tplg_parse_modcfg_ext (struct snd_soc_component *comp, +struct avs_tplg_modcfg_ext *cfg, +struct snd_soc_tplg_vendor_array *tuples, +u32 block_size) +{ +u32 esize; +int ret; + +/* See where pin block starts. */ + ret =avs_tplg_vendor_entry_size (tuples, block_size, +AVS_TKN_PIN_FMT_INDEX_U32 , &esize); +if (ret) +return ret; + + ret =avs_parse_tokens (comp, cfg, modcfg_ext_parsers, +ARRAY_SIZE (modcfg_ext_parsers), tuples, esize); +if (ret) +return ret; + + block_size -= esize; +/* Parse trailing in/out pin formats if any. */ +if (block_size) { +struct avs_tplg_pin_format *pins; +u32 num_pins; + + num_pins = cfg->generic.num_input_pins + cfg->generic.num_output_pins; +if (!num_pins) +return -EINVAL ; + + pins =devm_kcalloc (comp->card->dev, num_pins,sizeof (*pins),GFP_KERNEL ); +if (!pins) +return -ENOMEM ; + + tuples =avs_tplg_vendor_array_at (tuples, esize); + ret =parse_dictionary_entries (comp, tuples, block_size, + pins, num_pins,sizeof (*pins), +AVS_TKN_PIN_FMT_INDEX_U32 , + pin_format_parsers, +ARRAY_SIZE (pin_format_parsers)); +if (ret) +return ret; + cfg->generic.pin_fmts = pins; + } + +return 0 ; +} + +static int avs_tplg_parse_modcfgs_ext (struct snd_soc_component *comp, +struct snd_soc_tplg_vendor_array *tuples, +u32 block_size) +{ +struct avs_soc_component *acomp =to_avs_soc_component (comp); +struct avs_tplg *tplg = acomp->tplg; +int ret, i; + + ret =parse_dictionary_header (comp, tuples, (void **)&tplg->modcfgs_ext, + &tplg->num_modcfgs_ext, +sizeof (*tplg->modcfgs_ext), +AVS_TKN_MANIFEST_NUM_MODCFGS_EXT_U32 ); +if (ret) +return ret; + + block_size -=le32_to_cpu (tuples->size); +/* With header parsed, move on to parsing entries. */ + tuples =avs_tplg_vendor_array_next (tuples); + +for (i =0 ; i < tplg->num_modcfgs_ext; i++) { +struct avs_tplg_modcfg_ext *cfg = &tplg->modcfgs_ext[i]; +u32 esize; + + ret =avs_tplg_vendor_entry_size (tuples, block_size, +AVS_TKN_MODCFG_EXT_ID_U32 , &esize); +if (ret) +return ret; + + ret =avs_tplg_parse_modcfg_ext (comp, cfg, tuples, esize); +if (ret) +return ret; + + block_size -= esize; + tuples =avs_tplg_vendor_array_at (tuples, esize); + } + +return 0 ; +}
sound/soc/intel/avs/topology.h +59 -0
69 lines not on this page · raw message
Signature · 1 line
2.25.1
Cezary Rojewski
maintainerPATCH 4/14 ASoC: Intel: avs: Parse pplcfg and binding tuples
In reply to Cezary RojewskiPath in ADSP firmware is represented by one or more pipelines. Just like modules, these are described by a config structure. Add parsing helpers to support loading such information from the topology file.
--- sound/soc/intel/avs/topology.c | 114 +++++++++++++++++++++++++++++++++ sound/soc/intel/avs/topology.h | 28 ++++++++ 2 files changed, 142 insertions(+)
sound/soc/intel/avs/topology.c +114 -0
@@ -345,6 +345,8 @@ avs_parse_##name##_ptr(struct snd_soc_component *comp, void *elem, void *object, AVS_DEFINE_PTR_PARSER(audio_format, struct avs_audio_format, fmts); AVS_DEFINE_PTR_PARSER(modcfg_base, struct avs_tplg_modcfg_base, modcfgs_base); AVS_DEFINE_PTR_PARSER(modcfg_ext, struct avs_tplg_modcfg_ext, modcfgs_ext); +AVS_DEFINE_PTR_PARSER(pplcfg, struct avs_tplg_pplcfg, pplcfgs); +AVS_DEFINE_PTR_PARSER(binding, struct avs_tplg_binding, bindings);static int parse_audio_format_bitfield (struct snd_soc_component *comp,void *elem,void *object,u32 offset)
@@ -890,3 +892,115 @@ static int avs_tplg_parse_modcfgs_ext(struct snd_soc_component *comp,return 0 ; } + +static const struct avs_tplg_token_parser pplcfg_parsers[] = { + { + .token =AVS_TKN_PPLCFG_REQ_SIZE_U16 , + .type =SND_SOC_TPLG_TUPLE_TYPE_SHORT , + .offset = offsetof(struct avs_tplg_pplcfg , req_size), + .parse = avs_parse_short_token, + }, + { + .token =AVS_TKN_PPLCFG_PRIORITY_U8 , + .type =SND_SOC_TPLG_TUPLE_TYPE_BYTE , + .offset = offsetof(struct avs_tplg_pplcfg , priority), + .parse = avs_parse_byte_token, + }, + { + .token =AVS_TKN_PPLCFG_LOW_POWER_BOOL , + .type =SND_SOC_TPLG_TUPLE_TYPE_BOOL , + .offset = offsetof(struct avs_tplg_pplcfg , lp), + .parse = avs_parse_bool_token, + }, + { + .token =AVS_TKN_PPLCFG_ATTRIBUTES_U16 , + .type =SND_SOC_TPLG_TUPLE_TYPE_SHORT , + .offset = offsetof(struct avs_tplg_pplcfg , attributes), + .parse = avs_parse_short_token, + }, + { + .token =AVS_TKN_PPLCFG_TRIGGER_U32 , + .type =SND_SOC_TPLG_TUPLE_TYPE_WORD , + .offset = offsetof(struct avs_tplg_pplcfg , trigger), + .parse = avs_parse_word_token, + }, +}; + +static int avs_tplg_parse_pplcfgs (struct snd_soc_component *comp, +struct snd_soc_tplg_vendor_array *tuples, +u32 block_size) +{ +struct avs_soc_component *acomp =to_avs_soc_component (comp); +struct avs_tplg *tplg = acomp->tplg; + +return parse_dictionary (comp, tuples, block_size, (void **)&tplg->pplcfgs, + &tplg->num_pplcfgs,sizeof (*tplg->pplcfgs), +AVS_TKN_MANIFEST_NUM_PPLCFGS_U32 , +AVS_TKN_PPLCFG_ID_U32 , + pplcfg_parsers,ARRAY_SIZE (pplcfg_parsers)); +} + +static const struct avs_tplg_token_parser binding_parsers[] = { + { + .token =AVS_TKN_BINDING_TARGET_TPLG_NAME_STRING , + .type =SND_SOC_TPLG_TUPLE_TYPE_STRING , + .offset = offsetof(struct avs_tplg_binding , target_tplg_name), + .parse = parse_link_formatted_string, + }, + { + .token =AVS_TKN_BINDING_TARGET_PATH_TMPL_ID_U32 , + .type =SND_SOC_TPLG_TUPLE_TYPE_WORD , + .offset = offsetof(struct avs_tplg_binding , target_path_tmpl_id), + .parse = avs_parse_word_token, + }, + { + .token =AVS_TKN_BINDING_TARGET_PPL_ID_U32 , + .type =SND_SOC_TPLG_TUPLE_TYPE_WORD , + .offset = offsetof(struct avs_tplg_binding , target_ppl_id), + .parse = avs_parse_word_token, + }, + { + .token =AVS_TKN_BINDING_TARGET_MOD_ID_U32 , + .type =SND_SOC_TPLG_TUPLE_TYPE_WORD , + .offset = offsetof(struct avs_tplg_binding , target_mod_id), + .parse = avs_parse_word_token, + }, + { + .token =AVS_TKN_BINDING_TARGET_MOD_PIN_U8 , + .type =SND_SOC_TPLG_TUPLE_TYPE_BYTE , + .offset = offsetof(struct avs_tplg_binding , target_mod_pin), + .parse = avs_parse_byte_token, + }, + { + .token =AVS_TKN_BINDING_MOD_ID_U32 , + .type =SND_SOC_TPLG_TUPLE_TYPE_WORD , + .offset = offsetof(struct avs_tplg_binding , mod_id), + .parse = avs_parse_word_token, + }, + { + .token =AVS_TKN_BINDING_MOD_PIN_U8 , + .type =SND_SOC_TPLG_TUPLE_TYPE_BYTE , + .offset = offsetof(struct avs_tplg_binding , mod_pin), + .parse = avs_parse_byte_token, + }, + { + .token =AVS_TKN_BINDING_IS_SINK_U8 , + .type =SND_SOC_TPLG_TUPLE_TYPE_BYTE , + .offset = offsetof(struct avs_tplg_binding , is_sink), + .parse = avs_parse_byte_token, + }, +}; + +static int avs_tplg_parse_bindings (struct snd_soc_component *comp, +struct snd_soc_tplg_vendor_array *tuples, +u32 block_size) +{ +struct avs_soc_component *acomp =to_avs_soc_component (comp); +struct avs_tplg *tplg = acomp->tplg; + +return parse_dictionary (comp, tuples, block_size, (void **)&tplg->bindings, + &tplg->num_bindings,sizeof (*tplg->bindings), +AVS_TKN_MANIFEST_NUM_BINDINGS_U32 , +AVS_TKN_BINDING_ID_U32 , + binding_parsers,ARRAY_SIZE (binding_parsers)); +}
sound/soc/intel/avs/topology.h +28 -0
@@ -29,6 +29,10 @@ struct avs_tplg {u32 num_modcfgs_base;struct avs_tplg_modcfg_ext *modcfgs_ext;u32 num_modcfgs_ext; +struct avs_tplg_pplcfg *pplcfgs; +u32 num_pplcfgs; +struct avs_tplg_binding *bindings; +u32 num_bindings; };struct avs_tplg_library {
@@ -100,4 +104,28 @@ struct avs_tplg_modcfg_ext { }; }; +/* Specifies path behaviour during PCM ->trigger(START) command. */ +enum avs_tplg_trigger { +AVS_TPLG_TRIGGER_AUTO =0 , +}; + +struct avs_tplg_pplcfg { +u16 req_size; +u8 priority; +bool lp; +u16 attributes; +enum avs_tplg_trigger trigger; +}; + +struct avs_tplg_binding { +char target_tplg_name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN ]; +u32 target_path_tmpl_id; +u32 target_ppl_id; +u32 target_mod_id; +u8 target_mod_pin; +u32 mod_id; +u8 mod_pin; +u8 is_sink; +}; +#endif
Signature · 1 line
2.25.1
Cezary Rojewski
maintainerPATCH 5/14 ASoC: Intel: avs: Parse pipeline and module tuples
In reply to Cezary RojewskiShape of a path on DSP side, that is, the number and the layout of its pipelines and modules is paramount for streaming to be efficient and low power-consuming. Add parsing helpers to support loading such information from the topology file.
--- sound/soc/intel/avs/topology.c | 177 +++++++++++++++++++++++++++++++++ sound/soc/intel/avs/topology.h | 31 ++++++ 2 files changed, 208 insertions(+)
sound/soc/intel/avs/topology.c +177 -0
@@ -1004,3 +1004,180 @@ static int avs_tplg_parse_bindings(struct snd_soc_component *comp,AVS_TKN_BINDING_ID_U32 , binding_parsers, ARRAY_SIZE(binding_parsers)); } + +static const struct avs_tplg_token_parser module_parsers[] = { + { + .token =AVS_TKN_MOD_ID_U32 , + .type =SND_SOC_TPLG_TUPLE_TYPE_WORD , + .offset = offsetof(struct avs_tplg_module , id), + .parse = avs_parse_word_token, + }, + { + .token =AVS_TKN_MOD_MODCFG_BASE_ID_U32 , + .type =SND_SOC_TPLG_TUPLE_TYPE_WORD , + .offset = offsetof(struct avs_tplg_module , cfg_base), + .parse = avs_parse_modcfg_base_ptr, + }, + { + .token =AVS_TKN_MOD_IN_AFMT_ID_U32 , + .type =SND_SOC_TPLG_TUPLE_TYPE_WORD , + .offset = offsetof(struct avs_tplg_module , in_fmt), + .parse = avs_parse_audio_format_ptr, + }, + { + .token =AVS_TKN_MOD_CORE_ID_U8 , + .type =SND_SOC_TPLG_TUPLE_TYPE_BYTE , + .offset = offsetof(struct avs_tplg_module , core_id), + .parse = avs_parse_byte_token, + }, + { + .token =AVS_TKN_MOD_PROC_DOMAIN_U8 , + .type =SND_SOC_TPLG_TUPLE_TYPE_BYTE , + .offset = offsetof(struct avs_tplg_module , domain), + .parse = avs_parse_byte_token, + }, + { + .token =AVS_TKN_MOD_MODCFG_EXT_ID_U32 , + .type =SND_SOC_TPLG_TUPLE_TYPE_WORD , + .offset = offsetof(struct avs_tplg_module , cfg_ext), + .parse = avs_parse_modcfg_ext_ptr, + }, +}; + +static struct avs_tplg_module * +avs_tplg_module_create (struct snd_soc_component *comp,struct avs_tplg_pipeline *owner, +struct snd_soc_tplg_vendor_array *tuples,u32 block_size) +{ +struct avs_tplg_module *module; +int ret; + + module =devm_kzalloc (comp->card->dev,sizeof (*module),GFP_KERNEL ); +if (!module) +return ERR_PTR (-ENOMEM ); + + ret =avs_parse_tokens (comp, module, module_parsers, +ARRAY_SIZE (module_parsers), tuples, block_size); +if (ret <0 ) +return ERR_PTR (ret); + + module->owner = owner; +INIT_LIST_HEAD (&module->node); + +return module; +} + +static const struct avs_tplg_token_parser pipeline_parsers[] = { + { + .token =AVS_TKN_PPL_ID_U32 , + .type =SND_SOC_TPLG_TUPLE_TYPE_WORD , + .offset = offsetof(struct avs_tplg_pipeline , id), + .parse = avs_parse_word_token, + }, + { + .token =AVS_TKN_PPL_PPLCFG_ID_U32 , + .type =SND_SOC_TPLG_TUPLE_TYPE_WORD , + .offset = offsetof(struct avs_tplg_pipeline , cfg), + .parse = avs_parse_pplcfg_ptr, + }, + { + .token =AVS_TKN_PPL_NUM_BINDING_IDS_U32 , + .type =SND_SOC_TPLG_TUPLE_TYPE_WORD , + .offset = offsetof(struct avs_tplg_pipeline , num_bindings), + .parse = avs_parse_word_token, + }, +}; + +static const struct avs_tplg_token_parser bindings_parsers[] = { + { + .token =AVS_TKN_PPL_BINDING_ID_U32 , + .type =SND_SOC_TPLG_TUPLE_TYPE_WORD , + .offset =0 ,/* to treat pipeline->bindings as dictionary */ + .parse = avs_parse_binding_ptr, + }, +}; + +static struct avs_tplg_pipeline * +avs_tplg_pipeline_create (struct snd_soc_component *comp,struct avs_tplg_path *owner, +struct snd_soc_tplg_vendor_array *tuples,u32 block_size) +{ +struct avs_tplg_pipeline *pipeline; +u32 modblk_size, offset; +int ret; + + pipeline =devm_kzalloc (comp->card->dev,sizeof (*pipeline),GFP_KERNEL ); +if (!pipeline) +return ERR_PTR (-ENOMEM ); + + pipeline->owner = owner; +INIT_LIST_HEAD (&pipeline->mod_list); + +/* Pipeline header MUST be followed by at least one module. */ + ret =avs_tplg_vendor_array_lookup (tuples, block_size, +AVS_TKN_MOD_ID_U32 , &offset); +if (!ret && !offset) + ret = -EINVAL ; +if (ret) +return ERR_PTR (ret); + +/* Process header which precedes module sections. */ + ret =avs_parse_tokens (comp, pipeline, pipeline_parsers, +ARRAY_SIZE (pipeline_parsers), tuples, offset); +if (ret <0 ) +return ERR_PTR (ret); + + block_size -= offset; + tuples =avs_tplg_vendor_array_at (tuples, offset); + +/* Optionally, binding sections follow module ones. */ + ret =avs_tplg_vendor_array_lookup_next (tuples, block_size, +AVS_TKN_PPL_BINDING_ID_U32 , &offset); +if (ret) { +if (ret != -ENOENT ) +return ERR_PTR (ret); + +/* Does header information match actual block layout? */ +if (pipeline->num_bindings) +return ERR_PTR (-EINVAL ); + + modblk_size = block_size; + }else { + pipeline->bindings =devm_kcalloc (comp->card->dev, pipeline->num_bindings, +sizeof (*pipeline->bindings),GFP_KERNEL ); +if (!pipeline->bindings) +return ERR_PTR (-ENOMEM ); + + modblk_size = offset; + } + + block_size -= modblk_size; +do { +struct avs_tplg_module *module; +u32 esize; + + ret =avs_tplg_vendor_entry_size (tuples, modblk_size, +AVS_TKN_MOD_ID_U32 , &esize); +if (ret) +return ERR_PTR (ret); + + module =avs_tplg_module_create (comp, pipeline, tuples, esize); +if (IS_ERR (module)) { +dev_err (comp->dev,"parse module failed: %ld\n" , +PTR_ERR (module)); +return ERR_CAST (module); + } + +list_add_tail (&module->node, &pipeline->mod_list); + modblk_size -= esize; + tuples =avs_tplg_vendor_array_at (tuples, esize); + }while (modblk_size >0 ); + +/* What's left is optional range of bindings. */ + ret =parse_dictionary_entries (comp, tuples, block_size, pipeline->bindings, + pipeline->num_bindings,sizeof (*pipeline->bindings), +AVS_TKN_PPL_BINDING_ID_U32 , + bindings_parsers,ARRAY_SIZE (bindings_parsers)); +if (ret) +return ERR_PTR (ret); + +return pipeline; +}
sound/soc/intel/avs/topology.h +31 -0
@@ -128,4 +128,35 @@ struct avs_tplg_binding { u8 is_sink; }; +struct avs_tplg_path { +u32 id; +}; + +struct avs_tplg_pipeline { +u32 id; + +struct avs_tplg_pplcfg *cfg; +struct avs_tplg_binding **bindings; +u32 num_bindings; +struct list_head mod_list; + +struct avs_tplg_path *owner; +/* Path pipelines management. */ +struct list_head node; +}; + +struct avs_tplg_module { +u32 id; + +struct avs_tplg_modcfg_base *cfg_base; +struct avs_audio_format *in_fmt; +u8 core_id; +u8 domain; +struct avs_tplg_modcfg_ext *cfg_ext; + +struct avs_tplg_pipeline *owner; +/* Pipeline modules management. */ +struct list_head node; +}; +#endif
Signature · 1 line
2.25.1
Cezary Rojewski
maintainerPATCH 6/14 ASoC: Intel: avs: Parse path and path templates tuples
In reply to Cezary RojewskiPath template is similar to path description found in skylake-driver and it describes how given path shall look like in runtime - number of modules and pipelines that shape it and how they are laid out. It is tied to DAPM widget's (representing either a FE or a BE) private data.
Depending on the number of audio formats supported, each path template may carry one or more descriptions of given path. During runtime, when audio format is known, description matching said format is selected and used when instantiating path on ADSP firmware side through IPCs.
Add parsing helpers to support loading such information from the topology file.
--- sound/soc/intel/avs/topology.c | 158 +++++++++++++++++++++++++++++++++ sound/soc/intel/avs/topology.h | 27 ++++++ 2 files changed, 185 insertions(+)
sound/soc/intel/avs/topology.c +158 -0
@@ -1181,3 +1181,161 @@ avs_tplg_pipeline_create(struct snd_soc_component *comp, struct avs_tplg_path *oreturn pipeline; } + +static const struct avs_tplg_token_parser path_parsers[] = { + { + .token =AVS_TKN_PATH_ID_U32 , + .type =SND_SOC_TPLG_TUPLE_TYPE_WORD , + .offset = offsetof(struct avs_tplg_path , id), + .parse = avs_parse_word_token, + }, + { + .token =AVS_TKN_PATH_FE_FMT_ID_U32 , + .type =SND_SOC_TPLG_TUPLE_TYPE_WORD , + .offset = offsetof(struct avs_tplg_path , fe_fmt), + .parse = avs_parse_audio_format_ptr, + }, + { + .token =AVS_TKN_PATH_BE_FMT_ID_U32 , + .type =SND_SOC_TPLG_TUPLE_TYPE_WORD , + .offset = offsetof(struct avs_tplg_path , be_fmt), + .parse = avs_parse_audio_format_ptr, + }, +}; + +static struct avs_tplg_path * +avs_tplg_path_create (struct snd_soc_component *comp,struct avs_tplg_path_template *owner, +struct snd_soc_tplg_vendor_array *tuples,u32 block_size, +const struct avs_tplg_token_parser *parsers,u32 num_parsers) +{ +struct avs_tplg_pipeline *pipeline; +struct avs_tplg_path *path; +u32 offset; +int ret; + + path =devm_kzalloc (comp->card->dev,sizeof (*path),GFP_KERNEL ); +if (!path) +return ERR_PTR (-ENOMEM ); + + path->owner = owner; +INIT_LIST_HEAD (&path->ppl_list); +INIT_LIST_HEAD (&path->node); + +/* Path header MAY be followed by one or more pipelines. */ + ret =avs_tplg_vendor_array_lookup (tuples, block_size, +AVS_TKN_PPL_ID_U32 , &offset); +if (ret == -ENOENT ) + offset = block_size; +else if (ret) +return ERR_PTR (ret); +else if (!offset) +return ERR_PTR (-EINVAL ); + +/* Process header which precedes pipeline sections. */ + ret =avs_parse_tokens (comp, path, parsers, num_parsers, tuples, offset); +if (ret <0 ) +return ERR_PTR (ret); + + block_size -= offset; + tuples =avs_tplg_vendor_array_at (tuples, offset); +while (block_size >0 ) { +u32 esize; + + ret =avs_tplg_vendor_entry_size (tuples, block_size, +AVS_TKN_PPL_ID_U32 , &esize); +if (ret) +return ERR_PTR (ret); + + pipeline =avs_tplg_pipeline_create (comp, path, tuples, esize); +if (IS_ERR (pipeline)) { +dev_err (comp->dev,"parse pipeline failed: %ld\n" , +PTR_ERR (pipeline)); +return ERR_CAST (pipeline); + } + +list_add_tail (&pipeline->node, &path->ppl_list); + block_size -= esize; + tuples =avs_tplg_vendor_array_at (tuples, esize); + } + +return path; +} + +static const struct avs_tplg_token_parser path_tmpl_parsers[] = { + { + .token =AVS_TKN_PATH_TMPL_ID_U32 , + .type =SND_SOC_TPLG_TUPLE_TYPE_WORD , + .offset = offsetof(struct avs_tplg_path_template , id), + .parse = avs_parse_word_token, + }, +}; + +static int parse_path_template (struct snd_soc_component *comp, +struct snd_soc_tplg_vendor_array *tuples,u32 block_size, +struct avs_tplg_path_template *template, +const struct avs_tplg_token_parser *tmpl_tokens,u32 num_tmpl_tokens, +const struct avs_tplg_token_parser *path_tokens,u32 num_path_tokens) +{ +struct avs_tplg_path *path; +u32 offset; +int ret; + +/* Path template header MUST be followed by at least one path variant. */ + ret =avs_tplg_vendor_array_lookup (tuples, block_size, +AVS_TKN_PATH_ID_U32 , &offset); +if (ret) +return ret; + +/* Process header which precedes path variants sections. */ + ret =avs_parse_tokens (comp, template, tmpl_tokens, num_tmpl_tokens, tuples, offset); +if (ret <0 ) +return ret; + + block_size -= offset; + tuples =avs_tplg_vendor_array_at (tuples, offset); +do { +u32 esize; + + ret =avs_tplg_vendor_entry_size (tuples, block_size, +AVS_TKN_PATH_ID_U32 , &esize); +if (ret) +return ret; + + path =avs_tplg_path_create (comp, template, tuples, esize, path_tokens, + num_path_tokens); +if (IS_ERR (path)) { +dev_err (comp->dev,"parse path failed: %ld\n" ,PTR_ERR (path)); +return PTR_ERR (path); + } + +list_add_tail (&path->node, &template->path_list); + block_size -= esize; + tuples =avs_tplg_vendor_array_at (tuples, esize); + }while (block_size >0 ); + +return 0 ; +} + +static struct avs_tplg_path_template * +avs_tplg_path_template_create (struct snd_soc_component *comp,struct avs_tplg *owner, +struct snd_soc_tplg_vendor_array *tuples,u32 block_size) +{ +struct avs_tplg_path_template *template; +int ret; + + template =devm_kzalloc (comp->card->dev,sizeof (*template),GFP_KERNEL ); +if (!template) +return ERR_PTR (-ENOMEM ); + + template->owner = owner;/* Used to access component tplg is assigned to. */ +INIT_LIST_HEAD (&template->path_list); +INIT_LIST_HEAD (&template->node); + + ret =parse_path_template (comp, tuples, block_size, template, path_tmpl_parsers, +ARRAY_SIZE (path_tmpl_parsers), path_parsers, +ARRAY_SIZE (path_parsers)); +if (ret) +return ERR_PTR (ret); + +return template; +}
sound/soc/intel/avs/topology.h +27 -0
@@ -33,6 +33,8 @@ struct avs_tplg {u32 num_pplcfgs;struct avs_tplg_binding *bindings;u32 num_bindings; + +struct list_head path_tmpl_list; };struct avs_tplg_library {
@@ -128,8 +130,33 @@ struct avs_tplg_binding {u8 is_sink; }; +struct avs_tplg_path_template_id { +u32 id; +char tplg_name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN ]; +}; + +struct avs_tplg_path_template { +u32 id; + +struct list_head path_list; + +struct avs_tplg *owner; +/* Driver path templates management. */ +struct list_head node; +}; +struct avs_tplg_path {u32 id; + +/* Path format requirements. */ +struct avs_audio_format *fe_fmt; +struct avs_audio_format *be_fmt; + +struct list_head ppl_list; + +struct avs_tplg_path_template *owner; +/* Path template path-variants management. */ +struct list_head node; };struct avs_tplg_pipeline {
Signature · 1 line
2.25.1
Cezary Rojewski
maintainerPATCH 7/14 ASoC: Intel: avs: Add topology loading operations
In reply to Cezary RojewskiAVS topology is split into two major parts: dictionaries - found within ASoC topology manifest - and path templates.
Add custom handlers for a range of operations available in struct snd_soc_tplg_ops to allow for actually loading the topology file.
--- sound/soc/intel/Kconfig | 1 + sound/soc/intel/avs/Makefile | 3 +- sound/soc/intel/avs/avs.h | 2 + sound/soc/intel/avs/topology.c | 246 ++++++++++++++++++++++++++++++--- sound/soc/intel/avs/topology.h | 5 + 5 files changed, 235 insertions(+), 22 deletions(-)
sound/soc/intel/Kconfig +1 -0
@@ -214,6 +214,7 @@ config SND_SOC_INTEL_AVS depends on PCI && ACPI depends on COMMON_CLK select SND_SOC_ACPI + select SND_SOC_TOPOLOGY select SND_HDA_EXT_CORE select SND_HDA_DSP_LOADER help
sound/soc/intel/avs/Makefile +2 -1
@@ -1,6 +1,7 @@ # SPDX-License-Identifier: GPL-2.0-only -snd-soc-avs-objs := dsp.o ipc.o messages.o utils.o core.o loader.o +snd-soc-avs-objs := dsp.o ipc.o messages.o utils.o core.o loader.o \ + topology.o snd-soc-avs-objs += cldma.o obj-$(CONFIG_SND_SOC_INTEL_AVS) += snd-soc-avs.o
sound/soc/intel/avs/avs.h +2 -0
@@ -258,4 +258,6 @@ struct avs_soc_component {#define to_avs_soc_component (comp) \ container_of(comp, struct avs_soc_component, base) +extern const struct snd_soc_dai_ops avs_dai_fe_ops; +#endif /* __SOUND_SOC_INTEL_AVS_H */
sound/soc/intel/avs/topology.c +225 -21
273 lines not on this page · raw message
sound/soc/intel/avs/topology.h +5 -0
@@ -186,4 +186,9 @@ struct avs_tplg_module { struct list_head node; }; +struct avs_tplg *avs_tplg_new (struct snd_soc_component *comp); + +int avs_load_topology (struct snd_soc_component *comp,const char *filename); +int avs_remove_topology (struct snd_soc_component *comp); +#endif
Signature · 1 line
2.25.1
Cezary Rojewski
maintainerPATCH 8/14 ASoC: Intel: avs: Support link_mask formatted string
In reply to Cezary RojewskiAllow topology to specify formatted strings so machine board's predefined ->link_mask can be used to specify SSP port number automatically.
This is done to help reduce the amount of topology files as many I2S configurations contain codec of the same type with little to no differences in number of scenarios supported - the only difference being the port number codec is connected to.
--- sound/soc/intel/avs/topology.c | 59 ++++++++++++++++++++++++++++++++-- 1 file changed, 57 insertions(+), 2 deletions(-)
sound/soc/intel/avs/topology.c +57 -2
@@ -372,6 +372,26 @@ parse_audio_format_bitfield(struct snd_soc_component *comp, void *elem, void *obreturn 0 ; } +static int parse_link_formatted_string (struct snd_soc_component *comp,void *elem, +void *object,u32 offset) +{ +struct snd_soc_tplg_vendor_string_elem *tuple = elem; +struct snd_soc_acpi_mach *mach =dev_get_platdata (comp->card->dev); +char *val = (char *)((u8 *)object + offset); + +/* +* Dynamic naming - string formats, e.g.: ssp%d - supported only for +* topologies describing single device e.g.: an I2S codec on SSP0. +*/ +if (hweight_long (mach->link_mask) !=1 ) +return avs_parse_string_token (comp, elem, object, offset); + +snprintf (val,SNDRV_CTL_ELEM_ID_NAME_MAXLEN , tuple->string, +__ffs (mach->link_mask)); + +return 0 ; +} + static int parse_dictionary_header(struct snd_soc_component *comp, struct snd_soc_tplg_vendor_array *tuples,
@@ -928,7 +948,7 @@ static const struct avs_tplg_token_parser binding_parsers[] = { .token = AVS_TKN_BINDING_TARGET_TPLG_NAME_STRING, .type = SND_SOC_TPLG_TUPLE_TYPE_STRING, .offset = offsetof(struct avs_tplg_binding, target_tplg_name), - .parse = avs_parse_string_token, + .parse = parse_link_formatted_string, }, { .token = AVS_TKN_BINDING_TARGET_PATH_TMPL_ID_U32,
@@ -1323,6 +1343,31 @@ avs_tplg_path_template_create(struct snd_soc_component *comp, struct avs_tplg *oreturn template; } +static int avs_route_load (struct snd_soc_component *comp,int index, +struct snd_soc_dapm_route *route) +{ +struct snd_soc_acpi_mach *mach =dev_get_platdata (comp->card->dev); +size_t len =SNDRV_CTL_ELEM_ID_NAME_MAXLEN ; +char buf[SNDRV_CTL_ELEM_ID_NAME_MAXLEN ]; +u32 port; + +/* See parse_link_formatted_string() for dynamic naming when(s). */ +if (hweight_long (mach->link_mask) ==1 ) { + port =__ffs (mach->link_mask); + +snprintf (buf, len, route->source, port); +strncpy ((char *)route->source, buf, len); +snprintf (buf, len, route->sink, port); +strncpy ((char *)route->sink, buf, len); +if (route->control) { +snprintf (buf, len, route->control, port); +strncpy ((char *)route->control, buf, len); + } + } + +return 0 ; +} +static int avs_widget_load (struct snd_soc_component *comp,int index,struct snd_soc_dapm_widget *w,struct snd_soc_tplg_dapm_widget *dw)
@@ -1338,6 +1383,15 @@ static int avs_widget_load(struct snd_soc_component *comp, int index, tplg = acomp->tplg; mach =dev_get_platdata (comp->card->dev); +/* See parse_link_formatted_string() for dynamic naming when(s). */ +if (hweight_long (mach->link_mask) ==1 ) { +kfree (w->name); +/* w->name is freed later by soc_tplg_dapm_widget_create() */ + w->name =kasprintf (GFP_KERNEL , dw->name,__ffs (mach->link_mask)); +if (!w->name) +return -ENOMEM ; + } + template =avs_tplg_path_template_create (comp, tplg, dw->priv.array,le32_to_cpu (dw->priv.size));if (IS_ERR (template)) {
@@ -1380,7 +1434,7 @@ static const struct avs_tplg_token_parser manifest_parsers[] = { .token = AVS_TKN_MANIFEST_NAME_STRING, .type = SND_SOC_TPLG_TUPLE_TYPE_STRING, .offset = offsetof(struct avs_tplg, name), - .parse = avs_parse_string_token, + .parse = parse_link_formatted_string, }, { .token = AVS_TKN_MANIFEST_VERSION_U32,
@@ -1498,6 +1552,7 @@ static int avs_manifest(struct snd_soc_component *comp, int index, }static struct snd_soc_tplg_ops avs_tplg_ops = { + .dapm_route_load = avs_route_load, .widget_load = avs_widget_load, .dai_load = avs_dai_load, .link_load = avs_link_load,
Signature · 1 line
2.25.1
Cezary Rojewski
maintainerPATCH 9/14 ASoC: Intel: avs: Declare path and its components
In reply to Cezary RojewskiDeclare representatives for all crucial elements which stream on ADSP side is made of. That covers pipelines and modules subject which are presented by struct avs_path_pipeline and avs_path_module respectively. While struct avs_path_binding and struct avs_path do not represent any object on firmware side directly, they are needed to help track the interconnections and membership of every pipeline and module created.
--- sound/soc/intel/avs/path.h | 60 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 sound/soc/intel/avs/path.h
sound/soc/intel/avs/path.h new file +60 -0
@@ -0,0 +1,60 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* +* Copyright(c) 2021 Intel Corporation. All rights reserved. +* +* Authors: Cezary Rojewski <[email protected]> +* Amadeusz Slawinski <[email protected]> +*/ + +#ifndef __SOUND_SOC_INTEL_AVS_PATH_H +#define __SOUND_SOC_INTEL_AVS_PATH_H + +#include <linux/list.h> +#include "avs.h" +#include "topology.h" + +struct avs_path { +u32 dma_id; +struct list_head ppl_list; +u32 state; + +struct avs_tplg_path *template; +struct avs_dev *owner; +/* device path management */ +struct list_head node; +}; + +struct avs_path_pipeline { +u8 instance_id; +struct list_head mod_list; +struct list_head binding_list; + +struct avs_tplg_pipeline *template; +struct avs_path *owner; +/* path pipelines management */ +struct list_head node; +}; + +struct avs_path_module { +u16 module_id; +u16 instance_id; + +struct avs_tplg_module *template; +struct avs_path_pipeline *owner; +/* pipeline modules management */ +struct list_head node; +}; + +struct avs_path_binding { +struct avs_path_module *source; +u8 source_pin; +struct avs_path_module *sink; +u8 sink_pin; + +struct avs_tplg_binding *template; +struct avs_path_pipeline *owner; +/* pipeline bindings management */ +struct list_head node; +}; + +#endif
Signature · 1 line
2.25.1
Cezary Rojewski
maintainerPATCH 10/14 ASoC: Intel: avs: Path creation and freeing
In reply to Cezary RojewskiTo 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.
--- sound/soc/intel/avs/Makefile | 2 +- sound/soc/intel/avs/avs.h | 6 + sound/soc/intel/avs/path.c | 287 +++++++++++++++++++++++++++++++++++ sound/soc/intel/avs/path.h | 6 + 4 files changed, 300 insertions(+), 1 deletion(-) create mode 100644 sound/soc/intel/avs/path.c
sound/soc/intel/avs/Makefile +1 -1
@@ -1,7 +1,7 @@ # SPDX-License-Identifier: GPL-2.0-only snd-soc-avs-objs := dsp.o ipc.o messages.o utils.o core.o loader.o \ - topology.o + topology.o path.o snd-soc-avs-objs += cldma.o obj-$(CONFIG_SND_SOC_INTEL_AVS) += snd-soc-avs.o
sound/soc/intel/avs/avs.h +6 -0
@@ -105,6 +105,12 @@ struct avs_dev {char **lib_names;struct completion fw_ready; + +struct list_head comp_list; +struct mutex comp_list_mutex; +struct list_head path_list; +spinlock_t path_list_lock; +struct mutex path_mutex; };/* from hda_bus to avs_dev */
sound/soc/intel/avs/path.c new file +287 -0
287 lines not on this page · raw message
sound/soc/intel/avs/path.h +6 -0
@@ -57,4 +57,10 @@ struct avs_path_binding { struct list_head node; }; +void avs_path_free (struct avs_path *path); +struct avs_path *avs_path_create (struct avs_dev *adev,u32 dma_id, +struct avs_tplg_path_template *template, +struct snd_pcm_hw_params *fe_params, +struct snd_pcm_hw_params *be_params); +#endif
Signature · 1 line
2.25.1
kernel test robot
build botRe: [PATCH 10/14] ASoC: Intel: avs: Path creation and freeing
I love your patch! Perhaps something to improve:
Hi Cezary,
I love your patch! Perhaps something to improve:
[auto build test WARNING on broonie-sound/for-next]
[also build test WARNING on tiwai-sound/for-next next-20220328] [cannot apply to v5.17]
[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/intel-lab-lkp/linux/commits/Cezary-Rojewski/ASoC-Intel-avs-Topology-and-path-management/20220329-012230 base: https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next config: arm64-allyesconfig (https://download.01.org/0day-ci/archive/20220329/[email protected]/config) compiler: aarch64-linux-gcc (GCC) 11.2.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# https://github.com/intel-lab-lkp/linux/commit/cd5b9e82ba0830b3e2874f6b88054cf8c09c977d
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Cezary-Rojewski/ASoC-Intel-avs-Topology-and-path-management/20220329-012230 git checkout cd5b9e82ba0830b3e2874f6b88054cf8c09c977d
# save the config file to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross O=build_dir ARCH=arm64 SHELL=/bin/bash sound/soc/intel/avs/
If you fix the issue, kindly add following tag as appropriate
All warnings (new ones prefixed by >>):
sound/soc/intel/avs/path.c: In function 'avs_path_create_unlocked':
>> sound/soc/intel/avs/path.c:232:35: warning: variable 'acomp' set but not used [-Wunused-but-set-variable]
232 | struct avs_soc_component *acomp;
| ^~~~~vim +/acomp +232 sound/soc/intel/avs/path.c
228
229 static struct avs_path *avs_path_create_unlocked(struct avs_dev *adev, u32 dma_id,
230 struct avs_tplg_path *template)
231 {
> 232 struct avs_soc_component *acomp;
233 struct avs_path *path;
234 int ret;
235
236 acomp = to_avs_soc_component(template->owner->owner->comp);
237
238 path = kzalloc(sizeof(*path), GFP_KERNEL);
239 if (!path)
240 return ERR_PTR(-ENOMEM);
241
242 ret = avs_path_init(adev, path, template, dma_id);
243 if (ret < 0)
244 goto err;
245
246 path->state = AVS_PPL_STATE_INVALID;
247 return path;
248 err:
249 avs_path_free_unlocked(path);
250 return ERR_PTR(ret);
251 }
252
Signature · 2 lines
0-DAY CI Kernel Test Service https://01.org/lkp
Cezary Rojewski
maintainerPATCH 11/14 ASoC: Intel: avs: Path state management
In reply to Cezary RojewskiAdd 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.
--- sound/soc/intel/avs/path.c | 130 +++++++++++++++++++++++++++++++++++++ sound/soc/intel/avs/path.h | 5 ++ 2 files changed, 135 insertions(+)
sound/soc/intel/avs/path.c +130 -0
@@ -285,3 +285,133 @@ struct avs_path *avs_path_create(struct avs_dev *adev, u32 dma_id,return path; } + +int avs_path_bind (struct avs_path *path) +{ +struct avs_path_pipeline *ppl; +struct avs_dev *adev = path->owner; +int ret; + +list_for_each_entry (ppl, &path->ppl_list, node) { +struct avs_path_binding *binding; + +list_for_each_entry (binding, &ppl->binding_list, node) { +struct avs_path_module *source, *sink; + + source = binding->source; + sink = binding->sink; + + ret =avs_ipc_bind (adev, source->module_id, + source->instance_id, sink->module_id, + sink->instance_id, binding->sink_pin, + binding->source_pin); +if (ret) { +dev_err (adev->dev,"bind path failed: %d\n" , ret); +return AVS_IPC_RET (ret); + } + } + } + +return 0 ; +} + +int avs_path_unbind (struct avs_path *path) +{ +struct avs_path_pipeline *ppl; +struct avs_dev *adev = path->owner; +int ret; + +list_for_each_entry (ppl, &path->ppl_list, node) { +struct avs_path_binding *binding; + +list_for_each_entry (binding, &ppl->binding_list, node) { +struct avs_path_module *source, *sink; + + source = binding->source; + sink = binding->sink; + + ret =avs_ipc_unbind (adev, source->module_id, + source->instance_id, sink->module_id, + sink->instance_id, binding->sink_pin, + binding->source_pin); +if (ret) { +dev_err (adev->dev,"unbind path failed: %d\n" , ret); +return AVS_IPC_RET (ret); + } + } + } + +return 0 ; +} + +int avs_path_reset (struct avs_path *path) +{ +struct avs_path_pipeline *ppl; +struct avs_dev *adev = path->owner; +int ret; + +if (path->state ==AVS_PPL_STATE_RESET ) +return 0 ; + +list_for_each_entry (ppl, &path->ppl_list, node) { + ret =avs_ipc_set_pipeline_state (adev, ppl->instance_id, +AVS_PPL_STATE_RESET ); +if (ret) { +dev_err (adev->dev,"reset path failed: %d\n" , ret); + path->state =AVS_PPL_STATE_INVALID ; +return AVS_IPC_RET (ret); + } + } + + path->state =AVS_PPL_STATE_RESET ; +return 0 ; +} + +int avs_path_pause (struct avs_path *path) +{ +struct avs_path_pipeline *ppl; +struct avs_dev *adev = path->owner; +int ret; + +if (path->state ==AVS_PPL_STATE_PAUSED ) +return 0 ; + +list_for_each_entry_reverse (ppl, &path->ppl_list, node) { + ret =avs_ipc_set_pipeline_state (adev, ppl->instance_id, +AVS_PPL_STATE_PAUSED ); +if (ret) { +dev_err (adev->dev,"pause path failed: %d\n" , ret); + path->state =AVS_PPL_STATE_INVALID ; +return AVS_IPC_RET (ret); + } + } + + path->state =AVS_PPL_STATE_PAUSED ; +return 0 ; +} + +int avs_path_run (struct avs_path *path,int trigger) +{ +struct avs_path_pipeline *ppl; +struct avs_dev *adev = path->owner; +int ret; + +if (path->state ==AVS_PPL_STATE_RUNNING && trigger ==AVS_TPLG_TRIGGER_AUTO ) +return 0 ; + +list_for_each_entry (ppl, &path->ppl_list, node) { +if (ppl->template->cfg->trigger != trigger) +continue ; + + ret =avs_ipc_set_pipeline_state (adev, ppl->instance_id, +AVS_PPL_STATE_RUNNING ); +if (ret) { +dev_err (adev->dev,"run path failed: %d\n" , ret); + path->state =AVS_PPL_STATE_INVALID ; +return AVS_IPC_RET (ret); + } + } + + path->state =AVS_PPL_STATE_RUNNING ; +return 0 ; +}
sound/soc/intel/avs/path.h +5 -0
@@ -62,5 +62,10 @@ struct avs_path *avs_path_create(struct avs_dev *adev, u32 dma_id,struct avs_tplg_path_template *template, struct snd_pcm_hw_params *fe_params, struct snd_pcm_hw_params *be_params); +int avs_path_bind (struct avs_path *path); +int avs_path_unbind (struct avs_path *path); +int avs_path_reset (struct avs_path *path); +int avs_path_pause (struct avs_path *path); +int avs_path_run (struct avs_path *path,int trigger);#endif
Signature · 1 line
2.25.1
Cezary Rojewski
maintainerPATCH 12/14 ASoC: Intel: avs: Arm paths after creating them
In reply to Cezary RojewskiCreating 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.
--- sound/soc/intel/avs/path.c | 180 +++++++++++++++++++++++++++++++++++++ 1 file changed, 180 insertions(+)
sound/soc/intel/avs/path.c +180 -0
@@ -13,6 +13,73 @@#include "path.h" #include "topology.h" +/* Must be called with adev->comp_list_mutex held. */ +static struct avs_tplg * +avs_path_find_tplg (struct avs_dev *adev,const char *name) +{ +struct avs_soc_component *acomp; + +list_for_each_entry (acomp, &adev->comp_list, node) +if (!strcmp (acomp->tplg->name, name)) +return acomp->tplg; +return NULL ; +} + +static struct avs_path_module * +avs_path_find_module (struct avs_path_pipeline *ppl,u32 template_id) +{ +struct avs_path_module *mod; + +list_for_each_entry (mod, &ppl->mod_list, node) +if (mod->template->id == template_id) +return mod; +return NULL ; +} + +static struct avs_path_pipeline * +avs_path_find_pipeline (struct avs_path *path,u32 template_id) +{ +struct avs_path_pipeline *ppl; + +list_for_each_entry (ppl, &path->ppl_list, node) +if (ppl->template->id == template_id) +return ppl; +return NULL ; +} + +static struct avs_path * +avs_path_find_path (struct avs_dev *adev,const char *name,u32 template_id) +{ +struct avs_tplg_path_template *pos, *template =NULL ; +struct avs_tplg *tplg; +struct avs_path *path; + + tplg =avs_path_find_tplg (adev, name); +if (!tplg) +return NULL ; + +list_for_each_entry (pos, &tplg->path_tmpl_list, node) { +if (pos->id == template_id) { + template = pos; +break ; + } + } +if (!template) +return NULL ; + +spin_lock (&adev->path_list_lock); +/* Only one variant of given path template may be instantiated at a time. */ +list_for_each_entry (path, &adev->path_list, node) { +if (path->template->owner == template) { +spin_unlock (&adev->path_list_lock); +return path; + } + } + +spin_unlock (&adev->path_list_lock); +return NULL ; +} +static bool avs_test_hw_params (struct snd_pcm_hw_params *params,struct avs_audio_format *fmt) {
@@ -75,6 +142,58 @@ avs_path_module_create(struct avs_dev *adev,return mod; } +static int avs_path_binding_arm (struct avs_dev *adev,struct avs_path_binding *binding) +{ +struct avs_path_module *this_mod, *target_mod; +struct avs_path_pipeline *target_ppl; +struct avs_path *target_path; +struct avs_tplg_binding *t; + + t = binding->template; + this_mod =avs_path_find_module (binding->owner, + t->mod_id); +if (!this_mod) { +dev_err (adev->dev,"path mod %d not found\n" , t->mod_id); +return -EINVAL ; + } + +/* update with target_tplg_name too */ + target_path =avs_path_find_path (adev, t->target_tplg_name, + t->target_path_tmpl_id); +if (!target_path) { +dev_err (adev->dev,"target path %s:%d not found\n" , + t->target_tplg_name, t->target_path_tmpl_id); +return -EINVAL ; + } + + target_ppl =avs_path_find_pipeline (target_path, + t->target_ppl_id); +if (!target_ppl) { +dev_err (adev->dev,"target ppl %d not found\n" , t->target_ppl_id); +return -EINVAL ; + } + + target_mod =avs_path_find_module (target_ppl, t->target_mod_id); +if (!target_mod) { +dev_err (adev->dev,"target mod %d not found\n" , t->target_mod_id); +return -EINVAL ; + } + +if (t->is_sink) { + binding->sink = this_mod; + binding->sink_pin = t->mod_pin; + binding->source = target_mod; + binding->source_pin = t->target_mod_pin; + }else { + binding->sink = target_mod; + binding->sink_pin = t->target_mod_pin; + binding->source = this_mod; + binding->source_pin = t->mod_pin; + } + +return 0 ; +} +static void avs_path_binding_free (struct avs_dev *adev,struct avs_path_binding *binding) {kfree (binding);
@@ -97,6 +216,38 @@ static struct avs_path_binding *avs_path_binding_create(struct avs_dev *adev,return binding; } +static int avs_path_pipeline_arm (struct avs_dev *adev, +struct avs_path_pipeline *ppl) +{ +struct avs_path_module *mod; + +list_for_each_entry (mod, &ppl->mod_list, node) { +struct avs_path_module *source, *sink; +int ret; + +/* +* Only one module (so it's implicitly last) or it is the last +* one, either way we don't have next module to bind it to. +*/ +if (mod ==list_last_entry (&ppl->mod_list, + struct avs_path_module, node)) +break ; + +/* bind current module to next module on list */ + source = mod; + sink =list_next_entry (mod, node); +if (!source || !sink) +return -EINVAL ; + + ret =avs_ipc_bind (adev, source->module_id, source->instance_id, + sink->module_id, sink->instance_id,0 ,0 ); +if (ret) +return AVS_IPC_RET (ret); + } + +return 0 ; +} +static void avs_path_pipeline_free (struct avs_dev *adev,struct avs_path_pipeline *ppl) {
@@ -212,6 +363,31 @@ static int avs_path_init(struct avs_dev *adev, struct avs_path *path,return 0 ; } +static int avs_path_arm (struct avs_dev *adev,struct avs_path *path) +{ +struct avs_path_pipeline *ppl; +struct avs_path_binding *binding; +int ret; + +list_for_each_entry (ppl, &path->ppl_list, node) { +/* +* Arm all ppl bindings before binding internal modules +* as it costs no IPCs which isn't true for the latter. +*/ +list_for_each_entry (binding, &ppl->binding_list, node) { + ret =avs_path_binding_arm (adev, binding); +if (ret <0 ) +return ret; + } + + ret =avs_path_pipeline_arm (adev, ppl); +if (ret <0 ) +return ret; + } + +return 0 ; +} +static void avs_path_free_unlocked (struct avs_path *path) {struct avs_path_pipeline *ppl, *save;
@@ -243,6 +419,10 @@ static struct avs_path *avs_path_create_unlocked(struct avs_dev *adev, u32 dma_iif (ret <0 ) goto err; + ret =avs_path_arm (adev, path); +if (ret <0 ) + goto err; + path->state =AVS_PPL_STATE_INVALID ;return path; err:
Signature · 1 line
2.25.1
Cezary Rojewski
maintainerPATCH 13/14 ASoC: Intel: avs: Prepare modules before bindings them
In reply to Cezary RojewskiWhen 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.
--- sound/soc/intel/avs/path.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+)
sound/soc/intel/avs/path.c +35 -0
@@ -466,6 +466,37 @@ struct avs_path *avs_path_create(struct avs_dev *adev, u32 dma_id,return path; } +static int avs_path_bind_prepare (struct avs_dev *adev, +struct avs_path_binding *binding) +{ +const struct avs_audio_format *src_fmt, *sink_fmt; +struct avs_tplg_module *tsource = binding->source->template; +struct avs_path_module *source = binding->source; +int ret; + +/* +* only copier modules about to be bound +* to output pin other than 0 need preparation +*/ +if (!binding->source_pin) +return 0 ; +if (!guid_equal (&tsource->cfg_ext->type, &AVS_COPIER_MOD_UUID )) +return 0 ; + + src_fmt = tsource->in_fmt; + sink_fmt = binding->sink->template->in_fmt; + + ret =avs_ipc_copier_set_sink_format (adev, source->module_id, + source->instance_id, binding->source_pin, + src_fmt, sink_fmt); +if (ret) { +dev_err (adev->dev,"config copier failed: %d\n" , ret); +return AVS_IPC_RET (ret); + } + +return 0 ; +} +int avs_path_bind (struct avs_path *path) {struct avs_path_pipeline *ppl;
@@ -481,6 +512,10 @@ int avs_path_bind(struct avs_path *path) source = binding->source; sink = binding->sink; + ret =avs_path_bind_prepare (adev, binding); +if (ret <0 ) +return ret; + ret = avs_ipc_bind(adev, source->module_id, source->instance_id, sink->module_id, sink->instance_id, binding->sink_pin,
Signature · 1 line
2.25.1
Cezary Rojewski
maintainerPATCH 14/14 ASoC: Intel: avs: Configure modules according to their type
In reply to Cezary RojewskiEach 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.
--- sound/soc/intel/Kconfig | 1 + sound/soc/intel/avs/avs.h | 1 + sound/soc/intel/avs/path.c | 378 ++++++++++++++++++++++++++++++++++++- sound/soc/intel/avs/path.h | 1 + 4 files changed, 380 insertions(+), 1 deletion(-)
sound/soc/intel/Kconfig +1 -0
@@ -217,6 +217,7 @@ config SND_SOC_INTEL_AVS select SND_SOC_TOPOLOGY select SND_HDA_EXT_CORE select SND_HDA_DSP_LOADER + select SND_INTEL_NHLT help Enable support for Intel(R) cAVS 1.5 platforms with DSP capabilities. This includes Skylake, Kabylake, Amberlake and
sound/soc/intel/avs/avs.h +1 -0
@@ -106,6 +106,7 @@ struct avs_dev {struct completion fw_ready; +struct nhlt_acpi_table *nhlt;struct list_head comp_list;struct mutex comp_list_mutex;struct list_head path_list;
sound/soc/intel/avs/path.c +377 -1
396 lines not on this page · raw message
sound/soc/intel/avs/path.h +1 -0
@@ -38,6 +38,7 @@ struct avs_path_pipeline {struct avs_path_module {u16 module_id;u16 instance_id; +union avs_gtw_attributes gtw_attrs;struct avs_tplg_module *template;struct avs_path_pipeline *owner;
Signature · 1 line
2.25.1