2 Copyright (c) 2012, Broadcom Europe Ltd
5 Redistribution and use in source and binary forms, with or without
6 modification, are permitted provided that the following conditions are met:
7 * Redistributions of source code must retain the above copyright
8 notice, this list of conditions and the following disclaimer.
9 * Redistributions in binary form must reproduce the above copyright
10 notice, this list of conditions and the following disclaimer in the
11 documentation and/or other materials provided with the distribution.
12 * Neither the name of the copyright holder nor the
13 names of its contributors may be used to endorse or promote products
14 derived from this software without specific prior written permission.
16 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
20 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 #include "interface/khronos/common/khrn_int_common.h"
32 #include "middleware/khronos/common/khrn_image.h"
33 #include "middleware/khronos/egl/egl_disp.h"
34 #include "interface/khronos/include/EGL/egl.h"
35 #include "interface/khronos/include/EGL/eglext.h"
36 #include "interface/vcos/vcos.h"
38 bool khrn_hw_common_init(void);
39 void khrn_hw_common_term(void);
41 void khrn_delayed_display(KHRN_IMAGE_T *image, EGL_DISP_SLOT_HANDLE_T slot_handle);
42 void khrn_delayed_wait_for_display(uint32_t fifo, EGL_DISP_HANDLE_T disp_handle, uint32_t pos);
43 void khrn_delayed_copy_buffer(MEM_HANDLE_T dst_handle, MEM_HANDLE_T src_handle);
45 bool khrn_hw_supports_early_z(void);
47 /* flush all queued stuff */
48 extern void khrn_hw_common_flush(void);
50 /* wait for all flushed stuff to finish */
51 extern void khrn_hw_common_wait(void);
54 void khrn_hw_common_finish()
56 Flush all queued stuff. Wait for all flushed stuff to finish.
64 For all KHRN_IMAGE_T image:
65 image.conceptual_readable_by_master is true
66 image.conceptual_writeable_by_master is true
67 conceptual_buffers_owned_by_master is true
68 conceptual_programs_owned_by_master is true
71 static INLINE void khrn_hw_common_finish(void)
73 khrn_hw_common_flush();
74 khrn_hw_common_wait();
77 extern void khrn_sync_init(void);
78 extern void khrn_sync_notify_master(void);
79 extern void khrn_sync_master_wait(void);
80 #ifdef KHRN_BCG_WAIT_TIMEOUT
81 extern bool khrn_sync_master_wait_timeout(unsigned int t);
83 extern void khrn_sync_display_returned_notify(void); /* called when something comes off the display */
84 extern void khrn_specify_event(VCOS_EVENT_T *ev);
85 extern int32_t khrn_do_suspend_resume(uint32_t up);
87 typedef void KHRN_SYNC_MASTER_WAIT_FUNC(void);
88 typedef void KHRN_SPECIFY_EVENT_FUNC(VCOS_EVENT_T *ev);
89 typedef int32_t KHRN_DO_SUSPEND_RESUME_FUNC(uint32_t up);
94 } KHRN_CACHE_COUNTERS_T;
96 extern void khrn_memcpy(void *dest, const void *src, uint32_t size);
97 extern void khrn_memset(void *dest, uint32_t val, uint32_t size);
124 uint32_t dpthstclpass;
125 } KHRN_PERF_COUNTERS_T;
128 uint64_t qpu_cycles_idle;
129 uint64_t qpu_cycles_vert_shade;
130 uint64_t qpu_cycles_frag_shade;
131 uint64_t qpu_cycles_exe_valid;
132 uint64_t qpu_cycles_wait_tmu;
133 uint64_t qpu_cycles_wait_scb;
134 uint64_t qpu_cycles_wait_vary;
135 uint64_t qpu_icache_hits;
136 uint64_t qpu_icache_miss;
137 uint64_t qpu_ucache_hits;
138 uint64_t qpu_ucache_miss;
140 uint64_t tmu_total_quads;
141 uint64_t tmu_cache_miss;
145 } KHRN_DRIVER_HW_COUNTERS0_T;
148 uint64_t fep_valid_prims;
149 uint64_t fep_valid_prims_no_pixels;
150 uint64_t fep_earlyz_clipped_quads;
151 uint64_t fep_valid_quads;
153 uint64_t tlb_quads_no_stencil_pass_pixels;
154 uint64_t tlb_quads_no_z_stencil_pass_pixels;
155 uint64_t tlb_quads_z_stencil_pass_pixels;
156 uint64_t tlb_quads_all_pixels_zero_cvg;
157 uint64_t tlb_quads_all_pixels_nonzero_cvg;
158 uint64_t tlb_quads_valid_pixels_written;
160 uint64_t ptb_prims_viewport_discarded;
161 uint64_t ptb_prims_needing_clip;
163 uint64_t pse_prims_reverse_discarded;
165 uint64_t vpm_cycles_vdw_stalled;
166 uint64_t vpm_cycles_vcd_stalled;
167 } KHRN_DRIVER_HW_COUNTERS1_T;
170 uint32_t hard_clears;
171 uint32_t soft_clears;
172 uint32_t tb_grp_color_loads;
173 uint32_t tb_grp_ms_color_loads;
174 uint32_t tb_grp_ds_loads;
175 uint32_t tb_grp_color_stores;
176 uint32_t tb_grp_ms_color_stores;
177 uint32_t tb_grp_ds_stores;
178 uint32_t tb_color_loads;
179 uint32_t tb_ms_color_loads;
180 uint32_t tb_ds_loads;
181 uint32_t tb_color_stores;
182 uint32_t tb_ms_color_stores;
183 uint32_t tb_ds_stores;
184 uint32_t tex_submissions;
185 uint32_t tex_fast_paths;
186 uint32_t mipmap_gens;
187 uint32_t mipmap_gens_fast;
191 uint32_t hw_group_active;
194 uint32_t reset_time; /* time in ms when the statistics were last reset */
195 uint32_t in_time; /* time at which acquire happened */
196 uint32_t total_time; /* total of all (release time - acquire time) */
198 uint32_t last_cpu_time;
199 uint32_t last_cpu_ticks;
204 KHRN_DRIVER_HW_COUNTERS0_T hw_0;
205 KHRN_DRIVER_HW_COUNTERS1_T hw_1;
208 uint32_t l3c_group_active;
211 uint64_t l3c_read_bw_0;
212 uint64_t l3c_write_bw_1;
216 uint64_t l3c_mem_read_bw_0;
217 uint64_t l3c_mem_write_bw_1;
220 } KHRN_DRIVER_COUNTERS_T;
222 extern void khrn_hw_register_perf_counters(KHRN_DRIVER_COUNTERS_T *counters);
223 extern void khrn_hw_unregister_perf_counters(void);
224 extern void khrn_reset_driver_counters(int32_t hw_bank, int32_t l3c_bank);
226 extern KHRN_DRIVER_COUNTERS_T *khrn_driver_counters(void);
228 #if EGL_BRCM_driver_monitor
229 #define INCR_DRIVER_COUNTER(counter) khrn_driver_counters()->counter++;
231 #define INCR_DRIVER_COUNTER(counter) ;
234 extern void khrn_hw_kick(void);