xref: /openbmc/linux/sound/soc/sof/ipc4-topology.h (revision 11f373c3)
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 
30 #define SOF_IPC4_MODULE_INSTANCE_LIST_ITEM_SIZE 12
31 #define SOF_IPC4_PIPELINE_OBJECT_SIZE 448
32 #define SOF_IPC4_DATA_QUEUE_OBJECT_SIZE 128
33 #define SOF_IPC4_LL_TASK_OBJECT_SIZE 72
34 #define SOF_IPC4_DP_TASK_OBJECT_SIZE 104
35 #define SOF_IPC4_DP_TASK_LIST_SIZE (12 + 8)
36 #define SOF_IPC4_LL_TASK_LIST_ITEM_SIZE 12
37 #define SOF_IPC4_FW_MAX_PAGE_COUNT 20
38 #define SOF_IPC4_FW_MAX_QUEUE_COUNT 8
39 
40 /* Node index and mask applicable for host copier and ALH/HDA type DAI copiers */
41 #define SOF_IPC4_NODE_INDEX_MASK	0xFF
42 #define SOF_IPC4_NODE_INDEX(x)	((x) & SOF_IPC4_NODE_INDEX_MASK)
43 #define SOF_IPC4_NODE_TYPE(x)  ((x) << 8)
44 
45 /* Node ID for SSP type DAI copiers */
46 #define SOF_IPC4_NODE_INDEX_INTEL_SSP(x) (((x) & 0xf) << 4)
47 
48 /* Node ID for DMIC type DAI copiers */
49 #define SOF_IPC4_NODE_INDEX_INTEL_DMIC(x) ((x) & 0x7)
50 
51 #define SOF_IPC4_GAIN_ALL_CHANNELS_MASK 0xffffffff
52 #define SOF_IPC4_VOL_ZERO_DB	0x7fffffff
53 
54 #define ALH_MAX_NUMBER_OF_GTW   16
55 
56 #define SOF_IPC4_INVALID_NODE_ID	0xffffffff
57 
58 /*
59  * The base of multi-gateways. Multi-gateways addressing starts from
60  * ALH_MULTI_GTW_BASE and there are ALH_MULTI_GTW_COUNT multi-sources
61  * and ALH_MULTI_GTW_COUNT multi-sinks available.
62  * Addressing is continuous from ALH_MULTI_GTW_BASE to
63  * ALH_MULTI_GTW_BASE + ALH_MULTI_GTW_COUNT - 1.
64  */
65 #define ALH_MULTI_GTW_BASE	0x50
66 /* A magic number from FW */
67 #define ALH_MULTI_GTW_COUNT	8
68 
69 enum sof_ipc4_copier_module_config_params {
70 /*
71  * Use LARGE_CONFIG_SET to initialize timestamp event. Ipc mailbox must
72  * contain properly built CopierConfigTimestampInitData struct.
73  */
74 	SOF_IPC4_COPIER_MODULE_CFG_PARAM_TIMESTAMP_INIT = 1,
75 /*
76  * Use LARGE_CONFIG_SET to initialize copier sink. Ipc mailbox must contain
77  * properly built CopierConfigSetSinkFormat struct.
78  */
79 	SOF_IPC4_COPIER_MODULE_CFG_PARAM_SET_SINK_FORMAT,
80 /*
81  * Use LARGE_CONFIG_SET to initialize and enable on Copier data segment
82  * event. Ipc mailbox must contain properly built DataSegmentEnabled struct.
83  */
84 	SOF_IPC4_COPIER_MODULE_CFG_PARAM_DATA_SEGMENT_ENABLED,
85 /*
86  * Use LARGE_CONFIG_GET to retrieve Linear Link Position (LLP) value for non
87  * HD-A gateways.
88  */
89 	SOF_IPC4_COPIER_MODULE_CFG_PARAM_LLP_READING,
90 /*
91  * Use LARGE_CONFIG_GET to retrieve Linear Link Position (LLP) value for non
92  * HD-A gateways and corresponding total processed data
93  */
94 	SOF_IPC4_COPIER_MODULE_CFG_PARAM_LLP_READING_EXTENDED,
95 /*
96  * Use LARGE_CONFIG_SET to setup attenuation on output pins. Data is just uint32_t.
97  * note Config is only allowed when output pin is set up for 32bit and source
98  * is connected to Gateway
99  */
100 	SOF_IPC4_COPIER_MODULE_CFG_ATTENUATION,
101 };
102 
103 struct sof_ipc4_copier_config_set_sink_format {
104 /* Id of sink */
105 	u32 sink_id;
106 /*
107  * Input format used by the source
108  * attention must be the same as present if already initialized.
109  */
110 	struct sof_ipc4_audio_format source_fmt;
111 /* Output format used by the sink */
112 	struct sof_ipc4_audio_format sink_fmt;
113 } __packed __aligned(4);
114 
115 /**
116  * struct sof_ipc4_pipeline - pipeline config data
117  * @priority: Priority of this pipeline
118  * @lp_mode: Low power mode
119  * @mem_usage: Memory usage
120  * @state: Pipeline state
121  * @msg: message structure for pipeline
122  * @skip_during_fe_trigger: skip triggering this pipeline during the FE DAI trigger
123  */
124 struct sof_ipc4_pipeline {
125 	uint32_t priority;
126 	uint32_t lp_mode;
127 	uint32_t mem_usage;
128 	int state;
129 	struct sof_ipc4_msg msg;
130 	bool skip_during_fe_trigger;
131 };
132 
133 /**
134  * struct sof_ipc4_multi_pipeline_data - multi pipeline trigger IPC data
135  * @count: Number of pipelines to be triggered
136  * @pipeline_ids: Flexible array of IDs of the pipelines to be triggered
137  */
138 struct ipc4_pipeline_set_state_data {
139 	u32 count;
140 	DECLARE_FLEX_ARRAY(u32, pipeline_ids);
141 } __packed;
142 
143 /**
144  * struct sof_ipc4_available_audio_format - Available audio formats
145  * @base_config: Available base config
146  * @out_audio_fmt: Available output audio format
147  * @ref_audio_fmt: Reference audio format to match runtime audio format
148  * @dma_buffer_size: Available Gateway DMA buffer size (in bytes)
149  * @audio_fmt_num: Number of available audio formats
150  */
151 struct sof_ipc4_available_audio_format {
152 	struct sof_ipc4_base_module_cfg *base_config;
153 	struct sof_ipc4_audio_format *out_audio_fmt;
154 	struct sof_ipc4_audio_format *ref_audio_fmt;
155 	u32 *dma_buffer_size;
156 	int audio_fmt_num;
157 };
158 
159 /**
160  * struct sof_copier_gateway_cfg - IPC gateway configuration
161  * @node_id: ID of Gateway Node
162  * @dma_buffer_size: Preferred Gateway DMA buffer size (in bytes)
163  * @config_length: Length of gateway node configuration blob specified in #config_data
164  * config_data: Gateway node configuration blob
165  */
166 struct sof_copier_gateway_cfg {
167 	uint32_t node_id;
168 	uint32_t dma_buffer_size;
169 	uint32_t config_length;
170 	uint32_t config_data[];
171 };
172 
173 /**
174  * struct sof_ipc4_copier_data - IPC data for copier
175  * @base_config: Base configuration including input audio format
176  * @out_format: Output audio format
177  * @copier_feature_mask: Copier feature mask
178  * @gtw_cfg: Gateway configuration
179  */
180 struct sof_ipc4_copier_data {
181 	struct sof_ipc4_base_module_cfg base_config;
182 	struct sof_ipc4_audio_format out_format;
183 	uint32_t copier_feature_mask;
184 	struct sof_copier_gateway_cfg gtw_cfg;
185 };
186 
187 /**
188  * struct sof_ipc4_gtw_attributes: Gateway attributes
189  * @lp_buffer_alloc: Gateway data requested in low power memory
190  * @alloc_from_reg_file: Gateway data requested in register file memory
191  * @rsvd: reserved for future use
192  */
193 struct sof_ipc4_gtw_attributes {
194 	uint32_t lp_buffer_alloc : 1;
195 	uint32_t alloc_from_reg_file : 1;
196 	uint32_t rsvd : 30;
197 };
198 
199 /** struct sof_ipc4_alh_multi_gtw_cfg: ALH gateway cfg data
200  * @count: Number of streams (valid items in mapping array)
201  * @alh_id: ALH stream id of a single ALH stream aggregated
202  * @channel_mask: Channel mask
203  * @mapping: ALH streams
204  */
205 struct sof_ipc4_alh_multi_gtw_cfg {
206 	uint32_t count;
207 	struct {
208 		uint32_t alh_id;
209 		uint32_t channel_mask;
210 	} mapping[ALH_MAX_NUMBER_OF_GTW];
211 } __packed;
212 
213 /** struct sof_ipc4_alh_configuration_blob: ALH blob
214  * @gw_attr: Gateway attributes
215  * @alh_cfg: ALH configuration data
216  */
217 struct sof_ipc4_alh_configuration_blob {
218 	struct sof_ipc4_gtw_attributes gw_attr;
219 	struct sof_ipc4_alh_multi_gtw_cfg alh_cfg;
220 };
221 
222 /**
223  * struct sof_ipc4_copier - copier config data
224  * @data: IPC copier data
225  * @copier_config: Copier + blob
226  * @ipc_config_size: Size of copier_config
227  * @available_fmt: Available audio format
228  * @frame_fmt: frame format
229  * @msg: message structure for copier
230  * @gtw_attr: Gateway attributes for copier blob
231  * @dai_type: DAI type
232  * @dai_index: DAI index
233  */
234 struct sof_ipc4_copier {
235 	struct sof_ipc4_copier_data data;
236 	u32 *copier_config;
237 	uint32_t ipc_config_size;
238 	void *ipc_config_data;
239 	struct sof_ipc4_available_audio_format available_fmt;
240 	u32 frame_fmt;
241 	struct sof_ipc4_msg msg;
242 	struct sof_ipc4_gtw_attributes *gtw_attr;
243 	u32 dai_type;
244 	int dai_index;
245 };
246 
247 /**
248  * struct sof_ipc4_ctrl_value_chan: generic channel mapped value data
249  * @channel: Channel ID
250  * @value: gain value
251  */
252 struct sof_ipc4_ctrl_value_chan {
253 	u32 channel;
254 	u32 value;
255 };
256 
257 /**
258  * struct sof_ipc4_control_data - IPC data for kcontrol IO
259  * @msg: message structure for kcontrol IO
260  * @index: pipeline ID
261  * @chanv: channel ID and value array used by volume type controls
262  * @data: data for binary kcontrols
263  */
264 struct sof_ipc4_control_data {
265 	struct sof_ipc4_msg msg;
266 	int index;
267 
268 	union {
269 		struct sof_ipc4_ctrl_value_chan chanv[0];
270 		struct sof_abi_hdr data[0];
271 	};
272 };
273 
274 /**
275  * struct sof_ipc4_gain_data - IPC gain blob
276  * @channels: Channels
277  * @init_val: Initial value
278  * @curve_type: Curve type
279  * @reserved: reserved for future use
280  * @curve_duration_l: Curve duration low part
281  * @curve_duration_h: Curve duration high part
282  */
283 struct sof_ipc4_gain_data {
284 	uint32_t channels;
285 	uint32_t init_val;
286 	uint32_t curve_type;
287 	uint32_t reserved;
288 	uint32_t curve_duration_l;
289 	uint32_t curve_duration_h;
290 } __aligned(8);
291 
292 /**
293  * struct sof_ipc4_gain - gain config data
294  * @base_config: IPC base config data
295  * @data: IPC gain blob
296  * @available_fmt: Available audio format
297  * @msg: message structure for gain
298  */
299 struct sof_ipc4_gain {
300 	struct sof_ipc4_base_module_cfg base_config;
301 	struct sof_ipc4_gain_data data;
302 	struct sof_ipc4_available_audio_format available_fmt;
303 	struct sof_ipc4_msg msg;
304 };
305 
306 /**
307  * struct sof_ipc4_mixer - mixer config data
308  * @base_config: IPC base config data
309  * @available_fmt: Available audio format
310  * @msg: IPC4 message struct containing header and data info
311  */
312 struct sof_ipc4_mixer {
313 	struct sof_ipc4_base_module_cfg base_config;
314 	struct sof_ipc4_available_audio_format available_fmt;
315 	struct sof_ipc4_msg msg;
316 };
317 
318 /**
319  * struct sof_ipc4_src SRC config data
320  * @base_config: IPC base config data
321  * @sink_rate: Output rate for sink module
322  * @available_fmt: Available audio format
323  * @msg: IPC4 message struct containing header and data info
324  */
325 struct sof_ipc4_src {
326 	struct sof_ipc4_base_module_cfg base_config;
327 	uint32_t sink_rate;
328 	struct sof_ipc4_available_audio_format available_fmt;
329 	struct sof_ipc4_msg msg;
330 };
331 
332 #endif
333