1 /* SPDX-License-Identifier: GPL-2.0-only */ 2 /* 3 * Copyright(c) 2021 Intel Corporation 4 * 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_H 10 #define __SOUND_SOC_INTEL_AVS_TPLG_H 11 12 #include <linux/list.h> 13 #include "messages.h" 14 15 #define INVALID_OBJECT_ID UINT_MAX 16 17 struct snd_soc_component; 18 19 struct 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 43 struct avs_tplg_library { 44 char name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN]; 45 }; 46 47 /* Matches header of struct avs_mod_cfg_base. */ 48 struct avs_tplg_modcfg_base { 49 u32 cpc; 50 u32 ibs; 51 u32 obs; 52 u32 is_pages; 53 }; 54 55 struct avs_tplg_pin_format { 56 u32 pin_index; 57 u32 iobs; 58 struct avs_audio_format *fmt; 59 }; 60 61 struct 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 } copier; 78 struct { 79 struct avs_audio_format *ref_fmt; 80 struct avs_audio_format *out_fmt; 81 u32 wake_tick_period; 82 union avs_virtual_index vindex; 83 u32 dma_type; 84 u32 dma_buffer_size; 85 struct avs_audio_format *blob_fmt; /* optional override */ 86 } whm; 87 struct { 88 u32 out_channel_config; 89 u32 coefficients_select; 90 s32 coefficients[AVS_COEFF_CHANNELS_MAX]; 91 u32 channel_map; 92 } updown_mix; 93 struct { 94 u32 out_freq; 95 } src; 96 struct { 97 u32 out_freq; 98 u8 mode; 99 u8 disable_jitter_buffer; 100 } asrc; 101 struct { 102 u32 cpc_lp_mode; 103 } wov; 104 struct { 105 struct avs_audio_format *ref_fmt; 106 struct avs_audio_format *out_fmt; 107 u32 cpc_lp_mode; 108 } aec; 109 struct { 110 struct avs_audio_format *ref_fmt; 111 struct avs_audio_format *out_fmt; 112 } mux; 113 struct { 114 struct avs_audio_format *out_fmt; 115 } micsel; 116 struct { 117 u32 target_volume; 118 u32 curve_type; 119 u32 curve_duration; 120 } peakvol; 121 }; 122 }; 123 124 /* Specifies path behaviour during PCM ->trigger(START) command. */ 125 enum avs_tplg_trigger { 126 AVS_TPLG_TRIGGER_AUTO = 0, 127 }; 128 129 struct avs_tplg_pplcfg { 130 u16 req_size; 131 u8 priority; 132 bool lp; 133 u16 attributes; 134 enum avs_tplg_trigger trigger; 135 }; 136 137 struct avs_tplg_binding { 138 char target_tplg_name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN]; 139 u32 target_path_tmpl_id; 140 u32 target_ppl_id; 141 u32 target_mod_id; 142 u8 target_mod_pin; 143 u32 mod_id; 144 u8 mod_pin; 145 u8 is_sink; 146 }; 147 148 struct avs_tplg_path_template_id { 149 u32 id; 150 char tplg_name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN]; 151 }; 152 153 struct avs_tplg_path_template { 154 u32 id; 155 156 struct snd_soc_dapm_widget *w; 157 158 struct list_head path_list; 159 160 struct avs_tplg *owner; 161 /* Driver path templates management. */ 162 struct list_head node; 163 }; 164 165 struct avs_tplg_init_config { 166 u32 id; 167 168 u8 param; 169 size_t length; 170 void *data; 171 }; 172 173 struct avs_tplg_path { 174 u32 id; 175 176 /* Path format requirements. */ 177 struct avs_audio_format *fe_fmt; 178 struct avs_audio_format *be_fmt; 179 180 struct list_head ppl_list; 181 182 struct avs_tplg_path_template *owner; 183 /* Path template path-variants management. */ 184 struct list_head node; 185 }; 186 187 struct avs_tplg_pipeline { 188 u32 id; 189 190 struct avs_tplg_pplcfg *cfg; 191 struct avs_tplg_binding **bindings; 192 u32 num_bindings; 193 struct list_head mod_list; 194 195 struct avs_tplg_path *owner; 196 /* Path pipelines management. */ 197 struct list_head node; 198 }; 199 200 struct avs_tplg_module { 201 u32 id; 202 203 struct avs_tplg_modcfg_base *cfg_base; 204 struct avs_audio_format *in_fmt; 205 u8 core_id; 206 u8 domain; 207 struct avs_tplg_modcfg_ext *cfg_ext; 208 u32 ctl_id; 209 u32 num_config_ids; 210 u32 *config_ids; 211 212 struct avs_tplg_pipeline *owner; 213 /* Pipeline modules management. */ 214 struct list_head node; 215 }; 216 217 struct avs_tplg *avs_tplg_new(struct snd_soc_component *comp); 218 219 int avs_load_topology(struct snd_soc_component *comp, const char *filename); 220 int avs_remove_topology(struct snd_soc_component *comp); 221 222 #endif 223