ASoC: Intel: avs: Topology and path management

Merge series from Cezary Rojewski <cezary.rojewski@intel.com>:

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.
This commit is contained in:
Mark Brown 2022-04-20 14:22:05 +01:00
Родитель 89d2bce7e6 274d79e518
Коммит e1bbfccf3c
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 24D68B725D5487D0
8 изменённых файлов: 3024 добавлений и 1 удалений

Просмотреть файл

@ -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 <cezary.rojewski@intel.com>
* Amadeusz Slawinski <amadeuszx.slawinski@linux.intel.com>
*/
#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

Просмотреть файл

@ -214,8 +214,10 @@ 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
select SND_INTEL_NHLT
help
Enable support for Intel(R) cAVS 1.5 platforms with DSP
capabilities. This includes Skylake, Kabylake, Amberlake and

Просмотреть файл

@ -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 path.o
snd-soc-avs-objs += cldma.o
obj-$(CONFIG_SND_SOC_INTEL_AVS) += snd-soc-avs.o

Просмотреть файл

@ -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
@ -103,6 +105,13 @@ struct avs_dev {
char **lib_names;
struct completion fw_ready;
struct nhlt_acpi_table *nhlt;
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 */
@ -244,4 +253,18 @@ 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)
extern const struct snd_soc_dai_ops avs_dai_fe_ops;
#endif /* __SOUND_SOC_INTEL_AVS_H */

1005
sound/soc/intel/avs/path.c Normal file

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -0,0 +1,72 @@
/* SPDX-License-Identifier: GPL-2.0-only */
/*
* Copyright(c) 2021 Intel Corporation. All rights reserved.
*
* Authors: Cezary Rojewski <cezary.rojewski@intel.com>
* Amadeusz Slawinski <amadeuszx.slawinski@linux.intel.com>
*/
#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;
union avs_gtw_attributes gtw_attrs;
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;
};
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);
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

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -0,0 +1,194 @@
/* SPDX-License-Identifier: GPL-2.0-only */
/*
* Copyright(c) 2021 Intel Corporation. All rights reserved.
*
* Authors: Cezary Rojewski <cezary.rojewski@intel.com>
* Amadeusz Slawinski <amadeuszx.slawinski@linux.intel.com>
*/
#ifndef __SOUND_SOC_INTEL_AVS_TPLG_H
#define __SOUND_SOC_INTEL_AVS_TPLG_H
#include <linux/list.h>
#include "messages.h"
#define INVALID_OBJECT_ID UINT_MAX
struct snd_soc_component;
struct avs_tplg {
char name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN];
u32 version;
struct snd_soc_component *comp;
struct avs_tplg_library *libs;
u32 num_libs;
struct avs_audio_format *fmts;
u32 num_fmts;
struct avs_tplg_modcfg_base *modcfgs_base;
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 list_head path_tmpl_list;
};
struct avs_tplg_library {
char name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN];
};
/* Matches header of struct avs_mod_cfg_base. */
struct avs_tplg_modcfg_base {
u32 cpc;
u32 ibs;
u32 obs;
u32 is_pages;
};
struct avs_tplg_pin_format {
u32 pin_index;
u32 iobs;
struct avs_audio_format *fmt;
};
struct avs_tplg_modcfg_ext {
guid_t type;
union {
struct {
u16 num_input_pins;
u16 num_output_pins;
struct avs_tplg_pin_format *pin_fmts;
} generic;
struct {
struct avs_audio_format *out_fmt;
struct avs_audio_format *blob_fmt; /* optional override */
u32 feature_mask;
union avs_virtual_index vindex;
u32 dma_type;
u32 dma_buffer_size;
u32 config_length;
/* config_data part of priv data */
} copier;
struct {
u32 out_channel_config;
u32 coefficients_select;
s32 coefficients[AVS_CHANNELS_MAX];
u32 channel_map;
} updown_mix;
struct {
u32 out_freq;
} src;
struct {
u32 out_freq;
u8 mode;
u8 disable_jitter_buffer;
} asrc;
struct {
u32 cpc_lp_mode;
} wov;
struct {
struct avs_audio_format *ref_fmt;
struct avs_audio_format *out_fmt;
u32 cpc_lp_mode;
} aec;
struct {
struct avs_audio_format *ref_fmt;
struct avs_audio_format *out_fmt;
} mux;
struct {
struct avs_audio_format *out_fmt;
} micsel;
};
};
/* 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;
};
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 {
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;
};
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