559647a76d29096980b44e8c752731e836804cee
[firefly-linux-kernel-4.4.55.git] / drivers / gator / mali / mali_utgard_profiling_gator_api.h
1 /**
2  * Copyright (C) ARM Limited 2013. All rights reserved.
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License version 2 as
6  * published by the Free Software Foundation.
7  *
8  */
9
10 #ifndef __MALI_UTGARD_PROFILING_GATOR_API_H__
11 #define __MALI_UTGARD_PROFILING_GATOR_API_H__
12
13 #ifdef __cplusplus
14 extern "C"
15 {
16 #endif
17
18 #define MALI_PROFILING_API_VERSION 4
19
20 #define MAX_NUM_L2_CACHE_CORES 3
21 #define MAX_NUM_FP_CORES 8
22 #define MAX_NUM_VP_CORES 1
23
24 /** The list of events supported by the Mali DDK. */
25 typedef enum
26 {
27     /* Vertex processor activity */
28     ACTIVITY_VP_0 = 0,
29
30     /* Fragment processor activity */
31     ACTIVITY_FP_0, /* 1 */
32     ACTIVITY_FP_1,
33     ACTIVITY_FP_2,
34     ACTIVITY_FP_3,
35     ACTIVITY_FP_4,
36     ACTIVITY_FP_5,
37     ACTIVITY_FP_6,
38     ACTIVITY_FP_7,
39
40     /* L2 cache counters */
41     COUNTER_L2_0_C0,
42     COUNTER_L2_0_C1,
43     COUNTER_L2_1_C0,
44     COUNTER_L2_1_C1,
45     COUNTER_L2_2_C0,
46     COUNTER_L2_2_C1,
47
48     /* Vertex processor counters */
49     COUNTER_VP_0_C0, /*15*/
50     COUNTER_VP_0_C1,
51
52     /* Fragment processor counters */
53     COUNTER_FP_0_C0,
54     COUNTER_FP_0_C1,
55     COUNTER_FP_1_C0,
56     COUNTER_FP_1_C1,
57     COUNTER_FP_2_C0,
58     COUNTER_FP_2_C1,
59     COUNTER_FP_3_C0,
60     COUNTER_FP_3_C1,
61     COUNTER_FP_4_C0,
62     COUNTER_FP_4_C1,
63     COUNTER_FP_5_C0,
64     COUNTER_FP_5_C1,
65     COUNTER_FP_6_C0,
66     COUNTER_FP_6_C1,
67     COUNTER_FP_7_C0,
68     COUNTER_FP_7_C1, /* 32 */
69
70     /*
71      * If more hardware counters are added, the _mali_osk_hw_counter_table
72      * below should also be updated.
73      */
74
75     /* EGL software counters */
76     COUNTER_EGL_BLIT_TIME,
77
78     /* GLES software counters */
79     COUNTER_GLES_DRAW_ELEMENTS_CALLS,
80     COUNTER_GLES_DRAW_ELEMENTS_NUM_INDICES,
81     COUNTER_GLES_DRAW_ELEMENTS_NUM_TRANSFORMED,
82     COUNTER_GLES_DRAW_ARRAYS_CALLS,
83     COUNTER_GLES_DRAW_ARRAYS_NUM_TRANSFORMED,
84     COUNTER_GLES_DRAW_POINTS,
85     COUNTER_GLES_DRAW_LINES,
86     COUNTER_GLES_DRAW_LINE_LOOP,
87     COUNTER_GLES_DRAW_LINE_STRIP,
88     COUNTER_GLES_DRAW_TRIANGLES,
89     COUNTER_GLES_DRAW_TRIANGLE_STRIP,
90     COUNTER_GLES_DRAW_TRIANGLE_FAN,
91     COUNTER_GLES_NON_VBO_DATA_COPY_TIME,
92     COUNTER_GLES_UNIFORM_BYTES_COPIED_TO_MALI,
93     COUNTER_GLES_UPLOAD_TEXTURE_TIME,
94     COUNTER_GLES_UPLOAD_VBO_TIME,
95     COUNTER_GLES_NUM_FLUSHES,
96     COUNTER_GLES_NUM_VSHADERS_GENERATED,
97     COUNTER_GLES_NUM_FSHADERS_GENERATED,
98     COUNTER_GLES_VSHADER_GEN_TIME,
99     COUNTER_GLES_FSHADER_GEN_TIME,
100     COUNTER_GLES_INPUT_TRIANGLES,
101     COUNTER_GLES_VXCACHE_HIT,
102     COUNTER_GLES_VXCACHE_MISS,
103     COUNTER_GLES_VXCACHE_COLLISION,
104     COUNTER_GLES_CULLED_TRIANGLES,
105     COUNTER_GLES_CULLED_LINES,
106     COUNTER_GLES_BACKFACE_TRIANGLES,
107     COUNTER_GLES_GBCLIP_TRIANGLES,
108     COUNTER_GLES_GBCLIP_LINES,
109     COUNTER_GLES_TRIANGLES_DRAWN,
110     COUNTER_GLES_DRAWCALL_TIME,
111     COUNTER_GLES_TRIANGLES_COUNT,
112     COUNTER_GLES_INDEPENDENT_TRIANGLES_COUNT,
113     COUNTER_GLES_STRIP_TRIANGLES_COUNT,
114     COUNTER_GLES_FAN_TRIANGLES_COUNT,
115     COUNTER_GLES_LINES_COUNT,
116     COUNTER_GLES_INDEPENDENT_LINES_COUNT,
117     COUNTER_GLES_STRIP_LINES_COUNT,
118     COUNTER_GLES_LOOP_LINES_COUNT,
119
120     /* Framebuffer capture pseudo-counter */
121     COUNTER_FILMSTRIP,
122
123     NUMBER_OF_EVENTS
124 } _mali_osk_counter_id;
125
126 #define FIRST_ACTIVITY_EVENT    ACTIVITY_VP_0
127 #define LAST_ACTIVITY_EVENT     ACTIVITY_FP_7
128
129 #define FIRST_HW_COUNTER        COUNTER_L2_0_C0
130 #define LAST_HW_COUNTER         COUNTER_FP_7_C1
131
132 #define FIRST_SW_COUNTER        COUNTER_EGL_BLIT_TIME
133 #define LAST_SW_COUNTER         COUNTER_GLES_LOOP_LINES_COUNT
134
135 #define FIRST_SPECIAL_COUNTER   COUNTER_FILMSTRIP
136 #define LAST_SPECIAL_COUNTER    COUNTER_FILMSTRIP
137
138 /**
139  * Structure to pass performance counter data of a Mali core
140  */
141 typedef struct _mali_profiling_core_counters
142 {
143         u32 source0;
144         u32 value0;
145         u32 source1;
146         u32 value1;
147 } _mali_profiling_core_counters;
148
149 /**
150  * Structure to pass performance counter data of Mali L2 cache cores
151  */
152 typedef struct _mali_profiling_l2_counter_values
153 {
154         struct _mali_profiling_core_counters cores[MAX_NUM_L2_CACHE_CORES];
155 } _mali_profiling_l2_counter_values;
156
157 /**
158  * Structure to pass data defining Mali instance in use:
159  *
160  * mali_product_id - Mali product id
161  * mali_version_major - Mali version major number
162  * mali_version_minor - Mali version minor number
163  * num_of_l2_cores - number of L2 cache cores
164  * num_of_fp_cores - number of fragment processor cores
165  * num_of_vp_cores - number of vertex processor cores
166  */
167 typedef struct _mali_profiling_mali_version
168 {
169         u32 mali_product_id;
170         u32 mali_version_major;
171         u32 mali_version_minor;
172         u32 num_of_l2_cores;
173         u32 num_of_fp_cores;
174         u32 num_of_vp_cores;
175 } _mali_profiling_mali_version;
176
177 /*
178  * List of possible actions to be controlled by Streamline.
179  * The following numbers are used by gator to control the frame buffer dumping and s/w counter reporting.
180  * We cannot use the enums in mali_uk_types.h because they are unknown inside gator.
181  */
182 #define FBDUMP_CONTROL_ENABLE (1)
183 #define FBDUMP_CONTROL_RATE (2)
184 #define SW_COUNTER_ENABLE (3)
185 #define FBDUMP_CONTROL_RESIZE_FACTOR (4)
186
187 void _mali_profiling_control(u32 action, u32 value);
188
189 u32 _mali_profiling_get_l2_counters(_mali_profiling_l2_counter_values *values);
190
191 int _mali_profiling_set_event(u32 counter_id, s32 event_id);
192
193 u32 _mali_profiling_get_api_version(void);
194
195 void _mali_profiling_get_mali_version(struct _mali_profiling_mali_version *values);
196
197 #ifdef __cplusplus
198 }
199 #endif
200
201 #endif /* __MALI_UTGARD_PROFILING_GATOR_API_H__ */