1 /* SPDX-License-Identifier: GPL-2.0-only */ 2 /* 3 * Copyright(c) 2021 Intel Corporation. All rights reserved. 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 37 struct list_head path_tmpl_list; 38 }; 39 40 struct avs_tplg_library { 41 char name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN]; 42 }; 43 44 /* Matches header of struct avs_mod_cfg_base. */ 45 struct avs_tplg_modcfg_base { 46 u32 cpc; 47 u32 ibs; 48 u32 obs; 49 u32 is_pages; 50 }; 51 52 struct avs_tplg_pin_format { 53 u32 pin_index; 54 u32 iobs; 55 struct avs_audio_format *fmt; 56 }; 57 58 struct avs_tplg_modcfg_ext { 59 guid_t type; 60 61 union { 62 struct { 63 u16 num_input_pins; 64 u16 num_output_pins; 65 struct avs_tplg_pin_format *pin_fmts; 66 } generic; 67 struct { 68 struct avs_audio_format *out_fmt; 69 struct avs_audio_format *blob_fmt; /* optional override */ 70 u32 feature_mask; 71 union avs_virtual_index vindex; 72 u32 dma_type; 73 u32 dma_buffer_size; 74 u32 config_length; 75 /* config_data part of priv data */ 76 } copier; 77 struct { 78 u32 out_channel_config; 79 u32 coefficients_select; 80 s32 coefficients[AVS_CHANNELS_MAX]; 81 u32 channel_map; 82 } updown_mix; 83 struct { 84 u32 out_freq; 85 } src; 86 struct { 87 u32 out_freq; 88 u8 mode; 89 u8 disable_jitter_buffer; 90 } asrc; 91 struct { 92 u32 cpc_lp_mode; 93 } wov; 94 struct { 95 struct avs_audio_format *ref_fmt; 96 struct avs_audio_format *out_fmt; 97 u32 cpc_lp_mode; 98 } aec; 99 struct { 100 struct avs_audio_format *ref_fmt; 101 struct avs_audio_format *out_fmt; 102 } mux; 103 struct { 104 struct avs_audio_format *out_fmt; 105 } micsel; 106 }; 107 }; 108 109 /* Specifies path behaviour during PCM ->trigger(START) command. */ 110 enum avs_tplg_trigger { 111 AVS_TPLG_TRIGGER_AUTO = 0, 112 }; 113 114 struct avs_tplg_pplcfg { 115 u16 req_size; 116 u8 priority; 117 bool lp; 118 u16 attributes; 119 enum avs_tplg_trigger trigger; 120 }; 121 122 struct avs_tplg_binding { 123 char target_tplg_name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN]; 124 u32 target_path_tmpl_id; 125 u32 target_ppl_id; 126 u32 target_mod_id; 127 u8 target_mod_pin; 128 u32 mod_id; 129 u8 mod_pin; 130 u8 is_sink; 131 }; 132 133 struct avs_tplg_path_template_id { 134 u32 id; 135 char tplg_name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN]; 136 }; 137 138 struct avs_tplg_path_template { 139 u32 id; 140 141 struct snd_soc_dapm_widget *w; 142 143 struct list_head path_list; 144 145 struct avs_tplg *owner; 146 /* Driver path templates management. */ 147 struct list_head node; 148 }; 149 150 struct avs_tplg_path { 151 u32 id; 152 153 /* Path format requirements. */ 154 struct avs_audio_format *fe_fmt; 155 struct avs_audio_format *be_fmt; 156 157 struct list_head ppl_list; 158 159 struct avs_tplg_path_template *owner; 160 /* Path template path-variants management. */ 161 struct list_head node; 162 }; 163 164 struct avs_tplg_pipeline { 165 u32 id; 166 167 struct avs_tplg_pplcfg *cfg; 168 struct avs_tplg_binding **bindings; 169 u32 num_bindings; 170 struct list_head mod_list; 171 172 struct avs_tplg_path *owner; 173 /* Path pipelines management. */ 174 struct list_head node; 175 }; 176 177 struct avs_tplg_module { 178 u32 id; 179 180 struct avs_tplg_modcfg_base *cfg_base; 181 struct avs_audio_format *in_fmt; 182 u8 core_id; 183 u8 domain; 184 struct avs_tplg_modcfg_ext *cfg_ext; 185 u32 ctl_id; 186 187 struct avs_tplg_pipeline *owner; 188 /* Pipeline modules management. */ 189 struct list_head node; 190 }; 191 192 struct avs_tplg *avs_tplg_new(struct snd_soc_component *comp); 193 194 int avs_load_topology(struct snd_soc_component *comp, const char *filename); 195 int avs_remove_topology(struct snd_soc_component *comp); 196 197 #endif 198