xref: /openbmc/linux/sound/soc/sof/ipc4-topology.h (revision c765ceda78f0bd9df1217f9beaefea58ecf3865c)
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) << 5)
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 /**
70  * struct sof_ipc4_pipeline - pipeline config data
71  * @priority: Priority of this pipeline
72  * @lp_mode: Low power mode
73  * @mem_usage: Memory usage
74  * @state: Pipeline state
75  * @msg: message structure for pipeline
76  * @skip_during_fe_trigger: skip triggering this pipeline during the FE DAI trigger
77  */
78 struct sof_ipc4_pipeline {
79 	uint32_t priority;
80 	uint32_t lp_mode;
81 	uint32_t mem_usage;
82 	int state;
83 	struct sof_ipc4_msg msg;
84 	bool skip_during_fe_trigger;
85 };
86 
87 /**
88  * struct sof_ipc4_multi_pipeline_data - multi pipeline trigger IPC data
89  * @count: Number of pipelines to be triggered
90  * @pipeline_ids: Flexible array of IDs of the pipelines to be triggered
91  */
92 struct ipc4_pipeline_set_state_data {
93 	u32 count;
94 	DECLARE_FLEX_ARRAY(u32, pipeline_ids);
95 } __packed;
96 
97 /**
98  * struct sof_ipc4_available_audio_format - Available audio formats
99  * @base_config: Available base config
100  * @out_audio_fmt: Available output audio format
101  * @ref_audio_fmt: Reference audio format to match runtime audio format
102  * @dma_buffer_size: Available Gateway DMA buffer size (in bytes)
103  * @audio_fmt_num: Number of available audio formats
104  */
105 struct sof_ipc4_available_audio_format {
106 	struct sof_ipc4_base_module_cfg *base_config;
107 	struct sof_ipc4_audio_format *out_audio_fmt;
108 	struct sof_ipc4_audio_format *ref_audio_fmt;
109 	u32 *dma_buffer_size;
110 	int audio_fmt_num;
111 };
112 
113 /**
114  * struct sof_copier_gateway_cfg - IPC gateway configuration
115  * @node_id: ID of Gateway Node
116  * @dma_buffer_size: Preferred Gateway DMA buffer size (in bytes)
117  * @config_length: Length of gateway node configuration blob specified in #config_data
118  * config_data: Gateway node configuration blob
119  */
120 struct sof_copier_gateway_cfg {
121 	uint32_t node_id;
122 	uint32_t dma_buffer_size;
123 	uint32_t config_length;
124 	uint32_t config_data[];
125 };
126 
127 /**
128  * struct sof_ipc4_copier_data - IPC data for copier
129  * @base_config: Base configuration including input audio format
130  * @out_format: Output audio format
131  * @copier_feature_mask: Copier feature mask
132  * @gtw_cfg: Gateway configuration
133  */
134 struct sof_ipc4_copier_data {
135 	struct sof_ipc4_base_module_cfg base_config;
136 	struct sof_ipc4_audio_format out_format;
137 	uint32_t copier_feature_mask;
138 	struct sof_copier_gateway_cfg gtw_cfg;
139 };
140 
141 /**
142  * struct sof_ipc4_gtw_attributes: Gateway attributes
143  * @lp_buffer_alloc: Gateway data requested in low power memory
144  * @alloc_from_reg_file: Gateway data requested in register file memory
145  * @rsvd: reserved for future use
146  */
147 struct sof_ipc4_gtw_attributes {
148 	uint32_t lp_buffer_alloc : 1;
149 	uint32_t alloc_from_reg_file : 1;
150 	uint32_t rsvd : 30;
151 };
152 
153 /** struct sof_ipc4_alh_multi_gtw_cfg: ALH gateway cfg data
154  * @count: Number of streams (valid items in mapping array)
155  * @alh_id: ALH stream id of a single ALH stream aggregated
156  * @channel_mask: Channel mask
157  * @mapping: ALH streams
158  */
159 struct sof_ipc4_alh_multi_gtw_cfg {
160 	uint32_t count;
161 	struct {
162 		uint32_t alh_id;
163 		uint32_t channel_mask;
164 	} mapping[ALH_MAX_NUMBER_OF_GTW];
165 } __packed;
166 
167 /** struct sof_ipc4_alh_configuration_blob: ALH blob
168  * @gw_attr: Gateway attributes
169  * @alh_cfg: ALH configuration data
170  */
171 struct sof_ipc4_alh_configuration_blob {
172 	struct sof_ipc4_gtw_attributes gw_attr;
173 	struct sof_ipc4_alh_multi_gtw_cfg alh_cfg;
174 };
175 
176 /**
177  * struct sof_ipc4_copier - copier config data
178  * @data: IPC copier data
179  * @copier_config: Copier + blob
180  * @ipc_config_size: Size of copier_config
181  * @available_fmt: Available audio format
182  * @frame_fmt: frame format
183  * @msg: message structure for copier
184  * @gtw_attr: Gateway attributes for copier blob
185  * @dai_type: DAI type
186  * @dai_index: DAI index
187  */
188 struct sof_ipc4_copier {
189 	struct sof_ipc4_copier_data data;
190 	u32 *copier_config;
191 	uint32_t ipc_config_size;
192 	void *ipc_config_data;
193 	struct sof_ipc4_available_audio_format available_fmt;
194 	u32 frame_fmt;
195 	struct sof_ipc4_msg msg;
196 	struct sof_ipc4_gtw_attributes *gtw_attr;
197 	u32 dai_type;
198 	int dai_index;
199 };
200 
201 /**
202  * struct sof_ipc4_ctrl_value_chan: generic channel mapped value data
203  * @channel: Channel ID
204  * @value: gain value
205  */
206 struct sof_ipc4_ctrl_value_chan {
207 	u32 channel;
208 	u32 value;
209 };
210 
211 /**
212  * struct sof_ipc4_control_data - IPC data for kcontrol IO
213  * @msg: message structure for kcontrol IO
214  * @index: pipeline ID
215  * @chanv: channel ID and value array used by volume type controls
216  * @data: data for binary kcontrols
217  */
218 struct sof_ipc4_control_data {
219 	struct sof_ipc4_msg msg;
220 	int index;
221 
222 	union {
223 		struct sof_ipc4_ctrl_value_chan chanv[0];
224 		struct sof_abi_hdr data[0];
225 	};
226 };
227 
228 /**
229  * struct sof_ipc4_gain_data - IPC gain blob
230  * @channels: Channels
231  * @init_val: Initial value
232  * @curve_type: Curve type
233  * @reserved: reserved for future use
234  * @curve_duration: Curve duration
235  */
236 struct sof_ipc4_gain_data {
237 	uint32_t channels;
238 	uint32_t init_val;
239 	uint32_t curve_type;
240 	uint32_t reserved;
241 	uint32_t curve_duration;
242 } __aligned(8);
243 
244 /**
245  * struct sof_ipc4_gain - gain config data
246  * @base_config: IPC base config data
247  * @data: IPC gain blob
248  * @available_fmt: Available audio format
249  * @msg: message structure for gain
250  */
251 struct sof_ipc4_gain {
252 	struct sof_ipc4_base_module_cfg base_config;
253 	struct sof_ipc4_gain_data data;
254 	struct sof_ipc4_available_audio_format available_fmt;
255 	struct sof_ipc4_msg msg;
256 };
257 
258 /**
259  * struct sof_ipc4_mixer - mixer config data
260  * @base_config: IPC base config data
261  * @available_fmt: Available audio format
262  * @msg: IPC4 message struct containing header and data info
263  */
264 struct sof_ipc4_mixer {
265 	struct sof_ipc4_base_module_cfg base_config;
266 	struct sof_ipc4_available_audio_format available_fmt;
267 	struct sof_ipc4_msg msg;
268 };
269 
270 /**
271  * struct sof_ipc4_src SRC config data
272  * @base_config: IPC base config data
273  * @sink_rate: Output rate for sink module
274  * @available_fmt: Available audio format
275  * @msg: IPC4 message struct containing header and data info
276  */
277 struct sof_ipc4_src {
278 	struct sof_ipc4_base_module_cfg base_config;
279 	uint32_t sink_rate;
280 	struct sof_ipc4_available_audio_format available_fmt;
281 	struct sof_ipc4_msg msg;
282 };
283 
284 #endif
285