1ea12de76423549a0be79906bc852dde53505eeb
[profile/ivi/intel-emgd-kmod.git] / pvr / services4 / srvkm / include / metrics.h
1 /**********************************************************************
2  Copyright (c) Imagination Technologies Ltd.
3
4  Permission is hereby granted, free of charge, to any person obtaining a copy
5  of this software and associated documentation files (the "Software"), to deal
6  in the Software without restriction, including without limitation the rights
7  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8  copies of the Software, and to permit persons to whom the Software is
9  furnished to do so, subject to the following conditions:
10
11  The above copyright notice and this permission notice shall be included in
12  all copies or substantial portions of the Software.
13
14  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20  THE SOFTWARE.
21  ******************************************************************************/
22
23 #ifndef _METRICS_
24 #define _METRICS_
25
26
27 #if defined (__cplusplus)
28 extern "C" {
29 #endif
30
31
32 #if defined(DEBUG) || defined(TIMING)
33
34
35 typedef struct
36 {
37         IMG_UINT32 ui32Start;
38         IMG_UINT32 ui32Stop;
39         IMG_UINT32 ui32Total;
40         IMG_UINT32 ui32Count;
41 } Temporal_Data;
42
43 extern Temporal_Data asTimers[];
44
45 extern IMG_UINT32 PVRSRVTimeNow(IMG_VOID);
46 extern IMG_VOID   PVRSRVSetupMetricTimers(IMG_VOID *pvDevInfo);
47 extern IMG_VOID   PVRSRVOutputMetricTotals(IMG_VOID);
48
49
50 #define PVRSRV_TIMER_DUMMY                              0
51
52 #define PVRSRV_TIMER_EXAMPLE_1                  1
53 #define PVRSRV_TIMER_EXAMPLE_2                  2
54
55
56 #define PVRSRV_NUM_TIMERS               (PVRSRV_TIMER_EXAMPLE_2 + 1)
57
58 #define PVRSRV_TIME_START(X)    { \
59                                                                         asTimers[X].ui32Count += 1; \
60                                                                         asTimers[X].ui32Count |= 0x80000000L; \
61                                                                         asTimers[X].ui32Start = PVRSRVTimeNow(); \
62                                                                         asTimers[X].ui32Stop  = 0; \
63                                                                 }
64
65 #define PVRSRV_TIME_SUSPEND(X)  { \
66                                                                         asTimers[X].ui32Stop += PVRSRVTimeNow() - asTimers[X].ui32Start; \
67                                                                 }
68
69 #define PVRSRV_TIME_RESUME(X)   { \
70                                                                         asTimers[X].ui32Start = PVRSRVTimeNow(); \
71                                                                 }
72
73 #define PVRSRV_TIME_STOP(X)             { \
74                                                                         asTimers[X].ui32Stop  += PVRSRVTimeNow() - asTimers[X].ui32Start; \
75                                                                         asTimers[X].ui32Total += asTimers[X].ui32Stop; \
76                                                                         asTimers[X].ui32Count &= 0x7FFFFFFFL; \
77                                                                 }
78
79 #define PVRSRV_TIME_RESET(X)    { \
80                                                                         asTimers[X].ui32Start = 0; \
81                                                                         asTimers[X].ui32Stop  = 0; \
82                                                                         asTimers[X].ui32Total = 0; \
83                                                                         asTimers[X].ui32Count = 0; \
84                                                                 }
85
86
87 #if defined(__sh__)
88
89 #define TST_REG   ((volatile IMG_UINT8 *) (psDevInfo->pvSOCRegsBaseKM))
90
91 #define TCOR_2    ((volatile IMG_UINT *)  (psDevInfo->pvSOCRegsBaseKM+28))
92 #define TCNT_2    ((volatile IMG_UINT *)  (psDevInfo->pvSOCRegsBaseKM+32))
93 #define TCR_2     ((volatile IMG_UINT16 *)(psDevInfo->pvSOCRegsBaseKM+36))
94
95 #define TIMER_DIVISOR  4
96
97 #endif
98
99
100
101
102
103 #else
104
105
106
107 #define PVRSRV_TIME_START(X)
108 #define PVRSRV_TIME_SUSPEND(X)
109 #define PVRSRV_TIME_RESUME(X)
110 #define PVRSRV_TIME_STOP(X)
111 #define PVRSRV_TIME_RESET(X)
112
113 #define PVRSRVSetupMetricTimers(X)
114 #define PVRSRVOutputMetricTotals()
115
116
117
118 #endif
119
120 #if defined(__cplusplus)
121 }
122 #endif
123
124
125 #endif
126