xref: /openbmc/linux/include/sound/sof/topology.h (revision 66358069)
1311ce4feSLiam Girdwood /* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) */
2311ce4feSLiam Girdwood /*
3311ce4feSLiam Girdwood  * This file is provided under a dual BSD/GPLv2 license.  When using or
4311ce4feSLiam Girdwood  * redistributing this file, you may do so under either license.
5311ce4feSLiam Girdwood  *
6311ce4feSLiam Girdwood  * Copyright(c) 2018 Intel Corporation. All rights reserved.
7311ce4feSLiam Girdwood  */
8311ce4feSLiam Girdwood 
9311ce4feSLiam Girdwood #ifndef __INCLUDE_SOUND_SOF_TOPOLOGY_H__
10311ce4feSLiam Girdwood #define __INCLUDE_SOUND_SOF_TOPOLOGY_H__
11311ce4feSLiam Girdwood 
12311ce4feSLiam Girdwood #include <sound/sof/header.h>
13311ce4feSLiam Girdwood 
14311ce4feSLiam Girdwood /*
15311ce4feSLiam Girdwood  * Component
16311ce4feSLiam Girdwood  */
17311ce4feSLiam Girdwood 
18311ce4feSLiam Girdwood /* types of component */
19311ce4feSLiam Girdwood enum sof_comp_type {
20311ce4feSLiam Girdwood 	SOF_COMP_NONE = 0,
21311ce4feSLiam Girdwood 	SOF_COMP_HOST,
22311ce4feSLiam Girdwood 	SOF_COMP_DAI,
23311ce4feSLiam Girdwood 	SOF_COMP_SG_HOST,	/**< scatter gather variant */
24311ce4feSLiam Girdwood 	SOF_COMP_SG_DAI,	/**< scatter gather variant */
25311ce4feSLiam Girdwood 	SOF_COMP_VOLUME,
26311ce4feSLiam Girdwood 	SOF_COMP_MIXER,
27311ce4feSLiam Girdwood 	SOF_COMP_MUX,
28311ce4feSLiam Girdwood 	SOF_COMP_SRC,
29311ce4feSLiam Girdwood 	SOF_COMP_SPLITTER,
30311ce4feSLiam Girdwood 	SOF_COMP_TONE,
31311ce4feSLiam Girdwood 	SOF_COMP_SWITCH,
32311ce4feSLiam Girdwood 	SOF_COMP_BUFFER,
33311ce4feSLiam Girdwood 	SOF_COMP_EQ_IIR,
34311ce4feSLiam Girdwood 	SOF_COMP_EQ_FIR,
35311ce4feSLiam Girdwood 	SOF_COMP_KEYWORD_DETECT,
36311ce4feSLiam Girdwood 	SOF_COMP_KPB,			/* A key phrase buffer component */
37311ce4feSLiam Girdwood 	SOF_COMP_SELECTOR,		/**< channel selector component */
3866358069SJaska Uimonen 	SOF_COMP_DEMUX,
39311ce4feSLiam Girdwood 	/* keep FILEREAD/FILEWRITE as the last ones */
40311ce4feSLiam Girdwood 	SOF_COMP_FILEREAD = 10000,	/**< host test based file IO */
41311ce4feSLiam Girdwood 	SOF_COMP_FILEWRITE = 10001,	/**< host test based file IO */
42311ce4feSLiam Girdwood };
43311ce4feSLiam Girdwood 
44311ce4feSLiam Girdwood /* XRUN action for component */
45311ce4feSLiam Girdwood #define SOF_XRUN_STOP		1	/**< stop stream */
46311ce4feSLiam Girdwood #define SOF_XRUN_UNDER_ZERO	2	/**< send 0s to sink */
47311ce4feSLiam Girdwood #define SOF_XRUN_OVER_NULL	4	/**< send data to NULL */
48311ce4feSLiam Girdwood 
49311ce4feSLiam Girdwood /* create new generic component - SOF_IPC_TPLG_COMP_NEW */
50311ce4feSLiam Girdwood struct sof_ipc_comp {
51311ce4feSLiam Girdwood 	struct sof_ipc_cmd_hdr hdr;
52311ce4feSLiam Girdwood 	uint32_t id;
53311ce4feSLiam Girdwood 	enum sof_comp_type type;
54311ce4feSLiam Girdwood 	uint32_t pipeline_id;
55311ce4feSLiam Girdwood 
56311ce4feSLiam Girdwood 	/* reserved for future use */
57311ce4feSLiam Girdwood 	uint32_t reserved[2];
58311ce4feSLiam Girdwood } __packed;
59311ce4feSLiam Girdwood 
60311ce4feSLiam Girdwood /*
61311ce4feSLiam Girdwood  * Component Buffers
62311ce4feSLiam Girdwood  */
63311ce4feSLiam Girdwood 
64311ce4feSLiam Girdwood /*
65311ce4feSLiam Girdwood  * SOF memory capabilities, add new ones at the end
66311ce4feSLiam Girdwood  */
67311ce4feSLiam Girdwood #define SOF_MEM_CAPS_RAM			(1 << 0)
68311ce4feSLiam Girdwood #define SOF_MEM_CAPS_ROM			(1 << 1)
69311ce4feSLiam Girdwood #define SOF_MEM_CAPS_EXT			(1 << 2) /**< external */
70311ce4feSLiam Girdwood #define SOF_MEM_CAPS_LP			(1 << 3) /**< low power */
71311ce4feSLiam Girdwood #define SOF_MEM_CAPS_HP			(1 << 4) /**< high performance */
72311ce4feSLiam Girdwood #define SOF_MEM_CAPS_DMA			(1 << 5) /**< DMA'able */
73311ce4feSLiam Girdwood #define SOF_MEM_CAPS_CACHE			(1 << 6) /**< cacheable */
74311ce4feSLiam Girdwood #define SOF_MEM_CAPS_EXEC			(1 << 7) /**< executable */
75311ce4feSLiam Girdwood 
76311ce4feSLiam Girdwood /* create new component buffer - SOF_IPC_TPLG_BUFFER_NEW */
77311ce4feSLiam Girdwood struct sof_ipc_buffer {
78311ce4feSLiam Girdwood 	struct sof_ipc_comp comp;
79311ce4feSLiam Girdwood 	uint32_t size;		/**< buffer size in bytes */
80311ce4feSLiam Girdwood 	uint32_t caps;		/**< SOF_MEM_CAPS_ */
81311ce4feSLiam Girdwood } __packed;
82311ce4feSLiam Girdwood 
83311ce4feSLiam Girdwood /* generic component config data - must always be after struct sof_ipc_comp */
84311ce4feSLiam Girdwood struct sof_ipc_comp_config {
85311ce4feSLiam Girdwood 	struct sof_ipc_cmd_hdr hdr;
86311ce4feSLiam Girdwood 	uint32_t periods_sink;	/**< 0 means variable */
87311ce4feSLiam Girdwood 	uint32_t periods_source;	/**< 0 means variable */
88311ce4feSLiam Girdwood 	uint32_t reserved1;	/**< reserved */
89311ce4feSLiam Girdwood 	uint32_t frame_fmt;		/**< SOF_IPC_FRAME_ */
90311ce4feSLiam Girdwood 	uint32_t xrun_action;
91311ce4feSLiam Girdwood 
92311ce4feSLiam Girdwood 	/* reserved for future use */
93311ce4feSLiam Girdwood 	uint32_t reserved[2];
94311ce4feSLiam Girdwood } __packed;
95311ce4feSLiam Girdwood 
96311ce4feSLiam Girdwood /* generic host component */
97311ce4feSLiam Girdwood struct sof_ipc_comp_host {
98311ce4feSLiam Girdwood 	struct sof_ipc_comp comp;
99311ce4feSLiam Girdwood 	struct sof_ipc_comp_config config;
100311ce4feSLiam Girdwood 	uint32_t direction;	/**< SOF_IPC_STREAM_ */
101311ce4feSLiam Girdwood 	uint32_t no_irq;	/**< don't send periodic IRQ to host/DSP */
102311ce4feSLiam Girdwood 	uint32_t dmac_config; /**< DMA engine specific */
103311ce4feSLiam Girdwood }  __packed;
104311ce4feSLiam Girdwood 
105311ce4feSLiam Girdwood /* generic DAI component */
106311ce4feSLiam Girdwood struct sof_ipc_comp_dai {
107311ce4feSLiam Girdwood 	struct sof_ipc_comp comp;
108311ce4feSLiam Girdwood 	struct sof_ipc_comp_config config;
109311ce4feSLiam Girdwood 	uint32_t direction;	/**< SOF_IPC_STREAM_ */
110311ce4feSLiam Girdwood 	uint32_t dai_index;	/**< index of this type dai */
111311ce4feSLiam Girdwood 	uint32_t type;		/**< DAI type - SOF_DAI_ */
112311ce4feSLiam Girdwood 	uint32_t reserved;	/**< reserved */
113311ce4feSLiam Girdwood }  __packed;
114311ce4feSLiam Girdwood 
115311ce4feSLiam Girdwood /* generic mixer component */
116311ce4feSLiam Girdwood struct sof_ipc_comp_mixer {
117311ce4feSLiam Girdwood 	struct sof_ipc_comp comp;
118311ce4feSLiam Girdwood 	struct sof_ipc_comp_config config;
119311ce4feSLiam Girdwood }  __packed;
120311ce4feSLiam Girdwood 
121311ce4feSLiam Girdwood /* volume ramping types */
122311ce4feSLiam Girdwood enum sof_volume_ramp {
123311ce4feSLiam Girdwood 	SOF_VOLUME_LINEAR	= 0,
124311ce4feSLiam Girdwood 	SOF_VOLUME_LOG,
125311ce4feSLiam Girdwood 	SOF_VOLUME_LINEAR_ZC,
126311ce4feSLiam Girdwood 	SOF_VOLUME_LOG_ZC,
127311ce4feSLiam Girdwood };
128311ce4feSLiam Girdwood 
129311ce4feSLiam Girdwood /* generic volume component */
130311ce4feSLiam Girdwood struct sof_ipc_comp_volume {
131311ce4feSLiam Girdwood 	struct sof_ipc_comp comp;
132311ce4feSLiam Girdwood 	struct sof_ipc_comp_config config;
133311ce4feSLiam Girdwood 	uint32_t channels;
134311ce4feSLiam Girdwood 	uint32_t min_value;
135311ce4feSLiam Girdwood 	uint32_t max_value;
136311ce4feSLiam Girdwood 	uint32_t ramp;		/**< SOF_VOLUME_ */
137311ce4feSLiam Girdwood 	uint32_t initial_ramp;	/**< ramp space in ms */
138311ce4feSLiam Girdwood }  __packed;
139311ce4feSLiam Girdwood 
140311ce4feSLiam Girdwood /* generic SRC component */
141311ce4feSLiam Girdwood struct sof_ipc_comp_src {
142311ce4feSLiam Girdwood 	struct sof_ipc_comp comp;
143311ce4feSLiam Girdwood 	struct sof_ipc_comp_config config;
144311ce4feSLiam Girdwood 	/* either source or sink rate must be non zero */
145311ce4feSLiam Girdwood 	uint32_t source_rate;	/**< source rate or 0 for variable */
146311ce4feSLiam Girdwood 	uint32_t sink_rate;	/**< sink rate or 0 for variable */
147311ce4feSLiam Girdwood 	uint32_t rate_mask;	/**< SOF_RATE_ supported rates */
148311ce4feSLiam Girdwood } __packed;
149311ce4feSLiam Girdwood 
150311ce4feSLiam Girdwood /* generic MUX component */
151311ce4feSLiam Girdwood struct sof_ipc_comp_mux {
152311ce4feSLiam Girdwood 	struct sof_ipc_comp comp;
153311ce4feSLiam Girdwood 	struct sof_ipc_comp_config config;
154311ce4feSLiam Girdwood } __packed;
155311ce4feSLiam Girdwood 
156311ce4feSLiam Girdwood /* generic tone generator component */
157311ce4feSLiam Girdwood struct sof_ipc_comp_tone {
158311ce4feSLiam Girdwood 	struct sof_ipc_comp comp;
159311ce4feSLiam Girdwood 	struct sof_ipc_comp_config config;
160311ce4feSLiam Girdwood 	int32_t sample_rate;
161311ce4feSLiam Girdwood 	int32_t frequency;
162311ce4feSLiam Girdwood 	int32_t amplitude;
163311ce4feSLiam Girdwood 	int32_t freq_mult;
164311ce4feSLiam Girdwood 	int32_t ampl_mult;
165311ce4feSLiam Girdwood 	int32_t length;
166311ce4feSLiam Girdwood 	int32_t period;
167311ce4feSLiam Girdwood 	int32_t repeats;
168311ce4feSLiam Girdwood 	int32_t ramp_step;
169311ce4feSLiam Girdwood } __packed;
170311ce4feSLiam Girdwood 
171311ce4feSLiam Girdwood /** \brief Types of processing components */
172311ce4feSLiam Girdwood enum sof_ipc_process_type {
173311ce4feSLiam Girdwood 	SOF_PROCESS_NONE = 0,		/**< None */
174311ce4feSLiam Girdwood 	SOF_PROCESS_EQFIR,		/**< Intel FIR */
175311ce4feSLiam Girdwood 	SOF_PROCESS_EQIIR,		/**< Intel IIR */
176311ce4feSLiam Girdwood 	SOF_PROCESS_KEYWORD_DETECT,	/**< Keyword Detection */
177311ce4feSLiam Girdwood 	SOF_PROCESS_KPB,		/**< KeyPhrase Buffer Manager */
178311ce4feSLiam Girdwood 	SOF_PROCESS_CHAN_SELECTOR,	/**< Channel Selector */
17966358069SJaska Uimonen 	SOF_PROCESS_MUX,
18066358069SJaska Uimonen 	SOF_PROCESS_DEMUX,
181311ce4feSLiam Girdwood };
182311ce4feSLiam Girdwood 
183311ce4feSLiam Girdwood /* generic "effect", "codec" or proprietary processing component */
184311ce4feSLiam Girdwood struct sof_ipc_comp_process {
185311ce4feSLiam Girdwood 	struct sof_ipc_comp comp;
186311ce4feSLiam Girdwood 	struct sof_ipc_comp_config config;
187311ce4feSLiam Girdwood 	uint32_t size;	/**< size of bespoke data section in bytes */
188311ce4feSLiam Girdwood 	uint32_t type;	/**< sof_ipc_process_type */
189311ce4feSLiam Girdwood 
190311ce4feSLiam Girdwood 	/* reserved for future use */
191311ce4feSLiam Girdwood 	uint32_t reserved[7];
192311ce4feSLiam Girdwood 
193311ce4feSLiam Girdwood 	unsigned char data[0];
194311ce4feSLiam Girdwood } __packed;
195311ce4feSLiam Girdwood 
196311ce4feSLiam Girdwood /* frees components, buffers and pipelines
197311ce4feSLiam Girdwood  * SOF_IPC_TPLG_COMP_FREE, SOF_IPC_TPLG_PIPE_FREE, SOF_IPC_TPLG_BUFFER_FREE
198311ce4feSLiam Girdwood  */
199311ce4feSLiam Girdwood struct sof_ipc_free {
200311ce4feSLiam Girdwood 	struct sof_ipc_cmd_hdr hdr;
201311ce4feSLiam Girdwood 	uint32_t id;
202311ce4feSLiam Girdwood } __packed;
203311ce4feSLiam Girdwood 
204311ce4feSLiam Girdwood struct sof_ipc_comp_reply {
205311ce4feSLiam Girdwood 	struct sof_ipc_reply rhdr;
206311ce4feSLiam Girdwood 	uint32_t id;
207311ce4feSLiam Girdwood 	uint32_t offset;
208311ce4feSLiam Girdwood } __packed;
209311ce4feSLiam Girdwood 
210311ce4feSLiam Girdwood /*
211311ce4feSLiam Girdwood  * Pipeline
212311ce4feSLiam Girdwood  */
213311ce4feSLiam Girdwood 
214311ce4feSLiam Girdwood /** \brief Types of pipeline scheduling time domains */
215311ce4feSLiam Girdwood enum sof_ipc_pipe_sched_time_domain {
216311ce4feSLiam Girdwood 	SOF_TIME_DOMAIN_DMA = 0,	/**< DMA interrupt */
217311ce4feSLiam Girdwood 	SOF_TIME_DOMAIN_TIMER,		/**< Timer interrupt */
218311ce4feSLiam Girdwood };
219311ce4feSLiam Girdwood 
220311ce4feSLiam Girdwood /* new pipeline - SOF_IPC_TPLG_PIPE_NEW */
221311ce4feSLiam Girdwood struct sof_ipc_pipe_new {
222311ce4feSLiam Girdwood 	struct sof_ipc_cmd_hdr hdr;
223311ce4feSLiam Girdwood 	uint32_t comp_id;	/**< component id for pipeline */
224311ce4feSLiam Girdwood 	uint32_t pipeline_id;	/**< pipeline id */
225311ce4feSLiam Girdwood 	uint32_t sched_id;	/**< Scheduling component id */
226311ce4feSLiam Girdwood 	uint32_t core;		/**< core we run on */
227311ce4feSLiam Girdwood 	uint32_t period;	/**< execution period in us*/
228311ce4feSLiam Girdwood 	uint32_t priority;	/**< priority level 0 (low) to 10 (max) */
229311ce4feSLiam Girdwood 	uint32_t period_mips;	/**< worst case instruction count per period */
230311ce4feSLiam Girdwood 	uint32_t frames_per_sched;/**< output frames of pipeline, 0 is variable */
231311ce4feSLiam Girdwood 	uint32_t xrun_limit_usecs; /**< report xruns greater than limit */
232311ce4feSLiam Girdwood 	uint32_t time_domain;	/**< scheduling time domain */
233311ce4feSLiam Girdwood }  __packed;
234311ce4feSLiam Girdwood 
235311ce4feSLiam Girdwood /* pipeline construction complete - SOF_IPC_TPLG_PIPE_COMPLETE */
236311ce4feSLiam Girdwood struct sof_ipc_pipe_ready {
237311ce4feSLiam Girdwood 	struct sof_ipc_cmd_hdr hdr;
238311ce4feSLiam Girdwood 	uint32_t comp_id;
239311ce4feSLiam Girdwood }  __packed;
240311ce4feSLiam Girdwood 
241311ce4feSLiam Girdwood struct sof_ipc_pipe_free {
242311ce4feSLiam Girdwood 	struct sof_ipc_cmd_hdr hdr;
243311ce4feSLiam Girdwood 	uint32_t comp_id;
244311ce4feSLiam Girdwood }  __packed;
245311ce4feSLiam Girdwood 
246311ce4feSLiam Girdwood /* connect two components in pipeline - SOF_IPC_TPLG_COMP_CONNECT */
247311ce4feSLiam Girdwood struct sof_ipc_pipe_comp_connect {
248311ce4feSLiam Girdwood 	struct sof_ipc_cmd_hdr hdr;
249311ce4feSLiam Girdwood 	uint32_t source_id;
250311ce4feSLiam Girdwood 	uint32_t sink_id;
251311ce4feSLiam Girdwood }  __packed;
252311ce4feSLiam Girdwood 
253311ce4feSLiam Girdwood /* external events */
254311ce4feSLiam Girdwood enum sof_event_types {
255311ce4feSLiam Girdwood 	SOF_EVENT_NONE = 0,
256311ce4feSLiam Girdwood 	SOF_KEYWORD_DETECT_DAPM_EVENT,
257311ce4feSLiam Girdwood };
258311ce4feSLiam Girdwood 
259311ce4feSLiam Girdwood #endif
260