drm/GPU: Add support Imagination PowerVR GPU driver v1.17
[platform/kernel/linux-starfive.git] / drivers / gpu / drm / img / img-rogue / services / server / include / ospvr_gputrace.h
1 /*************************************************************************/ /*!
2 @File           ospvr_gputrace.h
3 @Title          PVR GPU Trace module common environment interface
4 @Copyright      Copyright (c) Imagination Technologies Ltd. All Rights Reserved
5 @License        Dual MIT/GPLv2
6
7 The contents of this file are subject to the MIT license as set out below.
8
9 Permission is hereby granted, free of charge, to any person obtaining a copy
10 of this software and associated documentation files (the "Software"), to deal
11 in the Software without restriction, including without limitation the rights
12 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 copies of the Software, and to permit persons to whom the Software is
14 furnished to do so, subject to the following conditions:
15
16 The above copyright notice and this permission notice shall be included in
17 all copies or substantial portions of the Software.
18
19 Alternatively, the contents of this file may be used under the terms of
20 the GNU General Public License Version 2 ("GPL") in which case the provisions
21 of GPL are applicable instead of those above.
22
23 If you wish to allow use of your version of this file only under the terms of
24 GPL, and not to allow others to use your version of this file under the terms
25 of the MIT license, indicate your decision by deleting the provisions above
26 and replace them with the notice and other provisions required by GPL as set
27 out in the file called "GPL-COPYING" included in this distribution. If you do
28 not delete the provisions above, a recipient may use your version of this file
29 under the terms of either the MIT license or GPL.
30
31 This License is also included in this distribution in the file called
32 "MIT-COPYING".
33
34 EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) THE SOFTWARE IS
35 PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
36 BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
37 PURPOSE AND NONINFRINGEMENT; AND (B) IN NO EVENT SHALL THE AUTHORS OR
38 COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
39 IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
40 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
41 */ /**************************************************************************/
42
43 #ifndef PVR_GPUTRACE_H_
44 #define PVR_GPUTRACE_H_
45
46 #include "img_types.h"
47 #include "img_defs.h"
48 #include "rgx_hwperf.h"
49 #include "device.h"
50
51 #if defined(__linux__)
52
53 void PVRGpuTraceEnqueueEvent(
54                 PVRSRV_DEVICE_NODE *psDevNode,
55                 IMG_UINT32 ui32FirmwareCtx,
56                 IMG_UINT32 ui32ExternalJobRef,
57                 IMG_UINT32 ui32InternalJobRef,
58                 RGX_HWPERF_KICK_TYPE eKickType);
59
60 /* Early initialisation of GPU Trace events logic.
61  * This function is called on *driver* initialisation. */
62 PVRSRV_ERROR PVRGpuTraceSupportInit(void);
63
64 /* GPU Trace resources final cleanup.
65  * This function is called on driver de-initialisation. */
66 void PVRGpuTraceSupportDeInit(void);
67
68 /* Initialisation for AppHints callbacks.
69  * This function is called during the late stage of driver initialisation but
70  * before the device initialisation but after the debugfs sub-system has been
71  * initialised. */
72 void PVRGpuTraceInitAppHintCallbacks(const PVRSRV_DEVICE_NODE *psDeviceNode);
73
74 /* Per-device initialisation of the GPU Trace resources */
75 PVRSRV_ERROR PVRGpuTraceInitDevice(PVRSRV_DEVICE_NODE *psDeviceNode);
76
77 /* Per-device cleanup for the GPU Trace resources. */
78 void PVRGpuTraceDeInitDevice(PVRSRV_DEVICE_NODE *psDeviceNode);
79
80 /* Enables the gpu trace sub-system for a given device. */
81 PVRSRV_ERROR PVRGpuTraceSetEnabled(
82                 PVRSRV_DEVICE_NODE *psDeviceNode,
83                 IMG_BOOL bNewValue);
84
85 /* Returns IMG_TRUE if the gpu trace sub-system has been enabled (but not
86  * necessarily initialised). */
87 IMG_BOOL PVRGpuTraceIsEnabled(void);
88
89 /* Performs some initialisation steps if the feature was enabled
90  * on driver startup. */
91 void PVRGpuTraceInitIfEnabled(PVRSRV_DEVICE_NODE *psDeviceNode);
92
93 /* FTrace events callbacks interface */
94
95 void PVRGpuTraceEnableUfoCallback(void);
96 void PVRGpuTraceDisableUfoCallback(void);
97
98 void PVRGpuTraceEnableFirmwareActivityCallback(void);
99 void PVRGpuTraceDisableFirmwareActivityCallback(void);
100
101 #else /* defined(__linux__) */
102
103 static inline void PVRGpuTraceEnqueueEvent(
104                 PVRSRV_DEVICE_NODE *psDevNode,
105                 IMG_UINT32 ui32FirmwareCtx,
106                 IMG_UINT32 ui32ExternalJobRef,
107                 IMG_UINT32 ui32InternalJobRef,
108                 RGX_HWPERF_KICK_TYPE eKickType)
109 {
110         PVR_UNREFERENCED_PARAMETER(psDevNode);
111         PVR_UNREFERENCED_PARAMETER(ui32ExternalJobRef);
112         PVR_UNREFERENCED_PARAMETER(ui32InternalJobRef);
113         PVR_UNREFERENCED_PARAMETER(eKickType);
114 }
115
116 static inline PVRSRV_ERROR PVRGpuTraceSupportInit(void) {
117         return PVRSRV_OK;
118 }
119
120 static inline void PVRGpuTraceSupportDeInit(void) {}
121
122 static inline void PVRGpuTraceInitAppHintCallbacks(
123                 const PVRSRV_DEVICE_NODE *psDeviceNode)
124 {
125         PVR_UNREFERENCED_PARAMETER(psDeviceNode);
126 }
127
128 static inline PVRSRV_ERROR PVRGpuTraceInitDevice(
129                 PVRSRV_DEVICE_NODE *psDeviceNode)
130 {
131         PVR_UNREFERENCED_PARAMETER(psDeviceNode);
132         return PVRSRV_OK;
133 }
134
135 static inline void PVRGpuTraceDeInitDevice(PVRSRV_DEVICE_NODE *psDeviceNode)
136 {
137         PVR_UNREFERENCED_PARAMETER(psDeviceNode);
138 }
139
140 static inline PVRSRV_ERROR PVRGpuTraceSetEnabled(
141                 PVRSRV_DEVICE_NODE *psDeviceNode,
142                 IMG_BOOL bNewValue)
143 {
144         PVR_UNREFERENCED_PARAMETER(psDeviceNode);
145         PVR_UNREFERENCED_PARAMETER(bNewValue);
146         return PVRSRV_OK;
147 }
148
149 static inline IMG_BOOL PVRGpuTraceIsEnabled(void)
150 {
151         return IMG_FALSE;
152 }
153
154 static inline void PVRGpuTraceInitIfEnabled(PVRSRV_DEVICE_NODE *psDeviceNode)
155 {
156         PVR_UNREFERENCED_PARAMETER(psDeviceNode);
157 }
158
159 static inline void PVRGpuTraceEnableUfoCallback(void) {}
160 static inline void PVRGpuTraceDisableUfoCallback(void) {}
161
162 static inline void PVRGpuTraceEnableFirmwareActivityCallback(void) {}
163 static inline void PVRGpuTraceDisableFirmwareActivityCallback(void) {}
164
165 #endif /* defined(__linux__) */
166
167 #endif /* PVR_GPUTRACE_H_ */