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/base-config.h 20 * \brief IPC4 global definitions. 21 * NOTE: This ABI uses bit fields and is non portable. 22 */ 23 24 #ifndef __SOF_IPC4_BASE_CONFIG_H__ 25 #define __SOF_IPC4_BASE_CONFIG_H__ 26 27 #include <stdint.h> 28 29 enum ipc4_sampling_frequency { 30 IPC4_FS_8000HZ = 8000, 31 IPC4_FS_11025HZ = 11025, 32 IPC4_FS_12000HZ = 12000, /**< Mp3, AAC, SRC only */ 33 IPC4_FS_16000HZ = 16000, 34 IPC4_FS_18900HZ = 18900, /**< SRC only for 44100 */ 35 IPC4_FS_22050HZ = 22050, 36 IPC4_FS_24000HZ = 24000, /**< Mp3, AAC, SRC only */ 37 IPC4_FS_32000HZ = 32000, 38 IPC4_FS_37800HZ = 37800, /**< SRC only for 44100 */ 39 IPC4_FS_44100HZ = 44100, 40 IPC4_FS_48000HZ = 48000, /**< Default */ 41 IPC4_FS_64000HZ = 64000, /**< AAC, SRC only */ 42 IPC4_FS_88200HZ = 88200, /**< AAC, SRC only */ 43 IPC4_FS_96000HZ = 96000, /**< AAC, SRC only */ 44 IPC4_FS_176400HZ = 176400, /**< SRC only */ 45 IPC4_FS_192000HZ = 192000, /**< SRC only */ 46 IPC4_FS_INVALID 47 }; 48 49 enum ipc4_bit_depth { 50 IPC4_DEPTH_8BIT = 8, /**< 8 bits depth */ 51 IPC4_DEPTH_16BIT = 16, /**< 16 bits depth */ 52 IPC4_DEPTH_24BIT = 24, /**< 24 bits depth - Default */ 53 IPC4_DEPTH_32BIT = 32, /**< 32 bits depth */ 54 IPC4_DEPTH_64BIT = 64, /**< 64 bits depth */ 55 IPC4_DEPTH_INVALID 56 }; 57 58 enum ipc4_channel_config { 59 IPC4_CHANNEL_CONFIG_MONO = 0, /**< one channel only */ 60 IPC4_CHANNEL_CONFIG_STEREO = 1, /**< L & R */ 61 IPC4_CHANNEL_CONFIG_2_POINT_1 = 2, /**< L, R & LFE; PCM only */ 62 IPC4_CHANNEL_CONFIG_3_POINT_0 = 3, /**< L, C & R; MP3 & AAC only */ 63 IPC4_CHANNEL_CONFIG_3_POINT_1 = 4, /**< L, C, R & LFE; PCM only */ 64 IPC4_CHANNEL_CONFIG_QUATRO = 5, /**< L, R, Ls & Rs; PCM only */ 65 IPC4_CHANNEL_CONFIG_4_POINT_0 = 6, /**< L, C, R & Cs; MP3 & AAC only */ 66 IPC4_CHANNEL_CONFIG_5_POINT_0 = 7, /**< L, C, R, Ls & Rs */ 67 IPC4_CHANNEL_CONFIG_5_POINT_1 = 8, /**< L, C, R, Ls, Rs & LFE */ 68 IPC4_CHANNEL_CONFIG_DUAL_MONO = 9, /**< one channel replicated in two */ 69 /**< Stereo (L,R) in 4 slots, 1st stream: [ L, R, -, - ] */ 70 IPC4_CHANNEL_CONFIG_I2S_DUAL_STEREO_0 = 10, 71 /**< Stereo (L,R) in 4 slots, 2nd stream: [ -, -, L, R ] */ 72 IPC4_CHANNEL_CONFIG_I2S_DUAL_STEREO_1 = 11, 73 IPC4_CHANNEL_CONFIG_7_POINT_1 = 12, /**< L, C, R, Ls, Rs & LFE., LS, RS */ 74 IPC4_CHANNEL_CONFIG_INVALID 75 }; 76 77 enum ipc4_channel_index { 78 CHANNEL_LEFT = 0, 79 CHANNEL_CENTER = 1, 80 CHANNEL_RIGHT = 2, 81 CHANNEL_LEFT_SURROUND = 3, 82 CHANNEL_CENTER_SURROUND = 3, 83 CHANNEL_RIGHT_SURROUND = 4, 84 CHANNEL_LEFT_SIDE = 5, 85 CHANNEL_RIGHT_SIDE = 6, 86 CHANNEL_LFE = 7, 87 CHANNEL_INVALID = 0xF, 88 }; 89 90 enum ipc4_interleaved_style { 91 IPC4_CHANNELS_INTERLEAVED = 0, 92 IPC4_CHANNELS_NONINTERLEAVED = 1, 93 }; 94 95 enum ipc4_sample_type { 96 IPC4_TYPE_MSB_INTEGER = 0, /**< integer with Most Significant Byte first */ 97 IPC4_TYPE_LSB_INTEGER = 1, /**< integer with Least Significant Byte first */ 98 IPC4_TYPE_SIGNED_INTEGER = 2, 99 IPC4_TYPE_UNSIGNED_INTEGER = 3, 100 IPC4_TYPE_FLOAT = 4 101 }; 102 103 enum ipc4_stream_type { 104 IPC4_STREAM_PCM = 0, /**< PCM stream */ 105 IPC4_STREAM_MP3 = 1, /**< MP3 encoded stream */ 106 IPC4_STREAM_AAC = 2, /**< AAC encoded stream */ 107 /* TODO: revisit max stream type count. Currently 108 * it aligns with windows audio driver and we will 109 * update all when more types are supported 110 */ 111 IPC4_STREAM_COUNT = 3, 112 IPC4_STREAM_INVALID = 0xFF 113 }; 114 115 struct ipc4_audio_format { 116 enum ipc4_sampling_frequency sampling_frequency; 117 enum ipc4_bit_depth depth; 118 uint32_t ch_map; 119 enum ipc4_channel_config ch_cfg; 120 uint32_t interleaving_style; 121 uint32_t channels_count : 8; 122 uint32_t valid_bit_depth : 8; 123 enum ipc4_sample_type s_type : 8; 124 uint32_t reserved : 8; 125 } __attribute__((packed, aligned(4))); 126 127 struct ipc4_base_module_cfg { 128 uint32_t cpc; /**< the max count of Cycles Per Chunk processing */ 129 uint32_t ibs; /**< input Buffer Size (in bytes) */ 130 uint32_t obs; /**< output Buffer Size (in bytes) */ 131 uint32_t is_pages; /**< number of physical pages used */ 132 struct ipc4_audio_format audio_fmt; 133 } __attribute__((packed, aligned(4))); 134 135 struct ipc4_input_pin_format { 136 uint32_t pin_index; /**< index of the pin */ 137 uint32_t ibs; /**< specifies input frame size (in bytes) */ 138 struct ipc4_audio_format audio_fmt; /**< format of the input data */ 139 } __attribute__((packed, aligned(4))); 140 141 struct ipc4_output_pin_format { 142 uint32_t pin_index; /**< index of the pin */ 143 uint32_t obs; /**< specifies output frame size (in bytes) */ 144 struct ipc4_audio_format audio_fmt; /**< format of the output data */ 145 } __attribute__((packed, aligned(4))); 146 147 struct ipc4_base_module_cfg_ext { 148 /* specifies number of items in input_pins array. Maximum size is 8 */ 149 uint16_t nb_input_pins; 150 /* specifies number of items in output_pins array. Maximum size is 8 */ 151 uint16_t nb_output_pins; 152 uint8_t reserved[12]; 153 /* Specifies format of input pins followed by output pins. 154 * Pin format arrays may be non-continuous i.e. may contain pin #0 format 155 * followed by pin #2 format in case pin #1 will not be in use. 156 * FW assigned format of the pin based on pin_index, not on a position of 157 * the item in the array. Applies to both input and output pins. 158 */ 159 uint8_t pin_formats[]; 160 } __attribute__((packed, aligned(4))); 161 162 #define ipc4_calc_base_module_cfg_ext_size(in_pins, out_pins) \ 163 (sizeof(struct ipc4_base_module_cfg_ext) + \ 164 (in_pins) * sizeof(struct ipc4_input_pin_format) + \ 165 (out_pins) * sizeof(struct ipc4_output_pin_format)) 166 167 /* Struct to combine the base_cfg and base_cfg_ext for easier parsing */ 168 struct ipc4_base_module_extended_cfg { 169 struct ipc4_base_module_cfg base_cfg; 170 struct ipc4_base_module_cfg_ext base_cfg_ext; 171 } __attribute__((packed, aligned(4))); 172 173 /* This enum defines short 16bit parameters common for all modules. 174 * Value of module specific parameters have to be less than 0x3000. 175 */ 176 enum ipc4_base_module_params { 177 /* handled inside LargeConfigGet of module instance */ 178 IPC4_MOD_INST_PROPS = 0xFE, 179 /* handled inside ConfigSet of module instance */ 180 IPC4_MOD_INST_ENABLE = 0x3000 181 }; 182 183 struct ipc4_pin_props { 184 /* type of the connected stream. */ 185 enum ipc4_stream_type stream_type; 186 187 /* audio format of the stream. The content is valid in case of ePcm stream_type. */ 188 struct ipc4_audio_format format; 189 190 /* unique ID of the physical queue connected to the pin. 191 * If there is no queue connected, then -1 (invalid queue ID) is set 192 */ 193 uint32_t phys_queue_id; 194 } __attribute__((packed, aligned(4))); 195 196 struct ipc4_pin_list_info { 197 uint32_t pin_count; 198 struct ipc4_pin_props pin_info[1]; 199 } __attribute__((packed, aligned(4))); 200 201 /* structure describing module instance properties used in response 202 * to module LargeConfigGet with MOD_INST_PROPS parameter. 203 */ 204 struct ipc4_module_instance_props { 205 uint32_t id; 206 uint32_t dp_queue_type; 207 uint32_t queue_alignment; 208 uint32_t cp_usage_mask; 209 uint32_t stack_bytes; 210 uint32_t bss_total_bytes; 211 uint32_t bss_used_bytes; 212 uint32_t ibs_bytes; 213 uint32_t obs_bytes; 214 uint32_t cpc; 215 uint32_t cpc_peak; 216 struct ipc4_pin_list_info input_queues; 217 struct ipc4_pin_list_info output_queues; 218 uint32_t input_gateway; 219 uint32_t output_gateway; 220 } __attribute__((packed, aligned(4))); 221 222 /* Reflects the last two entries in ModuleInstanceProps sttructure */ 223 struct ipc4_in_out_gateway { 224 uint32_t input_gateway; 225 uint32_t output_gateway; 226 } __attribute__((packed, aligned(4))); 227 228 /* this structure may be used by modules to carry 229 * short 16bit parameters as part of the IxC register content. 230 */ 231 union ipc4_cfg_param_id_data { 232 uint32_t dw; 233 struct { 234 uint32_t data16 : 16; /* Input/Output small config data */ 235 uint32_t id : 14; /* input parameter ID */ 236 uint32_t _rsvd : 2; 237 } f; 238 } __attribute__((packed, aligned(4))); 239 240 #endif 241