RK3368 GPU version Rogue M 1.28
[firefly-linux-kernel-4.4.55.git] / drivers / gpu / rogue_m / services / shared / include / sync.h
1 /*************************************************************************/ /*!
2 @File
3 @Title          Synchronisation interface header
4 @Copyright      Copyright (c) Imagination Technologies Ltd. All Rights Reserved
5 @Description    Defines the client side interface for synchronisation
6 @License        Dual MIT/GPLv2
7
8 The contents of this file are subject to the MIT license as set out below.
9
10 Permission is hereby granted, free of charge, to any person obtaining a copy
11 of this software and associated documentation files (the "Software"), to deal
12 in the Software without restriction, including without limitation the rights
13 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14 copies of the Software, and to permit persons to whom the Software is
15 furnished to do so, subject to the following conditions:
16
17 The above copyright notice and this permission notice shall be included in
18 all copies or substantial portions of the Software.
19
20 Alternatively, the contents of this file may be used under the terms of
21 the GNU General Public License Version 2 ("GPL") in which case the provisions
22 of GPL are applicable instead of those above.
23
24 If you wish to allow use of your version of this file only under the terms of
25 GPL, and not to allow others to use your version of this file under the terms
26 of the MIT license, indicate your decision by deleting the provisions above
27 and replace them with the notice and other provisions required by GPL as set
28 out in the file called "GPL-COPYING" included in this distribution. If you do
29 not delete the provisions above, a recipient may use your version of this file
30 under the terms of either the MIT license or GPL.
31
32 This License is also included in this distribution in the file called
33 "MIT-COPYING".
34
35 EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) THE SOFTWARE IS
36 PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
37 BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
38 PURPOSE AND NONINFRINGEMENT; AND (B) IN NO EVENT SHALL THE AUTHORS OR
39 COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
40 IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
41 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
42 */ /**************************************************************************/
43
44 #include "img_types.h"
45 #include "pvrsrv_error.h"
46 #include "sync_external.h"
47 #include "pdumpdefs.h"
48 #include "dllist.h"
49 #include "pvr_debug.h"
50
51 #ifndef _SYNC_
52 #define _SYNC_
53
54 #if defined(__KERNEL__) && defined(ANDROID) && !defined(__GENKSYMS__)
55 #define __pvrsrv_defined_struct_enum__
56 #include <services_kernel_client.h>
57 #endif
58
59 /*************************************************************************/ /*!
60 @Function       SyncPrimContextCreate
61
62 @Description    Create a new synchronisation context
63
64 @Input          hBridge                 Bridge handle
65
66 @Input          hDeviceNode             Device node handle
67
68 @Output         hSyncPrimContext        Handle to the created synchronisation
69                                         primitive context
70
71 @Return         PVRSRV_OK if the synchronisation primitive context was
72                 successfully created
73 */
74 /*****************************************************************************/
75 PVRSRV_ERROR
76 SyncPrimContextCreate(SYNC_BRIDGE_HANDLE        hBridge,
77                                           IMG_HANDLE                    hDeviceNode,
78                                           PSYNC_PRIM_CONTEXT    *hSyncPrimContext);
79
80 /*************************************************************************/ /*!
81 @Function       SyncPrimContextDestroy
82
83 @Description    Destroy a synchronisation context
84
85 @Input          hSyncPrimContext        Handle to the synchronisation
86                                         primitive context to destroy
87
88 @Return         None
89 */
90 /*****************************************************************************/
91 IMG_VOID
92 SyncPrimContextDestroy(PSYNC_PRIM_CONTEXT hSyncPrimContext);
93
94 /*************************************************************************/ /*!
95 @Function       SyncPrimAlloc
96
97 @Description    Allocate a new synchronisation primitive on the specified
98                 synchronisation context
99
100 @Input          hSyncPrimContext        Handle to the synchronisation
101                                         primitive context
102
103 @Output         ppsSync                 Created synchronisation primitive
104
105 @Input          pszClassName            Sync source annotation
106
107 @Return         PVRSRV_OK if the synchronisation primitive was
108                 successfully created
109 */
110 /*****************************************************************************/
111 PVRSRV_ERROR
112 SyncPrimAlloc(PSYNC_PRIM_CONTEXT                hSyncPrimContext,
113                           PVRSRV_CLIENT_SYNC_PRIM       **ppsSync,
114                           const IMG_CHAR                        *pszClassName);
115
116 #if defined(__KERNEL__)
117 /*************************************************************************/ /*!
118 @Function       SyncPrimAllocForServerSync
119
120 @Description    Allocate a new synchronisation primitive on the specified
121                 synchronisation context for a server sync
122
123 @Input          hSyncPrimContext        Handle to the synchronisation
124                                         primitive context
125
126 @Output         ppsSync                 Created synchronisation primitive
127
128 @Input          pszClassName            Sync source annotation
129
130 @Return         PVRSRV_OK if the synchronisation primitive was
131                 successfully created
132 */
133 /*****************************************************************************/
134 PVRSRV_ERROR
135 SyncPrimAllocForServerSync(PSYNC_PRIM_CONTEXT   hSyncPrimContext,
136                                                 PVRSRV_CLIENT_SYNC_PRIM **ppsSync,
137                                                 const IMG_CHAR          *pszClassName);
138 #endif
139
140 /*************************************************************************/ /*!
141 @Function       SyncPrimFree
142
143 @Description    Free a synchronisation primitive
144
145 @Input          psSync                  The synchronisation primitive to free
146
147 @Return         None
148 */
149 /*****************************************************************************/
150 IMG_VOID
151 SyncPrimFree(PVRSRV_CLIENT_SYNC_PRIM *psSync);
152
153 /*************************************************************************/ /*!
154 @Function       SyncPrimSet
155
156 @Description    Set the synchronisation primitive to a value
157
158 @Input          psSync                  The synchronisation primitive to set
159
160 @Input          ui32Value               Value to set it to
161
162 @Return         None
163 */
164 /*****************************************************************************/
165 IMG_VOID
166 SyncPrimSet(PVRSRV_CLIENT_SYNC_PRIM *psSync, IMG_UINT32 ui32Value);
167
168 #if defined(NO_HARDWARE)
169
170 /*************************************************************************/ /*!
171 @Function       SyncPrimNoHwUpdate
172
173 @Description    Updates the synchronisation primitive value (in NoHardware drivers)
174
175 @Input          psSync                  The synchronisation primitive to update
176
177 @Input          ui32Value               Value to update it to
178
179 @Return         None
180 */
181 /*****************************************************************************/
182 IMG_VOID
183 SyncPrimNoHwUpdate(PVRSRV_CLIENT_SYNC_PRIM *psSync, IMG_UINT32 ui32Value);
184 #endif
185
186 PVRSRV_ERROR
187 SyncPrimServerAlloc(SYNC_BRIDGE_HANDLE  hBridge,
188                                         IMG_HANDLE                      hDeviceNode,
189                                         PVRSRV_CLIENT_SYNC_PRIM **ppsSync,
190                                         const IMG_CHAR          *pszClassName
191                                         PVR_DBG_FILELINE_PARAM);
192
193 PVRSRV_ERROR
194 SyncPrimServerGetStatus(IMG_UINT32 ui32SyncCount,
195                                                 PVRSRV_CLIENT_SYNC_PRIM **papsSync,
196                                                 IMG_UINT32 *pui32UID,
197                                                 IMG_UINT32 *pui32FWAddr,
198                                                 IMG_UINT32 *pui32CurrentOp,
199                                                 IMG_UINT32 *pui32NextOp);
200
201 PVRSRV_ERROR
202 SyncPrimServerQueueOp(PVRSRV_CLIENT_SYNC_PRIM_OP *psSyncOp);
203
204 IMG_BOOL
205 SyncPrimIsServerSync(PVRSRV_CLIENT_SYNC_PRIM *psSync);
206
207 IMG_HANDLE
208 SyncPrimGetServerHandle(PVRSRV_CLIENT_SYNC_PRIM *psSync);
209
210
211
212 PVRSRV_ERROR
213 SyncPrimOpCreate(IMG_UINT32 ui32SyncCount,
214                                  PVRSRV_CLIENT_SYNC_PRIM **papsSyncPrim,
215                                  PSYNC_OP_COOKIE *ppsCookie);
216
217 PVRSRV_ERROR
218 SyncPrimOpTake(PSYNC_OP_COOKIE psCookie,
219                            IMG_UINT32 ui32SyncCount,
220                            PVRSRV_CLIENT_SYNC_PRIM_OP *pasSyncOp);
221
222 PVRSRV_ERROR
223 SyncPrimOpReady(PSYNC_OP_COOKIE psCookie,
224                                 IMG_BOOL *pbReady);
225
226 PVRSRV_ERROR
227 SyncPrimOpComplete(PSYNC_OP_COOKIE psCookie);
228
229 IMG_VOID
230 SyncPrimOpDestroy(PSYNC_OP_COOKIE psCookie);
231
232 PVRSRV_ERROR
233 SyncPrimOpResolve(PSYNC_OP_COOKIE psCookie,
234                                   IMG_UINT32 *pui32SyncCount,
235                                   PVRSRV_CLIENT_SYNC_PRIM_OP **ppsSyncOp);
236
237 PVRSRV_ERROR
238 SyncPrimDumpSyncs(IMG_UINT32 ui32SyncCount, PVRSRV_CLIENT_SYNC_PRIM **papsSync, const IMG_CHAR *pcszExtraInfo);
239
240 #if defined(PDUMP)
241 /*************************************************************************/ /*!
242 @Function       SyncPrimPDump
243
244 @Description    PDump the current value of the synchronisation primitive
245
246 @Input          psSync                  The synchronisation primitive to PDump
247
248 @Return         None
249 */
250 /*****************************************************************************/
251 IMG_VOID
252 SyncPrimPDump(PVRSRV_CLIENT_SYNC_PRIM *psSync);
253
254 /*************************************************************************/ /*!
255 @Function       SyncPrimPDumpValue
256
257 @Description    PDump the ui32Value as the value of the synchronisation 
258                                 primitive (regardless of the current value).
259
260 @Input          psSync          The synchronisation primitive to PDump
261 @Input                  ui32Value               Value to give to the sync prim on the pdump
262
263 @Return         None
264 */
265 /*****************************************************************************/
266 IMG_VOID
267 SyncPrimPDumpValue(PVRSRV_CLIENT_SYNC_PRIM *psSync, IMG_UINT32 ui32Value);
268
269 /*************************************************************************/ /*!
270 @Function       SyncPrimPDumpPol
271
272 @Description    Do a PDump poll of the synchronisation primitive
273
274 @Input          psSync                  The synchronisation primitive to PDump
275
276 @Input          ui32Value               Value to poll for 
277
278 @Input          ui32Mask                PDump mask operator
279
280 @Input          ui32PDumpFlags          PDump flags
281
282 @Return         None
283 */
284 /*****************************************************************************/
285 IMG_VOID
286 SyncPrimPDumpPol(PVRSRV_CLIENT_SYNC_PRIM *psSync,
287                                  IMG_UINT32 ui32Value,
288                                  IMG_UINT32 ui32Mask,
289                                  PDUMP_POLL_OPERATOR eOperator,
290                                  IMG_UINT32 ui32PDumpFlags);
291
292 /*************************************************************************/ /*!
293 @Function       SyncPrimOpPDumpPol
294
295 @Description    Do a PDump poll all the synchronisation primitives on this
296                                 Operation cookie.
297
298 @Input          psCookie                Operation cookie
299
300 @Input          ui32PDumpFlags          PDump flags
301
302 @Return         None
303 */
304 /*****************************************************************************/
305 IMG_VOID
306 SyncPrimOpPDumpPol(PSYNC_OP_COOKIE psCookie,
307                                  PDUMP_POLL_OPERATOR eOperator,
308                                  IMG_UINT32 ui32PDumpFlags);
309
310 /*************************************************************************/ /*!
311 @Function       SyncPrimPDumpCBP
312
313 @Description    Do a PDump CB poll using the synchronisation primitive
314
315 @Input          psSync                  The synchronisation primitive to PDump
316
317 @Input          uiWriteOffset           Current write offset of buffer
318
319 @Input          uiPacketSize            Size of the packet to write into CB
320
321 @Input          uiBufferSize            Size of the CB
322
323 @Return         None
324 */
325 /*****************************************************************************/
326 IMG_VOID 
327 SyncPrimPDumpCBP(PVRSRV_CLIENT_SYNC_PRIM *psSync,
328                                  IMG_UINT64 uiWriteOffset,
329                                  IMG_UINT64 uiPacketSize,
330                                  IMG_UINT64 uiBufferSize);
331
332 #else
333
334 #ifdef INLINE_IS_PRAGMA
335 #pragma inline(SyncPrimPDumpValue)
336 #endif
337 static INLINE IMG_VOID
338 SyncPrimPDumpValue(PVRSRV_CLIENT_SYNC_PRIM *psSync, IMG_UINT32 ui32Value)
339 {
340         PVR_UNREFERENCED_PARAMETER(psSync);
341         PVR_UNREFERENCED_PARAMETER(ui32Value);
342 }
343
344 #ifdef INLINE_IS_PRAGMA
345 #pragma inline(SyncPrimPDump)
346 #endif
347 static INLINE IMG_VOID
348 SyncPrimPDump(PVRSRV_CLIENT_SYNC_PRIM *psSync)
349 {
350         PVR_UNREFERENCED_PARAMETER(psSync);
351 }
352
353 #ifdef INLINE_IS_PRAGMA
354 #pragma inline(SyncPrimPDumpPol)
355 #endif
356 static INLINE IMG_VOID
357 SyncPrimPDumpPol(PVRSRV_CLIENT_SYNC_PRIM *psSync,
358                                  IMG_UINT32 ui32Value,
359                                  IMG_UINT32 ui32Mask,
360                                  PDUMP_POLL_OPERATOR eOperator,
361                                  IMG_UINT32 ui32PDumpFlags)
362 {
363         PVR_UNREFERENCED_PARAMETER(psSync);
364         PVR_UNREFERENCED_PARAMETER(ui32Value);
365         PVR_UNREFERENCED_PARAMETER(ui32Mask);
366         PVR_UNREFERENCED_PARAMETER(eOperator);
367         PVR_UNREFERENCED_PARAMETER(ui32PDumpFlags);
368 }
369
370 #ifdef INLINE_IS_PRAGMA
371 #pragma inline(SyncPrimServerPDumpPol)
372 #endif
373 static INLINE IMG_VOID
374 SyncPrimServerPDumpPol(PVRSRV_CLIENT_SYNC_PRIM *psSync,
375                                  PDUMP_POLL_OPERATOR eOperator,
376                                  IMG_UINT32 ui32PDumpFlags)
377 {
378         PVR_UNREFERENCED_PARAMETER(psSync);
379         PVR_UNREFERENCED_PARAMETER(eOperator);
380         PVR_UNREFERENCED_PARAMETER(ui32PDumpFlags);
381 }
382
383 #ifdef INLINE_IS_PRAGMA
384 #pragma inline(SyncPrimPDumpCBP)
385 #endif
386 static INLINE IMG_VOID 
387 SyncPrimPDumpCBP(PVRSRV_CLIENT_SYNC_PRIM *psSync,
388                                  IMG_UINT64 uiWriteOffset,
389                                  IMG_UINT64 uiPacketSize,
390                                  IMG_UINT64 uiBufferSize)
391 {
392         PVR_UNREFERENCED_PARAMETER(psSync);
393         PVR_UNREFERENCED_PARAMETER(uiWriteOffset);
394         PVR_UNREFERENCED_PARAMETER(uiPacketSize);
395         PVR_UNREFERENCED_PARAMETER(uiBufferSize);
396 }
397 #endif  /* PDUMP */
398 #endif  /* _PVRSRV_SYNC_ */
399