RK3368 GPU: Rogue N Init.
[firefly-linux-kernel-4.4.55.git] / drivers / staging / imgtec / rogue / generated / sync_bridge / client_sync_direct_bridge.c
1 /*************************************************************************/ /*!
2 @Title          Direct client bridge for sync
3 @Copyright      Copyright (c) Imagination Technologies Ltd. All Rights Reserved
4 @License        Dual MIT/GPLv2
5
6 The contents of this file are subject to the MIT license as set out below.
7
8 Permission is hereby granted, free of charge, to any person obtaining a copy
9 of this software and associated documentation files (the "Software"), to deal
10 in the Software without restriction, including without limitation the rights
11 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 copies of the Software, and to permit persons to whom the Software is
13 furnished to do so, subject to the following conditions:
14
15 The above copyright notice and this permission notice shall be included in
16 all copies or substantial portions of the Software.
17
18 Alternatively, the contents of this file may be used under the terms of
19 the GNU General Public License Version 2 ("GPL") in which case the provisions
20 of GPL are applicable instead of those above.
21
22 If you wish to allow use of your version of this file only under the terms of
23 GPL, and not to allow others to use your version of this file under the terms
24 of the MIT license, indicate your decision by deleting the provisions above
25 and replace them with the notice and other provisions required by GPL as set
26 out in the file called "GPL-COPYING" included in this distribution. If you do
27 not delete the provisions above, a recipient may use your version of this file
28 under the terms of either the MIT license or GPL.
29
30 This License is also included in this distribution in the file called
31 "MIT-COPYING".
32
33 EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) THE SOFTWARE IS
34 PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
35 BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
36 PURPOSE AND NONINFRINGEMENT; AND (B) IN NO EVENT SHALL THE AUTHORS OR
37 COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
38 IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
39 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
40 */ /**************************************************************************/
41
42 #include "client_sync_bridge.h"
43 #include "img_defs.h"
44 #include "pvr_debug.h"
45
46 /* Module specific includes */
47 #include "pdump.h"
48 #include "pdumpdefs.h"
49 #include "devicemem_typedefs.h"
50
51 #include "sync.h"
52 #include "sync_server.h"
53 #include "pdump.h"
54
55
56 IMG_INTERNAL PVRSRV_ERROR IMG_CALLCONV BridgeAllocSyncPrimitiveBlock(IMG_HANDLE hBridge,
57                                                                      IMG_HANDLE *phSyncHandle,
58                                                                      IMG_UINT32 *pui32SyncPrimVAddr,
59                                                                      IMG_UINT32 *pui32SyncPrimBlockSize,
60                                                                      IMG_HANDLE *phhSyncPMR)
61 {
62         PVRSRV_ERROR eError;
63         SYNC_PRIMITIVE_BLOCK * psSyncHandleInt;
64         PMR * pshSyncPMRInt;
65
66
67         eError =
68                 PVRSRVAllocSyncPrimitiveBlockKM(NULL, (PVRSRV_DEVICE_NODE *)((void*) hBridge)
69                 ,
70                                         &psSyncHandleInt,
71                                         pui32SyncPrimVAddr,
72                                         pui32SyncPrimBlockSize,
73                                         &pshSyncPMRInt);
74
75         *phSyncHandle = psSyncHandleInt;
76         *phhSyncPMR = pshSyncPMRInt;
77         return eError;
78 }
79
80 IMG_INTERNAL PVRSRV_ERROR IMG_CALLCONV BridgeFreeSyncPrimitiveBlock(IMG_HANDLE hBridge,
81                                                                     IMG_HANDLE hSyncHandle)
82 {
83         PVRSRV_ERROR eError;
84         SYNC_PRIMITIVE_BLOCK * psSyncHandleInt;
85         PVR_UNREFERENCED_PARAMETER(hBridge);
86
87         psSyncHandleInt = (SYNC_PRIMITIVE_BLOCK *) hSyncHandle;
88
89         eError =
90                 PVRSRVFreeSyncPrimitiveBlockKM(
91                                         psSyncHandleInt);
92
93         return eError;
94 }
95
96 IMG_INTERNAL PVRSRV_ERROR IMG_CALLCONV BridgeSyncPrimSet(IMG_HANDLE hBridge,
97                                                          IMG_HANDLE hSyncHandle,
98                                                          IMG_UINT32 ui32Index,
99                                                          IMG_UINT32 ui32Value)
100 {
101         PVRSRV_ERROR eError;
102         SYNC_PRIMITIVE_BLOCK * psSyncHandleInt;
103         PVR_UNREFERENCED_PARAMETER(hBridge);
104
105         psSyncHandleInt = (SYNC_PRIMITIVE_BLOCK *) hSyncHandle;
106
107         eError =
108                 PVRSRVSyncPrimSetKM(
109                                         psSyncHandleInt,
110                                         ui32Index,
111                                         ui32Value);
112
113         return eError;
114 }
115
116 IMG_INTERNAL PVRSRV_ERROR IMG_CALLCONV BridgeServerSyncPrimSet(IMG_HANDLE hBridge,
117                                                                IMG_HANDLE hSyncHandle,
118                                                                IMG_UINT32 ui32Value)
119 {
120         PVRSRV_ERROR eError;
121         SERVER_SYNC_PRIMITIVE * psSyncHandleInt;
122         PVR_UNREFERENCED_PARAMETER(hBridge);
123
124         psSyncHandleInt = (SERVER_SYNC_PRIMITIVE *) hSyncHandle;
125
126         eError =
127                 PVRSRVServerSyncPrimSetKM(
128                                         psSyncHandleInt,
129                                         ui32Value);
130
131         return eError;
132 }
133
134 IMG_INTERNAL PVRSRV_ERROR IMG_CALLCONV BridgeServerSyncAlloc(IMG_HANDLE hBridge,
135                                                              IMG_HANDLE *phSyncHandle,
136                                                              IMG_UINT32 *pui32SyncPrimVAddr,
137                                                              IMG_UINT32 ui32ClassNameSize,
138                                                              const IMG_CHAR *puiClassName)
139 {
140         PVRSRV_ERROR eError;
141         SERVER_SYNC_PRIMITIVE * psSyncHandleInt;
142
143
144         eError =
145                 PVRSRVServerSyncAllocKM(NULL, (PVRSRV_DEVICE_NODE *)((void*) hBridge)
146                 ,
147                                         &psSyncHandleInt,
148                                         pui32SyncPrimVAddr,
149                                         ui32ClassNameSize,
150                                         puiClassName);
151
152         *phSyncHandle = psSyncHandleInt;
153         return eError;
154 }
155
156 IMG_INTERNAL PVRSRV_ERROR IMG_CALLCONV BridgeServerSyncFree(IMG_HANDLE hBridge,
157                                                             IMG_HANDLE hSyncHandle)
158 {
159         PVRSRV_ERROR eError;
160         SERVER_SYNC_PRIMITIVE * psSyncHandleInt;
161         PVR_UNREFERENCED_PARAMETER(hBridge);
162
163         psSyncHandleInt = (SERVER_SYNC_PRIMITIVE *) hSyncHandle;
164
165         eError =
166                 PVRSRVServerSyncFreeKM(
167                                         psSyncHandleInt);
168
169         return eError;
170 }
171
172 IMG_INTERNAL PVRSRV_ERROR IMG_CALLCONV BridgeServerSyncQueueHWOp(IMG_HANDLE hBridge,
173                                                                  IMG_HANDLE hSyncHandle,
174                                                                  IMG_BOOL bbUpdate,
175                                                                  IMG_UINT32 *pui32FenceValue,
176                                                                  IMG_UINT32 *pui32UpdateValue)
177 {
178         PVRSRV_ERROR eError;
179         SERVER_SYNC_PRIMITIVE * psSyncHandleInt;
180         PVR_UNREFERENCED_PARAMETER(hBridge);
181
182         psSyncHandleInt = (SERVER_SYNC_PRIMITIVE *) hSyncHandle;
183
184         eError =
185                 PVRSRVServerSyncQueueHWOpKM(
186                                         psSyncHandleInt,
187                                         bbUpdate,
188                                         pui32FenceValue,
189                                         pui32UpdateValue);
190
191         return eError;
192 }
193
194 IMG_INTERNAL PVRSRV_ERROR IMG_CALLCONV BridgeServerSyncGetStatus(IMG_HANDLE hBridge,
195                                                                  IMG_UINT32 ui32SyncCount,
196                                                                  IMG_HANDLE *phSyncHandle,
197                                                                  IMG_UINT32 *pui32UID,
198                                                                  IMG_UINT32 *pui32FWAddr,
199                                                                  IMG_UINT32 *pui32CurrentOp,
200                                                                  IMG_UINT32 *pui32NextOp)
201 {
202         PVRSRV_ERROR eError;
203         SERVER_SYNC_PRIMITIVE * *psSyncHandleInt;
204         PVR_UNREFERENCED_PARAMETER(hBridge);
205
206         psSyncHandleInt = (SERVER_SYNC_PRIMITIVE **) phSyncHandle;
207
208         eError =
209                 PVRSRVServerSyncGetStatusKM(
210                                         ui32SyncCount,
211                                         psSyncHandleInt,
212                                         pui32UID,
213                                         pui32FWAddr,
214                                         pui32CurrentOp,
215                                         pui32NextOp);
216
217         return eError;
218 }
219
220 IMG_INTERNAL PVRSRV_ERROR IMG_CALLCONV BridgeSyncPrimOpCreate(IMG_HANDLE hBridge,
221                                                               IMG_UINT32 ui32SyncBlockCount,
222                                                               IMG_HANDLE *phBlockList,
223                                                               IMG_UINT32 ui32ClientSyncCount,
224                                                               IMG_UINT32 *pui32SyncBlockIndex,
225                                                               IMG_UINT32 *pui32Index,
226                                                               IMG_UINT32 ui32ServerSyncCount,
227                                                               IMG_HANDLE *phServerSync,
228                                                               IMG_HANDLE *phServerCookie)
229 {
230         PVRSRV_ERROR eError;
231         SYNC_PRIMITIVE_BLOCK * *psBlockListInt;
232         SERVER_SYNC_PRIMITIVE * *psServerSyncInt;
233         SERVER_OP_COOKIE * psServerCookieInt;
234         PVR_UNREFERENCED_PARAMETER(hBridge);
235
236         psBlockListInt = (SYNC_PRIMITIVE_BLOCK **) phBlockList;
237         psServerSyncInt = (SERVER_SYNC_PRIMITIVE **) phServerSync;
238
239         eError =
240                 PVRSRVSyncPrimOpCreateKM(
241                                         ui32SyncBlockCount,
242                                         psBlockListInt,
243                                         ui32ClientSyncCount,
244                                         pui32SyncBlockIndex,
245                                         pui32Index,
246                                         ui32ServerSyncCount,
247                                         psServerSyncInt,
248                                         &psServerCookieInt);
249
250         *phServerCookie = psServerCookieInt;
251         return eError;
252 }
253
254 IMG_INTERNAL PVRSRV_ERROR IMG_CALLCONV BridgeSyncPrimOpTake(IMG_HANDLE hBridge,
255                                                             IMG_HANDLE hServerCookie,
256                                                             IMG_UINT32 ui32ClientSyncCount,
257                                                             IMG_UINT32 *pui32Flags,
258                                                             IMG_UINT32 *pui32FenceValue,
259                                                             IMG_UINT32 *pui32UpdateValue,
260                                                             IMG_UINT32 ui32ServerSyncCount,
261                                                             IMG_UINT32 *pui32ServerFlags)
262 {
263         PVRSRV_ERROR eError;
264         SERVER_OP_COOKIE * psServerCookieInt;
265         PVR_UNREFERENCED_PARAMETER(hBridge);
266
267         psServerCookieInt = (SERVER_OP_COOKIE *) hServerCookie;
268
269         eError =
270                 PVRSRVSyncPrimOpTakeKM(
271                                         psServerCookieInt,
272                                         ui32ClientSyncCount,
273                                         pui32Flags,
274                                         pui32FenceValue,
275                                         pui32UpdateValue,
276                                         ui32ServerSyncCount,
277                                         pui32ServerFlags);
278
279         return eError;
280 }
281
282 IMG_INTERNAL PVRSRV_ERROR IMG_CALLCONV BridgeSyncPrimOpReady(IMG_HANDLE hBridge,
283                                                              IMG_HANDLE hServerCookie,
284                                                              IMG_BOOL *pbReady)
285 {
286         PVRSRV_ERROR eError;
287         SERVER_OP_COOKIE * psServerCookieInt;
288         PVR_UNREFERENCED_PARAMETER(hBridge);
289
290         psServerCookieInt = (SERVER_OP_COOKIE *) hServerCookie;
291
292         eError =
293                 PVRSRVSyncPrimOpReadyKM(
294                                         psServerCookieInt,
295                                         pbReady);
296
297         return eError;
298 }
299
300 IMG_INTERNAL PVRSRV_ERROR IMG_CALLCONV BridgeSyncPrimOpComplete(IMG_HANDLE hBridge,
301                                                                 IMG_HANDLE hServerCookie)
302 {
303         PVRSRV_ERROR eError;
304         SERVER_OP_COOKIE * psServerCookieInt;
305         PVR_UNREFERENCED_PARAMETER(hBridge);
306
307         psServerCookieInt = (SERVER_OP_COOKIE *) hServerCookie;
308
309         eError =
310                 PVRSRVSyncPrimOpCompleteKM(
311                                         psServerCookieInt);
312
313         return eError;
314 }
315
316 IMG_INTERNAL PVRSRV_ERROR IMG_CALLCONV BridgeSyncPrimOpDestroy(IMG_HANDLE hBridge,
317                                                                IMG_HANDLE hServerCookie)
318 {
319         PVRSRV_ERROR eError;
320         SERVER_OP_COOKIE * psServerCookieInt;
321         PVR_UNREFERENCED_PARAMETER(hBridge);
322
323         psServerCookieInt = (SERVER_OP_COOKIE *) hServerCookie;
324
325         eError =
326                 PVRSRVSyncPrimOpDestroyKM(
327                                         psServerCookieInt);
328
329         return eError;
330 }
331
332 IMG_INTERNAL PVRSRV_ERROR IMG_CALLCONV BridgeSyncPrimPDump(IMG_HANDLE hBridge,
333                                                            IMG_HANDLE hSyncHandle,
334                                                            IMG_UINT32 ui32Offset)
335 {
336 #if defined(PDUMP)
337         PVRSRV_ERROR eError;
338         SYNC_PRIMITIVE_BLOCK * psSyncHandleInt;
339         PVR_UNREFERENCED_PARAMETER(hBridge);
340
341         psSyncHandleInt = (SYNC_PRIMITIVE_BLOCK *) hSyncHandle;
342
343         eError =
344                 PVRSRVSyncPrimPDumpKM(
345                                         psSyncHandleInt,
346                                         ui32Offset);
347
348         return eError;
349 #else
350         PVR_UNREFERENCED_PARAMETER(hBridge);
351         PVR_UNREFERENCED_PARAMETER(hSyncHandle);
352         PVR_UNREFERENCED_PARAMETER(ui32Offset);
353
354         return PVRSRV_ERROR_NOT_IMPLEMENTED;
355 #endif
356 }
357
358 IMG_INTERNAL PVRSRV_ERROR IMG_CALLCONV BridgeSyncPrimPDumpValue(IMG_HANDLE hBridge,
359                                                                 IMG_HANDLE hSyncHandle,
360                                                                 IMG_UINT32 ui32Offset,
361                                                                 IMG_UINT32 ui32Value)
362 {
363 #if defined(PDUMP)
364         PVRSRV_ERROR eError;
365         SYNC_PRIMITIVE_BLOCK * psSyncHandleInt;
366         PVR_UNREFERENCED_PARAMETER(hBridge);
367
368         psSyncHandleInt = (SYNC_PRIMITIVE_BLOCK *) hSyncHandle;
369
370         eError =
371                 PVRSRVSyncPrimPDumpValueKM(
372                                         psSyncHandleInt,
373                                         ui32Offset,
374                                         ui32Value);
375
376         return eError;
377 #else
378         PVR_UNREFERENCED_PARAMETER(hBridge);
379         PVR_UNREFERENCED_PARAMETER(hSyncHandle);
380         PVR_UNREFERENCED_PARAMETER(ui32Offset);
381         PVR_UNREFERENCED_PARAMETER(ui32Value);
382
383         return PVRSRV_ERROR_NOT_IMPLEMENTED;
384 #endif
385 }
386
387 IMG_INTERNAL PVRSRV_ERROR IMG_CALLCONV BridgeSyncPrimPDumpPol(IMG_HANDLE hBridge,
388                                                               IMG_HANDLE hSyncHandle,
389                                                               IMG_UINT32 ui32Offset,
390                                                               IMG_UINT32 ui32Value,
391                                                               IMG_UINT32 ui32Mask,
392                                                               PDUMP_POLL_OPERATOR eOperator,
393                                                               PDUMP_FLAGS_T uiPDumpFlags)
394 {
395 #if defined(PDUMP)
396         PVRSRV_ERROR eError;
397         SYNC_PRIMITIVE_BLOCK * psSyncHandleInt;
398         PVR_UNREFERENCED_PARAMETER(hBridge);
399
400         psSyncHandleInt = (SYNC_PRIMITIVE_BLOCK *) hSyncHandle;
401
402         eError =
403                 PVRSRVSyncPrimPDumpPolKM(
404                                         psSyncHandleInt,
405                                         ui32Offset,
406                                         ui32Value,
407                                         ui32Mask,
408                                         eOperator,
409                                         uiPDumpFlags);
410
411         return eError;
412 #else
413         PVR_UNREFERENCED_PARAMETER(hBridge);
414         PVR_UNREFERENCED_PARAMETER(hSyncHandle);
415         PVR_UNREFERENCED_PARAMETER(ui32Offset);
416         PVR_UNREFERENCED_PARAMETER(ui32Value);
417         PVR_UNREFERENCED_PARAMETER(ui32Mask);
418         PVR_UNREFERENCED_PARAMETER(eOperator);
419         PVR_UNREFERENCED_PARAMETER(uiPDumpFlags);
420
421         return PVRSRV_ERROR_NOT_IMPLEMENTED;
422 #endif
423 }
424
425 IMG_INTERNAL PVRSRV_ERROR IMG_CALLCONV BridgeSyncPrimOpPDumpPol(IMG_HANDLE hBridge,
426                                                                 IMG_HANDLE hServerCookie,
427                                                                 PDUMP_POLL_OPERATOR eOperator,
428                                                                 PDUMP_FLAGS_T uiPDumpFlags)
429 {
430 #if defined(PDUMP)
431         PVRSRV_ERROR eError;
432         SERVER_OP_COOKIE * psServerCookieInt;
433         PVR_UNREFERENCED_PARAMETER(hBridge);
434
435         psServerCookieInt = (SERVER_OP_COOKIE *) hServerCookie;
436
437         eError =
438                 PVRSRVSyncPrimOpPDumpPolKM(
439                                         psServerCookieInt,
440                                         eOperator,
441                                         uiPDumpFlags);
442
443         return eError;
444 #else
445         PVR_UNREFERENCED_PARAMETER(hBridge);
446         PVR_UNREFERENCED_PARAMETER(hServerCookie);
447         PVR_UNREFERENCED_PARAMETER(eOperator);
448         PVR_UNREFERENCED_PARAMETER(uiPDumpFlags);
449
450         return PVRSRV_ERROR_NOT_IMPLEMENTED;
451 #endif
452 }
453
454 IMG_INTERNAL PVRSRV_ERROR IMG_CALLCONV BridgeSyncPrimPDumpCBP(IMG_HANDLE hBridge,
455                                                               IMG_HANDLE hSyncHandle,
456                                                               IMG_UINT32 ui32Offset,
457                                                               IMG_DEVMEM_OFFSET_T uiWriteOffset,
458                                                               IMG_DEVMEM_SIZE_T uiPacketSize,
459                                                               IMG_DEVMEM_SIZE_T uiBufferSize)
460 {
461 #if defined(PDUMP)
462         PVRSRV_ERROR eError;
463         SYNC_PRIMITIVE_BLOCK * psSyncHandleInt;
464         PVR_UNREFERENCED_PARAMETER(hBridge);
465
466         psSyncHandleInt = (SYNC_PRIMITIVE_BLOCK *) hSyncHandle;
467
468         eError =
469                 PVRSRVSyncPrimPDumpCBPKM(
470                                         psSyncHandleInt,
471                                         ui32Offset,
472                                         uiWriteOffset,
473                                         uiPacketSize,
474                                         uiBufferSize);
475
476         return eError;
477 #else
478         PVR_UNREFERENCED_PARAMETER(hBridge);
479         PVR_UNREFERENCED_PARAMETER(hSyncHandle);
480         PVR_UNREFERENCED_PARAMETER(ui32Offset);
481         PVR_UNREFERENCED_PARAMETER(uiWriteOffset);
482         PVR_UNREFERENCED_PARAMETER(uiPacketSize);
483         PVR_UNREFERENCED_PARAMETER(uiBufferSize);
484
485         return PVRSRV_ERROR_NOT_IMPLEMENTED;
486 #endif
487 }
488
489 IMG_INTERNAL PVRSRV_ERROR IMG_CALLCONV BridgeSyncAllocEvent(IMG_HANDLE hBridge,
490                                                             IMG_BOOL bServerSync,
491                                                             IMG_UINT32 ui32FWAddr,
492                                                             IMG_UINT32 ui32ClassNameSize,
493                                                             const IMG_CHAR *puiClassName)
494 {
495         PVRSRV_ERROR eError;
496         PVR_UNREFERENCED_PARAMETER(hBridge);
497
498
499         eError =
500                 PVRSRVSyncAllocEventKM(
501                                         bServerSync,
502                                         ui32FWAddr,
503                                         ui32ClassNameSize,
504                                         puiClassName);
505
506         return eError;
507 }
508
509 IMG_INTERNAL PVRSRV_ERROR IMG_CALLCONV BridgeSyncFreeEvent(IMG_HANDLE hBridge,
510                                                            IMG_UINT32 ui32FWAddr)
511 {
512         PVRSRV_ERROR eError;
513         PVR_UNREFERENCED_PARAMETER(hBridge);
514
515
516         eError =
517                 PVRSRVSyncFreeEventKM(
518                                         ui32FWAddr);
519
520         return eError;
521 }
522