RK3368 GPU: Rogue N Init.
[firefly-linux-kernel-4.4.55.git] / drivers / staging / imgtec / rogue / generated / rgxsignals_bridge / server_rgxsignals_bridge.c
1 /*************************************************************************/ /*!
2 @File
3 @Title          Server bridge for rgxsignals
4 @Copyright      Copyright (c) Imagination Technologies Ltd. All Rights Reserved
5 @Description    Implements the server side of the bridge for rgxsignals
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 "rgxsignals.h"
50
51
52 #include "common_rgxsignals_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
65 #include "rgx_bvnc_defs_km.h"
66
67
68
69
70 /* ***************************************************************************
71  * Server-side bridge entry points
72  */
73  
74 static IMG_INT
75 PVRSRVBridgeRGXNotifySignalUpdate(IMG_UINT32 ui32DispatchTableEntry,
76                                           PVRSRV_BRIDGE_IN_RGXNOTIFYSIGNALUPDATE *psRGXNotifySignalUpdateIN,
77                                           PVRSRV_BRIDGE_OUT_RGXNOTIFYSIGNALUPDATE *psRGXNotifySignalUpdateOUT,
78                                          CONNECTION_DATA *psConnection)
79 {
80         IMG_HANDLE hPrivData = psRGXNotifySignalUpdateIN->hPrivData;
81         IMG_HANDLE hPrivDataInt = NULL;
82
83
84         {
85                 PVRSRV_DEVICE_NODE *psDeviceNode = OSGetDevData(psConnection);
86
87                 /* Check that device supports the required feature */
88                 if ((psDeviceNode->pfnCheckDeviceFeature) &&
89                         !psDeviceNode->pfnCheckDeviceFeature(psDeviceNode, RGX_FEATURE_SIGNAL_SNOOPING_BIT_MASK))
90                 {
91                         psRGXNotifySignalUpdateOUT->eError = PVRSRV_ERROR_NOT_SUPPORTED;
92
93                         goto RGXNotifySignalUpdate_exit;
94                 }
95         }
96
97
98
99
100
101         /* Lock over handle lookup. */
102         LockHandle();
103
104
105
106
107
108                                 {
109                                         /* Look up the address from the handle */
110                                         psRGXNotifySignalUpdateOUT->eError =
111                                                 PVRSRVLookupHandleUnlocked(psConnection->psHandleBase,
112                                                                                         (void **) &hPrivDataInt,
113                                                                                         hPrivData,
114                                                                                         PVRSRV_HANDLE_TYPE_DEV_PRIV_DATA,
115                                                                                         IMG_TRUE);
116                                         if(psRGXNotifySignalUpdateOUT->eError != PVRSRV_OK)
117                                         {
118                                                 UnlockHandle();
119                                                 goto RGXNotifySignalUpdate_exit;
120                                         }
121                                 }
122         /* Release now we have looked up handles. */
123         UnlockHandle();
124
125         psRGXNotifySignalUpdateOUT->eError =
126                 PVRSRVRGXNotifySignalUpdateKM(psConnection, OSGetDevData(psConnection),
127                                         hPrivDataInt,
128                                         psRGXNotifySignalUpdateIN->sDevSignalAddress);
129
130
131
132
133 RGXNotifySignalUpdate_exit:
134
135         /* Lock over handle lookup cleanup. */
136         LockHandle();
137
138
139
140
141
142
143                                 {
144                                         /* Unreference the previously looked up handle */
145                                                 if(hPrivDataInt)
146                                                 {
147                                                         PVRSRVReleaseHandleUnlocked(psConnection->psHandleBase,
148                                                                                         hPrivData,
149                                                                                         PVRSRV_HANDLE_TYPE_DEV_PRIV_DATA);
150                                                 }
151                                 }
152         /* Release now we have cleaned up look up handles. */
153         UnlockHandle();
154
155
156         return 0;
157 }
158
159
160
161
162 /* *************************************************************************** 
163  * Server bridge dispatch related glue 
164  */
165
166 static IMG_BOOL bUseLock = IMG_TRUE;
167
168 PVRSRV_ERROR InitRGXSIGNALSBridge(void);
169 PVRSRV_ERROR DeinitRGXSIGNALSBridge(void);
170
171 /*
172  * Register all RGXSIGNALS functions with services
173  */
174 PVRSRV_ERROR InitRGXSIGNALSBridge(void)
175 {
176
177         SetDispatchTableEntry(PVRSRV_BRIDGE_RGXSIGNALS, PVRSRV_BRIDGE_RGXSIGNALS_RGXNOTIFYSIGNALUPDATE, PVRSRVBridgeRGXNotifySignalUpdate,
178                                         NULL, bUseLock);
179
180
181         return PVRSRV_OK;
182 }
183
184 /*
185  * Unregister all rgxsignals functions with services
186  */
187 PVRSRV_ERROR DeinitRGXSIGNALSBridge(void)
188 {
189         return PVRSRV_OK;
190 }