162306a36Sopenharmony_ci/*
262306a36Sopenharmony_ci * Copyright © 2014-2015 Broadcom
362306a36Sopenharmony_ci *
462306a36Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a
562306a36Sopenharmony_ci * copy of this software and associated documentation files (the "Software"),
662306a36Sopenharmony_ci * to deal in the Software without restriction, including without limitation
762306a36Sopenharmony_ci * the rights to use, copy, modify, merge, publish, distribute, sublicense,
862306a36Sopenharmony_ci * and/or sell copies of the Software, and to permit persons to whom the
962306a36Sopenharmony_ci * Software is furnished to do so, subject to the following conditions:
1062306a36Sopenharmony_ci *
1162306a36Sopenharmony_ci * The above copyright notice and this permission notice (including the next
1262306a36Sopenharmony_ci * paragraph) shall be included in all copies or substantial portions of the
1362306a36Sopenharmony_ci * Software.
1462306a36Sopenharmony_ci *
1562306a36Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1662306a36Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1762306a36Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
1862306a36Sopenharmony_ci * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1962306a36Sopenharmony_ci * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
2062306a36Sopenharmony_ci * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
2162306a36Sopenharmony_ci * IN THE SOFTWARE.
2262306a36Sopenharmony_ci */
2362306a36Sopenharmony_ci
2462306a36Sopenharmony_ci#ifndef _UAPI_VC4_DRM_H_
2562306a36Sopenharmony_ci#define _UAPI_VC4_DRM_H_
2662306a36Sopenharmony_ci
2762306a36Sopenharmony_ci#include "drm.h"
2862306a36Sopenharmony_ci
2962306a36Sopenharmony_ci#if defined(__cplusplus)
3062306a36Sopenharmony_ciextern "C" {
3162306a36Sopenharmony_ci#endif
3262306a36Sopenharmony_ci
3362306a36Sopenharmony_ci#define DRM_VC4_SUBMIT_CL                         0x00
3462306a36Sopenharmony_ci#define DRM_VC4_WAIT_SEQNO                        0x01
3562306a36Sopenharmony_ci#define DRM_VC4_WAIT_BO                           0x02
3662306a36Sopenharmony_ci#define DRM_VC4_CREATE_BO                         0x03
3762306a36Sopenharmony_ci#define DRM_VC4_MMAP_BO                           0x04
3862306a36Sopenharmony_ci#define DRM_VC4_CREATE_SHADER_BO                  0x05
3962306a36Sopenharmony_ci#define DRM_VC4_GET_HANG_STATE                    0x06
4062306a36Sopenharmony_ci#define DRM_VC4_GET_PARAM                         0x07
4162306a36Sopenharmony_ci#define DRM_VC4_SET_TILING                        0x08
4262306a36Sopenharmony_ci#define DRM_VC4_GET_TILING                        0x09
4362306a36Sopenharmony_ci#define DRM_VC4_LABEL_BO                          0x0a
4462306a36Sopenharmony_ci#define DRM_VC4_GEM_MADVISE                       0x0b
4562306a36Sopenharmony_ci#define DRM_VC4_PERFMON_CREATE                    0x0c
4662306a36Sopenharmony_ci#define DRM_VC4_PERFMON_DESTROY                   0x0d
4762306a36Sopenharmony_ci#define DRM_VC4_PERFMON_GET_VALUES                0x0e
4862306a36Sopenharmony_ci
4962306a36Sopenharmony_ci#define DRM_IOCTL_VC4_SUBMIT_CL           DRM_IOWR(DRM_COMMAND_BASE + DRM_VC4_SUBMIT_CL, struct drm_vc4_submit_cl)
5062306a36Sopenharmony_ci#define DRM_IOCTL_VC4_WAIT_SEQNO          DRM_IOWR(DRM_COMMAND_BASE + DRM_VC4_WAIT_SEQNO, struct drm_vc4_wait_seqno)
5162306a36Sopenharmony_ci#define DRM_IOCTL_VC4_WAIT_BO             DRM_IOWR(DRM_COMMAND_BASE + DRM_VC4_WAIT_BO, struct drm_vc4_wait_bo)
5262306a36Sopenharmony_ci#define DRM_IOCTL_VC4_CREATE_BO           DRM_IOWR(DRM_COMMAND_BASE + DRM_VC4_CREATE_BO, struct drm_vc4_create_bo)
5362306a36Sopenharmony_ci#define DRM_IOCTL_VC4_MMAP_BO             DRM_IOWR(DRM_COMMAND_BASE + DRM_VC4_MMAP_BO, struct drm_vc4_mmap_bo)
5462306a36Sopenharmony_ci#define DRM_IOCTL_VC4_CREATE_SHADER_BO    DRM_IOWR(DRM_COMMAND_BASE + DRM_VC4_CREATE_SHADER_BO, struct drm_vc4_create_shader_bo)
5562306a36Sopenharmony_ci#define DRM_IOCTL_VC4_GET_HANG_STATE      DRM_IOWR(DRM_COMMAND_BASE + DRM_VC4_GET_HANG_STATE, struct drm_vc4_get_hang_state)
5662306a36Sopenharmony_ci#define DRM_IOCTL_VC4_GET_PARAM           DRM_IOWR(DRM_COMMAND_BASE + DRM_VC4_GET_PARAM, struct drm_vc4_get_param)
5762306a36Sopenharmony_ci#define DRM_IOCTL_VC4_SET_TILING          DRM_IOWR(DRM_COMMAND_BASE + DRM_VC4_SET_TILING, struct drm_vc4_set_tiling)
5862306a36Sopenharmony_ci#define DRM_IOCTL_VC4_GET_TILING          DRM_IOWR(DRM_COMMAND_BASE + DRM_VC4_GET_TILING, struct drm_vc4_get_tiling)
5962306a36Sopenharmony_ci#define DRM_IOCTL_VC4_LABEL_BO            DRM_IOWR(DRM_COMMAND_BASE + DRM_VC4_LABEL_BO, struct drm_vc4_label_bo)
6062306a36Sopenharmony_ci#define DRM_IOCTL_VC4_GEM_MADVISE         DRM_IOWR(DRM_COMMAND_BASE + DRM_VC4_GEM_MADVISE, struct drm_vc4_gem_madvise)
6162306a36Sopenharmony_ci#define DRM_IOCTL_VC4_PERFMON_CREATE      DRM_IOWR(DRM_COMMAND_BASE + DRM_VC4_PERFMON_CREATE, struct drm_vc4_perfmon_create)
6262306a36Sopenharmony_ci#define DRM_IOCTL_VC4_PERFMON_DESTROY     DRM_IOWR(DRM_COMMAND_BASE + DRM_VC4_PERFMON_DESTROY, struct drm_vc4_perfmon_destroy)
6362306a36Sopenharmony_ci#define DRM_IOCTL_VC4_PERFMON_GET_VALUES  DRM_IOWR(DRM_COMMAND_BASE + DRM_VC4_PERFMON_GET_VALUES, struct drm_vc4_perfmon_get_values)
6462306a36Sopenharmony_ci
6562306a36Sopenharmony_cistruct drm_vc4_submit_rcl_surface {
6662306a36Sopenharmony_ci	__u32 hindex; /* Handle index, or ~0 if not present. */
6762306a36Sopenharmony_ci	__u32 offset; /* Offset to start of buffer. */
6862306a36Sopenharmony_ci	/*
6962306a36Sopenharmony_ci	 * Bits for either render config (color_write) or load/store packet.
7062306a36Sopenharmony_ci	 * Bits should all be 0 for MSAA load/stores.
7162306a36Sopenharmony_ci	 */
7262306a36Sopenharmony_ci	__u16 bits;
7362306a36Sopenharmony_ci
7462306a36Sopenharmony_ci#define VC4_SUBMIT_RCL_SURFACE_READ_IS_FULL_RES		(1 << 0)
7562306a36Sopenharmony_ci	__u16 flags;
7662306a36Sopenharmony_ci};
7762306a36Sopenharmony_ci
7862306a36Sopenharmony_ci/**
7962306a36Sopenharmony_ci * struct drm_vc4_submit_cl - ioctl argument for submitting commands to the 3D
8062306a36Sopenharmony_ci * engine.
8162306a36Sopenharmony_ci *
8262306a36Sopenharmony_ci * Drivers typically use GPU BOs to store batchbuffers / command lists and
8362306a36Sopenharmony_ci * their associated state.  However, because the VC4 lacks an MMU, we have to
8462306a36Sopenharmony_ci * do validation of memory accesses by the GPU commands.  If we were to store
8562306a36Sopenharmony_ci * our commands in BOs, we'd need to do uncached readback from them to do the
8662306a36Sopenharmony_ci * validation process, which is too expensive.  Instead, userspace accumulates
8762306a36Sopenharmony_ci * commands and associated state in plain memory, then the kernel copies the
8862306a36Sopenharmony_ci * data to its own address space, and then validates and stores it in a GPU
8962306a36Sopenharmony_ci * BO.
9062306a36Sopenharmony_ci */
9162306a36Sopenharmony_cistruct drm_vc4_submit_cl {
9262306a36Sopenharmony_ci	/* Pointer to the binner command list.
9362306a36Sopenharmony_ci	 *
9462306a36Sopenharmony_ci	 * This is the first set of commands executed, which runs the
9562306a36Sopenharmony_ci	 * coordinate shader to determine where primitives land on the screen,
9662306a36Sopenharmony_ci	 * then writes out the state updates and draw calls necessary per tile
9762306a36Sopenharmony_ci	 * to the tile allocation BO.
9862306a36Sopenharmony_ci	 */
9962306a36Sopenharmony_ci	__u64 bin_cl;
10062306a36Sopenharmony_ci
10162306a36Sopenharmony_ci	/* Pointer to the shader records.
10262306a36Sopenharmony_ci	 *
10362306a36Sopenharmony_ci	 * Shader records are the structures read by the hardware that contain
10462306a36Sopenharmony_ci	 * pointers to uniforms, shaders, and vertex attributes.  The
10562306a36Sopenharmony_ci	 * reference to the shader record has enough information to determine
10662306a36Sopenharmony_ci	 * how many pointers are necessary (fixed number for shaders/uniforms,
10762306a36Sopenharmony_ci	 * and an attribute count), so those BO indices into bo_handles are
10862306a36Sopenharmony_ci	 * just stored as __u32s before each shader record passed in.
10962306a36Sopenharmony_ci	 */
11062306a36Sopenharmony_ci	__u64 shader_rec;
11162306a36Sopenharmony_ci
11262306a36Sopenharmony_ci	/* Pointer to uniform data and texture handles for the textures
11362306a36Sopenharmony_ci	 * referenced by the shader.
11462306a36Sopenharmony_ci	 *
11562306a36Sopenharmony_ci	 * For each shader state record, there is a set of uniform data in the
11662306a36Sopenharmony_ci	 * order referenced by the record (FS, VS, then CS).  Each set of
11762306a36Sopenharmony_ci	 * uniform data has a __u32 index into bo_handles per texture
11862306a36Sopenharmony_ci	 * sample operation, in the order the QPU_W_TMUn_S writes appear in
11962306a36Sopenharmony_ci	 * the program.  Following the texture BO handle indices is the actual
12062306a36Sopenharmony_ci	 * uniform data.
12162306a36Sopenharmony_ci	 *
12262306a36Sopenharmony_ci	 * The individual uniform state blocks don't have sizes passed in,
12362306a36Sopenharmony_ci	 * because the kernel has to determine the sizes anyway during shader
12462306a36Sopenharmony_ci	 * code validation.
12562306a36Sopenharmony_ci	 */
12662306a36Sopenharmony_ci	__u64 uniforms;
12762306a36Sopenharmony_ci	__u64 bo_handles;
12862306a36Sopenharmony_ci
12962306a36Sopenharmony_ci	/* Size in bytes of the binner command list. */
13062306a36Sopenharmony_ci	__u32 bin_cl_size;
13162306a36Sopenharmony_ci	/* Size in bytes of the set of shader records. */
13262306a36Sopenharmony_ci	__u32 shader_rec_size;
13362306a36Sopenharmony_ci	/* Number of shader records.
13462306a36Sopenharmony_ci	 *
13562306a36Sopenharmony_ci	 * This could just be computed from the contents of shader_records and
13662306a36Sopenharmony_ci	 * the address bits of references to them from the bin CL, but it
13762306a36Sopenharmony_ci	 * keeps the kernel from having to resize some allocations it makes.
13862306a36Sopenharmony_ci	 */
13962306a36Sopenharmony_ci	__u32 shader_rec_count;
14062306a36Sopenharmony_ci	/* Size in bytes of the uniform state. */
14162306a36Sopenharmony_ci	__u32 uniforms_size;
14262306a36Sopenharmony_ci
14362306a36Sopenharmony_ci	/* Number of BO handles passed in (size is that times 4). */
14462306a36Sopenharmony_ci	__u32 bo_handle_count;
14562306a36Sopenharmony_ci
14662306a36Sopenharmony_ci	/* RCL setup: */
14762306a36Sopenharmony_ci	__u16 width;
14862306a36Sopenharmony_ci	__u16 height;
14962306a36Sopenharmony_ci	__u8 min_x_tile;
15062306a36Sopenharmony_ci	__u8 min_y_tile;
15162306a36Sopenharmony_ci	__u8 max_x_tile;
15262306a36Sopenharmony_ci	__u8 max_y_tile;
15362306a36Sopenharmony_ci	struct drm_vc4_submit_rcl_surface color_read;
15462306a36Sopenharmony_ci	struct drm_vc4_submit_rcl_surface color_write;
15562306a36Sopenharmony_ci	struct drm_vc4_submit_rcl_surface zs_read;
15662306a36Sopenharmony_ci	struct drm_vc4_submit_rcl_surface zs_write;
15762306a36Sopenharmony_ci	struct drm_vc4_submit_rcl_surface msaa_color_write;
15862306a36Sopenharmony_ci	struct drm_vc4_submit_rcl_surface msaa_zs_write;
15962306a36Sopenharmony_ci	__u32 clear_color[2];
16062306a36Sopenharmony_ci	__u32 clear_z;
16162306a36Sopenharmony_ci	__u8 clear_s;
16262306a36Sopenharmony_ci
16362306a36Sopenharmony_ci	__u32 pad:24;
16462306a36Sopenharmony_ci
16562306a36Sopenharmony_ci#define VC4_SUBMIT_CL_USE_CLEAR_COLOR			(1 << 0)
16662306a36Sopenharmony_ci/* By default, the kernel gets to choose the order that the tiles are
16762306a36Sopenharmony_ci * rendered in.  If this is set, then the tiles will be rendered in a
16862306a36Sopenharmony_ci * raster order, with the right-to-left vs left-to-right and
16962306a36Sopenharmony_ci * top-to-bottom vs bottom-to-top dictated by
17062306a36Sopenharmony_ci * VC4_SUBMIT_CL_RCL_ORDER_INCREASING_*.  This allows overlapping
17162306a36Sopenharmony_ci * blits to be implemented using the 3D engine.
17262306a36Sopenharmony_ci */
17362306a36Sopenharmony_ci#define VC4_SUBMIT_CL_FIXED_RCL_ORDER			(1 << 1)
17462306a36Sopenharmony_ci#define VC4_SUBMIT_CL_RCL_ORDER_INCREASING_X		(1 << 2)
17562306a36Sopenharmony_ci#define VC4_SUBMIT_CL_RCL_ORDER_INCREASING_Y		(1 << 3)
17662306a36Sopenharmony_ci	__u32 flags;
17762306a36Sopenharmony_ci
17862306a36Sopenharmony_ci	/* Returned value of the seqno of this render job (for the
17962306a36Sopenharmony_ci	 * wait ioctl).
18062306a36Sopenharmony_ci	 */
18162306a36Sopenharmony_ci	__u64 seqno;
18262306a36Sopenharmony_ci
18362306a36Sopenharmony_ci	/* ID of the perfmon to attach to this job. 0 means no perfmon. */
18462306a36Sopenharmony_ci	__u32 perfmonid;
18562306a36Sopenharmony_ci
18662306a36Sopenharmony_ci	/* Syncobj handle to wait on. If set, processing of this render job
18762306a36Sopenharmony_ci	 * will not start until the syncobj is signaled. 0 means ignore.
18862306a36Sopenharmony_ci	 */
18962306a36Sopenharmony_ci	__u32 in_sync;
19062306a36Sopenharmony_ci
19162306a36Sopenharmony_ci	/* Syncobj handle to export fence to. If set, the fence in the syncobj
19262306a36Sopenharmony_ci	 * will be replaced with a fence that signals upon completion of this
19362306a36Sopenharmony_ci	 * render job. 0 means ignore.
19462306a36Sopenharmony_ci	 */
19562306a36Sopenharmony_ci	__u32 out_sync;
19662306a36Sopenharmony_ci
19762306a36Sopenharmony_ci	__u32 pad2;
19862306a36Sopenharmony_ci};
19962306a36Sopenharmony_ci
20062306a36Sopenharmony_ci/**
20162306a36Sopenharmony_ci * struct drm_vc4_wait_seqno - ioctl argument for waiting for
20262306a36Sopenharmony_ci * DRM_VC4_SUBMIT_CL completion using its returned seqno.
20362306a36Sopenharmony_ci *
20462306a36Sopenharmony_ci * timeout_ns is the timeout in nanoseconds, where "0" means "don't
20562306a36Sopenharmony_ci * block, just return the status."
20662306a36Sopenharmony_ci */
20762306a36Sopenharmony_cistruct drm_vc4_wait_seqno {
20862306a36Sopenharmony_ci	__u64 seqno;
20962306a36Sopenharmony_ci	__u64 timeout_ns;
21062306a36Sopenharmony_ci};
21162306a36Sopenharmony_ci
21262306a36Sopenharmony_ci/**
21362306a36Sopenharmony_ci * struct drm_vc4_wait_bo - ioctl argument for waiting for
21462306a36Sopenharmony_ci * completion of the last DRM_VC4_SUBMIT_CL on a BO.
21562306a36Sopenharmony_ci *
21662306a36Sopenharmony_ci * This is useful for cases where multiple processes might be
21762306a36Sopenharmony_ci * rendering to a BO and you want to wait for all rendering to be
21862306a36Sopenharmony_ci * completed.
21962306a36Sopenharmony_ci */
22062306a36Sopenharmony_cistruct drm_vc4_wait_bo {
22162306a36Sopenharmony_ci	__u32 handle;
22262306a36Sopenharmony_ci	__u32 pad;
22362306a36Sopenharmony_ci	__u64 timeout_ns;
22462306a36Sopenharmony_ci};
22562306a36Sopenharmony_ci
22662306a36Sopenharmony_ci/**
22762306a36Sopenharmony_ci * struct drm_vc4_create_bo - ioctl argument for creating VC4 BOs.
22862306a36Sopenharmony_ci *
22962306a36Sopenharmony_ci * There are currently no values for the flags argument, but it may be
23062306a36Sopenharmony_ci * used in a future extension.
23162306a36Sopenharmony_ci */
23262306a36Sopenharmony_cistruct drm_vc4_create_bo {
23362306a36Sopenharmony_ci	__u32 size;
23462306a36Sopenharmony_ci	__u32 flags;
23562306a36Sopenharmony_ci	/** Returned GEM handle for the BO. */
23662306a36Sopenharmony_ci	__u32 handle;
23762306a36Sopenharmony_ci	__u32 pad;
23862306a36Sopenharmony_ci};
23962306a36Sopenharmony_ci
24062306a36Sopenharmony_ci/**
24162306a36Sopenharmony_ci * struct drm_vc4_mmap_bo - ioctl argument for mapping VC4 BOs.
24262306a36Sopenharmony_ci *
24362306a36Sopenharmony_ci * This doesn't actually perform an mmap.  Instead, it returns the
24462306a36Sopenharmony_ci * offset you need to use in an mmap on the DRM device node.  This
24562306a36Sopenharmony_ci * means that tools like valgrind end up knowing about the mapped
24662306a36Sopenharmony_ci * memory.
24762306a36Sopenharmony_ci *
24862306a36Sopenharmony_ci * There are currently no values for the flags argument, but it may be
24962306a36Sopenharmony_ci * used in a future extension.
25062306a36Sopenharmony_ci */
25162306a36Sopenharmony_cistruct drm_vc4_mmap_bo {
25262306a36Sopenharmony_ci	/** Handle for the object being mapped. */
25362306a36Sopenharmony_ci	__u32 handle;
25462306a36Sopenharmony_ci	__u32 flags;
25562306a36Sopenharmony_ci	/** offset into the drm node to use for subsequent mmap call. */
25662306a36Sopenharmony_ci	__u64 offset;
25762306a36Sopenharmony_ci};
25862306a36Sopenharmony_ci
25962306a36Sopenharmony_ci/**
26062306a36Sopenharmony_ci * struct drm_vc4_create_shader_bo - ioctl argument for creating VC4
26162306a36Sopenharmony_ci * shader BOs.
26262306a36Sopenharmony_ci *
26362306a36Sopenharmony_ci * Since allowing a shader to be overwritten while it's also being
26462306a36Sopenharmony_ci * executed from would allow privlege escalation, shaders must be
26562306a36Sopenharmony_ci * created using this ioctl, and they can't be mmapped later.
26662306a36Sopenharmony_ci */
26762306a36Sopenharmony_cistruct drm_vc4_create_shader_bo {
26862306a36Sopenharmony_ci	/* Size of the data argument. */
26962306a36Sopenharmony_ci	__u32 size;
27062306a36Sopenharmony_ci	/* Flags, currently must be 0. */
27162306a36Sopenharmony_ci	__u32 flags;
27262306a36Sopenharmony_ci
27362306a36Sopenharmony_ci	/* Pointer to the data. */
27462306a36Sopenharmony_ci	__u64 data;
27562306a36Sopenharmony_ci
27662306a36Sopenharmony_ci	/** Returned GEM handle for the BO. */
27762306a36Sopenharmony_ci	__u32 handle;
27862306a36Sopenharmony_ci	/* Pad, must be 0. */
27962306a36Sopenharmony_ci	__u32 pad;
28062306a36Sopenharmony_ci};
28162306a36Sopenharmony_ci
28262306a36Sopenharmony_cistruct drm_vc4_get_hang_state_bo {
28362306a36Sopenharmony_ci	__u32 handle;
28462306a36Sopenharmony_ci	__u32 paddr;
28562306a36Sopenharmony_ci	__u32 size;
28662306a36Sopenharmony_ci	__u32 pad;
28762306a36Sopenharmony_ci};
28862306a36Sopenharmony_ci
28962306a36Sopenharmony_ci/**
29062306a36Sopenharmony_ci * struct drm_vc4_hang_state - ioctl argument for collecting state
29162306a36Sopenharmony_ci * from a GPU hang for analysis.
29262306a36Sopenharmony_ci*/
29362306a36Sopenharmony_cistruct drm_vc4_get_hang_state {
29462306a36Sopenharmony_ci	/** Pointer to array of struct drm_vc4_get_hang_state_bo. */
29562306a36Sopenharmony_ci	__u64 bo;
29662306a36Sopenharmony_ci	/**
29762306a36Sopenharmony_ci	 * On input, the size of the bo array.  Output is the number
29862306a36Sopenharmony_ci	 * of bos to be returned.
29962306a36Sopenharmony_ci	 */
30062306a36Sopenharmony_ci	__u32 bo_count;
30162306a36Sopenharmony_ci
30262306a36Sopenharmony_ci	__u32 start_bin, start_render;
30362306a36Sopenharmony_ci
30462306a36Sopenharmony_ci	__u32 ct0ca, ct0ea;
30562306a36Sopenharmony_ci	__u32 ct1ca, ct1ea;
30662306a36Sopenharmony_ci	__u32 ct0cs, ct1cs;
30762306a36Sopenharmony_ci	__u32 ct0ra0, ct1ra0;
30862306a36Sopenharmony_ci
30962306a36Sopenharmony_ci	__u32 bpca, bpcs;
31062306a36Sopenharmony_ci	__u32 bpoa, bpos;
31162306a36Sopenharmony_ci
31262306a36Sopenharmony_ci	__u32 vpmbase;
31362306a36Sopenharmony_ci
31462306a36Sopenharmony_ci	__u32 dbge;
31562306a36Sopenharmony_ci	__u32 fdbgo;
31662306a36Sopenharmony_ci	__u32 fdbgb;
31762306a36Sopenharmony_ci	__u32 fdbgr;
31862306a36Sopenharmony_ci	__u32 fdbgs;
31962306a36Sopenharmony_ci	__u32 errstat;
32062306a36Sopenharmony_ci
32162306a36Sopenharmony_ci	/* Pad that we may save more registers into in the future. */
32262306a36Sopenharmony_ci	__u32 pad[16];
32362306a36Sopenharmony_ci};
32462306a36Sopenharmony_ci
32562306a36Sopenharmony_ci#define DRM_VC4_PARAM_V3D_IDENT0		0
32662306a36Sopenharmony_ci#define DRM_VC4_PARAM_V3D_IDENT1		1
32762306a36Sopenharmony_ci#define DRM_VC4_PARAM_V3D_IDENT2		2
32862306a36Sopenharmony_ci#define DRM_VC4_PARAM_SUPPORTS_BRANCHES		3
32962306a36Sopenharmony_ci#define DRM_VC4_PARAM_SUPPORTS_ETC1		4
33062306a36Sopenharmony_ci#define DRM_VC4_PARAM_SUPPORTS_THREADED_FS	5
33162306a36Sopenharmony_ci#define DRM_VC4_PARAM_SUPPORTS_FIXED_RCL_ORDER	6
33262306a36Sopenharmony_ci#define DRM_VC4_PARAM_SUPPORTS_MADVISE		7
33362306a36Sopenharmony_ci#define DRM_VC4_PARAM_SUPPORTS_PERFMON		8
33462306a36Sopenharmony_ci
33562306a36Sopenharmony_cistruct drm_vc4_get_param {
33662306a36Sopenharmony_ci	__u32 param;
33762306a36Sopenharmony_ci	__u32 pad;
33862306a36Sopenharmony_ci	__u64 value;
33962306a36Sopenharmony_ci};
34062306a36Sopenharmony_ci
34162306a36Sopenharmony_cistruct drm_vc4_get_tiling {
34262306a36Sopenharmony_ci	__u32 handle;
34362306a36Sopenharmony_ci	__u32 flags;
34462306a36Sopenharmony_ci	__u64 modifier;
34562306a36Sopenharmony_ci};
34662306a36Sopenharmony_ci
34762306a36Sopenharmony_cistruct drm_vc4_set_tiling {
34862306a36Sopenharmony_ci	__u32 handle;
34962306a36Sopenharmony_ci	__u32 flags;
35062306a36Sopenharmony_ci	__u64 modifier;
35162306a36Sopenharmony_ci};
35262306a36Sopenharmony_ci
35362306a36Sopenharmony_ci/**
35462306a36Sopenharmony_ci * struct drm_vc4_label_bo - Attach a name to a BO for debug purposes.
35562306a36Sopenharmony_ci */
35662306a36Sopenharmony_cistruct drm_vc4_label_bo {
35762306a36Sopenharmony_ci	__u32 handle;
35862306a36Sopenharmony_ci	__u32 len;
35962306a36Sopenharmony_ci	__u64 name;
36062306a36Sopenharmony_ci};
36162306a36Sopenharmony_ci
36262306a36Sopenharmony_ci/*
36362306a36Sopenharmony_ci * States prefixed with '__' are internal states and cannot be passed to the
36462306a36Sopenharmony_ci * DRM_IOCTL_VC4_GEM_MADVISE ioctl.
36562306a36Sopenharmony_ci */
36662306a36Sopenharmony_ci#define VC4_MADV_WILLNEED			0
36762306a36Sopenharmony_ci#define VC4_MADV_DONTNEED			1
36862306a36Sopenharmony_ci#define __VC4_MADV_PURGED			2
36962306a36Sopenharmony_ci#define __VC4_MADV_NOTSUPP			3
37062306a36Sopenharmony_ci
37162306a36Sopenharmony_cistruct drm_vc4_gem_madvise {
37262306a36Sopenharmony_ci	__u32 handle;
37362306a36Sopenharmony_ci	__u32 madv;
37462306a36Sopenharmony_ci	__u32 retained;
37562306a36Sopenharmony_ci	__u32 pad;
37662306a36Sopenharmony_ci};
37762306a36Sopenharmony_ci
37862306a36Sopenharmony_cienum {
37962306a36Sopenharmony_ci	VC4_PERFCNT_FEP_VALID_PRIMS_NO_RENDER,
38062306a36Sopenharmony_ci	VC4_PERFCNT_FEP_VALID_PRIMS_RENDER,
38162306a36Sopenharmony_ci	VC4_PERFCNT_FEP_CLIPPED_QUADS,
38262306a36Sopenharmony_ci	VC4_PERFCNT_FEP_VALID_QUADS,
38362306a36Sopenharmony_ci	VC4_PERFCNT_TLB_QUADS_NOT_PASSING_STENCIL,
38462306a36Sopenharmony_ci	VC4_PERFCNT_TLB_QUADS_NOT_PASSING_Z_AND_STENCIL,
38562306a36Sopenharmony_ci	VC4_PERFCNT_TLB_QUADS_PASSING_Z_AND_STENCIL,
38662306a36Sopenharmony_ci	VC4_PERFCNT_TLB_QUADS_ZERO_COVERAGE,
38762306a36Sopenharmony_ci	VC4_PERFCNT_TLB_QUADS_NON_ZERO_COVERAGE,
38862306a36Sopenharmony_ci	VC4_PERFCNT_TLB_QUADS_WRITTEN_TO_COLOR_BUF,
38962306a36Sopenharmony_ci	VC4_PERFCNT_PLB_PRIMS_OUTSIDE_VIEWPORT,
39062306a36Sopenharmony_ci	VC4_PERFCNT_PLB_PRIMS_NEED_CLIPPING,
39162306a36Sopenharmony_ci	VC4_PERFCNT_PSE_PRIMS_REVERSED,
39262306a36Sopenharmony_ci	VC4_PERFCNT_QPU_TOTAL_IDLE_CYCLES,
39362306a36Sopenharmony_ci	VC4_PERFCNT_QPU_TOTAL_CLK_CYCLES_VERTEX_COORD_SHADING,
39462306a36Sopenharmony_ci	VC4_PERFCNT_QPU_TOTAL_CLK_CYCLES_FRAGMENT_SHADING,
39562306a36Sopenharmony_ci	VC4_PERFCNT_QPU_TOTAL_CLK_CYCLES_EXEC_VALID_INST,
39662306a36Sopenharmony_ci	VC4_PERFCNT_QPU_TOTAL_CLK_CYCLES_WAITING_TMUS,
39762306a36Sopenharmony_ci	VC4_PERFCNT_QPU_TOTAL_CLK_CYCLES_WAITING_SCOREBOARD,
39862306a36Sopenharmony_ci	VC4_PERFCNT_QPU_TOTAL_CLK_CYCLES_WAITING_VARYINGS,
39962306a36Sopenharmony_ci	VC4_PERFCNT_QPU_TOTAL_INST_CACHE_HIT,
40062306a36Sopenharmony_ci	VC4_PERFCNT_QPU_TOTAL_INST_CACHE_MISS,
40162306a36Sopenharmony_ci	VC4_PERFCNT_QPU_TOTAL_UNIFORM_CACHE_HIT,
40262306a36Sopenharmony_ci	VC4_PERFCNT_QPU_TOTAL_UNIFORM_CACHE_MISS,
40362306a36Sopenharmony_ci	VC4_PERFCNT_TMU_TOTAL_TEXT_QUADS_PROCESSED,
40462306a36Sopenharmony_ci	VC4_PERFCNT_TMU_TOTAL_TEXT_CACHE_MISS,
40562306a36Sopenharmony_ci	VC4_PERFCNT_VPM_TOTAL_CLK_CYCLES_VDW_STALLED,
40662306a36Sopenharmony_ci	VC4_PERFCNT_VPM_TOTAL_CLK_CYCLES_VCD_STALLED,
40762306a36Sopenharmony_ci	VC4_PERFCNT_L2C_TOTAL_L2_CACHE_HIT,
40862306a36Sopenharmony_ci	VC4_PERFCNT_L2C_TOTAL_L2_CACHE_MISS,
40962306a36Sopenharmony_ci	VC4_PERFCNT_NUM_EVENTS,
41062306a36Sopenharmony_ci};
41162306a36Sopenharmony_ci
41262306a36Sopenharmony_ci#define DRM_VC4_MAX_PERF_COUNTERS	16
41362306a36Sopenharmony_ci
41462306a36Sopenharmony_cistruct drm_vc4_perfmon_create {
41562306a36Sopenharmony_ci	__u32 id;
41662306a36Sopenharmony_ci	__u32 ncounters;
41762306a36Sopenharmony_ci	__u8 events[DRM_VC4_MAX_PERF_COUNTERS];
41862306a36Sopenharmony_ci};
41962306a36Sopenharmony_ci
42062306a36Sopenharmony_cistruct drm_vc4_perfmon_destroy {
42162306a36Sopenharmony_ci	__u32 id;
42262306a36Sopenharmony_ci};
42362306a36Sopenharmony_ci
42462306a36Sopenharmony_ci/*
42562306a36Sopenharmony_ci * Returns the values of the performance counters tracked by this
42662306a36Sopenharmony_ci * perfmon (as an array of ncounters u64 values).
42762306a36Sopenharmony_ci *
42862306a36Sopenharmony_ci * No implicit synchronization is performed, so the user has to
42962306a36Sopenharmony_ci * guarantee that any jobs using this perfmon have already been
43062306a36Sopenharmony_ci * completed  (probably by blocking on the seqno returned by the
43162306a36Sopenharmony_ci * last exec that used the perfmon).
43262306a36Sopenharmony_ci */
43362306a36Sopenharmony_cistruct drm_vc4_perfmon_get_values {
43462306a36Sopenharmony_ci	__u32 id;
43562306a36Sopenharmony_ci	__u64 values_ptr;
43662306a36Sopenharmony_ci};
43762306a36Sopenharmony_ci
43862306a36Sopenharmony_ci#if defined(__cplusplus)
43962306a36Sopenharmony_ci}
44062306a36Sopenharmony_ci#endif
44162306a36Sopenharmony_ci
44262306a36Sopenharmony_ci#endif /* _UAPI_VC4_DRM_H_ */
443