import PULS_20160108
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / drivers / misc / mediatek / gpu / mt8127 / mali / mali / include / linux / mali / mali_utgard_uk_types.h
1 /*
2 * This confidential and proprietary software may be used only as
3 * authorised by a licensing agreement from ARM Limited
4 * (C) COPYRIGHT 2008-2013 ARM Limited
5 * ALL RIGHTS RESERVED
6 * The entire notice above must be reproduced on all authorised
7 * copies and copies may only be made to the extent permitted
8 * by a licensing agreement from ARM Limited.
9 */
10
11 /**
12 * @file mali_uk_types.h
13 * Defines the types and constants used in the user-kernel interface
14 */
15
16 #ifndef __MALI_UTGARD_UK_TYPES_H__
17 #define __MALI_UTGARD_UK_TYPES_H__
18
19 #ifdef __cplusplus
20 extern "C" {
21 #endif
22
23 /* Iteration functions depend on these values being consecutive. */
24 #define MALI_UK_TIMELINE_GP 0
25 #define MALI_UK_TIMELINE_PP 1
26 #define MALI_UK_TIMELINE_SOFT 2
27 #define MALI_UK_TIMELINE_MAX 3
28
29 typedef struct {
30 u32 points[MALI_UK_TIMELINE_MAX];
31 s32 sync_fd;
32 } _mali_uk_fence_t;
33
34 /**
35 * @addtogroup uddapi Unified Device Driver (UDD) APIs
36 *
37 * @{
38 */
39
40 /**
41 * @addtogroup u_k_api UDD User/Kernel Interface (U/K) APIs
42 *
43 * @{
44 */
45
46 /** @defgroup _mali_uk_core U/K Core
47 * @{ */
48
49 /** Definition of subsystem numbers, to assist in creating a unique identifier
50 * for each U/K call.
51 *
52 * @see _mali_uk_functions */
53 typedef enum {
54 _MALI_UK_CORE_SUBSYSTEM, /**< Core Group of U/K calls */
55 _MALI_UK_MEMORY_SUBSYSTEM, /**< Memory Group of U/K calls */
56 _MALI_UK_PP_SUBSYSTEM, /**< Fragment Processor Group of U/K calls */
57 _MALI_UK_GP_SUBSYSTEM, /**< Vertex Processor Group of U/K calls */
58 _MALI_UK_PROFILING_SUBSYSTEM, /**< Profiling Group of U/K calls */
59 _MALI_UK_PMM_SUBSYSTEM, /**< Power Management Module Group of U/K calls */
60 _MALI_UK_VSYNC_SUBSYSTEM, /**< VSYNC Group of U/K calls */
61 } _mali_uk_subsystem_t;
62
63 /** Within a function group each function has its unique sequence number
64 * to assist in creating a unique identifier for each U/K call.
65 *
66 * An ordered pair of numbers selected from
67 * ( \ref _mali_uk_subsystem_t,\ref _mali_uk_functions) will uniquely identify the
68 * U/K call across all groups of functions, and all functions. */
69 typedef enum {
70 /** Core functions */
71
72 _MALI_UK_OPEN = 0, /**< _mali_ukk_open() */
73 _MALI_UK_CLOSE, /**< _mali_ukk_close() */
74 _MALI_UK_WAIT_FOR_NOTIFICATION, /**< _mali_ukk_wait_for_notification() */
75 _MALI_UK_GET_API_VERSION, /**< _mali_ukk_get_api_version() */
76 _MALI_UK_POST_NOTIFICATION, /**< _mali_ukk_post_notification() */
77 _MALI_UK_GET_USER_SETTING, /**< _mali_ukk_get_user_setting() *//**< [out] */
78 _MALI_UK_GET_USER_SETTINGS, /**< _mali_ukk_get_user_settings() *//**< [out] */
79 _MALI_UK_REQUEST_HIGH_PRIORITY, /**< _mali_ukk_request_high_priority() */
80 _MALI_UK_TIMELINE_GET_LATEST_POINT, /**< _mali_ukk_timeline_get_latest_point() */
81 _MALI_UK_TIMELINE_WAIT, /**< _mali_ukk_timeline_wait() */
82 _MALI_UK_TIMELINE_CREATE_SYNC_FENCE, /**< _mali_ukk_timeline_create_sync_fence() */
83 _MALI_UK_SOFT_JOB_START, /**< _mali_ukk_soft_job_start() */
84 _MALI_UK_SOFT_JOB_SIGNAL, /**< _mali_ukk_soft_job_signal() */
85
86 /** Memory functions */
87
88 _MALI_UK_INIT_MEM = 0, /**< _mali_ukk_init_mem() */
89 _MALI_UK_TERM_MEM, /**< _mali_ukk_term_mem() */
90 _MALI_UK_GET_BIG_BLOCK, /**< _mali_ukk_get_big_block() */
91 _MALI_UK_FREE_BIG_BLOCK, /**< _mali_ukk_free_big_block() */
92 _MALI_UK_MAP_MEM, /**< _mali_ukk_mem_mmap() */
93 _MALI_UK_UNMAP_MEM, /**< _mali_ukk_mem_munmap() */
94 _MALI_UK_QUERY_MMU_PAGE_TABLE_DUMP_SIZE, /**< _mali_ukk_mem_get_mmu_page_table_dump_size() */
95 _MALI_UK_DUMP_MMU_PAGE_TABLE, /**< _mali_ukk_mem_dump_mmu_page_table() */
96 _MALI_UK_ATTACH_DMA_BUF, /**< _mali_ukk_attach_dma_buf() */
97 _MALI_UK_RELEASE_DMA_BUF, /**< _mali_ukk_release_dma_buf() */
98 _MALI_UK_DMA_BUF_GET_SIZE, /**< _mali_ukk_dma_buf_get_size() */
99 _MALI_UK_ATTACH_UMP_MEM, /**< _mali_ukk_attach_ump_mem() */
100 _MALI_UK_RELEASE_UMP_MEM, /**< _mali_ukk_release_ump_mem() */
101 _MALI_UK_MAP_EXT_MEM, /**< _mali_uku_map_external_mem() */
102 _MALI_UK_UNMAP_EXT_MEM, /**< _mali_uku_unmap_external_mem() */
103 _MALI_UK_VA_TO_MALI_PA, /**< _mali_uku_va_to_mali_pa() */
104 _MALI_UK_MEM_WRITE_SAFE, /**< _mali_uku_mem_write_safe() */
105
106 /** Common functions for each core */
107
108 _MALI_UK_START_JOB = 0, /**< Start a Fragment/Vertex Processor Job on a core */
109 _MALI_UK_GET_NUMBER_OF_CORES, /**< Get the number of Fragment/Vertex Processor cores */
110 _MALI_UK_GET_CORE_VERSION, /**< Get the Fragment/Vertex Processor version compatible with all cores */
111
112 /** Fragment Processor Functions */
113
114 _MALI_UK_PP_START_JOB = _MALI_UK_START_JOB, /**< _mali_ukk_pp_start_job() */
115 _MALI_UK_GET_PP_NUMBER_OF_CORES = _MALI_UK_GET_NUMBER_OF_CORES, /**< _mali_ukk_get_pp_number_of_cores() */
116 _MALI_UK_GET_PP_CORE_VERSION = _MALI_UK_GET_CORE_VERSION, /**< _mali_ukk_get_pp_core_version() */
117 _MALI_UK_PP_DISABLE_WB, /**< _mali_ukk_pp_job_disable_wb() */
118 _MALI_UK_PP_AND_GP_START_JOB, /**< _mali_ukk_pp_and_gp_start_job() */
119
120 /** Vertex Processor Functions */
121
122 _MALI_UK_GP_START_JOB = _MALI_UK_START_JOB, /**< _mali_ukk_gp_start_job() */
123 _MALI_UK_GET_GP_NUMBER_OF_CORES = _MALI_UK_GET_NUMBER_OF_CORES, /**< _mali_ukk_get_gp_number_of_cores() */
124 _MALI_UK_GET_GP_CORE_VERSION = _MALI_UK_GET_CORE_VERSION, /**< _mali_ukk_get_gp_core_version() */
125 _MALI_UK_GP_SUSPEND_RESPONSE, /**< _mali_ukk_gp_suspend_response() */
126
127 /** Profiling functions */
128
129 _MALI_UK_PROFILING_START = 0, /**< __mali_uku_profiling_start() */
130 _MALI_UK_PROFILING_ADD_EVENT, /**< __mali_uku_profiling_add_event() */
131 _MALI_UK_PROFILING_STOP, /**< __mali_uku_profiling_stop() */
132 _MALI_UK_PROFILING_GET_EVENT, /**< __mali_uku_profiling_get_event() */
133 _MALI_UK_PROFILING_CLEAR, /**< __mali_uku_profiling_clear() */
134 _MALI_UK_PROFILING_GET_CONFIG, /**< __mali_uku_profiling_get_config() */
135 _MALI_UK_PROFILING_REPORT_SW_COUNTERS,/**< __mali_uku_profiling_report_sw_counters() */
136
137 /** VSYNC reporting fuctions */
138 _MALI_UK_VSYNC_EVENT_REPORT = 0, /**< _mali_ukk_vsync_event_report() */
139
140 } _mali_uk_functions;
141
142 /** @brief Get the size necessary for system info
143 *
144 * @see _mali_ukk_get_system_info_size()
145 */
146 typedef struct {
147 void *ctx; /**< [in,out] user-kernel context (trashed on output) */
148 u32 size; /**< [out] size of buffer necessary to hold system information data, in bytes */
149 } _mali_uk_get_system_info_size_s;
150
151
152 /** @defgroup _mali_uk_getsysteminfo U/K Get System Info
153 * @{ */
154
155 /**
156 * Type definition for the core version number.
157 * Used when returning the version number read from a core
158 *
159 * Its format is that of the 32-bit Version register for a particular core.
160 * Refer to the "Mali200 and MaliGP2 3D Graphics Processor Technical Reference
161 * Manual", ARM DDI 0415C, for more information.
162 */
163 typedef u32 _mali_core_version;
164
165 /**
166 * Enum values for the different modes the driver can be put in.
167 * Normal is the default mode. The driver then uses a job queue and takes job objects from the clients.
168 * Job completion is reported using the _mali_ukk_wait_for_notification call.
169 * The driver blocks this io command until a job has completed or failed or a timeout occurs.
170 *
171 * The 'raw' mode is reserved for future expansion.
172 */
173 typedef enum _mali_driver_mode {
174 _MALI_DRIVER_MODE_RAW = 1, /**< Reserved for future expansion */
175 _MALI_DRIVER_MODE_NORMAL = 2 /**< Normal mode of operation */
176 } _mali_driver_mode;
177
178 /** @brief List of possible cores
179 *
180 * add new entries to the end of this enum */
181 typedef enum _mali_core_type {
182 _MALI_GP2 = 2, /**< MaliGP2 Programmable Vertex Processor */
183 _MALI_200 = 5, /**< Mali200 Programmable Fragment Processor */
184 _MALI_400_GP = 6, /**< Mali400 Programmable Vertex Processor */
185 _MALI_400_PP = 7, /**< Mali400 Programmable Fragment Processor */
186 /* insert new core here, do NOT alter the existing values */
187 } _mali_core_type;
188
189
190 /** @brief Capabilities of Memory Banks
191 *
192 * These may be used to restrict memory banks for certain uses. They may be
193 * used when access is not possible (e.g. Bus does not support access to it)
194 * or when access is possible but not desired (e.g. Access is slow).
195 *
196 * In the case of 'possible but not desired', there is no way of specifying
197 * the flags as an optimization hint, so that the memory could be used as a
198 * last resort.
199 *
200 * @see _mali_mem_info
201 */
202 typedef enum _mali_bus_usage {
203
204 _MALI_PP_READABLE = (1<<0), /** Readable by the Fragment Processor */
205 _MALI_PP_WRITEABLE = (1<<1), /** Writeable by the Fragment Processor */
206 _MALI_GP_READABLE = (1<<2), /** Readable by the Vertex Processor */
207 _MALI_GP_WRITEABLE = (1<<3), /** Writeable by the Vertex Processor */
208 _MALI_CPU_READABLE = (1<<4), /** Readable by the CPU */
209 _MALI_CPU_WRITEABLE = (1<<5), /** Writeable by the CPU */
210 _MALI_GP_L2_ALLOC = (1<<6), /** GP allocate mali L2 cache lines*/
211 _MALI_MMU_READABLE = _MALI_PP_READABLE | _MALI_GP_READABLE, /** Readable by the MMU (including all cores behind it) */
212 _MALI_MMU_WRITEABLE = _MALI_PP_WRITEABLE | _MALI_GP_WRITEABLE, /** Writeable by the MMU (including all cores behind it) */
213 } _mali_bus_usage;
214
215 typedef enum mali_memory_cache_settings {
216 MALI_CACHE_STANDARD = 0,
217 MALI_CACHE_GP_READ_ALLOCATE = 1,
218 } mali_memory_cache_settings ;
219
220
221 /** @brief Information about the Mali Memory system
222 *
223 * Information is stored in a linked list, which is stored entirely in the
224 * buffer pointed to by the system_info member of the
225 * _mali_uk_get_system_info_s arguments provided to _mali_ukk_get_system_info()
226 *
227 * Each element of the linked list describes a single Mali Memory bank.
228 * Each allocation can only come from one bank, and will not cross multiple
229 * banks.
230 *
231 * On Mali-MMU systems, there is only one bank, which describes the maximum
232 * possible address range that could be allocated (which may be much less than
233 * the available physical memory)
234 *
235 * The flags member describes the capabilities of the memory. It is an error
236 * to attempt to build a job for a particular core (PP or GP) when the memory
237 * regions used do not have the capabilities for supporting that core. This
238 * would result in a job abort from the Device Driver.
239 *
240 * For example, it is correct to build a PP job where read-only data structures
241 * are taken from a memory with _MALI_PP_READABLE set and
242 * _MALI_PP_WRITEABLE clear, and a framebuffer with _MALI_PP_WRITEABLE set and
243 * _MALI_PP_READABLE clear. However, it would be incorrect to use a framebuffer
244 * where _MALI_PP_WRITEABLE is clear.
245 */
246 typedef struct _mali_mem_info {
247 u32 size; /**< Size of the memory bank in bytes */
248 _mali_bus_usage flags; /**< Capabilitiy flags of the memory */
249 u32 maximum_order_supported; /**< log2 supported size */
250 u32 identifier; /* mali_memory_cache_settings cache_settings; */
251 struct _mali_mem_info * next; /**< Next List Link */
252 } _mali_mem_info;
253
254 /** @} */ /* end group _mali_uk_core */
255
256
257 /** @defgroup _mali_uk_gp U/K Vertex Processor
258 * @{ */
259
260 /** @defgroup _mali_uk_gp_suspend_response_s Vertex Processor Suspend Response
261 * @{ */
262
263 /** @brief Arguments for _mali_ukk_gp_suspend_response()
264 *
265 * When _mali_wait_for_notification() receives notification that a
266 * Vertex Processor job was suspended, you need to send a response to indicate
267 * what needs to happen with this job. You can either abort or resume the job.
268 *
269 * - set @c code to indicate response code. This is either @c _MALIGP_JOB_ABORT or
270 * @c _MALIGP_JOB_RESUME_WITH_NEW_HEAP to indicate you will provide a new heap
271 * for the job that will resolve the out of memory condition for the job.
272 * - copy the @c cookie value from the @c _mali_uk_gp_job_suspended_s notification;
273 * this is an identifier for the suspended job
274 * - set @c arguments[0] and @c arguments[1] to zero if you abort the job. If
275 * you resume it, @c argument[0] should specify the Mali start address for the new
276 * heap and @c argument[1] the Mali end address of the heap.
277 * - pass in the user-kernel context @c ctx that was returned from _mali_ukk_open()
278 *
279 */
280 typedef enum _maligp_job_suspended_response_code {
281 _MALIGP_JOB_ABORT, /**< Abort the Vertex Processor job */
282 _MALIGP_JOB_RESUME_WITH_NEW_HEAP /**< Resume the Vertex Processor job with a new heap */
283 } _maligp_job_suspended_response_code;
284
285 typedef struct {
286 void *ctx; /**< [in,out] user-kernel context (trashed on output) */
287 u32 cookie; /**< [in] cookie from the _mali_uk_gp_job_suspended_s notification */
288 _maligp_job_suspended_response_code code; /**< [in] abort or resume response code, see \ref _maligp_job_suspended_response_code */
289 u32 arguments[2]; /**< [in] 0 when aborting a job. When resuming a job, the Mali start and end address for a new heap to resume the job with */
290 } _mali_uk_gp_suspend_response_s;
291
292 /** @} */ /* end group _mali_uk_gp_suspend_response_s */
293
294 /** @defgroup _mali_uk_gpstartjob_s Vertex Processor Start Job
295 * @{ */
296
297 /** @brief Status indicating the result of starting a Vertex or Fragment processor job */
298 typedef enum {
299 _MALI_UK_START_JOB_STARTED, /**< Job started */
300 _MALI_UK_START_JOB_NOT_STARTED_DO_REQUEUE /**< Job could not be started at this time. Try starting the job again */
301 } _mali_uk_start_job_status;
302
303 /** @brief Status indicating the result of the execution of a Vertex or Fragment processor job */
304
305 typedef enum {
306 _MALI_UK_JOB_STATUS_END_SUCCESS = 1<<(16+0),
307 _MALI_UK_JOB_STATUS_END_OOM = 1<<(16+1),
308 _MALI_UK_JOB_STATUS_END_ABORT = 1<<(16+2),
309 _MALI_UK_JOB_STATUS_END_TIMEOUT_SW = 1<<(16+3),
310 _MALI_UK_JOB_STATUS_END_HANG = 1<<(16+4),
311 _MALI_UK_JOB_STATUS_END_SEG_FAULT = 1<<(16+5),
312 _MALI_UK_JOB_STATUS_END_ILLEGAL_JOB = 1<<(16+6),
313 _MALI_UK_JOB_STATUS_END_UNKNOWN_ERR = 1<<(16+7),
314 _MALI_UK_JOB_STATUS_END_SHUTDOWN = 1<<(16+8),
315 _MALI_UK_JOB_STATUS_END_SYSTEM_UNUSABLE = 1<<(16+9)
316 } _mali_uk_job_status;
317
318 #define MALIGP2_NUM_REGS_FRAME (6)
319
320 /** @brief Arguments for _mali_ukk_gp_start_job()
321 *
322 * To start a Vertex Processor job
323 * - associate the request with a reference to a @c mali_gp_job_info by setting
324 * user_job_ptr to the address of the @c mali_gp_job_info of the job.
325 * - set @c priority to the priority of the @c mali_gp_job_info
326 * - specify a timeout for the job by setting @c watchdog_msecs to the number of
327 * milliseconds the job is allowed to run. Specifying a value of 0 selects the
328 * default timeout in use by the device driver.
329 * - copy the frame registers from the @c mali_gp_job_info into @c frame_registers.
330 * - set the @c perf_counter_flag, @c perf_counter_src0 and @c perf_counter_src1 to zero
331 * for a non-instrumented build. For an instrumented build you can use up
332 * to two performance counters. Set the corresponding bit in @c perf_counter_flag
333 * to enable them. @c perf_counter_src0 and @c perf_counter_src1 specify
334 * the source of what needs to get counted (e.g. number of vertex loader
335 * cache hits). For source id values, see ARM DDI0415A, Table 3-60.
336 * - pass in the user-kernel context @c ctx that was returned from _mali_ukk_open()
337 *
338 * When @c _mali_ukk_gp_start_job() returns @c _MALI_OSK_ERR_OK, status contains the
339 * result of the request (see \ref _mali_uk_start_job_status). If the job could
340 * not get started (@c _MALI_UK_START_JOB_NOT_STARTED_DO_REQUEUE) it should be
341 * tried again.
342 *
343 * After the job has started, @c _mali_wait_for_notification() will be notified
344 * that the job finished or got suspended. It may get suspended due to
345 * resource shortage. If it finished (see _mali_ukk_wait_for_notification())
346 * the notification will contain a @c _mali_uk_gp_job_finished_s result. If
347 * it got suspended the notification will contain a @c _mali_uk_gp_job_suspended_s
348 * result.
349 *
350 * The @c _mali_uk_gp_job_finished_s contains the job status (see \ref _mali_uk_job_status),
351 * the number of milliseconds the job took to render, and values of core registers
352 * when the job finished (irq status, performance counters, renderer list
353 * address). A job has finished succesfully when its status is
354 * @c _MALI_UK_JOB_STATUS_FINISHED. If the hardware detected a timeout while rendering
355 * the job, or software detected the job is taking more than watchdog_msecs to
356 * complete, the status will indicate @c _MALI_UK_JOB_STATUS_HANG.
357 * If the hardware detected a bus error while accessing memory associated with the
358 * job, status will indicate @c _MALI_UK_JOB_STATUS_SEG_FAULT.
359 * status will indicate @c _MALI_UK_JOB_STATUS_NOT_STARTED if the driver had to
360 * stop the job but the job didn't start on the hardware yet, e.g. when the
361 * driver shutdown.
362 *
363 * In case the job got suspended, @c _mali_uk_gp_job_suspended_s contains
364 * the @c user_job_ptr identifier used to start the job with, the @c reason
365 * why the job stalled (see \ref _maligp_job_suspended_reason) and a @c cookie
366 * to identify the core on which the job stalled. This @c cookie will be needed
367 * when responding to this nofication by means of _mali_ukk_gp_suspend_response().
368 * (see _mali_ukk_gp_suspend_response()). The response is either to abort or
369 * resume the job. If the job got suspended due to an out of memory condition
370 * you may be able to resolve this by providing more memory and resuming the job.
371 *
372 */
373 typedef struct {
374 void *ctx; /**< [in,out] user-kernel context (trashed on output) */
375 u32 user_job_ptr; /**< [in] identifier for the job in user space, a @c mali_gp_job_info* */
376 u32 priority; /**< [in] job priority. A lower number means higher priority */
377 u32 frame_registers[MALIGP2_NUM_REGS_FRAME]; /**< [in] core specific registers associated with this job */
378 u32 perf_counter_flag; /**< [in] bitmask indicating which performance counters to enable, see \ref _MALI_PERFORMANCE_COUNTER_FLAG_SRC0_ENABLE and related macro definitions */
379 u32 perf_counter_src0; /**< [in] source id for performance counter 0 (see ARM DDI0415A, Table 3-60) */
380 u32 perf_counter_src1; /**< [in] source id for performance counter 1 (see ARM DDI0415A, Table 3-60) */
381 u32 frame_builder_id; /**< [in] id of the originating frame builder */
382 u32 flush_id; /**< [in] flush id within the originating frame builder */
383 _mali_uk_fence_t fence; /**< [in] fence this job must wait on */
384 u32 *timeline_point_ptr; /**< [in,out] pointer to location where point on gp timeline for this job will be written */
385 } _mali_uk_gp_start_job_s;
386
387 #define _MALI_PERFORMANCE_COUNTER_FLAG_SRC0_ENABLE (1<<0) /**< Enable performance counter SRC0 for a job */
388 #define _MALI_PERFORMANCE_COUNTER_FLAG_SRC1_ENABLE (1<<1) /**< Enable performance counter SRC1 for a job */
389 #define _MALI_PERFORMANCE_COUNTER_FLAG_HEATMAP_ENABLE (1<<2) /**< Enable per tile (aka heatmap) generation with for a job (using the enabled counter sources) */
390
391 /** @} */ /* end group _mali_uk_gpstartjob_s */
392
393 typedef struct {
394 u32 user_job_ptr; /**< [out] identifier for the job in user space */
395 _mali_uk_job_status status; /**< [out] status of finished job */
396 u32 heap_current_addr; /**< [out] value of the GP PLB PL heap start address register */
397 u32 perf_counter0; /**< [out] value of performance counter 0 (see ARM DDI0415A) */
398 u32 perf_counter1; /**< [out] value of performance counter 1 (see ARM DDI0415A) */
399 } _mali_uk_gp_job_finished_s;
400
401 typedef struct {
402 u32 user_job_ptr; /**< [out] identifier for the job in user space */
403 u32 cookie; /**< [out] identifier for the core in kernel space on which the job stalled */
404 } _mali_uk_gp_job_suspended_s;
405
406 /** @} */ /* end group _mali_uk_gp */
407
408
409 /** @defgroup _mali_uk_pp U/K Fragment Processor
410 * @{ */
411
412 #define _MALI_PP_MAX_SUB_JOBS 8
413
414 #define _MALI_PP_MAX_FRAME_REGISTERS ((0x058/4)+1)
415
416 #define _MALI_PP_MAX_WB_REGISTERS ((0x02C/4)+1)
417
418 #define _MALI_DLBU_MAX_REGISTERS 4
419
420 /** Flag for _mali_uk_pp_start_job_s */
421 #define _MALI_PP_JOB_FLAG_NO_NOTIFICATION (1<<0)
422 #define _MALI_PP_JOB_FLAG_IS_WINDOW_SURFACE (1<<1)
423
424 /** @defgroup _mali_uk_ppstartjob_s Fragment Processor Start Job
425 * @{ */
426
427 /** @brief Arguments for _mali_ukk_pp_start_job()
428 *
429 * To start a Fragment Processor job
430 * - associate the request with a reference to a mali_pp_job by setting
431 * @c user_job_ptr to the address of the @c mali_pp_job of the job.
432 * - set @c priority to the priority of the mali_pp_job
433 * - specify a timeout for the job by setting @c watchdog_msecs to the number of
434 * milliseconds the job is allowed to run. Specifying a value of 0 selects the
435 * default timeout in use by the device driver.
436 * - copy the frame registers from the @c mali_pp_job into @c frame_registers.
437 * For MALI200 you also need to copy the write back 0,1 and 2 registers.
438 * - set the @c perf_counter_flag, @c perf_counter_src0 and @c perf_counter_src1 to zero
439 * for a non-instrumented build. For an instrumented build you can use up
440 * to two performance counters. Set the corresponding bit in @c perf_counter_flag
441 * to enable them. @c perf_counter_src0 and @c perf_counter_src1 specify
442 * the source of what needs to get counted (e.g. number of vertex loader
443 * cache hits). For source id values, see ARM DDI0415A, Table 3-60.
444 * - pass in the user-kernel context in @c ctx that was returned from _mali_ukk_open()
445 *
446 * When _mali_ukk_pp_start_job() returns @c _MALI_OSK_ERR_OK, @c status contains the
447 * result of the request (see \ref _mali_uk_start_job_status). If the job could
448 * not get started (@c _MALI_UK_START_JOB_NOT_STARTED_DO_REQUEUE) it should be
449 * tried again.
450 *
451 * After the job has started, _mali_wait_for_notification() will be notified
452 * when the job finished. The notification will contain a
453 * @c _mali_uk_pp_job_finished_s result. It contains the @c user_job_ptr
454 * identifier used to start the job with, the job @c status (see \ref _mali_uk_job_status),
455 * the number of milliseconds the job took to render, and values of core registers
456 * when the job finished (irq status, performance counters, renderer list
457 * address). A job has finished succesfully when its status is
458 * @c _MALI_UK_JOB_STATUS_FINISHED. If the hardware detected a timeout while rendering
459 * the job, or software detected the job is taking more than @c watchdog_msecs to
460 * complete, the status will indicate @c _MALI_UK_JOB_STATUS_HANG.
461 * If the hardware detected a bus error while accessing memory associated with the
462 * job, status will indicate @c _MALI_UK_JOB_STATUS_SEG_FAULT.
463 * status will indicate @c _MALI_UK_JOB_STATUS_NOT_STARTED if the driver had to
464 * stop the job but the job didn't start on the hardware yet, e.g. when the
465 * driver shutdown.
466 *
467 */
468 typedef struct {
469 void *ctx; /**< [in,out] user-kernel context (trashed on output) */
470 u32 user_job_ptr; /**< [in] identifier for the job in user space */
471 u32 priority; /**< [in] job priority. A lower number means higher priority */
472 u32 frame_registers[_MALI_PP_MAX_FRAME_REGISTERS]; /**< [in] core specific registers associated with first sub job, see ARM DDI0415A */
473 u32 frame_registers_addr_frame[_MALI_PP_MAX_SUB_JOBS - 1]; /**< [in] ADDR_FRAME registers for sub job 1-7 */
474 u32 frame_registers_addr_stack[_MALI_PP_MAX_SUB_JOBS - 1]; /**< [in] ADDR_STACK registers for sub job 1-7 */
475 u32 wb0_registers[_MALI_PP_MAX_WB_REGISTERS];
476 u32 wb1_registers[_MALI_PP_MAX_WB_REGISTERS];
477 u32 wb2_registers[_MALI_PP_MAX_WB_REGISTERS];
478 u32 dlbu_registers[_MALI_DLBU_MAX_REGISTERS]; /**< [in] Dynamic load balancing unit registers */
479 u32 num_cores; /**< [in] Number of cores to set up (valid range: 1-4) */
480 u32 perf_counter_flag; /**< [in] bitmask indicating which performance counters to enable, see \ref _MALI_PERFORMANCE_COUNTER_FLAG_SRC0_ENABLE and related macro definitions */
481 u32 perf_counter_src0; /**< [in] source id for performance counter 0 (see ARM DDI0415A, Table 3-60) */
482 u32 perf_counter_src1; /**< [in] source id for performance counter 1 (see ARM DDI0415A, Table 3-60) */
483 u32 frame_builder_id; /**< [in] id of the originating frame builder */
484 u32 flush_id; /**< [in] flush id within the originating frame builder */
485 u32 flags; /**< [in] See _MALI_PP_JOB_FLAG_* for a list of avaiable flags */
486 u32 tilesx; /**< [in] number of tiles in the x direction (needed for heatmap generation */
487 u32 tilesy; /**< [in] number of tiles in y direction (needed for reading the heatmap memory) */
488 u32 heatmap_mem; /**< [in] memory address to store counter values per tile (aka heatmap) */
489 u32 num_memory_cookies; /**< [in] number of memory cookies attached to job */
490 u32 *memory_cookies; /**< [in] memory cookies attached to job */
491 _mali_uk_fence_t fence; /**< [in] fence this job must wait on */
492 u32 *timeline_point_ptr; /**< [in,out] pointer to location where point on pp timeline for this job will be written */
493 } _mali_uk_pp_start_job_s;
494
495 typedef struct {
496 void *ctx; /**< [in,out] user-kernel context (trashed on output) */
497 _mali_uk_gp_start_job_s *gp_args; /**< [in,out] GP uk arguments (see _mali_uk_gp_start_job_s) */
498 _mali_uk_pp_start_job_s *pp_args; /**< [in,out] PP uk arguments (see _mali_uk_pp_start_job_s) */
499 } _mali_uk_pp_and_gp_start_job_s;
500
501 /** @} */ /* end group _mali_uk_ppstartjob_s */
502
503 typedef struct {
504 u32 user_job_ptr; /**< [out] identifier for the job in user space */
505 _mali_uk_job_status status; /**< [out] status of finished job */
506 u32 perf_counter0[_MALI_PP_MAX_SUB_JOBS]; /**< [out] value of perfomance counter 0 (see ARM DDI0415A), one for each sub job */
507 u32 perf_counter1[_MALI_PP_MAX_SUB_JOBS]; /**< [out] value of perfomance counter 1 (see ARM DDI0415A), one for each sub job */
508 u32 perf_counter_src0;
509 u32 perf_counter_src1;
510 } _mali_uk_pp_job_finished_s;
511
512 typedef struct {
513 u32 number_of_enabled_cores; /**< [out] the new number of enabled cores */
514 } _mali_uk_pp_num_cores_changed_s;
515
516
517
518 /**
519 * Flags to indicate write-back units
520 */
521 typedef enum {
522 _MALI_UK_PP_JOB_WB0 = 1,
523 _MALI_UK_PP_JOB_WB1 = 2,
524 _MALI_UK_PP_JOB_WB2 = 4,
525 } _mali_uk_pp_job_wbx_flag;
526
527 typedef struct {
528 void *ctx; /**< [in,out] user-kernel context (trashed on output) */
529 u32 fb_id; /**< [in] Frame builder ID of job to disable WB units for */
530 u32 wb0_memory;
531 u32 wb1_memory;
532 u32 wb2_memory;
533 } _mali_uk_pp_disable_wb_s;
534
535
536 /** @} */ /* end group _mali_uk_pp */
537
538 /** @defgroup _mali_uk_soft_job U/K Soft Job
539 * @{ */
540
541 typedef struct {
542 void *ctx; /**< [in,out] user-kernel context (trashed on output) */
543 u32 type; /**< [in] type of soft job */
544 u32 user_job; /**< [in] identifier for the job in user space */
545 u32 *job_id_ptr; /**< [in,out] pointer to location where job id will be written */
546 _mali_uk_fence_t fence; /**< [in] fence this job must wait on */
547 u32 point; /**< [out] point on soft timeline for this job */
548 } _mali_uk_soft_job_start_s;
549
550 typedef struct {
551 u32 user_job; /**< [out] identifier for the job in user space */
552 } _mali_uk_soft_job_activated_s;
553
554 typedef struct {
555 void *ctx; /**< [in,out] user-kernel context (trashed on output) */
556 u32 job_id; /**< [in] id for soft job */
557 } _mali_uk_soft_job_signal_s;
558
559 /** @} */ /* end group _mali_uk_soft_job */
560
561 /** @addtogroup _mali_uk_core U/K Core
562 * @{ */
563
564 /** @defgroup _mali_uk_waitfornotification_s Wait For Notification
565 * @{ */
566
567 /** @brief Notification type encodings
568 *
569 * Each Notification type is an ordered pair of (subsystem,id), and is unique.
570 *
571 * The encoding of subsystem,id into a 32-bit word is:
572 * encoding = (( subsystem << _MALI_NOTIFICATION_SUBSYSTEM_SHIFT ) & _MALI_NOTIFICATION_SUBSYSTEM_MASK)
573 * | (( id << _MALI_NOTIFICATION_ID_SHIFT ) & _MALI_NOTIFICATION_ID_MASK)
574 *
575 * @see _mali_uk_wait_for_notification_s
576 */
577 typedef enum {
578 /** core notifications */
579
580 _MALI_NOTIFICATION_CORE_SHUTDOWN_IN_PROGRESS = (_MALI_UK_CORE_SUBSYSTEM << 16) | 0x20,
581 _MALI_NOTIFICATION_APPLICATION_QUIT = (_MALI_UK_CORE_SUBSYSTEM << 16) | 0x40,
582 _MALI_NOTIFICATION_SETTINGS_CHANGED = (_MALI_UK_CORE_SUBSYSTEM << 16) | 0x80,
583 _MALI_NOTIFICATION_SOFT_ACTIVATED = (_MALI_UK_CORE_SUBSYSTEM << 16) | 0x100,
584
585 /** Fragment Processor notifications */
586
587 _MALI_NOTIFICATION_PP_FINISHED = (_MALI_UK_PP_SUBSYSTEM << 16) | 0x10,
588 _MALI_NOTIFICATION_PP_NUM_CORE_CHANGE = (_MALI_UK_PP_SUBSYSTEM << 16) | 0x20,
589
590 /** Vertex Processor notifications */
591
592 _MALI_NOTIFICATION_GP_FINISHED = (_MALI_UK_GP_SUBSYSTEM << 16) | 0x10,
593 _MALI_NOTIFICATION_GP_STALLED = (_MALI_UK_GP_SUBSYSTEM << 16) | 0x20,
594
595 } _mali_uk_notification_type;
596
597 /** to assist in splitting up 32-bit notification value in subsystem and id value */
598 #define _MALI_NOTIFICATION_SUBSYSTEM_MASK 0xFFFF0000
599 #define _MALI_NOTIFICATION_SUBSYSTEM_SHIFT 16
600 #define _MALI_NOTIFICATION_ID_MASK 0x0000FFFF
601 #define _MALI_NOTIFICATION_ID_SHIFT 0
602
603
604 /** @brief Enumeration of possible settings which match mali_setting_t in user space
605 *
606 *
607 */
608 typedef enum {
609 _MALI_UK_USER_SETTING_SW_EVENTS_ENABLE = 0,
610 _MALI_UK_USER_SETTING_COLORBUFFER_CAPTURE_ENABLED,
611 _MALI_UK_USER_SETTING_DEPTHBUFFER_CAPTURE_ENABLED,
612 _MALI_UK_USER_SETTING_STENCILBUFFER_CAPTURE_ENABLED,
613 _MALI_UK_USER_SETTING_PER_TILE_COUNTERS_CAPTURE_ENABLED,
614 _MALI_UK_USER_SETTING_BUFFER_CAPTURE_COMPOSITOR,
615 _MALI_UK_USER_SETTING_BUFFER_CAPTURE_WINDOW,
616 _MALI_UK_USER_SETTING_BUFFER_CAPTURE_OTHER,
617 _MALI_UK_USER_SETTING_BUFFER_CAPTURE_N_FRAMES,
618 _MALI_UK_USER_SETTING_BUFFER_CAPTURE_RESIZE_FACTOR,
619 _MALI_UK_USER_SETTING_SW_COUNTER_ENABLED,
620 _MALI_UK_USER_SETTING_MAX,
621 } _mali_uk_user_setting_t;
622
623 /* See mali_user_settings_db.c */
624 extern const char *_mali_uk_user_setting_descriptions[];
625 #define _MALI_UK_USER_SETTING_DESCRIPTIONS \
626 { \
627 "sw_events_enable", \
628 "colorbuffer_capture_enable", \
629 "depthbuffer_capture_enable", \
630 "stencilbuffer_capture_enable", \
631 "per_tile_counters_enable", \
632 "buffer_capture_compositor", \
633 "buffer_capture_window", \
634 "buffer_capture_other", \
635 "buffer_capture_n_frames", \
636 "buffer_capture_resize_factor", \
637 "sw_counters_enable", \
638 };
639
640 /** @brief struct to hold the value to a particular setting as seen in the kernel space
641 */
642 typedef struct {
643 _mali_uk_user_setting_t setting;
644 u32 value;
645 } _mali_uk_settings_changed_s;
646
647 /** @brief Arguments for _mali_ukk_wait_for_notification()
648 *
649 * On successful return from _mali_ukk_wait_for_notification(), the members of
650 * this structure will indicate the reason for notification.
651 *
652 * Specifically, the source of the notification can be identified by the
653 * subsystem and id fields of the mali_uk_notification_type in the code.type
654 * member. The type member is encoded in a way to divide up the types into a
655 * subsystem field, and a per-subsystem ID field. See
656 * _mali_uk_notification_type for more information.
657 *
658 * Interpreting the data union member depends on the notification type:
659 *
660 * - type == _MALI_NOTIFICATION_CORE_SHUTDOWN_IN_PROGRESS
661 * - The kernel side is shutting down. No further
662 * _mali_uk_wait_for_notification() calls should be made.
663 * - In this case, the value of the data union member is undefined.
664 * - This is used to indicate to the user space client that it should close
665 * the connection to the Mali Device Driver.
666 * - type == _MALI_NOTIFICATION_PP_FINISHED
667 * - The notification data is of type _mali_uk_pp_job_finished_s. It contains the user_job_ptr
668 * identifier used to start the job with, the job status, the number of milliseconds the job took to render,
669 * and values of core registers when the job finished (irq status, performance counters, renderer list
670 * address).
671 * - A job has finished succesfully when its status member is _MALI_UK_JOB_STATUS_FINISHED.
672 * - If the hardware detected a timeout while rendering the job, or software detected the job is
673 * taking more than watchdog_msecs (see _mali_ukk_pp_start_job()) to complete, the status member will
674 * indicate _MALI_UK_JOB_STATUS_HANG.
675 * - If the hardware detected a bus error while accessing memory associated with the job, status will
676 * indicate _MALI_UK_JOB_STATUS_SEG_FAULT.
677 * - Status will indicate MALI_UK_JOB_STATUS_NOT_STARTED if the driver had to stop the job but the job
678 * didn't start the hardware yet, e.g. when the driver closes.
679 * - type == _MALI_NOTIFICATION_GP_FINISHED
680 * - The notification data is of type _mali_uk_gp_job_finished_s. The notification is similar to that of
681 * type == _MALI_NOTIFICATION_PP_FINISHED, except that several other GP core register values are returned.
682 * The status values have the same meaning for type == _MALI_NOTIFICATION_PP_FINISHED.
683 * - type == _MALI_NOTIFICATION_GP_STALLED
684 * - The nofication data is of type _mali_uk_gp_job_suspended_s. It contains the user_job_ptr
685 * identifier used to start the job with, the reason why the job stalled and a cookie to identify the core on
686 * which the job stalled.
687 * - The reason member of gp_job_suspended is set to _MALIGP_JOB_SUSPENDED_OUT_OF_MEMORY
688 * when the polygon list builder unit has run out of memory.
689 */
690 typedef struct {
691 void *ctx; /**< [in,out] user-kernel context (trashed on output) */
692 _mali_uk_notification_type type; /**< [out] Type of notification available */
693 union {
694 _mali_uk_gp_job_suspended_s gp_job_suspended;/**< [out] Notification data for _MALI_NOTIFICATION_GP_STALLED notification type */
695 _mali_uk_gp_job_finished_s gp_job_finished; /**< [out] Notification data for _MALI_NOTIFICATION_GP_FINISHED notification type */
696 _mali_uk_pp_job_finished_s pp_job_finished; /**< [out] Notification data for _MALI_NOTIFICATION_PP_FINISHED notification type */
697 _mali_uk_settings_changed_s setting_changed;/**< [out] Notification data for _MALI_NOTIFICAATION_SETTINGS_CHANGED notification type */
698 _mali_uk_soft_job_activated_s soft_job_activated; /**< [out] Notification data for _MALI_NOTIFICATION_SOFT_ACTIVATED notification type */
699 } data;
700 } _mali_uk_wait_for_notification_s;
701
702 /** @brief Arguments for _mali_ukk_post_notification()
703 *
704 * Posts the specified notification to the notification queue for this application.
705 * This is used to send a quit message to the callback thread.
706 */
707 typedef struct {
708 void *ctx; /**< [in,out] user-kernel context (trashed on output) */
709 _mali_uk_notification_type type; /**< [in] Type of notification to post */
710 } _mali_uk_post_notification_s;
711
712 /** @} */ /* end group _mali_uk_waitfornotification_s */
713
714 /** @defgroup _mali_uk_getapiversion_s Get API Version
715 * @{ */
716
717 /** helpers for Device Driver API version handling */
718
719 /** @brief Encode a version ID from a 16-bit input
720 *
721 * @note the input is assumed to be 16 bits. It must not exceed 16 bits. */
722 #define _MAKE_VERSION_ID(x) (((x) << 16UL) | (x))
723
724 /** @brief Check whether a 32-bit value is likely to be Device Driver API
725 * version ID. */
726 #define _IS_VERSION_ID(x) (((x) & 0xFFFF) == (((x) >> 16UL) & 0xFFFF))
727
728 /** @brief Decode a 16-bit version number from a 32-bit Device Driver API version
729 * ID */
730 #define _GET_VERSION(x) (((x) >> 16UL) & 0xFFFF)
731
732 /** @brief Determine whether two 32-bit encoded version IDs match */
733 #define _IS_API_MATCH(x, y) (IS_VERSION_ID((x)) && IS_VERSION_ID((y)) && (GET_VERSION((x)) == GET_VERSION((y))))
734
735 /**
736 * API version define.
737 * Indicates the version of the kernel API
738 * The version is a 16bit integer incremented on each API change.
739 * The 16bit integer is stored twice in a 32bit integer
740 * For example, for version 1 the value would be 0x00010001
741 */
742 #define _MALI_API_VERSION 401
743 #define _MALI_UK_API_VERSION _MAKE_VERSION_ID(_MALI_API_VERSION)
744
745 /**
746 * The API version is a 16-bit integer stored in both the lower and upper 16-bits
747 * of a 32-bit value. The 16-bit API version value is incremented on each API
748 * change. Version 1 would be 0x00010001. Used in _mali_uk_get_api_version_s.
749 */
750 typedef u32 _mali_uk_api_version;
751
752 /** @brief Arguments for _mali_uk_get_api_version()
753 *
754 * The user-side interface version must be written into the version member,
755 * encoded using _MAKE_VERSION_ID(). It will be compared to the API version of
756 * the kernel-side interface.
757 *
758 * On successful return, the version member will be the API version of the
759 * kernel-side interface. _MALI_UK_API_VERSION macro defines the current version
760 * of the API.
761 *
762 * The compatible member must be checked to see if the version of the user-side
763 * interface is compatible with the kernel-side interface, since future versions
764 * of the interface may be backwards compatible.
765 */
766 typedef struct {
767 void *ctx; /**< [in,out] user-kernel context (trashed on output) */
768 _mali_uk_api_version version; /**< [in,out] API version of user-side interface. */
769 int compatible; /**< [out] @c 1 when @version is compatible, @c 0 otherwise */
770 } _mali_uk_get_api_version_s;
771 /** @} */ /* end group _mali_uk_getapiversion_s */
772
773 /** @defgroup _mali_uk_get_user_settings_s Get user space settings */
774
775 /** @brief struct to keep the matching values of the user space settings within certain context
776 *
777 * Each member of the settings array corresponds to a matching setting in the user space and its value is the value
778 * of that particular setting.
779 *
780 * All settings are given reference to the context pointed to by the ctx pointer.
781 *
782 */
783 typedef struct {
784 void *ctx; /**< [in,out] user-kernel context (trashed on output) */
785 u32 settings[_MALI_UK_USER_SETTING_MAX]; /**< [out] The values for all settings */
786 } _mali_uk_get_user_settings_s;
787
788 /** @brief struct to hold the value of a particular setting from the user space within a given context
789 */
790 typedef struct {
791 void *ctx; /**< [in,out] user-kernel context (trashed on output) */
792 _mali_uk_user_setting_t setting; /**< [in] setting to get */
793 u32 value; /**< [out] value of setting */
794 } _mali_uk_get_user_setting_s;
795
796 /** @brief Arguments for _mali_ukk_request_high_priority() */
797 typedef struct {
798 void *ctx; /**< [in,out] user-kernel context (trashed on output) */
799 } _mali_uk_request_high_priority_s;
800
801 /** @} */ /* end group _mali_uk_core */
802
803
804 /** @defgroup _mali_uk_memory U/K Memory
805 * @{ */
806
807 /** Flag for _mali_uk_map_external_mem_s, _mali_uk_attach_ump_mem_s and _mali_uk_attach_dma_buf_s */
808 #define _MALI_MAP_EXTERNAL_MAP_GUARD_PAGE (1<<0)
809
810 typedef struct {
811 void *ctx; /**< [in,out] user-kernel context (trashed on output) */
812 u32 phys_addr; /**< [in] physical address */
813 u32 size; /**< [in] size */
814 u32 mali_address; /**< [in] mali address to map the physical memory to */
815 u32 rights; /**< [in] rights necessary for accessing memory */
816 u32 flags; /**< [in] flags, see \ref _MALI_MAP_EXTERNAL_MAP_GUARD_PAGE */
817 u32 cookie; /**< [out] identifier for mapped memory object in kernel space */
818 } _mali_uk_map_external_mem_s;
819
820 typedef struct {
821 void *ctx; /**< [in,out] user-kernel context (trashed on output) */
822 u32 cookie; /**< [out] identifier for mapped memory object in kernel space */
823 } _mali_uk_unmap_external_mem_s;
824
825 /** @note This is identical to _mali_uk_map_external_mem_s above, however phys_addr is replaced by memory descriptor */
826 typedef struct {
827 void *ctx; /**< [in,out] user-kernel context (trashed on output) */
828 u32 mem_fd; /**< [in] Memory descriptor */
829 u32 size; /**< [in] size */
830 u32 mali_address; /**< [in] mali address to map the physical memory to */
831 u32 rights; /**< [in] rights necessary for accessing memory */
832 u32 flags; /**< [in] flags, see \ref _MALI_MAP_EXTERNAL_MAP_GUARD_PAGE */
833 u32 cookie; /**< [out] identifier for mapped memory object in kernel space */
834 } _mali_uk_attach_dma_buf_s;
835
836 typedef struct {
837 void *ctx; /**< [in,out] user-kernel context (trashed on output) */
838 u32 mem_fd; /**< [in] Memory descriptor */
839 u32 size; /**< [out] size */
840 } _mali_uk_dma_buf_get_size_s;
841
842 typedef struct {
843 void *ctx; /**< [in,out] user-kernel context (trashed on output) */
844 u32 cookie; /**< [in] identifier for mapped memory object in kernel space */
845 } _mali_uk_release_dma_buf_s;
846
847 /** @note This is identical to _mali_uk_map_external_mem_s above, however phys_addr is replaced by secure_id */
848 typedef struct {
849 void *ctx; /**< [in,out] user-kernel context (trashed on output) */
850 u32 secure_id; /**< [in] secure id */
851 u32 size; /**< [in] size */
852 u32 mali_address; /**< [in] mali address to map the physical memory to */
853 u32 rights; /**< [in] rights necessary for accessing memory */
854 u32 flags; /**< [in] flags, see \ref _MALI_MAP_EXTERNAL_MAP_GUARD_PAGE */
855 u32 cookie; /**< [out] identifier for mapped memory object in kernel space */
856 } _mali_uk_attach_ump_mem_s;
857
858 typedef struct {
859 void *ctx; /**< [in,out] user-kernel context (trashed on output) */
860 u32 cookie; /**< [in] identifier for mapped memory object in kernel space */
861 } _mali_uk_release_ump_mem_s;
862
863 /** @brief Arguments for _mali_ukk_va_to_mali_pa()
864 *
865 * if size is zero or not a multiple of the system's page size, it will be
866 * rounded up to the next multiple of the page size. This will occur before
867 * any other use of the size parameter.
868 *
869 * if va is not PAGE_SIZE aligned, it will be rounded down to the next page
870 * boundary.
871 *
872 * The range (va) to ((u32)va)+(size-1) inclusive will be checked for physical
873 * contiguity.
874 *
875 * The implementor will check that the entire physical range is allowed to be mapped
876 * into user-space.
877 *
878 * Failure will occur if either of the above are not satisfied.
879 *
880 * Otherwise, the physical base address of the range is returned through pa,
881 * va is updated to be page aligned, and size is updated to be a non-zero
882 * multiple of the system's pagesize.
883 */
884 typedef struct {
885 void *ctx; /**< [in,out] user-kernel context (trashed on output) */
886 void *va; /**< [in,out] Virtual address of the start of the range */
887 u32 pa; /**< [out] Physical base address of the range */
888 u32 size; /**< [in,out] Size of the range, in bytes. */
889 } _mali_uk_va_to_mali_pa_s;
890
891 /**
892 * @brief Arguments for _mali_uk[uk]_mem_write_safe()
893 */
894 typedef struct {
895 void *ctx; /**< [in,out] user-kernel context (trashed on output) */
896 const void *src; /**< [in] Pointer to source data */
897 void *dest; /**< [in] Destination Mali buffer */
898 u32 size; /**< [in,out] Number of bytes to write/copy on input, number of bytes actually written/copied on output */
899 } _mali_uk_mem_write_safe_s;
900
901 typedef struct {
902 void *ctx; /**< [in,out] user-kernel context (trashed on output) */
903 u32 size; /**< [out] size of MMU page table information (registers + page tables) */
904 } _mali_uk_query_mmu_page_table_dump_size_s;
905
906 typedef struct {
907 void *ctx; /**< [in,out] user-kernel context (trashed on output) */
908 u32 size; /**< [in] size of buffer to receive mmu page table information */
909 void *buffer; /**< [in,out] buffer to receive mmu page table information */
910 u32 register_writes_size; /**< [out] size of MMU register dump */
911 u32 *register_writes; /**< [out] pointer within buffer where MMU register dump is stored */
912 u32 page_table_dump_size; /**< [out] size of MMU page table dump */
913 u32 *page_table_dump; /**< [out] pointer within buffer where MMU page table dump is stored */
914 } _mali_uk_dump_mmu_page_table_s;
915
916 /** @} */ /* end group _mali_uk_memory */
917
918
919 /** @addtogroup _mali_uk_pp U/K Fragment Processor
920 * @{ */
921
922 /** @brief Arguments for _mali_ukk_get_pp_number_of_cores()
923 *
924 * - pass in the user-kernel context @c ctx that was returned from _mali_ukk_open()
925 * - Upon successful return from _mali_ukk_get_pp_number_of_cores(), @c number_of_cores
926 * will contain the number of Fragment Processor cores in the system.
927 */
928 typedef struct {
929 void *ctx; /**< [in,out] user-kernel context (trashed on output) */
930 u32 number_of_total_cores; /**< [out] Total number of Fragment Processor cores in the system */
931 u32 number_of_enabled_cores; /**< [out] Number of enabled Fragment Processor cores */
932 } _mali_uk_get_pp_number_of_cores_s;
933
934 /** @brief Arguments for _mali_ukk_get_pp_core_version()
935 *
936 * - pass in the user-kernel context @c ctx that was returned from _mali_ukk_open()
937 * - Upon successful return from _mali_ukk_get_pp_core_version(), @c version contains
938 * the version that all Fragment Processor cores are compatible with.
939 */
940 typedef struct {
941 void *ctx; /**< [in,out] user-kernel context (trashed on output) */
942 _mali_core_version version; /**< [out] version returned from core, see \ref _mali_core_version */
943 } _mali_uk_get_pp_core_version_s;
944
945 /** @} */ /* end group _mali_uk_pp */
946
947
948 /** @addtogroup _mali_uk_gp U/K Vertex Processor
949 * @{ */
950
951 /** @brief Arguments for _mali_ukk_get_gp_number_of_cores()
952 *
953 * - pass in the user-kernel context @c ctx that was returned from _mali_ukk_open()
954 * - Upon successful return from _mali_ukk_get_gp_number_of_cores(), @c number_of_cores
955 * will contain the number of Vertex Processor cores in the system.
956 */
957 typedef struct {
958 void *ctx; /**< [in,out] user-kernel context (trashed on output) */
959 u32 number_of_cores; /**< [out] number of Vertex Processor cores in the system */
960 } _mali_uk_get_gp_number_of_cores_s;
961
962 /** @brief Arguments for _mali_ukk_get_gp_core_version()
963 *
964 * - pass in the user-kernel context @c ctx that was returned from _mali_ukk_open()
965 * - Upon successful return from _mali_ukk_get_gp_core_version(), @c version contains
966 * the version that all Vertex Processor cores are compatible with.
967 */
968 typedef struct {
969 void *ctx; /**< [in,out] user-kernel context (trashed on output) */
970 _mali_core_version version; /**< [out] version returned from core, see \ref _mali_core_version */
971 } _mali_uk_get_gp_core_version_s;
972
973 typedef struct {
974 void *ctx; /**< [in,out] user-kernel context (trashed on output) */
975 u32 limit; /**< [in,out] The desired limit for number of events to record on input, actual limit on output */
976 } _mali_uk_profiling_start_s;
977
978 typedef struct {
979 void *ctx; /**< [in,out] user-kernel context (trashed on output) */
980 u32 event_id; /**< [in] event id to register (see enum mali_profiling_events for values) */
981 u32 data[5]; /**< [in] event specific data */
982 } _mali_uk_profiling_add_event_s;
983
984 typedef struct {
985 void *ctx; /**< [in,out] user-kernel context (trashed on output) */
986 u32 count; /**< [out] The number of events sampled */
987 } _mali_uk_profiling_stop_s;
988
989 typedef struct {
990 void *ctx; /**< [in,out] user-kernel context (trashed on output) */
991 u32 index; /**< [in] which index to get (starting at zero) */
992 u64 timestamp; /**< [out] timestamp of event */
993 u32 event_id; /**< [out] event id of event (see enum mali_profiling_events for values) */
994 u32 data[5]; /**< [out] event specific data */
995 } _mali_uk_profiling_get_event_s;
996
997 typedef struct {
998 void *ctx; /**< [in,out] user-kernel context (trashed on output) */
999 } _mali_uk_profiling_clear_s;
1000
1001 /** @} */ /* end group _mali_uk_gp */
1002
1003
1004 /** @addtogroup _mali_uk_memory U/K Memory
1005 * @{ */
1006
1007 /** @brief Arguments to _mali_ukk_mem_mmap()
1008 *
1009 * Use of the phys_addr member depends on whether the driver is compiled for
1010 * Mali-MMU or nonMMU:
1011 * - in the nonMMU case, this is the physical address of the memory as seen by
1012 * the CPU (which may be a constant offset from that used by Mali)
1013 * - in the MMU case, this is the Mali Virtual base address of the memory to
1014 * allocate, and the particular physical pages used to back the memory are
1015 * entirely determined by _mali_ukk_mem_mmap(). The details of the physical pages
1016 * are not reported to user-space for security reasons.
1017 *
1018 * The cookie member must be stored for use later when freeing the memory by
1019 * calling _mali_ukk_mem_munmap(). In the Mali-MMU case, the cookie is secure.
1020 *
1021 * The ukk_private word must be set to zero when calling from user-space. On
1022 * Kernel-side, the OS implementation of the U/K interface can use it to
1023 * communicate data to the OS implementation of the OSK layer. In particular,
1024 * _mali_ukk_get_big_block() directly calls _mali_ukk_mem_mmap directly, and
1025 * will communicate its own ukk_private word through the ukk_private member
1026 * here. The common code itself will not inspect or modify the ukk_private
1027 * word, and so it may be safely used for whatever purposes necessary to
1028 * integrate Mali Memory handling into the OS.
1029 *
1030 * The uku_private member is currently reserved for use by the user-side
1031 * implementation of the U/K interface. Its value must be zero.
1032 */
1033 typedef struct {
1034 void *ctx; /**< [in,out] user-kernel context (trashed on output) */
1035 void *mapping; /**< [out] Returns user-space virtual address for the mapping */
1036 u32 size; /**< [in] Size of the requested mapping */
1037 u32 phys_addr; /**< [in] Physical address - could be offset, depending on caller+callee convention */
1038 u32 cookie; /**< [out] Returns a cookie for use in munmap calls */
1039 void *uku_private; /**< [in] User-side Private word used by U/K interface */
1040 void *ukk_private; /**< [in] Kernel-side Private word used by U/K interface */
1041 mali_memory_cache_settings cache_settings; /**< [in] Option to set special cache flags, tuning L2 efficency */
1042 } _mali_uk_mem_mmap_s;
1043
1044 /** @brief Arguments to _mali_ukk_mem_munmap()
1045 *
1046 * The cookie and mapping members must be that returned from the same previous
1047 * call to _mali_ukk_mem_mmap(). The size member must correspond to cookie
1048 * and mapping - that is, it must be the value originally supplied to a call to
1049 * _mali_ukk_mem_mmap that returned the values of mapping and cookie.
1050 *
1051 * An error will be returned if an attempt is made to unmap only part of the
1052 * originally obtained range, or to unmap more than was originally obtained.
1053 */
1054 typedef struct {
1055 void *ctx; /**< [in,out] user-kernel context (trashed on output) */
1056 void *mapping; /**< [in] The mapping returned from mmap call */
1057 u32 size; /**< [in] The size passed to mmap call */
1058 u32 cookie; /**< [in] Cookie from mmap call */
1059 } _mali_uk_mem_munmap_s;
1060 /** @} */ /* end group _mali_uk_memory */
1061
1062 /** @defgroup _mali_uk_vsync U/K VSYNC Wait Reporting Module
1063 * @{ */
1064
1065 /** @brief VSYNC events
1066 *
1067 * These events are reported when DDK starts to wait for vsync and when the
1068 * vsync has occured and the DDK can continue on the next frame.
1069 */
1070 typedef enum _mali_uk_vsync_event {
1071 _MALI_UK_VSYNC_EVENT_BEGIN_WAIT = 0,
1072 _MALI_UK_VSYNC_EVENT_END_WAIT
1073 } _mali_uk_vsync_event;
1074
1075 /** @brief Arguments to _mali_ukk_vsync_event()
1076 *
1077 */
1078 typedef struct {
1079 void *ctx; /**< [in,out] user-kernel context (trashed on output) */
1080 _mali_uk_vsync_event event; /**< [in] VSYNCH event type */
1081 } _mali_uk_vsync_event_report_s;
1082
1083 /** @} */ /* end group _mali_uk_vsync */
1084
1085 /** @defgroup _mali_uk_sw_counters_report U/K Software Counter Reporting
1086 * @{ */
1087
1088 /** @brief Software counter values
1089 *
1090 * Values recorded for each of the software counters during a single renderpass.
1091 */
1092 typedef struct {
1093 void *ctx; /**< [in,out] user-kernel context (trashed on output) */
1094 u32* counters; /**< [in] The array of counter values */
1095 u32 num_counters; /**< [in] The number of elements in counters array */
1096 } _mali_uk_sw_counters_report_s;
1097
1098 /** @} */ /* end group _mali_uk_sw_counters_report */
1099
1100 /** @defgroup _mali_uk_timeline U/K Mali Timeline
1101 * @{ */
1102
1103 typedef struct {
1104 void *ctx; /**< [in,out] user-kernel context (trashed on output) */
1105 u32 timeline; /**< [in] timeline id */
1106 u32 point; /**< [out] latest point on timeline */
1107 } _mali_uk_timeline_get_latest_point_s;
1108
1109 typedef struct {
1110 void *ctx; /**< [in,out] user-kernel context (trashed on output) */
1111 _mali_uk_fence_t fence; /**< [in] fence */
1112 u32 timeout; /**< [in] timeout (0 for no wait, -1 for blocking) */
1113 u32 status; /**< [out] status of fence (1 if signaled, 0 if timeout) */
1114 } _mali_uk_timeline_wait_s;
1115
1116 typedef struct {
1117 void *ctx; /**< [in,out] user-kernel context (trashed on output) */
1118 _mali_uk_fence_t fence; /**< [in] mali fence to create linux sync fence from */
1119 s32 sync_fd; /**< [out] file descriptor for new linux sync fence */
1120 } _mali_uk_timeline_create_sync_fence_s;
1121
1122 /** @} */ /* end group _mali_uk_timeline */
1123
1124 /** @} */ /* end group u_k_api */
1125
1126 /** @} */ /* end group uddapi */
1127
1128 #ifdef __cplusplus
1129 }
1130 #endif
1131
1132 #endif /* __MALI_UTGARD_UK_TYPES_H__ */