summaryrefslogtreecommitdiff
path: root/hifi/xaf/hifi-dpf/include/xf-opcode.h
blob: 6fa084654518fc4f2f0e0315bef604e73d56d98f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
/*******************************************************************************
* Copyright (C) 2018 Cadence Design Systems, Inc.
* 
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to use this Software with Cadence processor cores only and 
* not with any other processors and platforms, subject to
* the following conditions:
* 
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
* 
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

******************************************************************************/

/*******************************************************************************
 * xf-opcode.h
 *
 * Xtensa audio processing framework. Message API
 *
 ******************************************************************************/

#ifndef __XF_H
#error "xf-opcode.h mustn't be included directly"
#endif

/*******************************************************************************
 * Message routing composition - move somewhere else - tbd
 ******************************************************************************/

/* ...adjust IPC client of message going from user-space */
#define XF_MSG_AP_FROM_USER(id, client) \
    (((id) & ~(0xF << 2)) | (client))

/* ...wipe out IPC client from message going to user-space */
#define XF_MSG_AP_TO_USER(id)           \
    ((id) & ~(0xF << 18))

/* ...port specification (12 bits) */
#define __XF_PORT_SPEC(core, id, port)  ((core) | ((id) << 2) | ((port) << 8))
#define __XF_PORT_SPEC2(id, port)       ((id) | ((port) << 8))
#define XF_PORT_CORE(spec)              ((spec) & 0x3)
#define XF_PORT_CLIENT(spec)            (((spec) >> 2) & 0x3F)
#define XF_PORT_ID(spec)                (((spec) >> 8) & 0xF)

/* ...message id contains source and destination ports specification */
#define __XF_MSG_ID(src, dst)           (((src) & 0xFFFF) | (((dst) & 0xFFFF) << 16))
#define XF_MSG_SRC(id)                  (((id) >> 0) & 0xFFFF)
#define XF_MSG_SRC_CORE(id)             (((id) >> 0) & 0x3)
#define XF_MSG_SRC_CLIENT(id)           (((id) >> 2) & 0x3F)
#define XF_MSG_SRC_ID(id)               (((id) >> 0) & 0xFF)
#define XF_MSG_SRC_PORT(id)             (((id) >> 8) & 0xF)
#define XF_MSG_SRC_PROXY(id)            (((id) >> 15) & 0x1)
#define XF_MSG_DST(id)                  (((id) >> 16) & 0xFFFF)
#define XF_MSG_DST_CORE(id)             (((id) >> 16) & 0x3)
#define XF_MSG_DST_CLIENT(id)           (((id) >> 18) & 0x3F)
#define XF_MSG_DST_ID(id)               (((id) >> 16) & 0xFF)
#define XF_MSG_DST_PORT(id)             (((id) >> 24) & 0xF)
#define XF_MSG_DST_PROXY(id)            (((id) >> 31) & 0x1)

/* ...special treatment of AP-proxy destination field */
#define XF_AP_IPC_CLIENT(id)            (((id) >> 18) & 0xF)
#define XF_AP_CLIENT(id)                (((id) >> 22) & 0x1FF)
#define __XF_AP_PROXY(core)             ((core) | 0x8000)
#define __XF_DSP_PROXY(core)            ((core) | 0x8000)
#define __XF_AP_CLIENT(core, client)    ((core) | ((client) << 6) | 0x8000)

/* ...check if DSP message is shared between cores */
#define XF_MSG_SHARED(id)               \
    ({ u32 __id = (id); (XF_CFG_CORES_NUM > 1 ? (__id ^ (__id >> 16)) & 0x3 : 0); })

/*******************************************************************************
 * Opcode composition
 ******************************************************************************/

/* ...opcode composition with command/response data tags */
#define __XF_OPCODE(c, r, op)           (((c) << 31) | ((r) << 30) | ((op) & 0x3F))

/* ...accessors */
#define XF_OPCODE_CDATA(opcode)         ((opcode) & (1 << 31))
#define XF_OPCODE_RDATA(opcode)         ((opcode) & (1 << 30))
#define XF_OPCODE_TYPE(opcode)          ((opcode) & (0x3F))

/*******************************************************************************
 * Opcode types
 ******************************************************************************/

/* ...unregister client */
#define XF_UNREGISTER                   __XF_OPCODE(0, 0, 0)

/* ...register client at proxy */
#define XF_REGISTER                     __XF_OPCODE(1, 0, 1)

/* ...port routing command */
#define XF_ROUTE                        __XF_OPCODE(1, 0, 2)

/* ...port unrouting command */
#define XF_UNROUTE                      __XF_OPCODE(1, 0, 3)

/* ...shared buffer allocation */
#define XF_ALLOC                        __XF_OPCODE(0, 0, 4)

/* ...shared buffer freeing */
#define XF_FREE                         __XF_OPCODE(0, 0, 5)

/* ...set component parameters */
#define XF_SET_PARAM                    __XF_OPCODE(1, 0, 6)

/* ...get component parameters */
#define XF_GET_PARAM                    __XF_OPCODE(1, 1, 7)

/* ...input buffer reception */
#define XF_EMPTY_THIS_BUFFER            __XF_OPCODE(1, 0, 8)

/* ...output buffer reception */
#define XF_FILL_THIS_BUFFER             __XF_OPCODE(0, 1, 9)

/* ...flush specific port */
#define XF_FLUSH                        __XF_OPCODE(0, 0, 10)

/* ...start component operation */
#define XF_START                        __XF_OPCODE(0, 0, 11)

/* ...stop component operation */
#define XF_STOP                         __XF_OPCODE(0, 0, 12)

/* ...pause component operation */
#define XF_PAUSE                        __XF_OPCODE(0, 0, 13)

/* ...resume component operation */
#define XF_RESUME                       __XF_OPCODE(0, 0, 14)

/* ...extended parameter setting function */
#define XF_SET_PARAM_EXT                __XF_OPCODE(1, 1, 15)

/* ...extended parameter retrieval function */
#define XF_GET_PARAM_EXT                __XF_OPCODE(1, 1, 16)

/* ...total amount of supported decoder commands */
#define __XF_OP_NUM                     17

/*******************************************************************************
 * XF_START message definition
 ******************************************************************************/

typedef struct xf_start_msg
{
    /* ...effective sample rate */
    u32             sample_rate;

    /* ...number of channels */
    u32             channels;
    
    /* ...sample width */
    u32             pcm_width;
    
    /* ...minimal size of intput buffer */
    u32             input_length;
    
    /* ...size of output buffer */
    u32             output_length;
    
}   __attribute__((__packed__)) xf_start_msg_t;
    
/*******************************************************************************
 * XF_GET_PARAM message
 ******************************************************************************/

/* ...message body (command/response) */
typedef union xf_get_param_msg
{
    /* ...command structure */
    struct
    {
        /* ...array of parameters requested */
        u32                 id[0];

    }   __attribute__((__packed__)) c;

    /* ...response structure */
    struct
    {
        /* ...array of parameters values */
        u32                 value[0];

    }   __attribute__((__packed__)) r;

}   xf_get_param_msg_t;

/* ...length of the XF_GET_PARAM command/response */
#define XF_GET_PARAM_CMD_LEN(params)    (sizeof(u32) * (params))
#define XF_GET_PARAM_RSP_LEN(params)    (sizeof(u32) * (params))

/*******************************************************************************
 * XF_SET_PARAM message
 ******************************************************************************/

/* ...component initialization parameter */
typedef struct xf_set_param_item
{
    /* ...index of parameter passed to SET_CONFIG_PARAM call */
    u32                 id;

    /* ...value of parameter */
    u32                 value;

}   __attribute__ ((__packed__)) xf_set_param_item_t;

/* ...message body (no response message? - tbd) */
typedef struct xf_set_param_msg
{
    /* ...command message */
    xf_set_param_item_t     item[0];

}   __attribute__ ((__packed__)) xf_set_param_msg_t;

/* ...length of the command message */
#define XF_SET_PARAM_CMD_LEN(params)    (sizeof(xf_set_param_item_t) * (params))

/*******************************************************************************
 * XF_SET_PARAM_EXT/XF_GET_PARAM_EXT message
 ******************************************************************************/

/* ...extended parameter descriptor */
typedef struct xf_ext_param_desc
{
    /* ...index of parameter passed to SET/GET_CONFIG_PARAM call (16-bits only) */
    u16                 id;

    /* ...length of embedded input/output parameter data (in bytes) */
    u16                 length;

}   __attribute__ ((__packed__, __aligned__(4))) xf_ext_param_desc_t;
    
/* ...message body (no response message? - tbd) */
typedef struct xf_ext_param_msg
{
    /* ...extended parameter descriptor */
    xf_ext_param_desc_t     desc;

    /* ...parameter data (in the format expected by codec; 4 bytes aligned) */
    u8                      data[0];

}   __attribute__ ((__packed__, __aligned__(4))) xf_ext_param_msg_t;

/*******************************************************************************
 * XF_ROUTE definition
 ******************************************************************************/

/* ...port routing command */
typedef struct xf_route_port_msg
{
	/* ...source port specification */
	u32                 src;

	/* ...destination port specification */
	u32                 dst;

	/* ...number of buffers to allocate */
	u32                 alloc_number;

	/* ...length of buffer to allocate */
	u32                 alloc_size;

	/* ...alignment restriction for a buffer */
	u32                 alloc_align;

}	__attribute__((__packed__)) xf_route_port_msg_t;

/*******************************************************************************
 * XF_UNROUTE definition
 ******************************************************************************/

/* ...port unrouting command */
typedef struct xf_unroute_port_msg
{
	/* ...source port specification */
	u32                 src;

	/* ...destination port specification */
	u32                 dst;

}	__attribute__((__packed__)) xf_unroute_port_msg_t;