diff options
Diffstat (limited to 'drivers/gpu/pvr/metrics.c')
-rw-r--r-- | drivers/gpu/pvr/metrics.c | 160 |
1 files changed, 160 insertions, 0 deletions
diff --git a/drivers/gpu/pvr/metrics.c b/drivers/gpu/pvr/metrics.c new file mode 100644 index 00000000000..ee5cabd4998 --- /dev/null +++ b/drivers/gpu/pvr/metrics.c | |||
@@ -0,0 +1,160 @@ | |||
1 | /********************************************************************** | ||
2 | * | ||
3 | * Copyright(c) 2008 Imagination Technologies Ltd. All rights reserved. | ||
4 | * | ||
5 | * This program is free software; you can redistribute it and/or modify it | ||
6 | * under the terms and conditions of the GNU General Public License, | ||
7 | * version 2, as published by the Free Software Foundation. | ||
8 | * | ||
9 | * This program is distributed in the hope it will be useful but, except | ||
10 | * as otherwise stated in writing, without any warranty; without even the | ||
11 | * implied warranty of merchantability or fitness for a particular purpose. | ||
12 | * See the GNU General Public License for more details. | ||
13 | * | ||
14 | * You should have received a copy of the GNU General Public License along with | ||
15 | * this program; if not, write to the Free Software Foundation, Inc., | ||
16 | * 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. | ||
17 | * | ||
18 | * The full GNU General Public License is included in this distribution in | ||
19 | * the file called "COPYING". | ||
20 | * | ||
21 | * Contact Information: | ||
22 | * Imagination Technologies Ltd. <gpl-support@imgtec.com> | ||
23 | * Home Park Estate, Kings Langley, Herts, WD4 8LZ, UK | ||
24 | * | ||
25 | ******************************************************************************/ | ||
26 | |||
27 | #include "services_headers.h" | ||
28 | #include "metrics.h" | ||
29 | |||
30 | #if defined(SUPPORT_VGX) | ||
31 | #include "vgxapi_km.h" | ||
32 | #endif | ||
33 | |||
34 | #if defined(SUPPORT_SGX) | ||
35 | #include "sgxapi_km.h" | ||
36 | #endif | ||
37 | |||
38 | #if defined(DEBUG) || defined(TIMING) | ||
39 | |||
40 | static volatile IMG_UINT32 *pui32TimerRegister = 0; | ||
41 | |||
42 | #define PVRSRV_TIMER_TOTAL_IN_TICKS(X) asTimers[X].ui32Total | ||
43 | #define PVRSRV_TIMER_TOTAL_IN_MS(X) ((1000*asTimers[X].ui32Total)/ui32TicksPerMS) | ||
44 | #define PVRSRV_TIMER_COUNT(X) asTimers[X].ui32Count | ||
45 | |||
46 | |||
47 | Temporal_Data asTimers[PVRSRV_NUM_TIMERS]; | ||
48 | |||
49 | |||
50 | IMG_UINT32 PVRSRVTimeNow(IMG_VOID) | ||
51 | { | ||
52 | if (!pui32TimerRegister) | ||
53 | { | ||
54 | static IMG_BOOL bFirstTime = IMG_TRUE; | ||
55 | |||
56 | if (bFirstTime) | ||
57 | { | ||
58 | PVR_DPF((PVR_DBG_ERROR,"PVRSRVTimeNow: No timer register set up")); | ||
59 | |||
60 | bFirstTime = IMG_FALSE; | ||
61 | } | ||
62 | |||
63 | return 0; | ||
64 | } | ||
65 | |||
66 | #if defined(__sh__) | ||
67 | |||
68 | return (0xffffffff-*pui32TimerRegister); | ||
69 | |||
70 | #else | ||
71 | |||
72 | return 0; | ||
73 | |||
74 | #endif | ||
75 | } | ||
76 | |||
77 | |||
78 | static IMG_UINT32 PVRSRVGetCPUFreq(IMG_VOID) | ||
79 | { | ||
80 | IMG_UINT32 ui32Time1, ui32Time2; | ||
81 | |||
82 | ui32Time1 = PVRSRVTimeNow(); | ||
83 | |||
84 | OSWaitus(1000000); | ||
85 | |||
86 | ui32Time2 = PVRSRVTimeNow(); | ||
87 | |||
88 | PVR_DPF((PVR_DBG_WARNING, "PVRSRVGetCPUFreq: timer frequency = %d Hz", ui32Time2 - ui32Time1)); | ||
89 | |||
90 | return (ui32Time2 - ui32Time1); | ||
91 | } | ||
92 | |||
93 | |||
94 | IMG_VOID PVRSRVSetupMetricTimers(IMG_VOID *pvDevInfo) | ||
95 | { | ||
96 | IMG_UINT32 ui32Loop; | ||
97 | |||
98 | PVR_UNREFERENCED_PARAMETER(pvDevInfo); | ||
99 | |||
100 | for(ui32Loop=0; ui32Loop < (PVRSRV_NUM_TIMERS); ui32Loop++) | ||
101 | { | ||
102 | asTimers[ui32Loop].ui32Total = 0; | ||
103 | asTimers[ui32Loop].ui32Count = 0; | ||
104 | } | ||
105 | |||
106 | |||
107 | #if defined(__sh__) | ||
108 | |||
109 | |||
110 | |||
111 | |||
112 | |||
113 | *TCR_2 = TIMER_DIVISOR; | ||
114 | |||
115 | |||
116 | *TCOR_2 = *TCNT_2 = (IMG_UINT)0xffffffff; | ||
117 | |||
118 | |||
119 | *TST_REG |= (IMG_UINT8)0x04; | ||
120 | |||
121 | pui32TimerRegister = (IMG_UINT32 *)TCNT_2; | ||
122 | |||
123 | #else | ||
124 | |||
125 | pui32TimerRegister = 0; | ||
126 | |||
127 | #endif | ||
128 | |||
129 | } | ||
130 | |||
131 | |||
132 | IMG_VOID PVRSRVOutputMetricTotals(IMG_VOID) | ||
133 | { | ||
134 | IMG_UINT32 ui32TicksPerMS, ui32Loop; | ||
135 | |||
136 | ui32TicksPerMS = PVRSRVGetCPUFreq(); | ||
137 | |||
138 | if (!ui32TicksPerMS) | ||
139 | { | ||
140 | PVR_DPF((PVR_DBG_ERROR,"PVRSRVOutputMetricTotals: Failed to get CPU Freq")); | ||
141 | return; | ||
142 | } | ||
143 | |||
144 | for(ui32Loop=0; ui32Loop < (PVRSRV_NUM_TIMERS); ui32Loop++) | ||
145 | { | ||
146 | if (asTimers[ui32Loop].ui32Count & 0x80000000L) | ||
147 | { | ||
148 | PVR_DPF((PVR_DBG_WARNING,"PVRSRVOutputMetricTotals: Timer %u is still ON", ui32Loop)); | ||
149 | } | ||
150 | } | ||
151 | #if 0 | ||
152 | |||
153 | PVR_DPF((PVR_DBG_ERROR," Timer(%u): Total = %u",PVRSRV_TIMER_EXAMPLE_1, PVRSRV_TIMER_TOTAL_IN_TICKS(PVRSRV_TIMER_EXAMPLE_1))); | ||
154 | PVR_DPF((PVR_DBG_ERROR," Timer(%u): Time = %ums",PVRSRV_TIMER_EXAMPLE_1, PVRSRV_TIMER_TOTAL_IN_MS(PVRSRV_TIMER_EXAMPLE_1))); | ||
155 | PVR_DPF((PVR_DBG_ERROR," Timer(%u): Count = %u",PVRSRV_TIMER_EXAMPLE_1, PVRSRV_TIMER_COUNT(PVRSRV_TIMER_EXAMPLE_1))); | ||
156 | #endif | ||
157 | } | ||
158 | |||
159 | #endif | ||
160 | |||