RK3368 GPU version Rogue M 1.28
[firefly-linux-kernel-4.4.55.git] / drivers / gpu / rogue_m / generated / pdumpctrl_bridge / server_pdumpctrl_bridge.c
1 /*************************************************************************/ /*!
2 @File
3 @Title          Server bridge for pdumpctrl
4 @Copyright      Copyright (c) Imagination Technologies Ltd. All Rights Reserved
5 @Description    Implements the server side of the bridge for pdumpctrl
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 <stddef.h>
45 #include <asm/uaccess.h>
46
47 #include "img_defs.h"
48
49 #include "pdump_km.h"
50
51
52 #include "common_pdumpctrl_bridge.h"
53
54 #include "allocmem.h"
55 #include "pvr_debug.h"
56 #include "connection_server.h"
57 #include "pvr_bridge.h"
58 #include "rgx_bridge.h"
59 #include "srvcore.h"
60 #include "handle.h"
61
62 #if defined (SUPPORT_AUTH)
63 #include "osauth.h"
64 #endif
65
66 #include <linux/slab.h>
67
68 #include "lock.h"
69
70
71
72 /* ***************************************************************************
73  * Server-side bridge entry points
74  */
75  
76 static IMG_INT
77 PVRSRVBridgePVRSRVPDumpIsCapturing(IMG_UINT32 ui32DispatchTableEntry,
78                                           PVRSRV_BRIDGE_IN_PVRSRVPDUMPISCAPTURING *psPVRSRVPDumpIsCapturingIN,
79                                           PVRSRV_BRIDGE_OUT_PVRSRVPDUMPISCAPTURING *psPVRSRVPDumpIsCapturingOUT,
80                                          CONNECTION_DATA *psConnection)
81 {
82
83         PVR_UNREFERENCED_PARAMETER(psConnection);
84         PVR_UNREFERENCED_PARAMETER(psPVRSRVPDumpIsCapturingIN);
85
86
87
88
89
90
91         psPVRSRVPDumpIsCapturingOUT->eError =
92                 PDumpIsCaptureFrameKM(
93                                         &psPVRSRVPDumpIsCapturingOUT->bIsCapturing);
94
95
96
97
98
99         return 0;
100 }
101
102 static IMG_INT
103 PVRSRVBridgePVRSRVPDumpGetFrame(IMG_UINT32 ui32DispatchTableEntry,
104                                           PVRSRV_BRIDGE_IN_PVRSRVPDUMPGETFRAME *psPVRSRVPDumpGetFrameIN,
105                                           PVRSRV_BRIDGE_OUT_PVRSRVPDUMPGETFRAME *psPVRSRVPDumpGetFrameOUT,
106                                          CONNECTION_DATA *psConnection)
107 {
108
109         PVR_UNREFERENCED_PARAMETER(psPVRSRVPDumpGetFrameIN);
110
111
112
113
114
115
116         psPVRSRVPDumpGetFrameOUT->eError =
117                 PDumpGetFrameKM(psConnection,
118                                         &psPVRSRVPDumpGetFrameOUT->ui32Frame);
119
120
121
122
123
124         return 0;
125 }
126
127 static IMG_INT
128 PVRSRVBridgePVRSRVPDumpSetDefaultCaptureParams(IMG_UINT32 ui32DispatchTableEntry,
129                                           PVRSRV_BRIDGE_IN_PVRSRVPDUMPSETDEFAULTCAPTUREPARAMS *psPVRSRVPDumpSetDefaultCaptureParamsIN,
130                                           PVRSRV_BRIDGE_OUT_PVRSRVPDUMPSETDEFAULTCAPTUREPARAMS *psPVRSRVPDumpSetDefaultCaptureParamsOUT,
131                                          CONNECTION_DATA *psConnection)
132 {
133
134         PVR_UNREFERENCED_PARAMETER(psConnection);
135
136
137
138
139
140
141         psPVRSRVPDumpSetDefaultCaptureParamsOUT->eError =
142                 PDumpSetDefaultCaptureParamsKM(
143                                         psPVRSRVPDumpSetDefaultCaptureParamsIN->ui32Mode,
144                                         psPVRSRVPDumpSetDefaultCaptureParamsIN->ui32Start,
145                                         psPVRSRVPDumpSetDefaultCaptureParamsIN->ui32End,
146                                         psPVRSRVPDumpSetDefaultCaptureParamsIN->ui32Interval,
147                                         psPVRSRVPDumpSetDefaultCaptureParamsIN->ui32MaxParamFileSize);
148
149
150
151
152
153         return 0;
154 }
155
156 static IMG_INT
157 PVRSRVBridgePVRSRVPDumpIsLastCaptureFrame(IMG_UINT32 ui32DispatchTableEntry,
158                                           PVRSRV_BRIDGE_IN_PVRSRVPDUMPISLASTCAPTUREFRAME *psPVRSRVPDumpIsLastCaptureFrameIN,
159                                           PVRSRV_BRIDGE_OUT_PVRSRVPDUMPISLASTCAPTUREFRAME *psPVRSRVPDumpIsLastCaptureFrameOUT,
160                                          CONNECTION_DATA *psConnection)
161 {
162
163         PVR_UNREFERENCED_PARAMETER(psConnection);
164         PVR_UNREFERENCED_PARAMETER(psPVRSRVPDumpIsLastCaptureFrameIN);
165
166
167
168
169
170
171         psPVRSRVPDumpIsLastCaptureFrameOUT->eError =
172                 PDumpIsLastCaptureFrameKM(
173                                         );
174
175
176
177
178
179         return 0;
180 }
181
182 static IMG_INT
183 PVRSRVBridgePVRSRVPDumpStartInitPhase(IMG_UINT32 ui32DispatchTableEntry,
184                                           PVRSRV_BRIDGE_IN_PVRSRVPDUMPSTARTINITPHASE *psPVRSRVPDumpStartInitPhaseIN,
185                                           PVRSRV_BRIDGE_OUT_PVRSRVPDUMPSTARTINITPHASE *psPVRSRVPDumpStartInitPhaseOUT,
186                                          CONNECTION_DATA *psConnection)
187 {
188
189         PVR_UNREFERENCED_PARAMETER(psConnection);
190         PVR_UNREFERENCED_PARAMETER(psPVRSRVPDumpStartInitPhaseIN);
191
192
193
194
195
196
197         psPVRSRVPDumpStartInitPhaseOUT->eError =
198                 PDumpStartInitPhaseKM(
199                                         );
200
201
202
203
204
205         return 0;
206 }
207
208 static IMG_INT
209 PVRSRVBridgePVRSRVPDumpStopInitPhase(IMG_UINT32 ui32DispatchTableEntry,
210                                           PVRSRV_BRIDGE_IN_PVRSRVPDUMPSTOPINITPHASE *psPVRSRVPDumpStopInitPhaseIN,
211                                           PVRSRV_BRIDGE_OUT_PVRSRVPDUMPSTOPINITPHASE *psPVRSRVPDumpStopInitPhaseOUT,
212                                          CONNECTION_DATA *psConnection)
213 {
214
215         PVR_UNREFERENCED_PARAMETER(psConnection);
216
217
218
219
220
221
222         psPVRSRVPDumpStopInitPhaseOUT->eError =
223                 PDumpStopInitPhaseKM(
224                                         psPVRSRVPDumpStopInitPhaseIN->eModuleID);
225
226
227
228
229
230         return 0;
231 }
232
233
234
235 /* *************************************************************************** 
236  * Server bridge dispatch related glue 
237  */
238
239 static POS_LOCK pPDUMPCTRLBridgeLock;
240 static IMG_BYTE pbyPDUMPCTRLBridgeBuffer[20 +  8];
241
242 PVRSRV_ERROR InitPDUMPCTRLBridge(IMG_VOID);
243 PVRSRV_ERROR DeinitPDUMPCTRLBridge(IMG_VOID);
244
245 /*
246  * Register all PDUMPCTRL functions with services
247  */
248 PVRSRV_ERROR InitPDUMPCTRLBridge(IMG_VOID)
249 {
250         PVR_LOGR_IF_ERROR(OSLockCreate(&pPDUMPCTRLBridgeLock, LOCK_TYPE_PASSIVE), "OSLockCreate");
251
252         SetDispatchTableEntry(PVRSRV_BRIDGE_PDUMPCTRL, PVRSRV_BRIDGE_PDUMPCTRL_PVRSRVPDUMPISCAPTURING, PVRSRVBridgePVRSRVPDumpIsCapturing,
253                                         pPDUMPCTRLBridgeLock, pbyPDUMPCTRLBridgeBuffer,
254                                         20,  8);
255
256         SetDispatchTableEntry(PVRSRV_BRIDGE_PDUMPCTRL, PVRSRV_BRIDGE_PDUMPCTRL_PVRSRVPDUMPGETFRAME, PVRSRVBridgePVRSRVPDumpGetFrame,
257                                         pPDUMPCTRLBridgeLock, pbyPDUMPCTRLBridgeBuffer,
258                                         20,  8);
259
260         SetDispatchTableEntry(PVRSRV_BRIDGE_PDUMPCTRL, PVRSRV_BRIDGE_PDUMPCTRL_PVRSRVPDUMPSETDEFAULTCAPTUREPARAMS, PVRSRVBridgePVRSRVPDumpSetDefaultCaptureParams,
261                                         pPDUMPCTRLBridgeLock, pbyPDUMPCTRLBridgeBuffer,
262                                         20,  8);
263
264         SetDispatchTableEntry(PVRSRV_BRIDGE_PDUMPCTRL, PVRSRV_BRIDGE_PDUMPCTRL_PVRSRVPDUMPISLASTCAPTUREFRAME, PVRSRVBridgePVRSRVPDumpIsLastCaptureFrame,
265                                         pPDUMPCTRLBridgeLock, pbyPDUMPCTRLBridgeBuffer,
266                                         20,  8);
267
268         SetDispatchTableEntry(PVRSRV_BRIDGE_PDUMPCTRL, PVRSRV_BRIDGE_PDUMPCTRL_PVRSRVPDUMPSTARTINITPHASE, PVRSRVBridgePVRSRVPDumpStartInitPhase,
269                                         pPDUMPCTRLBridgeLock, pbyPDUMPCTRLBridgeBuffer,
270                                         20,  8);
271
272         SetDispatchTableEntry(PVRSRV_BRIDGE_PDUMPCTRL, PVRSRV_BRIDGE_PDUMPCTRL_PVRSRVPDUMPSTOPINITPHASE, PVRSRVBridgePVRSRVPDumpStopInitPhase,
273                                         pPDUMPCTRLBridgeLock, pbyPDUMPCTRLBridgeBuffer,
274                                         20,  8);
275
276
277         return PVRSRV_OK;
278 }
279
280 /*
281  * Unregister all pdumpctrl functions with services
282  */
283 PVRSRV_ERROR DeinitPDUMPCTRLBridge(IMG_VOID)
284 {
285         PVR_LOGR_IF_ERROR(OSLockDestroy(pPDUMPCTRLBridgeLock), "OSLockDestroy");
286         return PVRSRV_OK;
287 }
288