xref: /openbmc/linux/include/sound/sof/header.h (revision f519f0be)
1 /* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) 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) 2018 Intel Corporation. All rights reserved.
7  */
8 
9 #ifndef __INCLUDE_SOUND_SOF_HEADER_H__
10 #define __INCLUDE_SOUND_SOF_HEADER_H__
11 
12 #include <uapi/sound/sof/abi.h>
13 
14 /** \addtogroup sof_uapi uAPI
15  *  SOF uAPI specification.
16  *  @{
17  */
18 
19 /*
20  * IPC messages have a prefixed 32 bit identifier made up as follows :-
21  *
22  * 0xGCCCNNNN where
23  * G is global cmd type (4 bits)
24  * C is command type (12 bits)
25  * I is the ID number (16 bits) - monotonic and overflows
26  *
27  * This is sent at the start of the IPM message in the mailbox. Messages should
28  * not be sent in the doorbell (special exceptions for firmware .
29  */
30 
31 /* Global Message - Generic */
32 #define SOF_GLB_TYPE_SHIFT			28
33 #define SOF_GLB_TYPE_MASK			(0xf << SOF_GLB_TYPE_SHIFT)
34 #define SOF_GLB_TYPE(x)				((x) << SOF_GLB_TYPE_SHIFT)
35 
36 /* Command Message - Generic */
37 #define SOF_CMD_TYPE_SHIFT			16
38 #define SOF_CMD_TYPE_MASK			(0xfff << SOF_CMD_TYPE_SHIFT)
39 #define SOF_CMD_TYPE(x)				((x) << SOF_CMD_TYPE_SHIFT)
40 
41 /* Global Message Types */
42 #define SOF_IPC_GLB_REPLY			SOF_GLB_TYPE(0x1U)
43 #define SOF_IPC_GLB_COMPOUND			SOF_GLB_TYPE(0x2U)
44 #define SOF_IPC_GLB_TPLG_MSG			SOF_GLB_TYPE(0x3U)
45 #define SOF_IPC_GLB_PM_MSG			SOF_GLB_TYPE(0x4U)
46 #define SOF_IPC_GLB_COMP_MSG			SOF_GLB_TYPE(0x5U)
47 #define SOF_IPC_GLB_STREAM_MSG			SOF_GLB_TYPE(0x6U)
48 #define SOF_IPC_FW_READY			SOF_GLB_TYPE(0x7U)
49 #define SOF_IPC_GLB_DAI_MSG			SOF_GLB_TYPE(0x8U)
50 #define SOF_IPC_GLB_TRACE_MSG			SOF_GLB_TYPE(0x9U)
51 
52 /*
53  * DSP Command Message Types
54  */
55 
56 /* topology */
57 #define SOF_IPC_TPLG_COMP_NEW			SOF_CMD_TYPE(0x001)
58 #define SOF_IPC_TPLG_COMP_FREE			SOF_CMD_TYPE(0x002)
59 #define SOF_IPC_TPLG_COMP_CONNECT		SOF_CMD_TYPE(0x003)
60 #define SOF_IPC_TPLG_PIPE_NEW			SOF_CMD_TYPE(0x010)
61 #define SOF_IPC_TPLG_PIPE_FREE			SOF_CMD_TYPE(0x011)
62 #define SOF_IPC_TPLG_PIPE_CONNECT		SOF_CMD_TYPE(0x012)
63 #define SOF_IPC_TPLG_PIPE_COMPLETE		SOF_CMD_TYPE(0x013)
64 #define SOF_IPC_TPLG_BUFFER_NEW			SOF_CMD_TYPE(0x020)
65 #define SOF_IPC_TPLG_BUFFER_FREE		SOF_CMD_TYPE(0x021)
66 
67 /* PM */
68 #define SOF_IPC_PM_CTX_SAVE			SOF_CMD_TYPE(0x001)
69 #define SOF_IPC_PM_CTX_RESTORE			SOF_CMD_TYPE(0x002)
70 #define SOF_IPC_PM_CTX_SIZE			SOF_CMD_TYPE(0x003)
71 #define SOF_IPC_PM_CLK_SET			SOF_CMD_TYPE(0x004)
72 #define SOF_IPC_PM_CLK_GET			SOF_CMD_TYPE(0x005)
73 #define SOF_IPC_PM_CLK_REQ			SOF_CMD_TYPE(0x006)
74 #define SOF_IPC_PM_CORE_ENABLE			SOF_CMD_TYPE(0x007)
75 
76 /* component runtime config - multiple different types */
77 #define SOF_IPC_COMP_SET_VALUE			SOF_CMD_TYPE(0x001)
78 #define SOF_IPC_COMP_GET_VALUE			SOF_CMD_TYPE(0x002)
79 #define SOF_IPC_COMP_SET_DATA			SOF_CMD_TYPE(0x003)
80 #define SOF_IPC_COMP_GET_DATA			SOF_CMD_TYPE(0x004)
81 
82 /* DAI messages */
83 #define SOF_IPC_DAI_CONFIG			SOF_CMD_TYPE(0x001)
84 #define SOF_IPC_DAI_LOOPBACK			SOF_CMD_TYPE(0x002)
85 
86 /* stream */
87 #define SOF_IPC_STREAM_PCM_PARAMS		SOF_CMD_TYPE(0x001)
88 #define SOF_IPC_STREAM_PCM_PARAMS_REPLY		SOF_CMD_TYPE(0x002)
89 #define SOF_IPC_STREAM_PCM_FREE			SOF_CMD_TYPE(0x003)
90 #define SOF_IPC_STREAM_TRIG_START		SOF_CMD_TYPE(0x004)
91 #define SOF_IPC_STREAM_TRIG_STOP		SOF_CMD_TYPE(0x005)
92 #define SOF_IPC_STREAM_TRIG_PAUSE		SOF_CMD_TYPE(0x006)
93 #define SOF_IPC_STREAM_TRIG_RELEASE		SOF_CMD_TYPE(0x007)
94 #define SOF_IPC_STREAM_TRIG_DRAIN		SOF_CMD_TYPE(0x008)
95 #define SOF_IPC_STREAM_TRIG_XRUN		SOF_CMD_TYPE(0x009)
96 #define SOF_IPC_STREAM_POSITION			SOF_CMD_TYPE(0x00a)
97 #define SOF_IPC_STREAM_VORBIS_PARAMS		SOF_CMD_TYPE(0x010)
98 #define SOF_IPC_STREAM_VORBIS_FREE		SOF_CMD_TYPE(0x011)
99 
100 /* trace and debug */
101 #define SOF_IPC_TRACE_DMA_PARAMS		SOF_CMD_TYPE(0x001)
102 #define SOF_IPC_TRACE_DMA_POSITION		SOF_CMD_TYPE(0x002)
103 
104 /* Get message component id */
105 #define SOF_IPC_MESSAGE_ID(x)			((x) & 0xffff)
106 
107 /* maximum message size for mailbox Tx/Rx */
108 #define SOF_IPC_MSG_MAX_SIZE			384
109 
110 /*
111  * Structure Header - Header for all IPC structures except command structs.
112  * The size can be greater than the structure size and that means there is
113  * extended bespoke data beyond the end of the structure including variable
114  * arrays.
115  */
116 
117 struct sof_ipc_hdr {
118 	uint32_t size;			/**< size of structure */
119 } __packed;
120 
121 /*
122  * Command Header - Header for all IPC commands. Identifies IPC message.
123  * The size can be greater than the structure size and that means there is
124  * extended bespoke data beyond the end of the structure including variable
125  * arrays.
126  */
127 
128 struct sof_ipc_cmd_hdr {
129 	uint32_t size;			/**< size of structure */
130 	uint32_t cmd;			/**< SOF_IPC_GLB_ + cmd */
131 } __packed;
132 
133 /*
134  * Generic reply message. Some commands override this with their own reply
135  * types that must include this at start.
136  */
137 struct sof_ipc_reply {
138 	struct sof_ipc_cmd_hdr hdr;
139 	int32_t error;			/**< negative error numbers */
140 }  __packed;
141 
142 /*
143  * Compound commands - SOF_IPC_GLB_COMPOUND.
144  *
145  * Compound commands are sent to the DSP as a single IPC operation. The
146  * commands are split into blocks and each block has a header. This header
147  * identifies the command type and the number of commands before the next
148  * header.
149  */
150 
151 struct sof_ipc_compound_hdr {
152 	struct sof_ipc_cmd_hdr hdr;
153 	uint32_t count;		/**< count of 0 means end of compound sequence */
154 }  __packed;
155 
156 /** @}*/
157 
158 #endif
159