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_LL BIT(5) 19 #define SOF_IPC4_MODULE_INSTANCE_LIST_ITEM_SIZE 12 20 #define SOF_IPC4_PIPELINE_OBJECT_SIZE 448 21 #define SOF_IPC4_DATA_QUEUE_OBJECT_SIZE 128 22 #define SOF_IPC4_LL_TASK_OBJECT_SIZE 72 23 #define SOF_IPC4_DP_TASK_OBJECT_SIZE 104 24 #define SOF_IPC4_DP_TASK_LIST_SIZE (12 + 8) 25 #define SOF_IPC4_LL_TASK_LIST_ITEM_SIZE 12 26 #define SOF_IPC4_FW_MAX_PAGE_COUNT 20 27 #define SOF_IPC4_FW_MAX_QUEUE_COUNT 8 28 29 /* Node index and mask applicable for host copier and ALH/HDA type DAI copiers */ 30 #define SOF_IPC4_NODE_INDEX_MASK 0xFF 31 #define SOF_IPC4_NODE_INDEX(x) ((x) & SOF_IPC4_NODE_INDEX_MASK) 32 #define SOF_IPC4_NODE_TYPE(x) ((x) << 8) 33 34 /* Node ID for SSP type DAI copiers */ 35 #define SOF_IPC4_NODE_INDEX_INTEL_SSP(x) (((x) & 0xf) << 4) 36 37 /* Node ID for DMIC type DAI copiers */ 38 #define SOF_IPC4_NODE_INDEX_INTEL_DMIC(x) (((x) & 0x7) << 5) 39 40 #define SOF_IPC4_GAIN_ALL_CHANNELS_MASK 0xffffffff 41 #define SOF_IPC4_VOL_ZERO_DB 0x7fffffff 42 43 #define ALH_MAX_NUMBER_OF_GTW 16 44 45 /* 46 * The base of multi-gateways. Multi-gateways addressing starts from 47 * ALH_MULTI_GTW_BASE and there are ALH_MULTI_GTW_COUNT multi-sources 48 * and ALH_MULTI_GTW_COUNT multi-sinks available. 49 * Addressing is continuous from ALH_MULTI_GTW_BASE to 50 * ALH_MULTI_GTW_BASE + ALH_MULTI_GTW_COUNT - 1. 51 */ 52 #define ALH_MULTI_GTW_BASE 0x50 53 /* A magic number from FW */ 54 #define ALH_MULTI_GTW_COUNT 8 55 56 /** 57 * struct sof_ipc4_pipeline - pipeline config data 58 * @priority: Priority of this pipeline 59 * @lp_mode: Low power mode 60 * @mem_usage: Memory usage 61 * @state: Pipeline state 62 * @msg: message structure for pipeline 63 */ 64 struct sof_ipc4_pipeline { 65 uint32_t priority; 66 uint32_t lp_mode; 67 uint32_t mem_usage; 68 int state; 69 struct sof_ipc4_msg msg; 70 }; 71 72 /** 73 * struct sof_ipc4_available_audio_format - Available audio formats 74 * @base_config: Available base config 75 * @out_audio_fmt: Available output audio format 76 * @ref_audio_fmt: Reference audio format to match runtime audio format 77 * @dma_buffer_size: Available Gateway DMA buffer size (in bytes) 78 * @audio_fmt_num: Number of available audio formats 79 */ 80 struct sof_ipc4_available_audio_format { 81 struct sof_ipc4_base_module_cfg *base_config; 82 struct sof_ipc4_audio_format *out_audio_fmt; 83 struct sof_ipc4_audio_format *ref_audio_fmt; 84 u32 *dma_buffer_size; 85 int audio_fmt_num; 86 }; 87 88 /** 89 * struct sof_copier_gateway_cfg - IPC gateway configuration 90 * @node_id: ID of Gateway Node 91 * @dma_buffer_size: Preferred Gateway DMA buffer size (in bytes) 92 * @config_length: Length of gateway node configuration blob specified in #config_data 93 * config_data: Gateway node configuration blob 94 */ 95 struct sof_copier_gateway_cfg { 96 uint32_t node_id; 97 uint32_t dma_buffer_size; 98 uint32_t config_length; 99 uint32_t config_data[]; 100 }; 101 102 /** 103 * struct sof_ipc4_copier_data - IPC data for copier 104 * @base_config: Base configuration including input audio format 105 * @out_format: Output audio format 106 * @copier_feature_mask: Copier feature mask 107 * @gtw_cfg: Gateway configuration 108 */ 109 struct sof_ipc4_copier_data { 110 struct sof_ipc4_base_module_cfg base_config; 111 struct sof_ipc4_audio_format out_format; 112 uint32_t copier_feature_mask; 113 struct sof_copier_gateway_cfg gtw_cfg; 114 }; 115 116 /** 117 * struct sof_ipc4_gtw_attributes: Gateway attributes 118 * @lp_buffer_alloc: Gateway data requested in low power memory 119 * @alloc_from_reg_file: Gateway data requested in register file memory 120 * @rsvd: reserved for future use 121 */ 122 struct sof_ipc4_gtw_attributes { 123 uint32_t lp_buffer_alloc : 1; 124 uint32_t alloc_from_reg_file : 1; 125 uint32_t rsvd : 30; 126 }; 127 128 /** struct sof_ipc4_alh_multi_gtw_cfg: ALH gateway cfg data 129 * @count: Number of streams (valid items in mapping array) 130 * @alh_id: ALH stream id of a single ALH stream aggregated 131 * @channel_mask: Channel mask 132 * @mapping: ALH streams 133 */ 134 struct sof_ipc4_alh_multi_gtw_cfg { 135 uint32_t count; 136 struct { 137 uint32_t alh_id; 138 uint32_t channel_mask; 139 } mapping[ALH_MAX_NUMBER_OF_GTW]; 140 } __packed; 141 142 /** struct sof_ipc4_alh_configuration_blob: ALH blob 143 * @gw_attr: Gateway attributes 144 * @alh_cfg: ALH configuration data 145 */ 146 struct sof_ipc4_alh_configuration_blob { 147 struct sof_ipc4_gtw_attributes gw_attr; 148 struct sof_ipc4_alh_multi_gtw_cfg alh_cfg; 149 }; 150 151 /** 152 * struct sof_ipc4_copier - copier config data 153 * @data: IPC copier data 154 * @copier_config: Copier + blob 155 * @ipc_config_size: Size of copier_config 156 * @available_fmt: Available audio format 157 * @frame_fmt: frame format 158 * @msg: message structure for copier 159 * @gtw_attr: Gateway attributes for copier blob 160 * @dai_type: DAI type 161 * @dai_index: DAI index 162 */ 163 struct sof_ipc4_copier { 164 struct sof_ipc4_copier_data data; 165 u32 *copier_config; 166 uint32_t ipc_config_size; 167 void *ipc_config_data; 168 struct sof_ipc4_available_audio_format available_fmt; 169 u32 frame_fmt; 170 struct sof_ipc4_msg msg; 171 struct sof_ipc4_gtw_attributes *gtw_attr; 172 u32 dai_type; 173 int dai_index; 174 }; 175 176 /** 177 * struct sof_ipc4_ctrl_value_chan: generic channel mapped value data 178 * @channel: Channel ID 179 * @value: gain value 180 */ 181 struct sof_ipc4_ctrl_value_chan { 182 u32 channel; 183 u32 value; 184 }; 185 186 /** 187 * struct sof_ipc4_control_data - IPC data for kcontrol IO 188 * @msg: message structure for kcontrol IO 189 * @index: pipeline ID 190 * @chanv: channel ID and value array used by volume type controls 191 * @data: data for binary kcontrols 192 */ 193 struct sof_ipc4_control_data { 194 struct sof_ipc4_msg msg; 195 int index; 196 197 union { 198 struct sof_ipc4_ctrl_value_chan chanv[0]; 199 struct sof_abi_hdr data[0]; 200 }; 201 }; 202 203 /** 204 * struct sof_ipc4_gain_data - IPC gain blob 205 * @channels: Channels 206 * @init_val: Initial value 207 * @curve_type: Curve type 208 * @reserved: reserved for future use 209 * @curve_duration: Curve duration 210 */ 211 struct sof_ipc4_gain_data { 212 uint32_t channels; 213 uint32_t init_val; 214 uint32_t curve_type; 215 uint32_t reserved; 216 uint32_t curve_duration; 217 } __aligned(8); 218 219 /** 220 * struct sof_ipc4_gain - gain config data 221 * @base_config: IPC base config data 222 * @data: IPC gain blob 223 * @available_fmt: Available audio format 224 * @msg: message structure for gain 225 */ 226 struct sof_ipc4_gain { 227 struct sof_ipc4_base_module_cfg base_config; 228 struct sof_ipc4_gain_data data; 229 struct sof_ipc4_available_audio_format available_fmt; 230 struct sof_ipc4_msg msg; 231 }; 232 233 /** 234 * struct sof_ipc4_mixer - mixer config data 235 * @base_config: IPC base config data 236 * @available_fmt: Available audio format 237 * @msg: IPC4 message struct containing header and data info 238 */ 239 struct sof_ipc4_mixer { 240 struct sof_ipc4_base_module_cfg base_config; 241 struct sof_ipc4_available_audio_format available_fmt; 242 struct sof_ipc4_msg msg; 243 }; 244 245 #endif 246