RK3368 GPU: Rogue N Init.
[firefly-linux-kernel-4.4.55.git] / drivers / staging / imgtec / rogue / rgxapi_km.h
1 /*************************************************************************/ /*!
2 @File
3 @Title          RGX API Header kernel mode
4 @Copyright      Copyright (c) Imagination Technologies Ltd. All Rights Reserved
5 @Description    Exported RGX API details
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 __RGXAPI_KM_H__
45 #define __RGXAPI_KM_H__
46
47 #if defined(SUPPORT_SHARED_SLC) && !defined(PVRSRV_GPUVIRT_GUESTDRV)
48 /*!
49 ******************************************************************************
50
51  @Function      RGXInitSLC
52
53  @Description Init the SLC after a power up. It is required to call this 
54               function if using SUPPORT_SHARED_SLC. Otherwise, it shouldn't
55                           be called.
56
57  @Input    hDevHandle : RGX Device Node
58
59  @Return   PVRSRV_ERROR :
60
61 ******************************************************************************/
62 PVRSRV_ERROR RGXInitSLC(IMG_HANDLE hDevHandle);
63 #endif
64
65 #include "rgx_hwperf_km.h"
66
67
68 /******************************************************************************
69  * RGX HW Performance Profiling Control API(s)
70  *****************************************************************************/
71
72 /**************************************************************************/ /*!
73 @Function      RGXHWPerfLazyConnect
74 @Description   Obtain a connection object to the RGX device. The connection
75                            is not actually opened until HWPerfOpen() is called.
76 @Output        phDevData      Address of a handle to a connection object
77 @Return        PVRSRV_ERROR:  for system error codes
78 */ /***************************************************************************/
79 PVRSRV_ERROR RGXHWPerfLazyConnect(
80                 IMG_HANDLE* phDevData);
81
82
83 /**************************************************************************/ /*!
84 @Function      RGXHWPerfOpen
85 @Description   Opens a connection to the RGX device. Valid handle to the
86                            connection object has to be provided which means the this
87                            function needs to be preceded by the call to
88                            RGXHWPerfLazyConnect() function.
89 @Input        phDevData      handle to a connection object
90 @Return        PVRSRV_ERROR:  for system error codes
91 */ /***************************************************************************/
92 PVRSRV_ERROR RGXHWPerfOpen(
93                 IMG_HANDLE hDevData);
94
95
96 /**************************************************************************/ /*!
97 @Function      RGXHWPerfConnect
98 @Description   Obtain a connection object to the RGX device. Allocated
99                            connection object references opened connection.
100                            Calling this function is an equivalent of calling
101                            RGXHWPerfLazyConnect and RGXHWPerfOpen.
102 @Output        phDevData      Address of a handle to a connection object
103 @Return        PVRSRV_ERROR:  for system error codes
104 */ /***************************************************************************/
105 PVRSRV_ERROR RGXHWPerfConnect(
106                 IMG_HANDLE* phDevData);
107
108
109 /**************************************************************************/ /*!
110 @Function       RGXHWPerfFreeConnection
111 @Description    Frees the handle to RGX device
112 @Input          hSrvHandle    Handle to connection object as returned from
113                               RGXHWPerfLazyConnect()
114 @Return         PVRSRV_ERROR: for system error codes
115 */ /***************************************************************************/
116 PVRSRV_ERROR RGXHWPerfFreeConnection(
117                 IMG_HANDLE hDevData);
118
119
120 /**************************************************************************/ /*!
121 @Function       RGXHWPerfClose
122 @Description    Disconnect from the RGX device
123 @Input          hSrvHandle    Handle to connection object as returned from
124                               RGXHWPerfConnect() or RGXHWPerfOpen()
125 @Return         PVRSRV_ERROR: for system error codes
126 */ /***************************************************************************/
127 PVRSRV_ERROR RGXHWPerfClose(
128                 IMG_HANDLE hDevData);
129
130
131 /**************************************************************************/ /*!
132 @Function       RGXHWPerfDisconnect
133 @Description    Disconnect from the RGX device
134 @Input          hSrvHandle    Handle to connection object as returned from
135                               RGXHWPerfConnect() or RGXHWPerfOpen().
136                               Calling this function is an equivalent of calling
137                                           RGXHWPerfClose and RGXHWPerfFreeConnection.
138 @Return         PVRSRV_ERROR: for system error codes
139 */ /***************************************************************************/
140 PVRSRV_ERROR RGXHWPerfDisconnect(
141                 IMG_HANDLE hDevData);
142
143
144 /**************************************************************************/ /*!
145 @Function       RGXHWPerfControl
146 @Description    Enable or disable the generation of RGX HWPerf event packets.
147                  See RGXCtrlHWPerf().
148 @Input          hDevData         Handle to connection object
149 @Input          bToggle          Switch to toggle or apply mask.
150 @Input          ui64Mask         Mask of events to control.
151 @Return         PVRSRV_ERROR:    for system error codes
152 */ /***************************************************************************/
153 PVRSRV_ERROR IMG_CALLCONV RGXHWPerfControl(
154                 IMG_HANDLE           hDevData,
155                 RGX_HWPERF_STREAM_ID eStreamId,
156                 IMG_BOOL             bToggle,
157                 IMG_UINT64           ui64Mask);
158
159
160 /**************************************************************************/ /*!
161 @Function       RGXHWPerfConfigureAndEnableCounters
162 @Description    Enable and configure the performance counter block for
163                  one or more device layout modules.
164                  See RGXConfigureAndEnableHWPerfCounters().
165 @Input          hDevData         Handle to connection object
166 @Input          ui32NumBlocks    Number of elements in the array
167 @Input          asBlockConfigs   Address of the array of configuration blocks
168 @Return         PVRSRV_ERROR:    for system error codes
169 */ /***************************************************************************/
170 PVRSRV_ERROR IMG_CALLCONV RGXHWPerfConfigureAndEnableCounters(
171                 IMG_HANDLE                 hDevData,
172                 IMG_UINT32                 ui32NumBlocks,
173                 RGX_HWPERF_CONFIG_CNTBLK*  asBlockConfigs);
174
175
176 /**************************************************************************/ /*!
177 @Function       RGXDisableHWPerfCounters
178 @Description    Disable the performance counter block for one or more
179                  device layout modules. See RGXDisableHWPerfCounters().
180 @Input          hDevData        Handle to connection/device object
181 @Input          ui32NumBlocks   Number of elements in the array
182 @Input          aeBlockIDs      An array of bytes with values taken from
183                                  the RGX_HWPERF_CNTBLK_ID enumeration.
184 @Return         PVRSRV_ERROR:   for system error codes
185 */ /***************************************************************************/
186 PVRSRV_ERROR IMG_CALLCONV RGXHWPerfDisableCounters(
187                 IMG_HANDLE   hDevData,
188                 IMG_UINT32   ui32NumBlocks,
189                 IMG_UINT16*   aeBlockIDs);
190
191 /**************************************************************************/ /*!
192 @Function       RGXEnableHWPerfCounters
193 @Description    Enable the performance counter block for one or more
194                  device layout modules. See RGXEnableHWPerfCounters().
195 @Input          hDevData        Handle to connection/device object
196 @Input          ui32NumBlocks   Number of elements in the array
197 @Input          aeBlockIDs      An array of bytes with values taken from
198                                  the RGX_HWPERF_CNTBLK_ID enumeration.
199 @Return         PVRSRV_ERROR:   for system error codes
200 */ /***************************************************************************/
201 PVRSRV_ERROR IMG_CALLCONV RGXHWPerfEnableCounters(
202                 IMG_HANDLE   hDevData,
203                 IMG_UINT32   ui32NumBlocks,
204                 IMG_UINT16*   aeBlockIDs);
205
206 /******************************************************************************
207  * RGX HW Performance Profiling Retrieval API(s)
208  *
209  * The client must ensure their use of this acquire/release API for a single 
210  * connection/stream must not be shared with multiple execution contexts e.g.
211  * between a kernel thread and an ISR handler. It is the client’s
212  * responsibility to ensure this API is not interrupted by a high priority
213  * thread/ISR
214  *****************************************************************************/
215
216 /**************************************************************************/ /*!
217 @Function       RGXHWPerfAcquireData
218 @Description    When there is data available to read this call returns with
219                  the address and length of the data buffer the
220                  client can safely read. This buffer may contain one or more
221                  event packets. If no data is available then this call 
222                                  returns OK and sets *puiBufLen to 0 on exit.
223                                  Clients must pair this call with a ReleaseData call.
224 @Input          hDevData        Handle to connection/device object
225 @Input          eStreamId       ID of the HWPerf stream
226 @Output         ppBuf           Address of a pointer to a byte buffer. On exit
227                                  it contains the address of buffer to read from
228 @Output         puiBufLen       Pointer to an integer. On exit it is the size
229                                  of the data to read from the buffer
230 @Return         PVRSRV_ERROR:   for system error codes
231 */ /***************************************************************************/
232 PVRSRV_ERROR RGXHWPerfAcquireData(
233                 IMG_HANDLE  hDevData,
234                 RGX_HWPERF_STREAM_ID eStreamId,
235                 IMG_PBYTE*  ppBuf,
236                 IMG_UINT32* pui32BufLen);
237
238
239 /**************************************************************************/ /*!
240 @Function       RGXHWPerfGetFilter
241 @Description    Reads HWPerf stream filter where stream is identified by
242                 the given stream ID.
243 @Input          hDevData        Handle to connection/device object
244 @Input          eStreamId       ID of the HWPerf stream
245 @Output         IMG_UINT64      HWPerf filter value
246 @Return         PVRSRV_ERROR:   for system error codes
247 */ /***************************************************************************/
248 PVRSRV_ERROR RGXHWPerfGetFilter(
249                 IMG_HANDLE  hDevData,
250                 RGX_HWPERF_STREAM_ID eStreamId,
251                 IMG_UINT64 *ui64Filter
252 );
253
254
255 /**************************************************************************/ /*!
256 @Function       RGXHWPerfReleaseData
257 @Description    Called after client has read the event data out of the buffer
258                  retrieved from the Acquire Data call to release resources.
259 @Input          hDevData        Handle to connection/device object
260 @Return         PVRSRV_ERROR:   for system error codes
261 */ /***************************************************************************/
262 IMG_INTERNAL
263 PVRSRV_ERROR RGXHWPerfReleaseData(
264                 IMG_HANDLE hDevData,
265                 RGX_HWPERF_STREAM_ID eStreamId);
266
267
268 #endif /* __RGXAPI_KM_H__ */
269
270 /******************************************************************************
271  End of file (rgxapi_km.h)
272 ******************************************************************************/