1 /* SPDX-License-Identifier: BSD-3-Clause
2  *
3  * Copyright(c) 2018 Intel Corporation. All rights reserved.
4  *
5  * Author: Liam Girdwood <liam.r.girdwood@linux.intel.com>
6  *         Keyon Jie <yang.jie@linux.intel.com>
7  */
8 
9 /**
10  * \file include/ipc/control.h
11  * \brief IPC control commands
12  * \author Liam Girdwood <liam.r.girdwood@linux.intel.com>
13  * \author Keyon Jie <yang.jie@linux.intel.com>
14  */
15 
16 #ifndef __IPC_CONTROL_H__
17 #define __IPC_CONTROL_H__
18 
19 #include <ipc/header.h>
20 #include <ipc/stream.h>
21 #include <kernel/header.h>
22 #include <stdint.h>
23 
24 /** \addtogroup sof_uapi_control uAPI Control
25  *  SOF uAPI specification - component controls.
26  *  @{
27  */
28 
29 /** \name Component Mixers and Controls
30  *  @{
31  */
32 
33 /** Channel positions - uses same values as ALSA */
34 enum sof_ipc_chmap {
35 	SOF_CHMAP_UNKNOWN = 0,
36 	SOF_CHMAP_NA,		/**< N/A, silent */
37 	SOF_CHMAP_MONO,		/**< mono stream */
38 	SOF_CHMAP_FL,		/**< front left */
39 	SOF_CHMAP_FR,		/**< front right */
40 	SOF_CHMAP_RL,		/**< rear left */
41 	SOF_CHMAP_RR,		/**< rear right */
42 	SOF_CHMAP_FC,		/**< front centre */
43 	SOF_CHMAP_LFE,		/**< LFE */
44 	SOF_CHMAP_SL,		/**< side left */
45 	SOF_CHMAP_SR,		/**< side right */
46 	SOF_CHMAP_RC,		/**< rear centre */
47 	SOF_CHMAP_FLC,		/**< front left centre */
48 	SOF_CHMAP_FRC,		/**< front right centre */
49 	SOF_CHMAP_RLC,		/**< rear left centre */
50 	SOF_CHMAP_RRC,		/**< rear right centre */
51 	SOF_CHMAP_FLW,		/**< front left wide */
52 	SOF_CHMAP_FRW,		/**< front right wide */
53 	SOF_CHMAP_FLH,		/**< front left high */
54 	SOF_CHMAP_FCH,		/**< front centre high */
55 	SOF_CHMAP_FRH,		/**< front right high */
56 	SOF_CHMAP_TC,		/**< top centre */
57 	SOF_CHMAP_TFL,		/**< top front left */
58 	SOF_CHMAP_TFR,		/**< top front right */
59 	SOF_CHMAP_TFC,		/**< top front centre */
60 	SOF_CHMAP_TRL,		/**< top rear left */
61 	SOF_CHMAP_TRR,		/**< top rear right */
62 	SOF_CHMAP_TRC,		/**< top rear centre */
63 	SOF_CHMAP_TFLC,		/**< top front left centre */
64 	SOF_CHMAP_TFRC,		/**< top front right centre */
65 	SOF_CHMAP_TSL,		/**< top side left */
66 	SOF_CHMAP_TSR,		/**< top side right */
67 	SOF_CHMAP_LLFE,		/**< left LFE */
68 	SOF_CHMAP_RLFE,		/**< right LFE */
69 	SOF_CHMAP_BC,		/**< bottom centre */
70 	SOF_CHMAP_BLC,		/**< bottom left centre */
71 	SOF_CHMAP_BRC,		/**< bottom right centre */
72 	SOF_CHMAP_LAST = SOF_CHMAP_BRC,
73 };
74 
75 /**
76  * Control data type and direction.
77  * SOF_CTRL_TYPE_VALUE_CHAN uses struct sof_ipc_ctrl_value_chan.
78  * SOF_CTRL_TYPE_VALUE_COMP uses struct sof_ipc_ctrl_value_comp.
79  * SOF_CTRL_TYPE_DATA_GET uses sof_abi_hdr.
80  */
81 enum sof_ipc_ctrl_type {
82 	SOF_CTRL_TYPE_VALUE_CHAN_GET = 0,
83 	SOF_CTRL_TYPE_VALUE_CHAN_SET,
84 
85 	SOF_CTRL_TYPE_VALUE_COMP_GET,
86 	SOF_CTRL_TYPE_VALUE_COMP_SET,
87 
88 	SOF_CTRL_TYPE_DATA_GET,
89 	SOF_CTRL_TYPE_DATA_SET,
90 };
91 
92 /** Control command type. */
93 enum sof_ipc_ctrl_cmd {
94 	SOF_CTRL_CMD_VOLUME = 0, /**< maps to ALSA volume style controls */
95 	SOF_CTRL_CMD_ENUM,	/**< maps to ALSA enum style controls */
96 	SOF_CTRL_CMD_SWITCH,	/**< maps to ALSA switch style controls */
97 	SOF_CTRL_CMD_BINARY,	/**< maps to ALSA binary style controls */
98 };
99 
100 /** Generic channel mapped value data. */
101 struct sof_ipc_ctrl_value_chan {
102 	uint32_t channel;	/**< channel map - enum sof_ipc_chmap */
103 	uint32_t value;
104 } __attribute__((packed, aligned(4)));
105 
106 /**
107  * Generic component mapped value data.
108  */
109 struct sof_ipc_ctrl_value_comp {
110 	uint32_t index;	/**< component source/sink/control index in control */
111 	union {
112 		uint32_t uvalue;
113 		int32_t svalue;
114 	};
115 } __attribute__((packed, aligned(4)));
116 
117 /**
118  * Generic control data.
119  */
120 struct sof_ipc_ctrl_data {
121 	struct sof_ipc_reply rhdr;
122 	uint32_t comp_id;
123 
124 	/* control access and data type */
125 	uint32_t type;		/**< enum sof_ipc_ctrl_type */
126 	uint32_t cmd;		/**< enum sof_ipc_ctrl_cmd */
127 	uint32_t index;		/**< control index for comps > 1 control */
128 
129 	/* control data - can either be appended or DMAed from host */
130 	struct sof_ipc_host_buffer buffer;
131 	uint32_t num_elems;	/**< in array elems or bytes for data type */
132 	uint32_t elems_remaining;	/**< elems remaining if sent in parts */
133 
134 	uint32_t msg_index;	/**< index for large messages sent in parts */
135 
136 	/* reserved for future use */
137 	uint32_t reserved[6];
138 
139 	/* control data - add new types if needed */
140 	union {
141 		/* channel values can be used by volume type controls */
142 		struct sof_ipc_ctrl_value_chan chanv[0];
143 		/* component values used by routing controls like mux, mixer */
144 		struct sof_ipc_ctrl_value_comp compv[0];
145 		/* data can be used by binary controls */
146 		struct sof_abi_hdr data[0];
147 	};
148 } __attribute__((packed, aligned(4)));
149 
150 /** Event type */
151 enum sof_ipc_ctrl_event_type {
152 	SOF_CTRL_EVENT_GENERIC = 0,	/**< generic event */
153 	SOF_CTRL_EVENT_GENERIC_METADATA,	/**< generic event with metadata */
154 	SOF_CTRL_EVENT_KD,	/**< keyword detection event */
155 	SOF_CTRL_EVENT_VAD,	/**< voice activity detection event */
156 };
157 
158 /**
159  * Generic notification data.
160  */
161 struct sof_ipc_comp_event {
162 	struct sof_ipc_reply rhdr;
163 	uint16_t src_comp_type;	/**< COMP_TYPE_ */
164 	uint32_t src_comp_id;	/**< source component id */
165 	uint32_t event_type;	/**< event type - SOF_CTRL_EVENT_* */
166 	uint32_t num_elems;	/**< in array elems or bytes for data type */
167 
168 	/* reserved for future use */
169 	uint32_t reserved[8];
170 
171 	/* control data - add new types if needed */
172 	union {
173 		/* data can be used by binary controls */
174 		struct sof_abi_hdr data[0];
175 		/* event specific values */
176 		uint32_t event_value;
177 	};
178 } __attribute__((packed, aligned(4)));
179 
180 /** @}*/
181 
182 /** @}*/
183 
184 #endif /* __IPC_CONTROL_H__ */
185