1 /* SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause) */ 2 /* 3 * This file is provided under a dual BSD/GPLv2 license. When using or 4 * redistributing this file, you may do so under either license. 5 * 6 * Copyright(c) 2022 Intel Corporation. All rights reserved. 7 */ 8 9 #ifndef __INCLUDE_SOUND_SOF_IPC4_TOPOLOGY_H__ 10 #define __INCLUDE_SOUND_SOF_IPC4_TOPOLOGY_H__ 11 12 #include <sound/sof/ipc4/header.h> 13 14 #define SOF_IPC4_FW_PAGE_SIZE BIT(12) 15 #define SOF_IPC4_FW_PAGE(x) ((((x) + BIT(12) - 1) & ~(BIT(12) - 1)) >> 12) 16 #define SOF_IPC4_FW_ROUNDUP(x) (((x) + BIT(6) - 1) & (~(BIT(6) - 1))) 17 18 #define SOF_IPC4_MODULE_LOAD_TYPE GENMASK(3, 0) 19 #define SOF_IPC4_MODULE_AUTO_START BIT(4) 20 /* 21 * Two module schedule domains in fw : 22 * LL domain - Low latency domain 23 * DP domain - Data processing domain 24 * The LL setting should be equal to !DP setting 25 */ 26 #define SOF_IPC4_MODULE_LL BIT(5) 27 #define SOF_IPC4_MODULE_DP BIT(6) 28 #define SOF_IPC4_MODULE_LIB_CODE BIT(7) 29 #define SOF_IPC4_MODULE_INIT_CONFIG_MASK GENMASK(11, 8) 30 31 #define SOF_IPC4_MODULE_INIT_CONFIG_TYPE_BASE_CFG 0 32 #define SOF_IPC4_MODULE_INIT_CONFIG_TYPE_BASE_CFG_WITH_EXT 1 33 34 #define SOF_IPC4_MODULE_INSTANCE_LIST_ITEM_SIZE 12 35 #define SOF_IPC4_PIPELINE_OBJECT_SIZE 448 36 #define SOF_IPC4_DATA_QUEUE_OBJECT_SIZE 128 37 #define SOF_IPC4_LL_TASK_OBJECT_SIZE 72 38 #define SOF_IPC4_DP_TASK_OBJECT_SIZE 104 39 #define SOF_IPC4_DP_TASK_LIST_SIZE (12 + 8) 40 #define SOF_IPC4_LL_TASK_LIST_ITEM_SIZE 12 41 #define SOF_IPC4_FW_MAX_PAGE_COUNT 20 42 #define SOF_IPC4_FW_MAX_QUEUE_COUNT 8 43 44 /* Node index and mask applicable for host copier and ALH/HDA type DAI copiers */ 45 #define SOF_IPC4_NODE_INDEX_MASK 0xFF 46 #define SOF_IPC4_NODE_INDEX(x) ((x) & SOF_IPC4_NODE_INDEX_MASK) 47 #define SOF_IPC4_NODE_TYPE(x) ((x) << 8) 48 49 /* Node ID for SSP type DAI copiers */ 50 #define SOF_IPC4_NODE_INDEX_INTEL_SSP(x) (((x) & 0xf) << 4) 51 52 /* Node ID for DMIC type DAI copiers */ 53 #define SOF_IPC4_NODE_INDEX_INTEL_DMIC(x) ((x) & 0x7) 54 55 #define SOF_IPC4_GAIN_ALL_CHANNELS_MASK 0xffffffff 56 #define SOF_IPC4_VOL_ZERO_DB 0x7fffffff 57 58 #define ALH_MAX_NUMBER_OF_GTW 16 59 60 #define SOF_IPC4_INVALID_NODE_ID 0xffffffff 61 62 /* FW requires minimum 2ms DMA buffer size */ 63 #define SOF_IPC4_MIN_DMA_BUFFER_SIZE 2 64 65 /* 66 * The base of multi-gateways. Multi-gateways addressing starts from 67 * ALH_MULTI_GTW_BASE and there are ALH_MULTI_GTW_COUNT multi-sources 68 * and ALH_MULTI_GTW_COUNT multi-sinks available. 69 * Addressing is continuous from ALH_MULTI_GTW_BASE to 70 * ALH_MULTI_GTW_BASE + ALH_MULTI_GTW_COUNT - 1. 71 */ 72 #define ALH_MULTI_GTW_BASE 0x50 73 /* A magic number from FW */ 74 #define ALH_MULTI_GTW_COUNT 8 75 76 enum sof_ipc4_copier_module_config_params { 77 /* 78 * Use LARGE_CONFIG_SET to initialize timestamp event. Ipc mailbox must 79 * contain properly built CopierConfigTimestampInitData struct. 80 */ 81 SOF_IPC4_COPIER_MODULE_CFG_PARAM_TIMESTAMP_INIT = 1, 82 /* 83 * Use LARGE_CONFIG_SET to initialize copier sink. Ipc mailbox must contain 84 * properly built CopierConfigSetSinkFormat struct. 85 */ 86 SOF_IPC4_COPIER_MODULE_CFG_PARAM_SET_SINK_FORMAT, 87 /* 88 * Use LARGE_CONFIG_SET to initialize and enable on Copier data segment 89 * event. Ipc mailbox must contain properly built DataSegmentEnabled struct. 90 */ 91 SOF_IPC4_COPIER_MODULE_CFG_PARAM_DATA_SEGMENT_ENABLED, 92 /* 93 * Use LARGE_CONFIG_GET to retrieve Linear Link Position (LLP) value for non 94 * HD-A gateways. 95 */ 96 SOF_IPC4_COPIER_MODULE_CFG_PARAM_LLP_READING, 97 /* 98 * Use LARGE_CONFIG_GET to retrieve Linear Link Position (LLP) value for non 99 * HD-A gateways and corresponding total processed data 100 */ 101 SOF_IPC4_COPIER_MODULE_CFG_PARAM_LLP_READING_EXTENDED, 102 /* 103 * Use LARGE_CONFIG_SET to setup attenuation on output pins. Data is just uint32_t. 104 * note Config is only allowed when output pin is set up for 32bit and source 105 * is connected to Gateway 106 */ 107 SOF_IPC4_COPIER_MODULE_CFG_ATTENUATION, 108 }; 109 110 struct sof_ipc4_copier_config_set_sink_format { 111 /* Id of sink */ 112 u32 sink_id; 113 /* 114 * Input format used by the source 115 * attention must be the same as present if already initialized. 116 */ 117 struct sof_ipc4_audio_format source_fmt; 118 /* Output format used by the sink */ 119 struct sof_ipc4_audio_format sink_fmt; 120 } __packed __aligned(4); 121 122 /** 123 * struct sof_ipc4_pipeline - pipeline config data 124 * @priority: Priority of this pipeline 125 * @lp_mode: Low power mode 126 * @mem_usage: Memory usage 127 * @core_id: Target core for the pipeline 128 * @state: Pipeline state 129 * @msg: message structure for pipeline 130 * @skip_during_fe_trigger: skip triggering this pipeline during the FE DAI trigger 131 */ 132 struct sof_ipc4_pipeline { 133 uint32_t priority; 134 uint32_t lp_mode; 135 uint32_t mem_usage; 136 uint32_t core_id; 137 int state; 138 struct sof_ipc4_msg msg; 139 bool skip_during_fe_trigger; 140 }; 141 142 /** 143 * struct sof_ipc4_multi_pipeline_data - multi pipeline trigger IPC data 144 * @count: Number of pipelines to be triggered 145 * @pipeline_ids: Flexible array of IDs of the pipelines to be triggered 146 */ 147 struct ipc4_pipeline_set_state_data { 148 u32 count; 149 DECLARE_FLEX_ARRAY(u32, pipeline_ids); 150 } __packed; 151 152 /** 153 * struct sof_ipc4_pin_format - Module pin format 154 * @pin_index: pin index 155 * @buffer_size: buffer size in bytes 156 * @audio_fmt: audio format for the pin 157 * 158 * This structure can be used for both output or input pins and the pin_index is relative to the 159 * pin type i.e output/input pin 160 */ 161 struct sof_ipc4_pin_format { 162 u32 pin_index; 163 u32 buffer_size; 164 struct sof_ipc4_audio_format audio_fmt; 165 }; 166 167 /** 168 * struct sof_ipc4_available_audio_format - Available audio formats 169 * @output_pin_fmts: Available output pin formats 170 * @input_pin_fmts: Available input pin formats 171 * @num_input_formats: Number of input pin formats 172 * @num_output_formats: Number of output pin formats 173 */ 174 struct sof_ipc4_available_audio_format { 175 struct sof_ipc4_pin_format *output_pin_fmts; 176 struct sof_ipc4_pin_format *input_pin_fmts; 177 u32 num_input_formats; 178 u32 num_output_formats; 179 }; 180 181 /** 182 * struct sof_copier_gateway_cfg - IPC gateway configuration 183 * @node_id: ID of Gateway Node 184 * @dma_buffer_size: Preferred Gateway DMA buffer size (in bytes) 185 * @config_length: Length of gateway node configuration blob specified in #config_data 186 * config_data: Gateway node configuration blob 187 */ 188 struct sof_copier_gateway_cfg { 189 uint32_t node_id; 190 uint32_t dma_buffer_size; 191 uint32_t config_length; 192 uint32_t config_data[]; 193 }; 194 195 /** 196 * struct sof_ipc4_copier_data - IPC data for copier 197 * @base_config: Base configuration including input audio format 198 * @out_format: Output audio format 199 * @copier_feature_mask: Copier feature mask 200 * @gtw_cfg: Gateway configuration 201 */ 202 struct sof_ipc4_copier_data { 203 struct sof_ipc4_base_module_cfg base_config; 204 struct sof_ipc4_audio_format out_format; 205 uint32_t copier_feature_mask; 206 struct sof_copier_gateway_cfg gtw_cfg; 207 }; 208 209 /** 210 * struct sof_ipc4_gtw_attributes: Gateway attributes 211 * @lp_buffer_alloc: Gateway data requested in low power memory 212 * @alloc_from_reg_file: Gateway data requested in register file memory 213 * @rsvd: reserved for future use 214 */ 215 struct sof_ipc4_gtw_attributes { 216 uint32_t lp_buffer_alloc : 1; 217 uint32_t alloc_from_reg_file : 1; 218 uint32_t rsvd : 30; 219 }; 220 221 /** struct sof_ipc4_alh_multi_gtw_cfg: ALH gateway cfg data 222 * @count: Number of streams (valid items in mapping array) 223 * @alh_id: ALH stream id of a single ALH stream aggregated 224 * @channel_mask: Channel mask 225 * @mapping: ALH streams 226 */ 227 struct sof_ipc4_alh_multi_gtw_cfg { 228 uint32_t count; 229 struct { 230 uint32_t alh_id; 231 uint32_t channel_mask; 232 } mapping[ALH_MAX_NUMBER_OF_GTW]; 233 } __packed; 234 235 /** struct sof_ipc4_alh_configuration_blob: ALH blob 236 * @gw_attr: Gateway attributes 237 * @alh_cfg: ALH configuration data 238 */ 239 struct sof_ipc4_alh_configuration_blob { 240 struct sof_ipc4_gtw_attributes gw_attr; 241 struct sof_ipc4_alh_multi_gtw_cfg alh_cfg; 242 }; 243 244 /** 245 * struct sof_ipc4_copier - copier config data 246 * @data: IPC copier data 247 * @copier_config: Copier + blob 248 * @ipc_config_size: Size of copier_config 249 * @available_fmt: Available audio format 250 * @frame_fmt: frame format 251 * @msg: message structure for copier 252 * @gtw_attr: Gateway attributes for copier blob 253 * @dai_type: DAI type 254 * @dai_index: DAI index 255 */ 256 struct sof_ipc4_copier { 257 struct sof_ipc4_copier_data data; 258 u32 *copier_config; 259 uint32_t ipc_config_size; 260 void *ipc_config_data; 261 struct sof_ipc4_available_audio_format available_fmt; 262 u32 frame_fmt; 263 struct sof_ipc4_msg msg; 264 struct sof_ipc4_gtw_attributes *gtw_attr; 265 u32 dai_type; 266 int dai_index; 267 }; 268 269 /** 270 * struct sof_ipc4_ctrl_value_chan: generic channel mapped value data 271 * @channel: Channel ID 272 * @value: gain value 273 */ 274 struct sof_ipc4_ctrl_value_chan { 275 u32 channel; 276 u32 value; 277 }; 278 279 /** 280 * struct sof_ipc4_control_data - IPC data for kcontrol IO 281 * @msg: message structure for kcontrol IO 282 * @index: pipeline ID 283 * @chanv: channel ID and value array used by volume type controls 284 * @data: data for binary kcontrols 285 */ 286 struct sof_ipc4_control_data { 287 struct sof_ipc4_msg msg; 288 int index; 289 290 union { 291 DECLARE_FLEX_ARRAY(struct sof_ipc4_ctrl_value_chan, chanv); 292 DECLARE_FLEX_ARRAY(struct sof_abi_hdr, data); 293 }; 294 }; 295 296 /** 297 * struct sof_ipc4_gain_data - IPC gain blob 298 * @channels: Channels 299 * @init_val: Initial value 300 * @curve_type: Curve type 301 * @reserved: reserved for future use 302 * @curve_duration_l: Curve duration low part 303 * @curve_duration_h: Curve duration high part 304 */ 305 struct sof_ipc4_gain_data { 306 uint32_t channels; 307 uint32_t init_val; 308 uint32_t curve_type; 309 uint32_t reserved; 310 uint32_t curve_duration_l; 311 uint32_t curve_duration_h; 312 } __aligned(8); 313 314 /** 315 * struct sof_ipc4_gain - gain config data 316 * @base_config: IPC base config data 317 * @data: IPC gain blob 318 * @available_fmt: Available audio format 319 * @msg: message structure for gain 320 */ 321 struct sof_ipc4_gain { 322 struct sof_ipc4_base_module_cfg base_config; 323 struct sof_ipc4_gain_data data; 324 struct sof_ipc4_available_audio_format available_fmt; 325 struct sof_ipc4_msg msg; 326 }; 327 328 /** 329 * struct sof_ipc4_mixer - mixer config data 330 * @base_config: IPC base config data 331 * @available_fmt: Available audio format 332 * @msg: IPC4 message struct containing header and data info 333 */ 334 struct sof_ipc4_mixer { 335 struct sof_ipc4_base_module_cfg base_config; 336 struct sof_ipc4_available_audio_format available_fmt; 337 struct sof_ipc4_msg msg; 338 }; 339 340 /** 341 * struct sof_ipc4_src SRC config data 342 * @base_config: IPC base config data 343 * @sink_rate: Output rate for sink module 344 * @available_fmt: Available audio format 345 * @msg: IPC4 message struct containing header and data info 346 */ 347 struct sof_ipc4_src { 348 struct sof_ipc4_base_module_cfg base_config; 349 uint32_t sink_rate; 350 struct sof_ipc4_available_audio_format available_fmt; 351 struct sof_ipc4_msg msg; 352 }; 353 354 /** 355 * struct sof_ipc4_base_module_cfg_ext - base module config extension containing the pin format 356 * information for the module. Both @num_input_pin_fmts and @num_output_pin_fmts cannot be 0 for a 357 * module. 358 * @num_input_pin_fmts: number of input pin formats in the @pin_formats array 359 * @num_output_pin_fmts: number of output pin formats in the @pin_formats array 360 * @reserved: reserved for future use 361 * @pin_formats: flexible array consisting of @num_input_pin_fmts input pin format items followed 362 * by @num_output_pin_fmts output pin format items 363 */ 364 struct sof_ipc4_base_module_cfg_ext { 365 u16 num_input_pin_fmts; 366 u16 num_output_pin_fmts; 367 u8 reserved[12]; 368 DECLARE_FLEX_ARRAY(struct sof_ipc4_pin_format, pin_formats); 369 } __packed; 370 371 /** 372 * struct sof_ipc4_process - process config data 373 * @base_config: IPC base config data 374 * @base_config_ext: Base config extension data for module init 375 * @output_format: Output audio format 376 * @available_fmt: Available audio format 377 * @ipc_config_data: Process module config data 378 * @ipc_config_size: Size of process module config data 379 * @msg: IPC4 message struct containing header and data info 380 * @base_config_ext_size: Size of the base config extension data in bytes 381 * @init_config: Module init config type (SOF_IPC4_MODULE_INIT_CONFIG_TYPE_*) 382 */ 383 struct sof_ipc4_process { 384 struct sof_ipc4_base_module_cfg base_config; 385 struct sof_ipc4_base_module_cfg_ext *base_config_ext; 386 struct sof_ipc4_audio_format output_format; 387 struct sof_ipc4_available_audio_format available_fmt; 388 void *ipc_config_data; 389 uint32_t ipc_config_size; 390 struct sof_ipc4_msg msg; 391 u32 base_config_ext_size; 392 u32 init_config; 393 }; 394 395 #endif 396