RK3368 GPU: Rogue N Init.
[firefly-linux-kernel-4.4.55.git] / drivers / staging / imgtec / rogue / srvcore.h
1 /**************************************************************************/ /*!
2 @File
3 @Title          PVR Bridge Functionality
4 @Copyright      Copyright (c) Imagination Technologies Ltd. All Rights Reserved
5 @Description    Header for the PVR Bridge code
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 #ifndef __BRIDGED_PVR_BRIDGE_H__
45 #define __BRIDGED_PVR_BRIDGE_H__
46
47 #include "lock_types.h"
48 #include "connection_server.h"
49 #include "pvr_debug.h"
50
51 #include "pvr_bridge.h"
52 #if defined(SUPPORT_RGX)
53 #include "rgx_bridge.h"
54 #endif
55
56 PVRSRV_ERROR
57 CopyFromUserWrapper(CONNECTION_DATA *psConnection,
58                                         IMG_UINT32 ui32DispatchTableEntry,
59                                         void *pvDest,
60                                         void *pvSrc,
61                                         IMG_UINT32 ui32Size);
62 PVRSRV_ERROR
63 CopyToUserWrapper(CONNECTION_DATA *psConnection, 
64                                   IMG_UINT32 ui32DispatchTableEntry,
65                                   void *pvDest,
66                                   void *pvSrc,
67                                   IMG_UINT32 ui32Size);
68
69 IMG_INT
70 DummyBW(IMG_UINT32 ui32DispatchTableEntry,
71                 void *psBridgeIn,
72                 void *psBridgeOut,
73                 CONNECTION_DATA *psConnection);
74
75 typedef IMG_INT (*BridgeWrapperFunction)(IMG_UINT32 ui32DispatchTableEntry,
76                                                                          void *psBridgeIn,
77                                                                          void *psBridgeOut,
78                                                                          CONNECTION_DATA *psConnection);
79
80 typedef struct _PVRSRV_BRIDGE_DISPATCH_TABLE_ENTRY
81 {
82         BridgeWrapperFunction pfFunction; /*!< The wrapper function that validates the ioctl
83                                                                                 arguments before calling into srvkm proper */
84         POS_LOCK        hBridgeLock;    /*!< The bridge lock which needs to be acquired 
85                                                 before calling the above wrapper */
86         IMG_BOOL    bUseLock;                 /*!< Specify whether to use a bridge lock at all */
87 #if defined(DEBUG_BRIDGE_KM)
88         const IMG_CHAR *pszIOCName; /*!< Name of the ioctl: e.g. "PVRSRV_BRIDGE_CONNECT_SERVICES" */
89         const IMG_CHAR *pszFunctionName; /*!< Name of the wrapper function: e.g. "PVRSRVConnectBW" */
90         const IMG_CHAR *pszBridgeLockName;      /*!< Name of bridge lock which will be acquired */
91         IMG_UINT32 ui32CallCount; /*!< The total number of times the ioctl has been called */
92         IMG_UINT32 ui32CopyFromUserTotalBytes; /*!< The total number of bytes copied from
93                                                                                          userspace within this ioctl */
94         IMG_UINT32 ui32CopyToUserTotalBytes; /*!< The total number of bytes copied from
95                                                                                    userspace within this ioctl */
96         IMG_UINT64 ui64TotalTimeNS; /*!< The total amount of time spent in this bridge function */
97         IMG_UINT64 ui64MaxTimeNS; /*!< The maximum amount of time for a single call to this bridge function */
98 #endif
99 }PVRSRV_BRIDGE_DISPATCH_TABLE_ENTRY;
100
101 #if defined(SUPPORT_RGX)
102         #define BRIDGE_DISPATCH_TABLE_ENTRY_COUNT  (PVRSRV_BRIDGE_RGX_DISPATCH_LAST+1)
103         #define BRIDGE_DISPATCH_TABLE_START_ENTRY_COUNT  (PVRSRV_BRIDGE_RGX_LAST+1)
104 #else
105         #define BRIDGE_DISPATCH_TABLE_ENTRY_COUNT  (PVRSRV_BRIDGE_DISPATCH_LAST+1)
106         #define BRIDGE_DISPATCH_TABLE_START_ENTRY_COUNT  (PVRSRV_BRIDGE_LAST+1)
107 #endif
108
109 extern PVRSRV_BRIDGE_DISPATCH_TABLE_ENTRY g_BridgeDispatchTable[BRIDGE_DISPATCH_TABLE_ENTRY_COUNT];
110
111 void BridgeDispatchTableStartOffsetsInit(void);
112
113 void
114 _SetDispatchTableEntry(IMG_UINT32 ui32BridgeGroup,
115                                            IMG_UINT32 ui32Index,
116                                            const IMG_CHAR *pszIOCName,
117                                            BridgeWrapperFunction pfFunction,
118                                            const IMG_CHAR *pszFunctionName,
119                                            POS_LOCK hBridgeLock,
120                                            const IMG_CHAR* pszBridgeLockName,
121                                            IMG_BOOL bUseLock );
122
123
124 /* PRQA S 0884,3410 2*/ /* macro relies on the lack of brackets */
125 #define SetDispatchTableEntry(ui32BridgeGroup, ui32Index, pfFunction,\
126                                         hBridgeLock, bUseLock) \
127         _SetDispatchTableEntry(ui32BridgeGroup, ui32Index, #ui32Index, (BridgeWrapperFunction)pfFunction, #pfFunction,\
128                                                         (POS_LOCK)hBridgeLock, #hBridgeLock, bUseLock )
129
130 #define DISPATCH_TABLE_GAP_THRESHOLD 5
131
132
133 #if defined(DEBUG_BRIDGE_KM)
134 typedef struct _PVRSRV_BRIDGE_GLOBAL_STATS
135 {
136         IMG_UINT32 ui32IOCTLCount;
137         IMG_UINT32 ui32TotalCopyFromUserBytes;
138         IMG_UINT32 ui32TotalCopyToUserBytes;
139 } PVRSRV_BRIDGE_GLOBAL_STATS;
140
141 /* OS specific code may want to report the stats held here and within the
142  * BRIDGE_DISPATCH_TABLE_ENTRYs (E.g. on Linux we report these via a
143  * debugfs entry /sys/kernel/debug/pvr/bridge_stats) */
144 extern PVRSRV_BRIDGE_GLOBAL_STATS g_BridgeGlobalStats;
145 #endif
146
147 PVRSRV_ERROR BridgeInit(void);
148 void BridgeDeinit(void);
149
150 PVRSRV_ERROR BridgedDispatchKM(CONNECTION_DATA * psConnection,
151                                           PVRSRV_BRIDGE_PACKAGE   * psBridgePackageKM);
152
153
154 PVRSRV_ERROR
155 PVRSRVConnectKM(CONNECTION_DATA *psConnection,
156                 PVRSRV_DEVICE_NODE * psDeviceNode,
157                                 IMG_UINT32 ui32Flags,
158                                 IMG_UINT32 ui32ClientBuildOptions,
159                                 IMG_UINT32 ui32ClientDDKVersion,
160                                 IMG_UINT32 ui32ClientDDKBuild,
161                                 IMG_UINT8  *pui8KernelArch,
162                                 IMG_UINT32 *ui32CapabilityFlags,
163                                 IMG_UINT32 *ui32PVRBridges,
164                                 IMG_UINT32 *ui32RGXBridges);
165
166 PVRSRV_ERROR
167 PVRSRVDisconnectKM(void);
168
169 PVRSRV_ERROR
170 PVRSRVInitSrvDisconnectKM(CONNECTION_DATA *psConnection,
171                           PVRSRV_DEVICE_NODE *psDeviceNode,
172                           IMG_BOOL bInitSuccesful,
173                           IMG_UINT32 ui32ClientBuildOptions);
174
175 PVRSRV_ERROR
176 PVRSRVAcquireGlobalEventObjectKM(IMG_HANDLE *phGlobalEventObject);
177
178 PVRSRV_ERROR
179 PVRSRVReleaseGlobalEventObjectKM(IMG_HANDLE hGlobalEventObject);
180
181 PVRSRV_ERROR
182 PVRSRVDumpDebugInfoKM(CONNECTION_DATA *psConnection,
183                                           PVRSRV_DEVICE_NODE *psDeviceNode,
184                                           IMG_UINT32 ui32VerbLevel);
185
186 PVRSRV_ERROR
187 PVRSRVGetDevClockSpeedKM(CONNECTION_DATA * psConnection,
188                          PVRSRV_DEVICE_NODE *psDeviceNode,
189                          IMG_PUINT32  pui32RGXClockSpeed);
190
191 PVRSRV_ERROR
192 PVRSRVHWOpTimeoutKM(CONNECTION_DATA *psConnection,
193                                         PVRSRV_DEVICE_NODE *psDeviceNode);
194
195 PVRSRV_ERROR PVRSRVAlignmentCheckKM(CONNECTION_DATA *psConnection,
196                                     PVRSRV_DEVICE_NODE * psDeviceNode,
197                                     IMG_UINT32 ui32FWAlignChecksSize,
198                                     IMG_UINT32 aui32FWAlignChecks[]);
199
200 PVRSRV_ERROR PVRSRVGetDeviceStatusKM(CONNECTION_DATA *psConnection,
201                                      PVRSRV_DEVICE_NODE *psDeviceNode,
202                                      IMG_UINT32 *pui32DeviceStatus);
203
204 #endif /* __BRIDGED_PVR_BRIDGE_H__ */
205
206 /******************************************************************************
207  End of file (srvcore.h)
208 ******************************************************************************/