RK3368 GPU: Rogue N Init.
[firefly-linux-kernel-4.4.55.git] / drivers / staging / imgtec / rogue / 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 #include <linux/slab.h>
63
64 #include "lock.h"
65
66
67
68
69
70 /* ***************************************************************************
71  * Server-side bridge entry points
72  */
73  
74 static IMG_INT
75 PVRSRVBridgePVRSRVPDumpIsCapturing(IMG_UINT32 ui32DispatchTableEntry,
76                                           PVRSRV_BRIDGE_IN_PVRSRVPDUMPISCAPTURING *psPVRSRVPDumpIsCapturingIN,
77                                           PVRSRV_BRIDGE_OUT_PVRSRVPDUMPISCAPTURING *psPVRSRVPDumpIsCapturingOUT,
78                                          CONNECTION_DATA *psConnection)
79 {
80
81
82
83         PVR_UNREFERENCED_PARAMETER(psConnection);
84         PVR_UNREFERENCED_PARAMETER(psPVRSRVPDumpIsCapturingIN);
85
86
87
88
89
90         psPVRSRVPDumpIsCapturingOUT->eError =
91                 PDumpIsCaptureFrameKM(
92                                         &psPVRSRVPDumpIsCapturingOUT->bIsCapturing);
93
94
95
96
97
98
99
100
101         return 0;
102 }
103
104
105 static IMG_INT
106 PVRSRVBridgePVRSRVPDumpGetFrame(IMG_UINT32 ui32DispatchTableEntry,
107                                           PVRSRV_BRIDGE_IN_PVRSRVPDUMPGETFRAME *psPVRSRVPDumpGetFrameIN,
108                                           PVRSRV_BRIDGE_OUT_PVRSRVPDUMPGETFRAME *psPVRSRVPDumpGetFrameOUT,
109                                          CONNECTION_DATA *psConnection)
110 {
111
112
113
114         PVR_UNREFERENCED_PARAMETER(psPVRSRVPDumpGetFrameIN);
115
116
117
118
119
120         psPVRSRVPDumpGetFrameOUT->eError =
121                 PDumpGetFrameKM(psConnection, OSGetDevData(psConnection),
122                                         &psPVRSRVPDumpGetFrameOUT->ui32Frame);
123
124
125
126
127
128
129
130
131         return 0;
132 }
133
134
135 static IMG_INT
136 PVRSRVBridgePVRSRVPDumpSetDefaultCaptureParams(IMG_UINT32 ui32DispatchTableEntry,
137                                           PVRSRV_BRIDGE_IN_PVRSRVPDUMPSETDEFAULTCAPTUREPARAMS *psPVRSRVPDumpSetDefaultCaptureParamsIN,
138                                           PVRSRV_BRIDGE_OUT_PVRSRVPDUMPSETDEFAULTCAPTUREPARAMS *psPVRSRVPDumpSetDefaultCaptureParamsOUT,
139                                          CONNECTION_DATA *psConnection)
140 {
141
142
143
144         PVR_UNREFERENCED_PARAMETER(psConnection);
145
146
147
148
149
150         psPVRSRVPDumpSetDefaultCaptureParamsOUT->eError =
151                 PDumpSetDefaultCaptureParamsKM(
152                                         psPVRSRVPDumpSetDefaultCaptureParamsIN->ui32Mode,
153                                         psPVRSRVPDumpSetDefaultCaptureParamsIN->ui32Start,
154                                         psPVRSRVPDumpSetDefaultCaptureParamsIN->ui32End,
155                                         psPVRSRVPDumpSetDefaultCaptureParamsIN->ui32Interval,
156                                         psPVRSRVPDumpSetDefaultCaptureParamsIN->ui32MaxParamFileSize);
157
158
159
160
161
162
163
164
165         return 0;
166 }
167
168
169 static IMG_INT
170 PVRSRVBridgePVRSRVPDumpIsLastCaptureFrame(IMG_UINT32 ui32DispatchTableEntry,
171                                           PVRSRV_BRIDGE_IN_PVRSRVPDUMPISLASTCAPTUREFRAME *psPVRSRVPDumpIsLastCaptureFrameIN,
172                                           PVRSRV_BRIDGE_OUT_PVRSRVPDUMPISLASTCAPTUREFRAME *psPVRSRVPDumpIsLastCaptureFrameOUT,
173                                          CONNECTION_DATA *psConnection)
174 {
175
176
177
178         PVR_UNREFERENCED_PARAMETER(psConnection);
179         PVR_UNREFERENCED_PARAMETER(psPVRSRVPDumpIsLastCaptureFrameIN);
180
181
182
183
184
185         psPVRSRVPDumpIsLastCaptureFrameOUT->eError =
186                 PDumpIsLastCaptureFrameKM(
187                                         &psPVRSRVPDumpIsLastCaptureFrameOUT->bpbIsLastCaptureFrame);
188
189
190
191
192
193
194
195
196         return 0;
197 }
198
199
200
201
202 /* *************************************************************************** 
203  * Server bridge dispatch related glue 
204  */
205
206 static POS_LOCK pPDUMPCTRLBridgeLock;
207 static IMG_BOOL bUseLock = IMG_TRUE;
208
209 PVRSRV_ERROR InitPDUMPCTRLBridge(void);
210 PVRSRV_ERROR DeinitPDUMPCTRLBridge(void);
211
212 /*
213  * Register all PDUMPCTRL functions with services
214  */
215 PVRSRV_ERROR InitPDUMPCTRLBridge(void)
216 {
217         PVR_LOGR_IF_ERROR(OSLockCreate(&pPDUMPCTRLBridgeLock, LOCK_TYPE_PASSIVE), "OSLockCreate");
218
219         SetDispatchTableEntry(PVRSRV_BRIDGE_PDUMPCTRL, PVRSRV_BRIDGE_PDUMPCTRL_PVRSRVPDUMPISCAPTURING, PVRSRVBridgePVRSRVPDumpIsCapturing,
220                                         pPDUMPCTRLBridgeLock, bUseLock);
221
222         SetDispatchTableEntry(PVRSRV_BRIDGE_PDUMPCTRL, PVRSRV_BRIDGE_PDUMPCTRL_PVRSRVPDUMPGETFRAME, PVRSRVBridgePVRSRVPDumpGetFrame,
223                                         pPDUMPCTRLBridgeLock, bUseLock);
224
225         SetDispatchTableEntry(PVRSRV_BRIDGE_PDUMPCTRL, PVRSRV_BRIDGE_PDUMPCTRL_PVRSRVPDUMPSETDEFAULTCAPTUREPARAMS, PVRSRVBridgePVRSRVPDumpSetDefaultCaptureParams,
226                                         pPDUMPCTRLBridgeLock, bUseLock);
227
228         SetDispatchTableEntry(PVRSRV_BRIDGE_PDUMPCTRL, PVRSRV_BRIDGE_PDUMPCTRL_PVRSRVPDUMPISLASTCAPTUREFRAME, PVRSRVBridgePVRSRVPDumpIsLastCaptureFrame,
229                                         pPDUMPCTRLBridgeLock, bUseLock);
230
231
232         return PVRSRV_OK;
233 }
234
235 /*
236  * Unregister all pdumpctrl functions with services
237  */
238 PVRSRV_ERROR DeinitPDUMPCTRLBridge(void)
239 {
240         PVR_LOGR_IF_ERROR(OSLockDestroy(pPDUMPCTRLBridgeLock), "OSLockDestroy");
241         return PVRSRV_OK;
242 }