1 /* SPDX-License-Identifier: BSD-3-Clause 2 * 3 * Copyright(c) 2021 Intel Corporation. All rights reserved. 4 */ 5 6 /* 7 * This file contains structures that are exact copies of an existing ABI used 8 * by IOT middleware. They are Intel specific and will be used by one middleware. 9 * 10 * Some of the structures may contain programming implementations that makes them 11 * unsuitable for generic use and general usage. 12 * 13 * This code is mostly copied "as-is" from existing C++ interface files hence the use of 14 * different style in places. The intention is to keep the interface as close as possible to 15 * original so it's easier to track changes with IPC host code. 16 */ 17 18 /** 19 * \file include/ipc4/module.h 20 * \brief IPC4 module definitions 21 * NOTE: This ABI uses bit fields and is non portable. 22 */ 23 24 #ifndef __IPC4_MODULE_H__ 25 #define __IPC4_MODULE_H__ 26 27 #include <stdint.h> 28 29 /* TODO: revisit it. Now it aligns with audio sdk 30 * and we will update this value and sdk when more 31 * libraries are supported 32 */ 33 #define IPC4_MAX_SUPPORTED_LIBRARIES 16 34 35 #define SOF_IPC4_DST_QUEUE_ID_BITFIELD_SIZE 3 36 #define SOF_IPC4_SRC_QUEUE_ID_BITFIELD_SIZE 3 37 38 enum sof_ipc4_module_type { 39 SOF_IPC4_MOD_INIT_INSTANCE = 0, 40 SOF_IPC4_MOD_CONFIG_GET = 1, 41 SOF_IPC4_MOD_CONFIG_SET = 2, 42 SOF_IPC4_MOD_LARGE_CONFIG_GET = 3, 43 SOF_IPC4_MOD_LARGE_CONFIG_SET = 4, 44 SOF_IPC4_MOD_BIND = 5, 45 SOF_IPC4_MOD_UNBIND = 6, 46 SOF_IPC4_MOD_SET_DX = 7, 47 SOF_IPC4_MOD_SET_D0IX = 8, 48 SOF_IPC4_MOD_ENTER_MODULE_RESTORE = 9, 49 SOF_IPC4_MOD_EXIT_MODULE_RESTORE = 10, 50 SOF_IPC4_MOD_DELETE_INSTANCE = 11, 51 }; 52 53 /* 54 * Host Driver sends this message to create a new module instance. 55 */ 56 struct ipc4_module_init_ext_init { 57 /**< if it is set to 1, proc_domain should be ignored and processing */ 58 /* domain is RTOS scheduling */ 59 uint32_t rtos_domain : 1; 60 /**< Indicates that GNA is used by a module and additional information */ 61 /* (gna_config) is passed after ExtendedData. */ 62 uint32_t gna_used : 1; 63 uint32_t rsvd_0 : 30; 64 uint32_t rsvd_1[2]; 65 } __attribute__((packed, aligned(4))); 66 67 struct ipc4_module_init_ext_data { 68 struct ipc4_module_init_ext_init extended_init; 69 70 /**< Data (actual size set to param_block_size) */ 71 uint32_t param_data[0]; 72 } __attribute__((packed, aligned(4))); 73 74 struct ipc4_module_init_gna_config { 75 /**< Number of GNA cycles required to process one input frame. */ 76 /* This information is used by DP scheduler to correctly schedule 77 * a DP module. 78 */ 79 uint32_t gna_cpc; 80 uint32_t rsvd; 81 } __attribute__((packed, aligned(4))); 82 83 struct ipc4_module_init_data { 84 /**< Data (actual size set to param_block_size) */ 85 uint32_t param_data[0]; 86 } __attribute__((packed, aligned(4))); 87 88 /*! 89 Created instance is a child element of pipeline identified by the ppl_id 90 specified by the driver. 91 92 The module_id should be set to an index of the module entry in the FW Image 93 Manifest. 94 95 The instance_id assigned by the driver should be in the 96 0..ModuleEntry.max_instance_count range defined in the FW Image Manifest. 97 98 Initial configuration of the module instance is provided by the driver in 99 the param_data array. Size of the array is specified in param_block_size 100 field of the message header. 101 102 Refer to Module Configuration section of FW I/F Specification for details on 103 module specific initial configuration parameters. 104 105 \remark hide_methods 106 */ 107 struct ipc4_module_init_instance { 108 109 union { 110 uint32_t dat; 111 112 struct { 113 /**< module id */ 114 uint32_t module_id : 16; 115 /**< instance id */ 116 uint32_t instance_id : 8; 117 /**< ModuleMsg::INIT_INSTANCE */ 118 uint32_t type : 5; 119 /**< Msg::MSG_REQUEST */ 120 uint32_t rsp : 1; 121 /**< Msg::MODULE_MSG */ 122 uint32_t msg_tgt : 1; 123 uint32_t _reserved_0 : 1; 124 } r; 125 } header; 126 127 union { 128 uint32_t dat; 129 130 struct { 131 /**< Size of Data::param_data[] (in dwords) */ 132 uint32_t param_block_size : 16; 133 /**< ID of module instance's parent pipeline */ 134 uint32_t ppl_instance_id : 8; 135 /**< ID of core that instance will run on */ 136 uint32_t core_id : 4; 137 /**< Processing domain, 0-LL, 1-DP */ 138 uint32_t proc_domain : 1; 139 /* reserved in cAVS */ 140 uint32_t extended_init : 1; 141 uint32_t _hw_reserved_2 : 2; 142 } r; 143 } data; 144 145 struct ipc4_module_init_ext_init ext_init; 146 struct ipc4_module_init_ext_data ext_data; 147 struct ipc4_module_init_gna_config gna_config; 148 struct ipc4_module_init_data init_data; 149 } __attribute__((packed, aligned(4))); 150 151 /*! 152 SW Driver sends Bind IPC message to connect two module instances together 153 creating data processing path between them. 154 155 Unbind IPC message is sent to destroy a connection between two module instances 156 (belonging to different pipelines) previously created with Bind call. 157 158 NOTE: when both module instances are parts of the same pipeline Unbind IPC would 159 be ignored by FW since FW does not support changing internal topology of pipeline 160 during run-time. The only way to change pipeline topology is to delete the whole 161 pipeline and create it in modified form. 162 163 \remark hide_methods 164 */ 165 struct ipc4_module_bind_unbind { 166 union { 167 uint32_t dat; 168 169 struct { 170 /**< module id */ 171 uint32_t module_id : 16; 172 /**< instance id */ 173 uint32_t instance_id : 8; 174 /**< ModuleMsg::BIND / UNBIND. */ 175 uint32_t type : 5; 176 /**< Msg::MSG_REQUEST */ 177 uint32_t rsp : 1; 178 /**< Msg::MODULE_MSG */ 179 uint32_t msg_tgt : 1; 180 uint32_t _reserved_0 : 1; 181 } r; 182 } header; 183 184 union { 185 uint32_t dat; 186 187 struct { 188 /**< destination module id */ 189 uint32_t dst_module_id : 16; 190 /**< destination instance id */ 191 uint32_t dst_instance_id : 8; 192 /**< destination queue (pin) id */ 193 uint32_t dst_queue : SOF_IPC4_DST_QUEUE_ID_BITFIELD_SIZE; 194 /**< source queue (pin) id */ 195 uint32_t src_queue : SOF_IPC4_SRC_QUEUE_ID_BITFIELD_SIZE; 196 uint32_t _reserved_2 : 2; 197 } r; 198 } data; 199 } __attribute__((packed, aligned(4))); 200 201 struct ipc4_module_large_config { 202 union { 203 uint32_t dat; 204 205 struct { 206 /**< module id */ 207 uint32_t module_id : 16; 208 /**< instance id */ 209 uint32_t instance_id : 8; 210 /**< ModuleMsg::LARGE_CONFIG_GET / LARGE_CONFIG_SET */ 211 uint32_t type : 5; 212 /**< Msg::MSG_REQUEST */ 213 uint32_t rsp : 1; 214 /**< Msg::MODULE_MSG */ 215 uint32_t msg_tgt : 1; 216 uint32_t _reserved_0 : 1; 217 } r; 218 } header; 219 220 union { 221 uint32_t dat; 222 223 struct { 224 /**< data size/offset */ 225 uint32_t data_off_size : 20; 226 /**< param type : VENDOR_CONFIG_PARAM / GENERIC_CONFIG_PARAM */ 227 uint32_t large_param_id : 8; 228 /**< 1 if final block */ 229 uint32_t final_block : 1; 230 /**< 1 if first block */ 231 uint32_t init_block : 1; 232 uint32_t _reserved_2 : 2; 233 } r; 234 } data; 235 } __attribute__((packed, aligned(4))); 236 237 struct ipc4_module_delete_instance { 238 union { 239 uint32_t dat; 240 241 struct { 242 uint32_t module_id : 16; 243 uint32_t instance_id : 8; 244 /**< ModuleMsg::DELETE_INSTANCE */ 245 uint32_t type : 5; 246 /**< Msg::MSG_REQUEST */ 247 uint32_t rsp : 1; 248 /**< Msg::MODULE_MSG */ 249 uint32_t msg_tgt : 1; 250 uint32_t _reserved_0 : 1; 251 } r; 252 } header; 253 254 union { 255 uint32_t dat; 256 257 struct { 258 uint32_t rsvd : 30; 259 uint32_t _reserved_1 : 2; 260 } r; 261 } data; 262 } __attribute__((packed, aligned(4))); 263 264 #define IPC4_COMP_ID(x, y) ((x) << 16 | (y)) 265 #define IPC4_MOD_ID(x) ((x) >> 16) 266 #define IPC4_INST_ID(x) ((x) & 0xffff) 267 #define IPC4_SRC_QUEUE_ID(x) (((x) >> 16) & 0xffff) 268 #define IPC4_SINK_QUEUE_ID(x) ((x) & 0xffff) 269 270 #endif 271