211 lines · c
1/* SPDX-License-Identifier: GPL-2.0-only */2/*3 * Copyright(c) 2021 Intel Corporation4 *5 * Authors: Cezary Rojewski <cezary.rojewski@intel.com>6 * Amadeusz Slawinski <amadeuszx.slawinski@linux.intel.com>7 */8 9#ifndef __SOUND_SOC_INTEL_AVS_TPLG_H10#define __SOUND_SOC_INTEL_AVS_TPLG_H11 12#include <linux/list.h>13#include "messages.h"14 15#define INVALID_OBJECT_ID UINT_MAX16 17struct snd_soc_component;18 19struct avs_tplg {20 char name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN];21 u32 version;22 struct snd_soc_component *comp;23 24 struct avs_tplg_library *libs;25 u32 num_libs;26 struct avs_audio_format *fmts;27 u32 num_fmts;28 struct avs_tplg_modcfg_base *modcfgs_base;29 u32 num_modcfgs_base;30 struct avs_tplg_modcfg_ext *modcfgs_ext;31 u32 num_modcfgs_ext;32 struct avs_tplg_pplcfg *pplcfgs;33 u32 num_pplcfgs;34 struct avs_tplg_binding *bindings;35 u32 num_bindings;36 u32 num_condpath_tmpls;37 struct avs_tplg_init_config *init_configs;38 u32 num_init_configs;39 40 struct list_head path_tmpl_list;41};42 43struct avs_tplg_library {44 char name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN];45};46 47/* Matches header of struct avs_mod_cfg_base. */48struct avs_tplg_modcfg_base {49 u32 cpc;50 u32 ibs;51 u32 obs;52 u32 is_pages;53};54 55struct avs_tplg_pin_format {56 u32 pin_index;57 u32 iobs;58 struct avs_audio_format *fmt;59};60 61struct avs_tplg_modcfg_ext {62 guid_t type;63 64 union {65 struct {66 u16 num_input_pins;67 u16 num_output_pins;68 struct avs_tplg_pin_format *pin_fmts;69 } generic;70 struct {71 struct avs_audio_format *out_fmt;72 struct avs_audio_format *blob_fmt; /* optional override */73 u32 feature_mask;74 union avs_virtual_index vindex;75 u32 dma_type;76 u32 dma_buffer_size;77 u32 config_length;78 /* config_data part of priv data */79 } copier;80 struct {81 u32 out_channel_config;82 u32 coefficients_select;83 s32 coefficients[AVS_CHANNELS_MAX];84 u32 channel_map;85 } updown_mix;86 struct {87 u32 out_freq;88 } src;89 struct {90 u32 out_freq;91 u8 mode;92 u8 disable_jitter_buffer;93 } asrc;94 struct {95 u32 cpc_lp_mode;96 } wov;97 struct {98 struct avs_audio_format *ref_fmt;99 struct avs_audio_format *out_fmt;100 u32 cpc_lp_mode;101 } aec;102 struct {103 struct avs_audio_format *ref_fmt;104 struct avs_audio_format *out_fmt;105 } mux;106 struct {107 struct avs_audio_format *out_fmt;108 } micsel;109 };110};111 112/* Specifies path behaviour during PCM ->trigger(START) command. */113enum avs_tplg_trigger {114 AVS_TPLG_TRIGGER_AUTO = 0,115};116 117struct avs_tplg_pplcfg {118 u16 req_size;119 u8 priority;120 bool lp;121 u16 attributes;122 enum avs_tplg_trigger trigger;123};124 125struct avs_tplg_binding {126 char target_tplg_name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN];127 u32 target_path_tmpl_id;128 u32 target_ppl_id;129 u32 target_mod_id;130 u8 target_mod_pin;131 u32 mod_id;132 u8 mod_pin;133 u8 is_sink;134};135 136struct avs_tplg_path_template_id {137 u32 id;138 char tplg_name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN];139};140 141struct avs_tplg_path_template {142 u32 id;143 144 struct snd_soc_dapm_widget *w;145 146 struct list_head path_list;147 148 struct avs_tplg *owner;149 /* Driver path templates management. */150 struct list_head node;151};152 153struct avs_tplg_init_config {154 u32 id;155 156 u8 param;157 size_t length;158 void *data;159};160 161struct avs_tplg_path {162 u32 id;163 164 /* Path format requirements. */165 struct avs_audio_format *fe_fmt;166 struct avs_audio_format *be_fmt;167 168 struct list_head ppl_list;169 170 struct avs_tplg_path_template *owner;171 /* Path template path-variants management. */172 struct list_head node;173};174 175struct avs_tplg_pipeline {176 u32 id;177 178 struct avs_tplg_pplcfg *cfg;179 struct avs_tplg_binding **bindings;180 u32 num_bindings;181 struct list_head mod_list;182 183 struct avs_tplg_path *owner;184 /* Path pipelines management. */185 struct list_head node;186};187 188struct avs_tplg_module {189 u32 id;190 191 struct avs_tplg_modcfg_base *cfg_base;192 struct avs_audio_format *in_fmt;193 u8 core_id;194 u8 domain;195 struct avs_tplg_modcfg_ext *cfg_ext;196 u32 ctl_id;197 u32 num_config_ids;198 u32 *config_ids;199 200 struct avs_tplg_pipeline *owner;201 /* Pipeline modules management. */202 struct list_head node;203};204 205struct avs_tplg *avs_tplg_new(struct snd_soc_component *comp);206 207int avs_load_topology(struct snd_soc_component *comp, const char *filename);208int avs_remove_topology(struct snd_soc_component *comp);209 210#endif211