blob: f585f5c223c632894e227dd79a71e2bffcc6c339 [file] [log] [blame]
Niranjan Yadlacee816e2018-04-19 12:03:47 -07001/*******************************************************************************
2* Copyright (C) 2018 Cadence Design Systems, Inc.
3*
4* Permission is hereby granted, free of charge, to any person obtaining
5* a copy of this software and associated documentation files (the
6* "Software"), to use this Software with Cadence processor cores only and
7* not with any other processors and platforms, subject to
8* the following conditions:
9*
10* The above copyright notice and this permission notice shall be included
11* in all copies or substantial portions of the Software.
12*
13* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
14* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
15* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
16* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
17* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
18* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
19* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20
21******************************************************************************/
22
23#ifndef __XF_H
24#error "xf-opcode.h mustn't be included directly"
25#endif
26
27/*******************************************************************************
28 * Message routing composition - move somewhere else - tbd
29 ******************************************************************************/
30
31/* ...adjust IPC client of message going from user-space */
32#define XF_MSG_AP_FROM_USER(id, client) \
33 (((id) & ~(0xF << 2)) | (client))
34
35/* ...wipe out IPC client from message going to user-space */
36#define XF_MSG_AP_TO_USER(id) \
37 ((id) & ~(0xF << 18))
38
39/* ...port specification (12 bits) */
40#define __XF_PORT_SPEC(core, id, port) ((core) | ((id) << 2) | ((port) << 8))
41#define __XF_PORT_SPEC2(id, port) ((id) | ((port) << 8))
42#define XF_PORT_CORE(spec) ((spec) & 0x3)
43#define XF_PORT_CLIENT(spec) (((spec) >> 2) & 0x3F)
44#define XF_PORT_ID(spec) (((spec) >> 8) & 0xF)
45
46/* ...message id contains source and destination ports specification */
47#define __XF_MSG_ID(src, dst) (((src) & 0xFFFF) | (((dst) & 0xFFFF) << 16))
48#define XF_MSG_SRC(id) (((id) >> 0) & 0xFFFF)
49#define XF_MSG_SRC_CORE(id) (((id) >> 0) & 0x3)
50#define XF_MSG_SRC_CLIENT(id) (((id) >> 2) & 0x3F)
51#define XF_MSG_SRC_ID(id) (((id) >> 0) & 0xFF)
52#define XF_MSG_SRC_PORT(id) (((id) >> 8) & 0xF)
53#define XF_MSG_SRC_PROXY(id) (((id) >> 15) & 0x1)
54#define XF_MSG_DST(id) (((id) >> 16) & 0xFFFF)
55#define XF_MSG_DST_CORE(id) (((id) >> 16) & 0x3)
56#define XF_MSG_DST_CLIENT(id) (((id) >> 18) & 0x3F)
57#define XF_MSG_DST_ID(id) (((id) >> 16) & 0xFF)
58#define XF_MSG_DST_PORT(id) (((id) >> 24) & 0xF)
59#define XF_MSG_DST_PROXY(id) (((id) >> 31) & 0x1)
60
61/* ...special treatment of AP-proxy destination field */
62#define XF_AP_IPC_CLIENT(id) (((id) >> 18) & 0xF)
63#define XF_AP_CLIENT(id) (((id) >> 22) & 0x1FF)
64#define __XF_AP_PROXY(core) ((core) | 0x8000)
65#define __XF_DSP_PROXY(core) ((core) | 0x8000)
66#define __XF_AP_CLIENT(core, client) ((core) | ((client) << 6) | 0x8000)
67
68/*******************************************************************************
69 * Opcode composition
70 ******************************************************************************/
71
72/* ...opcode composition with command/response data tags */
73#define __XF_OPCODE(c, r, op) (((c) << 31) | ((r) << 30) | ((op) & 0x3F))
74
75/* ...accessors */
76#define XF_OPCODE_CDATA(opcode) ((opcode) & (1 << 31))
77#define XF_OPCODE_RDATA(opcode) ((opcode) & (1 << 30))
78#define XF_OPCODE_TYPE(opcode) ((opcode) & (0x3F))
79
80/*******************************************************************************
81 * Opcode types
82 ******************************************************************************/
83
84/* ...unregister client */
85#define XF_UNREGISTER __XF_OPCODE(0, 0, 0)
86
87/* ...register client at proxy */
88#define XF_REGISTER __XF_OPCODE(1, 0, 1)
89
90/* ...port routing command */
91#define XF_ROUTE __XF_OPCODE(1, 0, 2)
92
93/* ...port unrouting command */
94#define XF_UNROUTE __XF_OPCODE(1, 0, 3)
95
96/* ...shared buffer allocation */
97#define XF_ALLOC __XF_OPCODE(0, 0, 4)
98
99/* ...shared buffer freeing */
100#define XF_FREE __XF_OPCODE(0, 0, 5)
101
102/* ...set component parameters */
103#define XF_SET_PARAM __XF_OPCODE(1, 0, 6)
104
105/* ...get component parameters */
106#define XF_GET_PARAM __XF_OPCODE(1, 1, 7)
107
108/* ...input buffer reception */
109#define XF_EMPTY_THIS_BUFFER __XF_OPCODE(1, 0, 8)
110
111/* ...output buffer reception */
112#define XF_FILL_THIS_BUFFER __XF_OPCODE(0, 1, 9)
113
114/* ...flush specific port */
115#define XF_FLUSH __XF_OPCODE(0, 0, 10)
116
117/* ...start component operation */
118#define XF_START __XF_OPCODE(0, 0, 11)
119
120/* ...stop component operation */
121#define XF_STOP __XF_OPCODE(0, 0, 12)
122
123/* ...pause component operation */
124#define XF_PAUSE __XF_OPCODE(0, 0, 13)
125
126/* ...resume component operation */
127#define XF_RESUME __XF_OPCODE(0, 0, 14)
128
129/* ...extended parameter setting function */
130#define XF_SET_PARAM_EXT __XF_OPCODE(1, 1, 15)
131
132/* ...extended parameter retrieval function */
133#define XF_GET_PARAM_EXT __XF_OPCODE(1, 1, 16)
134
135/* ...total amount of supported decoder commands */
136#define __XF_OP_NUM 17
137
138/*******************************************************************************
139 * XF_START message definition
140 ******************************************************************************/
141
142typedef struct xf_start_msg
143{
144 /* ...effective sample rate */
145 u32 sample_rate;
146
147 /* ...number of channels */
148 u32 channels;
149
150 /* ...sample width */
151 u32 pcm_width;
152
153 /* ...minimal size of intput buffer */
154 u32 input_length;
155
156 /* ...size of output buffer */
157 u32 output_length;
158
159} __attribute__((__packed__)) xf_start_msg_t;
160
161/*******************************************************************************
162 * XF_GET_PARAM message
163 ******************************************************************************/
164
165/* ...message body (command/response) */
166typedef union xf_get_param_msg
167{
168 /* ...command structure */
169 struct
170 {
171 /* ...array of parameters requested */
172 u32 id[0];
173
174 } __attribute__((__packed__)) c;
175
176 /* ...response structure */
177 struct
178 {
179 /* ...array of parameters values */
180 u32 value[0];
181
182 } __attribute__((__packed__)) r;
183
184} xf_get_param_msg_t;
185
186/* ...length of the XF_GET_PARAM command/response */
187#define XF_GET_PARAM_CMD_LEN(params) (sizeof(u32) * (params))
188#define XF_GET_PARAM_RSP_LEN(params) (sizeof(u32) * (params))
189
190/*******************************************************************************
191 * XF_SET_PARAM message
192 ******************************************************************************/
193
194/* ...component initialization parameter */
195typedef struct xf_set_param_item
196{
197 /* ...index of parameter passed to SET_CONFIG_PARAM call */
198 u32 id;
199
200 /* ...value of parameter */
201 u32 value;
202
203} __attribute__ ((__packed__)) xf_set_param_item_t;
204
205/* ...message body (no response message? - tbd) */
206typedef struct xf_set_param_msg
207{
208 /* ...command message */
209 xf_set_param_item_t item[0];
210
211} __attribute__ ((__packed__)) xf_set_param_msg_t;
212
213/* ...length of the command message */
214#define XF_SET_PARAM_CMD_LEN(params) (sizeof(xf_set_param_item_t) * (params))
215
216/*******************************************************************************
217 * XF_SET_PARAM_EXT/XF_GET_PARAM_EXT message
218 ******************************************************************************/
219
220/* ...extended parameter descriptor */
221typedef struct xf_ext_param_desc
222{
223 /* ...index of parameter passed to SET/GET_CONFIG_PARAM call (16-bits only) */
224 u16 id;
225
226 /* ...length of embedded input/output parameter data (in bytes) */
227 u16 length;
228
229} __attribute__ ((__packed__, __aligned__(4))) xf_ext_param_desc_t;
230
231/* ...message body (no response message? - tbd) */
232typedef struct xf_ext_param_msg
233{
234 /* ...extended parameter descriptor */
235 xf_ext_param_desc_t desc;
236
237 /* ...parameter data (in the format expected by codec) */
238 u8 data[0];
239
240} __attribute__ ((__packed__)) xf_ext_param_msg_t;
241
242/* ...access macros */
243
244#define xf_ext_param_first(e) \
245 (&(e)->desc)
246
247#define xf_ext_param_next(d) \
248 (xf_ext_param_desc_t *)(((xf_ext_param_msg_t *)(d))->data + (((d)->length + 3) & ~3))
249
250#define xf_ext_param_length(e, d) \
251 ((u32)((u8 *)(d) - (u8 *)(ext)))
252
253#define xf_ext_param_data(d, t) \
254 ((t *)&(d)[1])
255
256#define xf_ext_param_setup(d, i, t, s) \
257 ((d)->id = (i), (d)->length = (s), xf_ext_param_data(d, t))
258
259
260/*******************************************************************************
261 * XF_ROUTE definition
262 ******************************************************************************/
263
264/* ...port routing command */
265typedef struct xf_route_port_msg
266{
267 /* ...source port specification */
268 u32 src;
269
270 /* ...destination port specification */
271 u32 dst;
272
273 /* ...number of buffers to allocate */
274 u32 alloc_number;
275
276 /* ...length of buffer to allocate */
277 u32 alloc_size;
278
279 /* ...alignment restriction for a buffer */
280 u32 alloc_align;
281
282} __attribute__((__packed__)) xf_route_port_msg_t;
283
284/*******************************************************************************
285 * XF_UNROUTE definition
286 ******************************************************************************/
287
288/* ...port unrouting command */
289typedef struct xf_unroute_port_msg
290{
291 /* ...source port specification */
292 u32 src;
293
294 /* ...destination port specification */
295 u32 dst;
296
297} __attribute__((__packed__)) xf_unroute_port_msg_t;