xref: /aosp_15_r20/external/igt-gpu-tools/include/drm-uapi/vc4_drm.h (revision d83cc019efdc2edc6c4b16e9034a3ceb8d35d77c)
1*d83cc019SAndroid Build Coastguard Worker /*
2*d83cc019SAndroid Build Coastguard Worker  * Copyright © 2014-2015 Broadcom
3*d83cc019SAndroid Build Coastguard Worker  *
4*d83cc019SAndroid Build Coastguard Worker  * Permission is hereby granted, free of charge, to any person obtaining a
5*d83cc019SAndroid Build Coastguard Worker  * copy of this software and associated documentation files (the "Software"),
6*d83cc019SAndroid Build Coastguard Worker  * to deal in the Software without restriction, including without limitation
7*d83cc019SAndroid Build Coastguard Worker  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8*d83cc019SAndroid Build Coastguard Worker  * and/or sell copies of the Software, and to permit persons to whom the
9*d83cc019SAndroid Build Coastguard Worker  * Software is furnished to do so, subject to the following conditions:
10*d83cc019SAndroid Build Coastguard Worker  *
11*d83cc019SAndroid Build Coastguard Worker  * The above copyright notice and this permission notice (including the next
12*d83cc019SAndroid Build Coastguard Worker  * paragraph) shall be included in all copies or substantial portions of the
13*d83cc019SAndroid Build Coastguard Worker  * Software.
14*d83cc019SAndroid Build Coastguard Worker  *
15*d83cc019SAndroid Build Coastguard Worker  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16*d83cc019SAndroid Build Coastguard Worker  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17*d83cc019SAndroid Build Coastguard Worker  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
18*d83cc019SAndroid Build Coastguard Worker  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19*d83cc019SAndroid Build Coastguard Worker  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20*d83cc019SAndroid Build Coastguard Worker  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21*d83cc019SAndroid Build Coastguard Worker  * IN THE SOFTWARE.
22*d83cc019SAndroid Build Coastguard Worker  */
23*d83cc019SAndroid Build Coastguard Worker 
24*d83cc019SAndroid Build Coastguard Worker #ifndef _VC4_DRM_H_
25*d83cc019SAndroid Build Coastguard Worker #define _VC4_DRM_H_
26*d83cc019SAndroid Build Coastguard Worker 
27*d83cc019SAndroid Build Coastguard Worker #include "drm.h"
28*d83cc019SAndroid Build Coastguard Worker 
29*d83cc019SAndroid Build Coastguard Worker #if defined(__cplusplus)
30*d83cc019SAndroid Build Coastguard Worker extern "C" {
31*d83cc019SAndroid Build Coastguard Worker #endif
32*d83cc019SAndroid Build Coastguard Worker 
33*d83cc019SAndroid Build Coastguard Worker #define DRM_VC4_SUBMIT_CL                         0x00
34*d83cc019SAndroid Build Coastguard Worker #define DRM_VC4_WAIT_SEQNO                        0x01
35*d83cc019SAndroid Build Coastguard Worker #define DRM_VC4_WAIT_BO                           0x02
36*d83cc019SAndroid Build Coastguard Worker #define DRM_VC4_CREATE_BO                         0x03
37*d83cc019SAndroid Build Coastguard Worker #define DRM_VC4_MMAP_BO                           0x04
38*d83cc019SAndroid Build Coastguard Worker #define DRM_VC4_CREATE_SHADER_BO                  0x05
39*d83cc019SAndroid Build Coastguard Worker #define DRM_VC4_GET_HANG_STATE                    0x06
40*d83cc019SAndroid Build Coastguard Worker #define DRM_VC4_GET_PARAM                         0x07
41*d83cc019SAndroid Build Coastguard Worker #define DRM_VC4_SET_TILING                        0x08
42*d83cc019SAndroid Build Coastguard Worker #define DRM_VC4_GET_TILING                        0x09
43*d83cc019SAndroid Build Coastguard Worker #define DRM_VC4_LABEL_BO                          0x0a
44*d83cc019SAndroid Build Coastguard Worker #define DRM_VC4_GEM_MADVISE                       0x0b
45*d83cc019SAndroid Build Coastguard Worker #define DRM_VC4_PERFMON_CREATE                    0x0c
46*d83cc019SAndroid Build Coastguard Worker #define DRM_VC4_PERFMON_DESTROY                   0x0d
47*d83cc019SAndroid Build Coastguard Worker #define DRM_VC4_PERFMON_GET_VALUES                0x0e
48*d83cc019SAndroid Build Coastguard Worker 
49*d83cc019SAndroid Build Coastguard Worker #define DRM_IOCTL_VC4_SUBMIT_CL           DRM_IOWR(DRM_COMMAND_BASE + DRM_VC4_SUBMIT_CL, struct drm_vc4_submit_cl)
50*d83cc019SAndroid Build Coastguard Worker #define DRM_IOCTL_VC4_WAIT_SEQNO          DRM_IOWR(DRM_COMMAND_BASE + DRM_VC4_WAIT_SEQNO, struct drm_vc4_wait_seqno)
51*d83cc019SAndroid Build Coastguard Worker #define DRM_IOCTL_VC4_WAIT_BO             DRM_IOWR(DRM_COMMAND_BASE + DRM_VC4_WAIT_BO, struct drm_vc4_wait_bo)
52*d83cc019SAndroid Build Coastguard Worker #define DRM_IOCTL_VC4_CREATE_BO           DRM_IOWR(DRM_COMMAND_BASE + DRM_VC4_CREATE_BO, struct drm_vc4_create_bo)
53*d83cc019SAndroid Build Coastguard Worker #define DRM_IOCTL_VC4_MMAP_BO             DRM_IOWR(DRM_COMMAND_BASE + DRM_VC4_MMAP_BO, struct drm_vc4_mmap_bo)
54*d83cc019SAndroid Build Coastguard Worker #define DRM_IOCTL_VC4_CREATE_SHADER_BO    DRM_IOWR(DRM_COMMAND_BASE + DRM_VC4_CREATE_SHADER_BO, struct drm_vc4_create_shader_bo)
55*d83cc019SAndroid Build Coastguard Worker #define DRM_IOCTL_VC4_GET_HANG_STATE      DRM_IOWR(DRM_COMMAND_BASE + DRM_VC4_GET_HANG_STATE, struct drm_vc4_get_hang_state)
56*d83cc019SAndroid Build Coastguard Worker #define DRM_IOCTL_VC4_GET_PARAM           DRM_IOWR(DRM_COMMAND_BASE + DRM_VC4_GET_PARAM, struct drm_vc4_get_param)
57*d83cc019SAndroid Build Coastguard Worker #define DRM_IOCTL_VC4_SET_TILING          DRM_IOWR(DRM_COMMAND_BASE + DRM_VC4_SET_TILING, struct drm_vc4_set_tiling)
58*d83cc019SAndroid Build Coastguard Worker #define DRM_IOCTL_VC4_GET_TILING          DRM_IOWR(DRM_COMMAND_BASE + DRM_VC4_GET_TILING, struct drm_vc4_get_tiling)
59*d83cc019SAndroid Build Coastguard Worker #define DRM_IOCTL_VC4_LABEL_BO            DRM_IOWR(DRM_COMMAND_BASE + DRM_VC4_LABEL_BO, struct drm_vc4_label_bo)
60*d83cc019SAndroid Build Coastguard Worker #define DRM_IOCTL_VC4_GEM_MADVISE         DRM_IOWR(DRM_COMMAND_BASE + DRM_VC4_GEM_MADVISE, struct drm_vc4_gem_madvise)
61*d83cc019SAndroid Build Coastguard Worker #define DRM_IOCTL_VC4_PERFMON_CREATE      DRM_IOWR(DRM_COMMAND_BASE + DRM_VC4_PERFMON_CREATE, struct drm_vc4_perfmon_create)
62*d83cc019SAndroid Build Coastguard Worker #define DRM_IOCTL_VC4_PERFMON_DESTROY     DRM_IOWR(DRM_COMMAND_BASE + DRM_VC4_PERFMON_DESTROY, struct drm_vc4_perfmon_destroy)
63*d83cc019SAndroid Build Coastguard Worker #define DRM_IOCTL_VC4_PERFMON_GET_VALUES  DRM_IOWR(DRM_COMMAND_BASE + DRM_VC4_PERFMON_GET_VALUES, struct drm_vc4_perfmon_get_values)
64*d83cc019SAndroid Build Coastguard Worker 
65*d83cc019SAndroid Build Coastguard Worker struct drm_vc4_submit_rcl_surface {
66*d83cc019SAndroid Build Coastguard Worker 	__u32 hindex; /* Handle index, or ~0 if not present. */
67*d83cc019SAndroid Build Coastguard Worker 	__u32 offset; /* Offset to start of buffer. */
68*d83cc019SAndroid Build Coastguard Worker 	/*
69*d83cc019SAndroid Build Coastguard Worker 	 * Bits for either render config (color_write) or load/store packet.
70*d83cc019SAndroid Build Coastguard Worker 	 * Bits should all be 0 for MSAA load/stores.
71*d83cc019SAndroid Build Coastguard Worker 	 */
72*d83cc019SAndroid Build Coastguard Worker 	__u16 bits;
73*d83cc019SAndroid Build Coastguard Worker 
74*d83cc019SAndroid Build Coastguard Worker #define VC4_SUBMIT_RCL_SURFACE_READ_IS_FULL_RES		(1 << 0)
75*d83cc019SAndroid Build Coastguard Worker 	__u16 flags;
76*d83cc019SAndroid Build Coastguard Worker };
77*d83cc019SAndroid Build Coastguard Worker 
78*d83cc019SAndroid Build Coastguard Worker /**
79*d83cc019SAndroid Build Coastguard Worker  * struct drm_vc4_submit_cl - ioctl argument for submitting commands to the 3D
80*d83cc019SAndroid Build Coastguard Worker  * engine.
81*d83cc019SAndroid Build Coastguard Worker  *
82*d83cc019SAndroid Build Coastguard Worker  * Drivers typically use GPU BOs to store batchbuffers / command lists and
83*d83cc019SAndroid Build Coastguard Worker  * their associated state.  However, because the VC4 lacks an MMU, we have to
84*d83cc019SAndroid Build Coastguard Worker  * do validation of memory accesses by the GPU commands.  If we were to store
85*d83cc019SAndroid Build Coastguard Worker  * our commands in BOs, we'd need to do uncached readback from them to do the
86*d83cc019SAndroid Build Coastguard Worker  * validation process, which is too expensive.  Instead, userspace accumulates
87*d83cc019SAndroid Build Coastguard Worker  * commands and associated state in plain memory, then the kernel copies the
88*d83cc019SAndroid Build Coastguard Worker  * data to its own address space, and then validates and stores it in a GPU
89*d83cc019SAndroid Build Coastguard Worker  * BO.
90*d83cc019SAndroid Build Coastguard Worker  */
91*d83cc019SAndroid Build Coastguard Worker struct drm_vc4_submit_cl {
92*d83cc019SAndroid Build Coastguard Worker 	/* Pointer to the binner command list.
93*d83cc019SAndroid Build Coastguard Worker 	 *
94*d83cc019SAndroid Build Coastguard Worker 	 * This is the first set of commands executed, which runs the
95*d83cc019SAndroid Build Coastguard Worker 	 * coordinate shader to determine where primitives land on the screen,
96*d83cc019SAndroid Build Coastguard Worker 	 * then writes out the state updates and draw calls necessary per tile
97*d83cc019SAndroid Build Coastguard Worker 	 * to the tile allocation BO.
98*d83cc019SAndroid Build Coastguard Worker 	 */
99*d83cc019SAndroid Build Coastguard Worker 	__u64 bin_cl;
100*d83cc019SAndroid Build Coastguard Worker 
101*d83cc019SAndroid Build Coastguard Worker 	/* Pointer to the shader records.
102*d83cc019SAndroid Build Coastguard Worker 	 *
103*d83cc019SAndroid Build Coastguard Worker 	 * Shader records are the structures read by the hardware that contain
104*d83cc019SAndroid Build Coastguard Worker 	 * pointers to uniforms, shaders, and vertex attributes.  The
105*d83cc019SAndroid Build Coastguard Worker 	 * reference to the shader record has enough information to determine
106*d83cc019SAndroid Build Coastguard Worker 	 * how many pointers are necessary (fixed number for shaders/uniforms,
107*d83cc019SAndroid Build Coastguard Worker 	 * and an attribute count), so those BO indices into bo_handles are
108*d83cc019SAndroid Build Coastguard Worker 	 * just stored as __u32s before each shader record passed in.
109*d83cc019SAndroid Build Coastguard Worker 	 */
110*d83cc019SAndroid Build Coastguard Worker 	__u64 shader_rec;
111*d83cc019SAndroid Build Coastguard Worker 
112*d83cc019SAndroid Build Coastguard Worker 	/* Pointer to uniform data and texture handles for the textures
113*d83cc019SAndroid Build Coastguard Worker 	 * referenced by the shader.
114*d83cc019SAndroid Build Coastguard Worker 	 *
115*d83cc019SAndroid Build Coastguard Worker 	 * For each shader state record, there is a set of uniform data in the
116*d83cc019SAndroid Build Coastguard Worker 	 * order referenced by the record (FS, VS, then CS).  Each set of
117*d83cc019SAndroid Build Coastguard Worker 	 * uniform data has a __u32 index into bo_handles per texture
118*d83cc019SAndroid Build Coastguard Worker 	 * sample operation, in the order the QPU_W_TMUn_S writes appear in
119*d83cc019SAndroid Build Coastguard Worker 	 * the program.  Following the texture BO handle indices is the actual
120*d83cc019SAndroid Build Coastguard Worker 	 * uniform data.
121*d83cc019SAndroid Build Coastguard Worker 	 *
122*d83cc019SAndroid Build Coastguard Worker 	 * The individual uniform state blocks don't have sizes passed in,
123*d83cc019SAndroid Build Coastguard Worker 	 * because the kernel has to determine the sizes anyway during shader
124*d83cc019SAndroid Build Coastguard Worker 	 * code validation.
125*d83cc019SAndroid Build Coastguard Worker 	 */
126*d83cc019SAndroid Build Coastguard Worker 	__u64 uniforms;
127*d83cc019SAndroid Build Coastguard Worker 	__u64 bo_handles;
128*d83cc019SAndroid Build Coastguard Worker 
129*d83cc019SAndroid Build Coastguard Worker 	/* Size in bytes of the binner command list. */
130*d83cc019SAndroid Build Coastguard Worker 	__u32 bin_cl_size;
131*d83cc019SAndroid Build Coastguard Worker 	/* Size in bytes of the set of shader records. */
132*d83cc019SAndroid Build Coastguard Worker 	__u32 shader_rec_size;
133*d83cc019SAndroid Build Coastguard Worker 	/* Number of shader records.
134*d83cc019SAndroid Build Coastguard Worker 	 *
135*d83cc019SAndroid Build Coastguard Worker 	 * This could just be computed from the contents of shader_records and
136*d83cc019SAndroid Build Coastguard Worker 	 * the address bits of references to them from the bin CL, but it
137*d83cc019SAndroid Build Coastguard Worker 	 * keeps the kernel from having to resize some allocations it makes.
138*d83cc019SAndroid Build Coastguard Worker 	 */
139*d83cc019SAndroid Build Coastguard Worker 	__u32 shader_rec_count;
140*d83cc019SAndroid Build Coastguard Worker 	/* Size in bytes of the uniform state. */
141*d83cc019SAndroid Build Coastguard Worker 	__u32 uniforms_size;
142*d83cc019SAndroid Build Coastguard Worker 
143*d83cc019SAndroid Build Coastguard Worker 	/* Number of BO handles passed in (size is that times 4). */
144*d83cc019SAndroid Build Coastguard Worker 	__u32 bo_handle_count;
145*d83cc019SAndroid Build Coastguard Worker 
146*d83cc019SAndroid Build Coastguard Worker 	/* RCL setup: */
147*d83cc019SAndroid Build Coastguard Worker 	__u16 width;
148*d83cc019SAndroid Build Coastguard Worker 	__u16 height;
149*d83cc019SAndroid Build Coastguard Worker 	__u8 min_x_tile;
150*d83cc019SAndroid Build Coastguard Worker 	__u8 min_y_tile;
151*d83cc019SAndroid Build Coastguard Worker 	__u8 max_x_tile;
152*d83cc019SAndroid Build Coastguard Worker 	__u8 max_y_tile;
153*d83cc019SAndroid Build Coastguard Worker 	struct drm_vc4_submit_rcl_surface color_read;
154*d83cc019SAndroid Build Coastguard Worker 	struct drm_vc4_submit_rcl_surface color_write;
155*d83cc019SAndroid Build Coastguard Worker 	struct drm_vc4_submit_rcl_surface zs_read;
156*d83cc019SAndroid Build Coastguard Worker 	struct drm_vc4_submit_rcl_surface zs_write;
157*d83cc019SAndroid Build Coastguard Worker 	struct drm_vc4_submit_rcl_surface msaa_color_write;
158*d83cc019SAndroid Build Coastguard Worker 	struct drm_vc4_submit_rcl_surface msaa_zs_write;
159*d83cc019SAndroid Build Coastguard Worker 	__u32 clear_color[2];
160*d83cc019SAndroid Build Coastguard Worker 	__u32 clear_z;
161*d83cc019SAndroid Build Coastguard Worker 	__u8 clear_s;
162*d83cc019SAndroid Build Coastguard Worker 
163*d83cc019SAndroid Build Coastguard Worker 	__u32 pad:24;
164*d83cc019SAndroid Build Coastguard Worker 
165*d83cc019SAndroid Build Coastguard Worker #define VC4_SUBMIT_CL_USE_CLEAR_COLOR			(1 << 0)
166*d83cc019SAndroid Build Coastguard Worker /* By default, the kernel gets to choose the order that the tiles are
167*d83cc019SAndroid Build Coastguard Worker  * rendered in.  If this is set, then the tiles will be rendered in a
168*d83cc019SAndroid Build Coastguard Worker  * raster order, with the right-to-left vs left-to-right and
169*d83cc019SAndroid Build Coastguard Worker  * top-to-bottom vs bottom-to-top dictated by
170*d83cc019SAndroid Build Coastguard Worker  * VC4_SUBMIT_CL_RCL_ORDER_INCREASING_*.  This allows overlapping
171*d83cc019SAndroid Build Coastguard Worker  * blits to be implemented using the 3D engine.
172*d83cc019SAndroid Build Coastguard Worker  */
173*d83cc019SAndroid Build Coastguard Worker #define VC4_SUBMIT_CL_FIXED_RCL_ORDER			(1 << 1)
174*d83cc019SAndroid Build Coastguard Worker #define VC4_SUBMIT_CL_RCL_ORDER_INCREASING_X		(1 << 2)
175*d83cc019SAndroid Build Coastguard Worker #define VC4_SUBMIT_CL_RCL_ORDER_INCREASING_Y		(1 << 3)
176*d83cc019SAndroid Build Coastguard Worker 	__u32 flags;
177*d83cc019SAndroid Build Coastguard Worker 
178*d83cc019SAndroid Build Coastguard Worker 	/* Returned value of the seqno of this render job (for the
179*d83cc019SAndroid Build Coastguard Worker 	 * wait ioctl).
180*d83cc019SAndroid Build Coastguard Worker 	 */
181*d83cc019SAndroid Build Coastguard Worker 	__u64 seqno;
182*d83cc019SAndroid Build Coastguard Worker 
183*d83cc019SAndroid Build Coastguard Worker 	/* ID of the perfmon to attach to this job. 0 means no perfmon. */
184*d83cc019SAndroid Build Coastguard Worker 	__u32 perfmonid;
185*d83cc019SAndroid Build Coastguard Worker 
186*d83cc019SAndroid Build Coastguard Worker 	/* Syncobj handle to wait on. If set, processing of this render job
187*d83cc019SAndroid Build Coastguard Worker 	 * will not start until the syncobj is signaled. 0 means ignore.
188*d83cc019SAndroid Build Coastguard Worker 	 */
189*d83cc019SAndroid Build Coastguard Worker 	__u32 in_sync;
190*d83cc019SAndroid Build Coastguard Worker 
191*d83cc019SAndroid Build Coastguard Worker 	/* Syncobj handle to export fence to. If set, the fence in the syncobj
192*d83cc019SAndroid Build Coastguard Worker 	 * will be replaced with a fence that signals upon completion of this
193*d83cc019SAndroid Build Coastguard Worker 	 * render job. 0 means ignore.
194*d83cc019SAndroid Build Coastguard Worker 	 */
195*d83cc019SAndroid Build Coastguard Worker 	__u32 out_sync;
196*d83cc019SAndroid Build Coastguard Worker 
197*d83cc019SAndroid Build Coastguard Worker 	__u32 pad2;
198*d83cc019SAndroid Build Coastguard Worker };
199*d83cc019SAndroid Build Coastguard Worker 
200*d83cc019SAndroid Build Coastguard Worker /**
201*d83cc019SAndroid Build Coastguard Worker  * struct drm_vc4_wait_seqno - ioctl argument for waiting for
202*d83cc019SAndroid Build Coastguard Worker  * DRM_VC4_SUBMIT_CL completion using its returned seqno.
203*d83cc019SAndroid Build Coastguard Worker  *
204*d83cc019SAndroid Build Coastguard Worker  * timeout_ns is the timeout in nanoseconds, where "0" means "don't
205*d83cc019SAndroid Build Coastguard Worker  * block, just return the status."
206*d83cc019SAndroid Build Coastguard Worker  */
207*d83cc019SAndroid Build Coastguard Worker struct drm_vc4_wait_seqno {
208*d83cc019SAndroid Build Coastguard Worker 	__u64 seqno;
209*d83cc019SAndroid Build Coastguard Worker 	__u64 timeout_ns;
210*d83cc019SAndroid Build Coastguard Worker };
211*d83cc019SAndroid Build Coastguard Worker 
212*d83cc019SAndroid Build Coastguard Worker /**
213*d83cc019SAndroid Build Coastguard Worker  * struct drm_vc4_wait_bo - ioctl argument for waiting for
214*d83cc019SAndroid Build Coastguard Worker  * completion of the last DRM_VC4_SUBMIT_CL on a BO.
215*d83cc019SAndroid Build Coastguard Worker  *
216*d83cc019SAndroid Build Coastguard Worker  * This is useful for cases where multiple processes might be
217*d83cc019SAndroid Build Coastguard Worker  * rendering to a BO and you want to wait for all rendering to be
218*d83cc019SAndroid Build Coastguard Worker  * completed.
219*d83cc019SAndroid Build Coastguard Worker  */
220*d83cc019SAndroid Build Coastguard Worker struct drm_vc4_wait_bo {
221*d83cc019SAndroid Build Coastguard Worker 	__u32 handle;
222*d83cc019SAndroid Build Coastguard Worker 	__u32 pad;
223*d83cc019SAndroid Build Coastguard Worker 	__u64 timeout_ns;
224*d83cc019SAndroid Build Coastguard Worker };
225*d83cc019SAndroid Build Coastguard Worker 
226*d83cc019SAndroid Build Coastguard Worker /**
227*d83cc019SAndroid Build Coastguard Worker  * struct drm_vc4_create_bo - ioctl argument for creating VC4 BOs.
228*d83cc019SAndroid Build Coastguard Worker  *
229*d83cc019SAndroid Build Coastguard Worker  * There are currently no values for the flags argument, but it may be
230*d83cc019SAndroid Build Coastguard Worker  * used in a future extension.
231*d83cc019SAndroid Build Coastguard Worker  */
232*d83cc019SAndroid Build Coastguard Worker struct drm_vc4_create_bo {
233*d83cc019SAndroid Build Coastguard Worker 	__u32 size;
234*d83cc019SAndroid Build Coastguard Worker 	__u32 flags;
235*d83cc019SAndroid Build Coastguard Worker 	/** Returned GEM handle for the BO. */
236*d83cc019SAndroid Build Coastguard Worker 	__u32 handle;
237*d83cc019SAndroid Build Coastguard Worker 	__u32 pad;
238*d83cc019SAndroid Build Coastguard Worker };
239*d83cc019SAndroid Build Coastguard Worker 
240*d83cc019SAndroid Build Coastguard Worker /**
241*d83cc019SAndroid Build Coastguard Worker  * struct drm_vc4_mmap_bo - ioctl argument for mapping VC4 BOs.
242*d83cc019SAndroid Build Coastguard Worker  *
243*d83cc019SAndroid Build Coastguard Worker  * This doesn't actually perform an mmap.  Instead, it returns the
244*d83cc019SAndroid Build Coastguard Worker  * offset you need to use in an mmap on the DRM device node.  This
245*d83cc019SAndroid Build Coastguard Worker  * means that tools like valgrind end up knowing about the mapped
246*d83cc019SAndroid Build Coastguard Worker  * memory.
247*d83cc019SAndroid Build Coastguard Worker  *
248*d83cc019SAndroid Build Coastguard Worker  * There are currently no values for the flags argument, but it may be
249*d83cc019SAndroid Build Coastguard Worker  * used in a future extension.
250*d83cc019SAndroid Build Coastguard Worker  */
251*d83cc019SAndroid Build Coastguard Worker struct drm_vc4_mmap_bo {
252*d83cc019SAndroid Build Coastguard Worker 	/** Handle for the object being mapped. */
253*d83cc019SAndroid Build Coastguard Worker 	__u32 handle;
254*d83cc019SAndroid Build Coastguard Worker 	__u32 flags;
255*d83cc019SAndroid Build Coastguard Worker 	/** offset into the drm node to use for subsequent mmap call. */
256*d83cc019SAndroid Build Coastguard Worker 	__u64 offset;
257*d83cc019SAndroid Build Coastguard Worker };
258*d83cc019SAndroid Build Coastguard Worker 
259*d83cc019SAndroid Build Coastguard Worker /**
260*d83cc019SAndroid Build Coastguard Worker  * struct drm_vc4_create_shader_bo - ioctl argument for creating VC4
261*d83cc019SAndroid Build Coastguard Worker  * shader BOs.
262*d83cc019SAndroid Build Coastguard Worker  *
263*d83cc019SAndroid Build Coastguard Worker  * Since allowing a shader to be overwritten while it's also being
264*d83cc019SAndroid Build Coastguard Worker  * executed from would allow privlege escalation, shaders must be
265*d83cc019SAndroid Build Coastguard Worker  * created using this ioctl, and they can't be mmapped later.
266*d83cc019SAndroid Build Coastguard Worker  */
267*d83cc019SAndroid Build Coastguard Worker struct drm_vc4_create_shader_bo {
268*d83cc019SAndroid Build Coastguard Worker 	/* Size of the data argument. */
269*d83cc019SAndroid Build Coastguard Worker 	__u32 size;
270*d83cc019SAndroid Build Coastguard Worker 	/* Flags, currently must be 0. */
271*d83cc019SAndroid Build Coastguard Worker 	__u32 flags;
272*d83cc019SAndroid Build Coastguard Worker 
273*d83cc019SAndroid Build Coastguard Worker 	/* Pointer to the data. */
274*d83cc019SAndroid Build Coastguard Worker 	__u64 data;
275*d83cc019SAndroid Build Coastguard Worker 
276*d83cc019SAndroid Build Coastguard Worker 	/** Returned GEM handle for the BO. */
277*d83cc019SAndroid Build Coastguard Worker 	__u32 handle;
278*d83cc019SAndroid Build Coastguard Worker 	/* Pad, must be 0. */
279*d83cc019SAndroid Build Coastguard Worker 	__u32 pad;
280*d83cc019SAndroid Build Coastguard Worker };
281*d83cc019SAndroid Build Coastguard Worker 
282*d83cc019SAndroid Build Coastguard Worker struct drm_vc4_get_hang_state_bo {
283*d83cc019SAndroid Build Coastguard Worker 	__u32 handle;
284*d83cc019SAndroid Build Coastguard Worker 	__u32 paddr;
285*d83cc019SAndroid Build Coastguard Worker 	__u32 size;
286*d83cc019SAndroid Build Coastguard Worker 	__u32 pad;
287*d83cc019SAndroid Build Coastguard Worker };
288*d83cc019SAndroid Build Coastguard Worker 
289*d83cc019SAndroid Build Coastguard Worker /**
290*d83cc019SAndroid Build Coastguard Worker  * struct drm_vc4_hang_state - ioctl argument for collecting state
291*d83cc019SAndroid Build Coastguard Worker  * from a GPU hang for analysis.
292*d83cc019SAndroid Build Coastguard Worker */
293*d83cc019SAndroid Build Coastguard Worker struct drm_vc4_get_hang_state {
294*d83cc019SAndroid Build Coastguard Worker 	/** Pointer to array of struct drm_vc4_get_hang_state_bo. */
295*d83cc019SAndroid Build Coastguard Worker 	__u64 bo;
296*d83cc019SAndroid Build Coastguard Worker 	/**
297*d83cc019SAndroid Build Coastguard Worker 	 * On input, the size of the bo array.  Output is the number
298*d83cc019SAndroid Build Coastguard Worker 	 * of bos to be returned.
299*d83cc019SAndroid Build Coastguard Worker 	 */
300*d83cc019SAndroid Build Coastguard Worker 	__u32 bo_count;
301*d83cc019SAndroid Build Coastguard Worker 
302*d83cc019SAndroid Build Coastguard Worker 	__u32 start_bin, start_render;
303*d83cc019SAndroid Build Coastguard Worker 
304*d83cc019SAndroid Build Coastguard Worker 	__u32 ct0ca, ct0ea;
305*d83cc019SAndroid Build Coastguard Worker 	__u32 ct1ca, ct1ea;
306*d83cc019SAndroid Build Coastguard Worker 	__u32 ct0cs, ct1cs;
307*d83cc019SAndroid Build Coastguard Worker 	__u32 ct0ra0, ct1ra0;
308*d83cc019SAndroid Build Coastguard Worker 
309*d83cc019SAndroid Build Coastguard Worker 	__u32 bpca, bpcs;
310*d83cc019SAndroid Build Coastguard Worker 	__u32 bpoa, bpos;
311*d83cc019SAndroid Build Coastguard Worker 
312*d83cc019SAndroid Build Coastguard Worker 	__u32 vpmbase;
313*d83cc019SAndroid Build Coastguard Worker 
314*d83cc019SAndroid Build Coastguard Worker 	__u32 dbge;
315*d83cc019SAndroid Build Coastguard Worker 	__u32 fdbgo;
316*d83cc019SAndroid Build Coastguard Worker 	__u32 fdbgb;
317*d83cc019SAndroid Build Coastguard Worker 	__u32 fdbgr;
318*d83cc019SAndroid Build Coastguard Worker 	__u32 fdbgs;
319*d83cc019SAndroid Build Coastguard Worker 	__u32 errstat;
320*d83cc019SAndroid Build Coastguard Worker 
321*d83cc019SAndroid Build Coastguard Worker 	/* Pad that we may save more registers into in the future. */
322*d83cc019SAndroid Build Coastguard Worker 	__u32 pad[16];
323*d83cc019SAndroid Build Coastguard Worker };
324*d83cc019SAndroid Build Coastguard Worker 
325*d83cc019SAndroid Build Coastguard Worker #define DRM_VC4_PARAM_V3D_IDENT0		0
326*d83cc019SAndroid Build Coastguard Worker #define DRM_VC4_PARAM_V3D_IDENT1		1
327*d83cc019SAndroid Build Coastguard Worker #define DRM_VC4_PARAM_V3D_IDENT2		2
328*d83cc019SAndroid Build Coastguard Worker #define DRM_VC4_PARAM_SUPPORTS_BRANCHES		3
329*d83cc019SAndroid Build Coastguard Worker #define DRM_VC4_PARAM_SUPPORTS_ETC1		4
330*d83cc019SAndroid Build Coastguard Worker #define DRM_VC4_PARAM_SUPPORTS_THREADED_FS	5
331*d83cc019SAndroid Build Coastguard Worker #define DRM_VC4_PARAM_SUPPORTS_FIXED_RCL_ORDER	6
332*d83cc019SAndroid Build Coastguard Worker #define DRM_VC4_PARAM_SUPPORTS_MADVISE		7
333*d83cc019SAndroid Build Coastguard Worker #define DRM_VC4_PARAM_SUPPORTS_PERFMON		8
334*d83cc019SAndroid Build Coastguard Worker 
335*d83cc019SAndroid Build Coastguard Worker struct drm_vc4_get_param {
336*d83cc019SAndroid Build Coastguard Worker 	__u32 param;
337*d83cc019SAndroid Build Coastguard Worker 	__u32 pad;
338*d83cc019SAndroid Build Coastguard Worker 	__u64 value;
339*d83cc019SAndroid Build Coastguard Worker };
340*d83cc019SAndroid Build Coastguard Worker 
341*d83cc019SAndroid Build Coastguard Worker struct drm_vc4_get_tiling {
342*d83cc019SAndroid Build Coastguard Worker 	__u32 handle;
343*d83cc019SAndroid Build Coastguard Worker 	__u32 flags;
344*d83cc019SAndroid Build Coastguard Worker 	__u64 modifier;
345*d83cc019SAndroid Build Coastguard Worker };
346*d83cc019SAndroid Build Coastguard Worker 
347*d83cc019SAndroid Build Coastguard Worker struct drm_vc4_set_tiling {
348*d83cc019SAndroid Build Coastguard Worker 	__u32 handle;
349*d83cc019SAndroid Build Coastguard Worker 	__u32 flags;
350*d83cc019SAndroid Build Coastguard Worker 	__u64 modifier;
351*d83cc019SAndroid Build Coastguard Worker };
352*d83cc019SAndroid Build Coastguard Worker 
353*d83cc019SAndroid Build Coastguard Worker /**
354*d83cc019SAndroid Build Coastguard Worker  * struct drm_vc4_label_bo - Attach a name to a BO for debug purposes.
355*d83cc019SAndroid Build Coastguard Worker  */
356*d83cc019SAndroid Build Coastguard Worker struct drm_vc4_label_bo {
357*d83cc019SAndroid Build Coastguard Worker 	__u32 handle;
358*d83cc019SAndroid Build Coastguard Worker 	__u32 len;
359*d83cc019SAndroid Build Coastguard Worker 	__u64 name;
360*d83cc019SAndroid Build Coastguard Worker };
361*d83cc019SAndroid Build Coastguard Worker 
362*d83cc019SAndroid Build Coastguard Worker /*
363*d83cc019SAndroid Build Coastguard Worker  * States prefixed with '__' are internal states and cannot be passed to the
364*d83cc019SAndroid Build Coastguard Worker  * DRM_IOCTL_VC4_GEM_MADVISE ioctl.
365*d83cc019SAndroid Build Coastguard Worker  */
366*d83cc019SAndroid Build Coastguard Worker #define VC4_MADV_WILLNEED			0
367*d83cc019SAndroid Build Coastguard Worker #define VC4_MADV_DONTNEED			1
368*d83cc019SAndroid Build Coastguard Worker #define __VC4_MADV_PURGED			2
369*d83cc019SAndroid Build Coastguard Worker #define __VC4_MADV_NOTSUPP			3
370*d83cc019SAndroid Build Coastguard Worker 
371*d83cc019SAndroid Build Coastguard Worker struct drm_vc4_gem_madvise {
372*d83cc019SAndroid Build Coastguard Worker 	__u32 handle;
373*d83cc019SAndroid Build Coastguard Worker 	__u32 madv;
374*d83cc019SAndroid Build Coastguard Worker 	__u32 retained;
375*d83cc019SAndroid Build Coastguard Worker 	__u32 pad;
376*d83cc019SAndroid Build Coastguard Worker };
377*d83cc019SAndroid Build Coastguard Worker 
378*d83cc019SAndroid Build Coastguard Worker enum {
379*d83cc019SAndroid Build Coastguard Worker 	VC4_PERFCNT_FEP_VALID_PRIMS_NO_RENDER,
380*d83cc019SAndroid Build Coastguard Worker 	VC4_PERFCNT_FEP_VALID_PRIMS_RENDER,
381*d83cc019SAndroid Build Coastguard Worker 	VC4_PERFCNT_FEP_CLIPPED_QUADS,
382*d83cc019SAndroid Build Coastguard Worker 	VC4_PERFCNT_FEP_VALID_QUADS,
383*d83cc019SAndroid Build Coastguard Worker 	VC4_PERFCNT_TLB_QUADS_NOT_PASSING_STENCIL,
384*d83cc019SAndroid Build Coastguard Worker 	VC4_PERFCNT_TLB_QUADS_NOT_PASSING_Z_AND_STENCIL,
385*d83cc019SAndroid Build Coastguard Worker 	VC4_PERFCNT_TLB_QUADS_PASSING_Z_AND_STENCIL,
386*d83cc019SAndroid Build Coastguard Worker 	VC4_PERFCNT_TLB_QUADS_ZERO_COVERAGE,
387*d83cc019SAndroid Build Coastguard Worker 	VC4_PERFCNT_TLB_QUADS_NON_ZERO_COVERAGE,
388*d83cc019SAndroid Build Coastguard Worker 	VC4_PERFCNT_TLB_QUADS_WRITTEN_TO_COLOR_BUF,
389*d83cc019SAndroid Build Coastguard Worker 	VC4_PERFCNT_PLB_PRIMS_OUTSIDE_VIEWPORT,
390*d83cc019SAndroid Build Coastguard Worker 	VC4_PERFCNT_PLB_PRIMS_NEED_CLIPPING,
391*d83cc019SAndroid Build Coastguard Worker 	VC4_PERFCNT_PSE_PRIMS_REVERSED,
392*d83cc019SAndroid Build Coastguard Worker 	VC4_PERFCNT_QPU_TOTAL_IDLE_CYCLES,
393*d83cc019SAndroid Build Coastguard Worker 	VC4_PERFCNT_QPU_TOTAL_CLK_CYCLES_VERTEX_COORD_SHADING,
394*d83cc019SAndroid Build Coastguard Worker 	VC4_PERFCNT_QPU_TOTAL_CLK_CYCLES_FRAGMENT_SHADING,
395*d83cc019SAndroid Build Coastguard Worker 	VC4_PERFCNT_QPU_TOTAL_CLK_CYCLES_EXEC_VALID_INST,
396*d83cc019SAndroid Build Coastguard Worker 	VC4_PERFCNT_QPU_TOTAL_CLK_CYCLES_WAITING_TMUS,
397*d83cc019SAndroid Build Coastguard Worker 	VC4_PERFCNT_QPU_TOTAL_CLK_CYCLES_WAITING_SCOREBOARD,
398*d83cc019SAndroid Build Coastguard Worker 	VC4_PERFCNT_QPU_TOTAL_CLK_CYCLES_WAITING_VARYINGS,
399*d83cc019SAndroid Build Coastguard Worker 	VC4_PERFCNT_QPU_TOTAL_INST_CACHE_HIT,
400*d83cc019SAndroid Build Coastguard Worker 	VC4_PERFCNT_QPU_TOTAL_INST_CACHE_MISS,
401*d83cc019SAndroid Build Coastguard Worker 	VC4_PERFCNT_QPU_TOTAL_UNIFORM_CACHE_HIT,
402*d83cc019SAndroid Build Coastguard Worker 	VC4_PERFCNT_QPU_TOTAL_UNIFORM_CACHE_MISS,
403*d83cc019SAndroid Build Coastguard Worker 	VC4_PERFCNT_TMU_TOTAL_TEXT_QUADS_PROCESSED,
404*d83cc019SAndroid Build Coastguard Worker 	VC4_PERFCNT_TMU_TOTAL_TEXT_CACHE_MISS,
405*d83cc019SAndroid Build Coastguard Worker 	VC4_PERFCNT_VPM_TOTAL_CLK_CYCLES_VDW_STALLED,
406*d83cc019SAndroid Build Coastguard Worker 	VC4_PERFCNT_VPM_TOTAL_CLK_CYCLES_VCD_STALLED,
407*d83cc019SAndroid Build Coastguard Worker 	VC4_PERFCNT_L2C_TOTAL_L2_CACHE_HIT,
408*d83cc019SAndroid Build Coastguard Worker 	VC4_PERFCNT_L2C_TOTAL_L2_CACHE_MISS,
409*d83cc019SAndroid Build Coastguard Worker 	VC4_PERFCNT_NUM_EVENTS,
410*d83cc019SAndroid Build Coastguard Worker };
411*d83cc019SAndroid Build Coastguard Worker 
412*d83cc019SAndroid Build Coastguard Worker #define DRM_VC4_MAX_PERF_COUNTERS	16
413*d83cc019SAndroid Build Coastguard Worker 
414*d83cc019SAndroid Build Coastguard Worker struct drm_vc4_perfmon_create {
415*d83cc019SAndroid Build Coastguard Worker 	__u32 id;
416*d83cc019SAndroid Build Coastguard Worker 	__u32 ncounters;
417*d83cc019SAndroid Build Coastguard Worker 	__u8 events[DRM_VC4_MAX_PERF_COUNTERS];
418*d83cc019SAndroid Build Coastguard Worker };
419*d83cc019SAndroid Build Coastguard Worker 
420*d83cc019SAndroid Build Coastguard Worker struct drm_vc4_perfmon_destroy {
421*d83cc019SAndroid Build Coastguard Worker 	__u32 id;
422*d83cc019SAndroid Build Coastguard Worker };
423*d83cc019SAndroid Build Coastguard Worker 
424*d83cc019SAndroid Build Coastguard Worker /*
425*d83cc019SAndroid Build Coastguard Worker  * Returns the values of the performance counters tracked by this
426*d83cc019SAndroid Build Coastguard Worker  * perfmon (as an array of ncounters u64 values).
427*d83cc019SAndroid Build Coastguard Worker  *
428*d83cc019SAndroid Build Coastguard Worker  * No implicit synchronization is performed, so the user has to
429*d83cc019SAndroid Build Coastguard Worker  * guarantee that any jobs using this perfmon have already been
430*d83cc019SAndroid Build Coastguard Worker  * completed  (probably by blocking on the seqno returned by the
431*d83cc019SAndroid Build Coastguard Worker  * last exec that used the perfmon).
432*d83cc019SAndroid Build Coastguard Worker  */
433*d83cc019SAndroid Build Coastguard Worker struct drm_vc4_perfmon_get_values {
434*d83cc019SAndroid Build Coastguard Worker 	__u32 id;
435*d83cc019SAndroid Build Coastguard Worker 	__u64 values_ptr;
436*d83cc019SAndroid Build Coastguard Worker };
437*d83cc019SAndroid Build Coastguard Worker 
438*d83cc019SAndroid Build Coastguard Worker #if defined(__cplusplus)
439*d83cc019SAndroid Build Coastguard Worker }
440*d83cc019SAndroid Build Coastguard Worker #endif
441*d83cc019SAndroid Build Coastguard Worker 
442*d83cc019SAndroid Build Coastguard Worker #endif /* _VC4_DRM_H_ */
443