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 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 /* IPC4 sample types */ 45 #define SOF_IPC4_TYPE_MSB_INTEGER 0 46 #define SOF_IPC4_TYPE_LSB_INTEGER 1 47 #define SOF_IPC4_TYPE_SIGNED_INTEGER 2 48 #define SOF_IPC4_TYPE_UNSIGNED_INTEGER 3 49 #define SOF_IPC4_TYPE_FLOAT 4 50 #define SOF_IPC4_TYPE_A_LAW 5 51 #define SOF_IPC4_TYPE_MU_LAW 6 52 53 /* Node index and mask applicable for host copier and ALH/HDA type DAI copiers */ 54 #define SOF_IPC4_NODE_INDEX_MASK 0xFF 55 #define SOF_IPC4_NODE_INDEX(x) ((x) & SOF_IPC4_NODE_INDEX_MASK) 56 #define SOF_IPC4_NODE_TYPE(x) ((x) << 8) 57 #define SOF_IPC4_GET_NODE_TYPE(node_id) ((node_id) >> 8) 58 59 /* Node ID for SSP type DAI copiers */ 60 #define SOF_IPC4_NODE_INDEX_INTEL_SSP(x) (((x) & 0xf) << 4) 61 62 /* Node ID for DMIC type DAI copiers */ 63 #define SOF_IPC4_NODE_INDEX_INTEL_DMIC(x) ((x) & 0x7) 64 65 #define SOF_IPC4_GAIN_ALL_CHANNELS_MASK 0xffffffff 66 #define SOF_IPC4_VOL_ZERO_DB 0x7fffffff 67 68 #define SOF_IPC4_DMA_DEVICE_MAX_COUNT 16 69 70 #define SOF_IPC4_CHAIN_DMA_NODE_ID 0x7fffffff 71 #define SOF_IPC4_INVALID_NODE_ID 0xffffffff 72 73 /* FW requires minimum 2ms DMA buffer size */ 74 #define SOF_IPC4_MIN_DMA_BUFFER_SIZE 2 75 76 /* 77 * The base of multi-gateways. Multi-gateways addressing starts from 78 * ALH_MULTI_GTW_BASE and there are ALH_MULTI_GTW_COUNT multi-sources 79 * and ALH_MULTI_GTW_COUNT multi-sinks available. 80 * Addressing is continuous from ALH_MULTI_GTW_BASE to 81 * ALH_MULTI_GTW_BASE + ALH_MULTI_GTW_COUNT - 1. 82 */ 83 #define ALH_MULTI_GTW_BASE 0x50 84 /* A magic number from FW */ 85 #define ALH_MULTI_GTW_COUNT 8 86 87 enum sof_ipc4_copier_module_config_params { 88 /* 89 * Use LARGE_CONFIG_SET to initialize timestamp event. Ipc mailbox must 90 * contain properly built CopierConfigTimestampInitData struct. 91 */ 92 SOF_IPC4_COPIER_MODULE_CFG_PARAM_TIMESTAMP_INIT = 1, 93 /* 94 * Use LARGE_CONFIG_SET to initialize copier sink. Ipc mailbox must contain 95 * properly built CopierConfigSetSinkFormat struct. 96 */ 97 SOF_IPC4_COPIER_MODULE_CFG_PARAM_SET_SINK_FORMAT, 98 /* 99 * Use LARGE_CONFIG_SET to initialize and enable on Copier data segment 100 * event. Ipc mailbox must contain properly built DataSegmentEnabled struct. 101 */ 102 SOF_IPC4_COPIER_MODULE_CFG_PARAM_DATA_SEGMENT_ENABLED, 103 /* 104 * Use LARGE_CONFIG_GET to retrieve Linear Link Position (LLP) value for non 105 * HD-A gateways. 106 */ 107 SOF_IPC4_COPIER_MODULE_CFG_PARAM_LLP_READING, 108 /* 109 * Use LARGE_CONFIG_GET to retrieve Linear Link Position (LLP) value for non 110 * HD-A gateways and corresponding total processed data 111 */ 112 SOF_IPC4_COPIER_MODULE_CFG_PARAM_LLP_READING_EXTENDED, 113 /* 114 * Use LARGE_CONFIG_SET to setup attenuation on output pins. Data is just uint32_t. 115 * note Config is only allowed when output pin is set up for 32bit and source 116 * is connected to Gateway 117 */ 118 SOF_IPC4_COPIER_MODULE_CFG_ATTENUATION, 119 }; 120 121 /* Scheduling domain, unset, Low Latency, or Data Processing */ 122 enum sof_comp_domain { 123 SOF_COMP_DOMAIN_UNSET = 0, /* Take domain value from manifest */ 124 SOF_COMP_DOMAIN_LL, /* Low Latency scheduling domain */ 125 SOF_COMP_DOMAIN_DP, /* Data Processing scheduling domain */ 126 }; 127 128 struct sof_ipc4_copier_config_set_sink_format { 129 /* Id of sink */ 130 u32 sink_id; 131 /* 132 * Input format used by the source 133 * attention must be the same as present if already initialized. 134 */ 135 struct sof_ipc4_audio_format source_fmt; 136 /* Output format used by the sink */ 137 struct sof_ipc4_audio_format sink_fmt; 138 } __packed __aligned(4); 139 140 /** 141 * struct sof_ipc4_pipeline - pipeline config data 142 * @priority: Priority of this pipeline 143 * @lp_mode: Low power mode 144 * @mem_usage: Memory usage 145 * @core_id: Target core for the pipeline 146 * @state: Pipeline state 147 * @use_chain_dma: flag to indicate if the firmware shall use chained DMA 148 * @msg: message structure for pipeline 149 * @skip_during_fe_trigger: skip triggering this pipeline during the FE DAI trigger 150 */ 151 struct sof_ipc4_pipeline { 152 uint32_t priority; 153 uint32_t lp_mode; 154 uint32_t mem_usage; 155 uint32_t core_id; 156 int state; 157 bool use_chain_dma; 158 struct sof_ipc4_msg msg; 159 bool skip_during_fe_trigger; 160 }; 161 162 /** 163 * struct sof_ipc4_multi_pipeline_data - multi pipeline trigger IPC data 164 * @count: Number of pipelines to be triggered 165 * @pipeline_instance_ids: Flexible array of IDs of the pipelines to be triggered 166 */ 167 struct ipc4_pipeline_set_state_data { 168 u32 count; 169 DECLARE_FLEX_ARRAY(u32, pipeline_instance_ids); 170 } __packed; 171 172 /** 173 * struct sof_ipc4_pin_format - Module pin format 174 * @pin_index: pin index 175 * @buffer_size: buffer size in bytes 176 * @audio_fmt: audio format for the pin 177 * 178 * This structure can be used for both output or input pins and the pin_index is relative to the 179 * pin type i.e output/input pin 180 */ 181 struct sof_ipc4_pin_format { 182 u32 pin_index; 183 u32 buffer_size; 184 struct sof_ipc4_audio_format audio_fmt; 185 }; 186 187 /** 188 * struct sof_ipc4_available_audio_format - Available audio formats 189 * @output_pin_fmts: Available output pin formats 190 * @input_pin_fmts: Available input pin formats 191 * @num_input_formats: Number of input pin formats 192 * @num_output_formats: Number of output pin formats 193 */ 194 struct sof_ipc4_available_audio_format { 195 struct sof_ipc4_pin_format *output_pin_fmts; 196 struct sof_ipc4_pin_format *input_pin_fmts; 197 u32 num_input_formats; 198 u32 num_output_formats; 199 }; 200 201 /** 202 * struct sof_copier_gateway_cfg - IPC gateway configuration 203 * @node_id: ID of Gateway Node 204 * @dma_buffer_size: Preferred Gateway DMA buffer size (in bytes) 205 * @config_length: Length of gateway node configuration blob specified in #config_data 206 * config_data: Gateway node configuration blob 207 */ 208 struct sof_copier_gateway_cfg { 209 uint32_t node_id; 210 uint32_t dma_buffer_size; 211 uint32_t config_length; 212 uint32_t config_data[]; 213 }; 214 215 /** 216 * struct sof_ipc4_copier_data - IPC data for copier 217 * @base_config: Base configuration including input audio format 218 * @out_format: Output audio format 219 * @copier_feature_mask: Copier feature mask 220 * @gtw_cfg: Gateway configuration 221 */ 222 struct sof_ipc4_copier_data { 223 struct sof_ipc4_base_module_cfg base_config; 224 struct sof_ipc4_audio_format out_format; 225 uint32_t copier_feature_mask; 226 struct sof_copier_gateway_cfg gtw_cfg; 227 }; 228 229 /** 230 * struct sof_ipc4_gtw_attributes: Gateway attributes 231 * @lp_buffer_alloc: Gateway data requested in low power memory 232 * @alloc_from_reg_file: Gateway data requested in register file memory 233 * @rsvd: reserved for future use 234 */ 235 struct sof_ipc4_gtw_attributes { 236 uint32_t lp_buffer_alloc : 1; 237 uint32_t alloc_from_reg_file : 1; 238 uint32_t rsvd : 30; 239 }; 240 241 /** 242 * struct sof_ipc4_dma_device_stream_ch_map: abstract representation of 243 * channel mapping to DMAs 244 * @device: representation of hardware device address or FIFO 245 * @channel_mask: channels handled by @device. Channels are expected to be 246 * contiguous 247 */ 248 struct sof_ipc4_dma_device_stream_ch_map { 249 uint32_t device; 250 uint32_t channel_mask; 251 }; 252 253 /** 254 * struct sof_ipc4_dma_stream_ch_map: DMA configuration data 255 * @device_count: Number valid items in mapping array 256 * @mapping: device address and channel mask 257 */ 258 struct sof_ipc4_dma_stream_ch_map { 259 uint32_t device_count; 260 struct sof_ipc4_dma_device_stream_ch_map mapping[SOF_IPC4_DMA_DEVICE_MAX_COUNT]; 261 } __packed; 262 263 #define SOF_IPC4_DMA_METHOD_HDA 1 264 #define SOF_IPC4_DMA_METHOD_GPDMA 2 /* defined for consistency but not used */ 265 266 /** 267 * struct sof_ipc4_dma_config: DMA configuration 268 * @dma_method: HDAudio or GPDMA 269 * @pre_allocated_by_host: 1 if host driver allocates DMA channels, 0 otherwise 270 * @dma_channel_id: for HDaudio defined as @stream_id - 1 271 * @stream_id: HDaudio stream tag 272 * @dma_stream_channel_map: array of device/channel mappings 273 * @dma_priv_config_size: currently not used 274 * @dma_priv_config: currently not used 275 */ 276 struct sof_ipc4_dma_config { 277 uint8_t dma_method; 278 uint8_t pre_allocated_by_host; 279 uint16_t rsvd; 280 uint32_t dma_channel_id; 281 uint32_t stream_id; 282 struct sof_ipc4_dma_stream_ch_map dma_stream_channel_map; 283 uint32_t dma_priv_config_size; 284 uint8_t dma_priv_config[]; 285 } __packed; 286 287 #define SOF_IPC4_GTW_DMA_CONFIG_ID 0x1000 288 289 /** 290 * struct sof_ipc4_dma_config: DMA configuration 291 * @type: set to SOF_IPC4_GTW_DMA_CONFIG_ID 292 * @length: sizeof(struct sof_ipc4_dma_config) + dma_config.dma_priv_config_size 293 * @dma_config: actual DMA configuration 294 */ 295 struct sof_ipc4_dma_config_tlv { 296 uint32_t type; 297 uint32_t length; 298 struct sof_ipc4_dma_config dma_config; 299 } __packed; 300 301 /** struct sof_ipc4_alh_configuration_blob: ALH blob 302 * @gw_attr: Gateway attributes 303 * @alh_cfg: ALH configuration data 304 */ 305 struct sof_ipc4_alh_configuration_blob { 306 struct sof_ipc4_gtw_attributes gw_attr; 307 struct sof_ipc4_dma_stream_ch_map alh_cfg; 308 }; 309 310 /** 311 * struct sof_ipc4_copier - copier config data 312 * @data: IPC copier data 313 * @copier_config: Copier + blob 314 * @ipc_config_size: Size of copier_config 315 * @available_fmt: Available audio format 316 * @frame_fmt: frame format 317 * @msg: message structure for copier 318 * @gtw_attr: Gateway attributes for copier blob 319 * @dai_type: DAI type 320 * @dai_index: DAI index 321 * @dma_config_tlv: DMA configuration 322 */ 323 struct sof_ipc4_copier { 324 struct sof_ipc4_copier_data data; 325 u32 *copier_config; 326 uint32_t ipc_config_size; 327 void *ipc_config_data; 328 struct sof_ipc4_available_audio_format available_fmt; 329 u32 frame_fmt; 330 struct sof_ipc4_msg msg; 331 struct sof_ipc4_gtw_attributes *gtw_attr; 332 u32 dai_type; 333 int dai_index; 334 struct sof_ipc4_dma_config_tlv dma_config_tlv[SOF_IPC4_DMA_DEVICE_MAX_COUNT]; 335 }; 336 337 /** 338 * struct sof_ipc4_ctrl_value_chan: generic channel mapped value data 339 * @channel: Channel ID 340 * @value: Value associated with @channel 341 */ 342 struct sof_ipc4_ctrl_value_chan { 343 u32 channel; 344 u32 value; 345 }; 346 347 /** 348 * struct sof_ipc4_control_data - IPC data for kcontrol IO 349 * @msg: message structure for kcontrol IO 350 * @index: pipeline ID 351 * @chanv: channel ID and value array used by volume type controls 352 * @data: data for binary kcontrols 353 */ 354 struct sof_ipc4_control_data { 355 struct sof_ipc4_msg msg; 356 int index; 357 358 union { 359 DECLARE_FLEX_ARRAY(struct sof_ipc4_ctrl_value_chan, chanv); 360 DECLARE_FLEX_ARRAY(struct sof_abi_hdr, data); 361 }; 362 }; 363 364 #define SOF_IPC4_SWITCH_CONTROL_PARAM_ID 200 365 #define SOF_IPC4_ENUM_CONTROL_PARAM_ID 201 366 367 /** 368 * struct sof_ipc4_control_msg_payload - IPC payload for kcontrol parameters 369 * @id: unique id of the control 370 * @num_elems: Number of elements in the chanv array 371 * @reserved: reserved for future use, must be set to 0 372 * @chanv: channel ID and value array 373 */ 374 struct sof_ipc4_control_msg_payload { 375 uint16_t id; 376 uint16_t num_elems; 377 uint32_t reserved[4]; 378 DECLARE_FLEX_ARRAY(struct sof_ipc4_ctrl_value_chan, chanv); 379 } __packed; 380 381 /** 382 * struct sof_ipc4_gain_params - IPC gain parameters 383 * @channels: Channels 384 * @init_val: Initial value 385 * @curve_type: Curve type 386 * @reserved: reserved for future use 387 * @curve_duration_l: Curve duration low part 388 * @curve_duration_h: Curve duration high part 389 */ 390 struct sof_ipc4_gain_params { 391 uint32_t channels; 392 uint32_t init_val; 393 uint32_t curve_type; 394 uint32_t reserved; 395 uint32_t curve_duration_l; 396 uint32_t curve_duration_h; 397 } __packed __aligned(4); 398 399 /** 400 * struct sof_ipc4_gain_data - IPC gain init blob 401 * @base_config: IPC base config data 402 * @params: Initial parameters for the gain module 403 */ 404 struct sof_ipc4_gain_data { 405 struct sof_ipc4_base_module_cfg base_config; 406 struct sof_ipc4_gain_params params; 407 } __packed __aligned(4); 408 409 /** 410 * struct sof_ipc4_gain - gain config data 411 * @data: IPC gain blob 412 * @available_fmt: Available audio format 413 * @msg: message structure for gain 414 */ 415 struct sof_ipc4_gain { 416 struct sof_ipc4_gain_data data; 417 struct sof_ipc4_available_audio_format available_fmt; 418 struct sof_ipc4_msg msg; 419 }; 420 421 /** 422 * struct sof_ipc4_mixer - mixer config data 423 * @base_config: IPC base config data 424 * @available_fmt: Available audio format 425 * @msg: IPC4 message struct containing header and data info 426 */ 427 struct sof_ipc4_mixer { 428 struct sof_ipc4_base_module_cfg base_config; 429 struct sof_ipc4_available_audio_format available_fmt; 430 struct sof_ipc4_msg msg; 431 }; 432 433 /* 434 * struct sof_ipc4_src_data - IPC data for SRC 435 * @base_config: IPC base config data 436 * @sink_rate: Output rate for sink module 437 */ 438 struct sof_ipc4_src_data { 439 struct sof_ipc4_base_module_cfg base_config; 440 uint32_t sink_rate; 441 } __packed __aligned(4); 442 443 /** 444 * struct sof_ipc4_src - SRC config data 445 * @data: IPC base config data 446 * @available_fmt: Available audio format 447 * @msg: IPC4 message struct containing header and data info 448 */ 449 struct sof_ipc4_src { 450 struct sof_ipc4_src_data data; 451 struct sof_ipc4_available_audio_format available_fmt; 452 struct sof_ipc4_msg msg; 453 }; 454 455 /* 456 * struct sof_ipc4_asrc_data - IPC data for ASRC 457 * @base_config: IPC base config data 458 * @out_freq: Output rate for sink module, passed as such from topology to FW. 459 * @asrc_mode: Control for ASRC features with bit-fields, passed as such from topolgy to FW. 460 */ 461 struct sof_ipc4_asrc_data { 462 struct sof_ipc4_base_module_cfg base_config; 463 uint32_t out_freq; 464 uint32_t asrc_mode; 465 } __packed __aligned(4); 466 467 /** 468 * struct sof_ipc4_asrc - ASRC config data 469 * @data: IPC base config data 470 * @available_fmt: Available audio format 471 * @msg: IPC4 message struct containing header and data info 472 */ 473 struct sof_ipc4_asrc { 474 struct sof_ipc4_asrc_data data; 475 struct sof_ipc4_available_audio_format available_fmt; 476 struct sof_ipc4_msg msg; 477 }; 478 479 /** 480 * struct sof_ipc4_base_module_cfg_ext - base module config extension containing the pin format 481 * information for the module. Both @num_input_pin_fmts and @num_output_pin_fmts cannot be 0 for a 482 * module. 483 * @num_input_pin_fmts: number of input pin formats in the @pin_formats array 484 * @num_output_pin_fmts: number of output pin formats in the @pin_formats array 485 * @reserved: reserved for future use 486 * @pin_formats: flexible array consisting of @num_input_pin_fmts input pin format items followed 487 * by @num_output_pin_fmts output pin format items 488 */ 489 struct sof_ipc4_base_module_cfg_ext { 490 u16 num_input_pin_fmts; 491 u16 num_output_pin_fmts; 492 u8 reserved[12]; 493 DECLARE_FLEX_ARRAY(struct sof_ipc4_pin_format, pin_formats); 494 } __packed; 495 496 /** 497 * struct sof_ipc4_process - process config data 498 * @base_config: IPC base config data 499 * @base_config_ext: Base config extension data for module init 500 * @output_format: Output audio format 501 * @available_fmt: Available audio format 502 * @ipc_config_data: Process module config data 503 * @ipc_config_size: Size of process module config data 504 * @msg: IPC4 message struct containing header and data info 505 * @base_config_ext_size: Size of the base config extension data in bytes 506 * @init_config: Module init config type (SOF_IPC4_MODULE_INIT_CONFIG_TYPE_*) 507 */ 508 struct sof_ipc4_process { 509 struct sof_ipc4_base_module_cfg base_config; 510 struct sof_ipc4_base_module_cfg_ext *base_config_ext; 511 struct sof_ipc4_audio_format output_format; 512 struct sof_ipc4_available_audio_format available_fmt; 513 void *ipc_config_data; 514 uint32_t ipc_config_size; 515 struct sof_ipc4_msg msg; 516 u32 base_config_ext_size; 517 u32 init_config; 518 }; 519 520 bool sof_ipc4_copier_is_single_bitdepth(struct snd_sof_dev *sdev, 521 struct sof_ipc4_pin_format *pin_fmts, 522 u32 pin_fmts_size); 523 #endif 524