tizen 2.4 release
[kernel/linux-3.0.git] / drivers / gpu / arm / mali400 / mali / common / mali_osk_profiling.h
1 /*
2  * Copyright (C) 2011-2012 ARM Limited. All rights reserved.
3  *
4  * This program is free software and is provided to you under the terms of the GNU General Public License version 2
5  * as published by the Free Software Foundation, and any use by you of this program is subject to the terms of such GNU licence.
6  *
7  * A copy of the licence is included with the program, and can also be obtained from Free Software
8  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
9  */
10
11 #ifndef __MALI_OSK_PROFILING_H__
12 #define __MALI_OSK_PROFILING_H__
13
14 #if defined(CONFIG_MALI400_PROFILING) && defined (CONFIG_TRACEPOINTS)
15
16 #include "mali_linux_trace.h"
17 #include "mali_profiling_events.h"
18
19 #define MALI_PROFILING_MAX_BUFFER_ENTRIES 1048576
20
21 #define MALI_PROFILING_NO_HW_COUNTER = ((u32)-1)
22
23 /** @defgroup _mali_osk_profiling External profiling connectivity
24  * @{ */
25
26 /**
27  * Initialize the profiling module.
28  * @return _MALI_OSK_ERR_OK on success, otherwise failure.
29  */
30 _mali_osk_errcode_t _mali_osk_profiling_init(mali_bool auto_start);
31
32 /*
33  * Terminate the profiling module.
34  */
35 void _mali_osk_profiling_term(void);
36
37 /**
38  * Start recording profiling data
39  *
40  * The specified limit will determine how large the capture buffer is.
41  * MALI_PROFILING_MAX_BUFFER_ENTRIES determines the maximum size allowed by the device driver.
42  *
43  * @param limit The desired maximum number of events to record on input, the actual maximum on output.
44  * @return _MALI_OSK_ERR_OK on success, otherwise failure.
45  */
46 _mali_osk_errcode_t _mali_osk_profiling_start(u32 * limit);
47
48 /**
49  * Add an profiling event
50  *
51  * @param event_id The event identificator.
52  * @param data0 First data parameter, depending on event_id specified.
53  * @param data1 Second data parameter, depending on event_id specified.
54  * @param data2 Third data parameter, depending on event_id specified.
55  * @param data3 Fourth data parameter, depending on event_id specified.
56  * @param data4 Fifth data parameter, depending on event_id specified.
57  * @return _MALI_OSK_ERR_OK on success, otherwise failure.
58  */
59 /* Call Linux tracepoint directly */
60 #define _mali_osk_profiling_add_event(event_id, data0, data1, data2, data3, data4) trace_mali_timeline_event((event_id), (data0), (data1), (data2), (data3), (data4))
61
62 /**
63  * Report a hardware counter event.
64  *
65  * @param counter_id The ID of the counter.
66  * @param value The value of the counter.
67  */
68
69 /* Call Linux tracepoint directly */
70 #define _mali_osk_profiling_report_hw_counter(counter_id, value) trace_mali_hw_counter(counter_id, value)
71
72 /**
73  * Report SW counters
74  *
75  * @param counters array of counter values
76  */
77 void _mali_osk_profiling_report_sw_counters(u32 *counters);
78
79 /**
80  * Stop recording profiling data
81  *
82  * @param count Returns the number of recorded events.
83  * @return _MALI_OSK_ERR_OK on success, otherwise failure.
84  */
85 _mali_osk_errcode_t _mali_osk_profiling_stop(u32 * count);
86
87 /**
88  * Retrieves the number of events that can be retrieved
89  *
90  * @return The number of recorded events that can be retrieved.
91  */
92 u32 _mali_osk_profiling_get_count(void);
93
94 /**
95  * Retrieve an event
96  *
97  * @param index Event index (start with 0 and continue until this function fails to retrieve all events)
98  * @param timestamp The timestamp for the retrieved event will be stored here.
99  * @param event_id The event ID for the retrieved event will be stored here.
100  * @param data The 5 data values for the retrieved event will be stored here.
101  * @return _MALI_OSK_ERR_OK on success, otherwise failure.
102  */
103 _mali_osk_errcode_t _mali_osk_profiling_get_event(u32 index, u64* timestamp, u32* event_id, u32 data[5]);
104
105 /**
106  * Clear the recorded buffer.
107  *
108  * This is needed in order to start another recording.
109  *
110  * @return _MALI_OSK_ERR_OK on success, otherwise failure.
111  */
112 _mali_osk_errcode_t _mali_osk_profiling_clear(void);
113
114 /**
115  * Checks if a recording of profiling data is in progress
116  *
117  * @return MALI_TRUE if recording of profiling data is in progress, MALI_FALSE if not
118  */
119 mali_bool _mali_osk_profiling_is_recording(void);
120
121 /**
122  * Checks if profiling data is available for retrival
123  *
124  * @return MALI_TRUE if profiling data is avaiable, MALI_FALSE if not
125  */
126 mali_bool _mali_osk_profiling_have_recording(void);
127
128 /** @} */ /* end group _mali_osk_profiling */
129
130 #else /* defined(CONFIG_MALI400_PROFILING)  && defined(CONFIG_TRACEPOINTS) */
131
132  /* Dummy add_event, for when profiling is disabled. */
133
134 #define _mali_osk_profiling_add_event(event_id, data0, data1, data2, data3, data4)
135
136 #endif /* defined(CONFIG_MALI400_PROFILING)  && defined(CONFIG_TRACEPOINTS) */
137
138 #endif /* __MALI_OSK_PROFILING_H__ */
139
140