162306a36Sopenharmony_ci/*
262306a36Sopenharmony_ci * Copyright © 2014-2018 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 _V3D_DRM_H_
2562306a36Sopenharmony_ci#define _V3D_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_V3D_SUBMIT_CL                         0x00
3462306a36Sopenharmony_ci#define DRM_V3D_WAIT_BO                           0x01
3562306a36Sopenharmony_ci#define DRM_V3D_CREATE_BO                         0x02
3662306a36Sopenharmony_ci#define DRM_V3D_MMAP_BO                           0x03
3762306a36Sopenharmony_ci#define DRM_V3D_GET_PARAM                         0x04
3862306a36Sopenharmony_ci#define DRM_V3D_GET_BO_OFFSET                     0x05
3962306a36Sopenharmony_ci#define DRM_V3D_SUBMIT_TFU                        0x06
4062306a36Sopenharmony_ci#define DRM_V3D_SUBMIT_CSD                        0x07
4162306a36Sopenharmony_ci#define DRM_V3D_PERFMON_CREATE                    0x08
4262306a36Sopenharmony_ci#define DRM_V3D_PERFMON_DESTROY                   0x09
4362306a36Sopenharmony_ci#define DRM_V3D_PERFMON_GET_VALUES                0x0a
4462306a36Sopenharmony_ci
4562306a36Sopenharmony_ci#define DRM_IOCTL_V3D_SUBMIT_CL           DRM_IOWR(DRM_COMMAND_BASE + DRM_V3D_SUBMIT_CL, struct drm_v3d_submit_cl)
4662306a36Sopenharmony_ci#define DRM_IOCTL_V3D_WAIT_BO             DRM_IOWR(DRM_COMMAND_BASE + DRM_V3D_WAIT_BO, struct drm_v3d_wait_bo)
4762306a36Sopenharmony_ci#define DRM_IOCTL_V3D_CREATE_BO           DRM_IOWR(DRM_COMMAND_BASE + DRM_V3D_CREATE_BO, struct drm_v3d_create_bo)
4862306a36Sopenharmony_ci#define DRM_IOCTL_V3D_MMAP_BO             DRM_IOWR(DRM_COMMAND_BASE + DRM_V3D_MMAP_BO, struct drm_v3d_mmap_bo)
4962306a36Sopenharmony_ci#define DRM_IOCTL_V3D_GET_PARAM           DRM_IOWR(DRM_COMMAND_BASE + DRM_V3D_GET_PARAM, struct drm_v3d_get_param)
5062306a36Sopenharmony_ci#define DRM_IOCTL_V3D_GET_BO_OFFSET       DRM_IOWR(DRM_COMMAND_BASE + DRM_V3D_GET_BO_OFFSET, struct drm_v3d_get_bo_offset)
5162306a36Sopenharmony_ci#define DRM_IOCTL_V3D_SUBMIT_TFU          DRM_IOW(DRM_COMMAND_BASE + DRM_V3D_SUBMIT_TFU, struct drm_v3d_submit_tfu)
5262306a36Sopenharmony_ci#define DRM_IOCTL_V3D_SUBMIT_CSD          DRM_IOW(DRM_COMMAND_BASE + DRM_V3D_SUBMIT_CSD, struct drm_v3d_submit_csd)
5362306a36Sopenharmony_ci#define DRM_IOCTL_V3D_PERFMON_CREATE      DRM_IOWR(DRM_COMMAND_BASE + DRM_V3D_PERFMON_CREATE, \
5462306a36Sopenharmony_ci						   struct drm_v3d_perfmon_create)
5562306a36Sopenharmony_ci#define DRM_IOCTL_V3D_PERFMON_DESTROY     DRM_IOWR(DRM_COMMAND_BASE + DRM_V3D_PERFMON_DESTROY, \
5662306a36Sopenharmony_ci						   struct drm_v3d_perfmon_destroy)
5762306a36Sopenharmony_ci#define DRM_IOCTL_V3D_PERFMON_GET_VALUES  DRM_IOWR(DRM_COMMAND_BASE + DRM_V3D_PERFMON_GET_VALUES, \
5862306a36Sopenharmony_ci						   struct drm_v3d_perfmon_get_values)
5962306a36Sopenharmony_ci
6062306a36Sopenharmony_ci#define DRM_V3D_SUBMIT_CL_FLUSH_CACHE             0x01
6162306a36Sopenharmony_ci#define DRM_V3D_SUBMIT_EXTENSION		  0x02
6262306a36Sopenharmony_ci
6362306a36Sopenharmony_ci/* struct drm_v3d_extension - ioctl extensions
6462306a36Sopenharmony_ci *
6562306a36Sopenharmony_ci * Linked-list of generic extensions where the id identify which struct is
6662306a36Sopenharmony_ci * pointed by ext_data. Therefore, DRM_V3D_EXT_ID_* is used on id to identify
6762306a36Sopenharmony_ci * the extension type.
6862306a36Sopenharmony_ci */
6962306a36Sopenharmony_cistruct drm_v3d_extension {
7062306a36Sopenharmony_ci	__u64 next;
7162306a36Sopenharmony_ci	__u32 id;
7262306a36Sopenharmony_ci#define DRM_V3D_EXT_ID_MULTI_SYNC		0x01
7362306a36Sopenharmony_ci	__u32 flags; /* mbz */
7462306a36Sopenharmony_ci};
7562306a36Sopenharmony_ci
7662306a36Sopenharmony_ci/* struct drm_v3d_sem - wait/signal semaphore
7762306a36Sopenharmony_ci *
7862306a36Sopenharmony_ci * If binary semaphore, it only takes syncobj handle and ignores flags and
7962306a36Sopenharmony_ci * point fields. Point is defined for timeline syncobj feature.
8062306a36Sopenharmony_ci */
8162306a36Sopenharmony_cistruct drm_v3d_sem {
8262306a36Sopenharmony_ci	__u32 handle; /* syncobj */
8362306a36Sopenharmony_ci	/* rsv below, for future uses */
8462306a36Sopenharmony_ci	__u32 flags;
8562306a36Sopenharmony_ci	__u64 point;  /* for timeline sem support */
8662306a36Sopenharmony_ci	__u64 mbz[2]; /* must be zero, rsv */
8762306a36Sopenharmony_ci};
8862306a36Sopenharmony_ci
8962306a36Sopenharmony_ci/* Enum for each of the V3D queues. */
9062306a36Sopenharmony_cienum v3d_queue {
9162306a36Sopenharmony_ci	V3D_BIN,
9262306a36Sopenharmony_ci	V3D_RENDER,
9362306a36Sopenharmony_ci	V3D_TFU,
9462306a36Sopenharmony_ci	V3D_CSD,
9562306a36Sopenharmony_ci	V3D_CACHE_CLEAN,
9662306a36Sopenharmony_ci};
9762306a36Sopenharmony_ci
9862306a36Sopenharmony_ci/**
9962306a36Sopenharmony_ci * struct drm_v3d_multi_sync - ioctl extension to add support multiples
10062306a36Sopenharmony_ci * syncobjs for commands submission.
10162306a36Sopenharmony_ci *
10262306a36Sopenharmony_ci * When an extension of DRM_V3D_EXT_ID_MULTI_SYNC id is defined, it points to
10362306a36Sopenharmony_ci * this extension to define wait and signal dependencies, instead of single
10462306a36Sopenharmony_ci * in/out sync entries on submitting commands. The field flags is used to
10562306a36Sopenharmony_ci * determine the stage to set wait dependencies.
10662306a36Sopenharmony_ci */
10762306a36Sopenharmony_cistruct drm_v3d_multi_sync {
10862306a36Sopenharmony_ci	struct drm_v3d_extension base;
10962306a36Sopenharmony_ci	/* Array of wait and signal semaphores */
11062306a36Sopenharmony_ci	__u64 in_syncs;
11162306a36Sopenharmony_ci	__u64 out_syncs;
11262306a36Sopenharmony_ci
11362306a36Sopenharmony_ci	/* Number of entries */
11462306a36Sopenharmony_ci	__u32 in_sync_count;
11562306a36Sopenharmony_ci	__u32 out_sync_count;
11662306a36Sopenharmony_ci
11762306a36Sopenharmony_ci	/* set the stage (v3d_queue) to sync */
11862306a36Sopenharmony_ci	__u32 wait_stage;
11962306a36Sopenharmony_ci
12062306a36Sopenharmony_ci	__u32 pad; /* mbz */
12162306a36Sopenharmony_ci};
12262306a36Sopenharmony_ci
12362306a36Sopenharmony_ci/**
12462306a36Sopenharmony_ci * struct drm_v3d_submit_cl - ioctl argument for submitting commands to the 3D
12562306a36Sopenharmony_ci * engine.
12662306a36Sopenharmony_ci *
12762306a36Sopenharmony_ci * This asks the kernel to have the GPU execute an optional binner
12862306a36Sopenharmony_ci * command list, and a render command list.
12962306a36Sopenharmony_ci *
13062306a36Sopenharmony_ci * The L1T, slice, L2C, L2T, and GCA caches will be flushed before
13162306a36Sopenharmony_ci * each CL executes.  The VCD cache should be flushed (if necessary)
13262306a36Sopenharmony_ci * by the submitted CLs.  The TLB writes are guaranteed to have been
13362306a36Sopenharmony_ci * flushed by the time the render done IRQ happens, which is the
13462306a36Sopenharmony_ci * trigger for out_sync.  Any dirtying of cachelines by the job (only
13562306a36Sopenharmony_ci * possible using TMU writes) must be flushed by the caller using the
13662306a36Sopenharmony_ci * DRM_V3D_SUBMIT_CL_FLUSH_CACHE_FLAG flag.
13762306a36Sopenharmony_ci */
13862306a36Sopenharmony_cistruct drm_v3d_submit_cl {
13962306a36Sopenharmony_ci	/* Pointer to the binner command list.
14062306a36Sopenharmony_ci	 *
14162306a36Sopenharmony_ci	 * This is the first set of commands executed, which runs the
14262306a36Sopenharmony_ci	 * coordinate shader to determine where primitives land on the screen,
14362306a36Sopenharmony_ci	 * then writes out the state updates and draw calls necessary per tile
14462306a36Sopenharmony_ci	 * to the tile allocation BO.
14562306a36Sopenharmony_ci	 *
14662306a36Sopenharmony_ci	 * This BCL will block on any previous BCL submitted on the
14762306a36Sopenharmony_ci	 * same FD, but not on any RCL or BCLs submitted by other
14862306a36Sopenharmony_ci	 * clients -- that is left up to the submitter to control
14962306a36Sopenharmony_ci	 * using in_sync_bcl if necessary.
15062306a36Sopenharmony_ci	 */
15162306a36Sopenharmony_ci	__u32 bcl_start;
15262306a36Sopenharmony_ci
15362306a36Sopenharmony_ci	/** End address of the BCL (first byte after the BCL) */
15462306a36Sopenharmony_ci	__u32 bcl_end;
15562306a36Sopenharmony_ci
15662306a36Sopenharmony_ci	/* Offset of the render command list.
15762306a36Sopenharmony_ci	 *
15862306a36Sopenharmony_ci	 * This is the second set of commands executed, which will either
15962306a36Sopenharmony_ci	 * execute the tiles that have been set up by the BCL, or a fixed set
16062306a36Sopenharmony_ci	 * of tiles (in the case of RCL-only blits).
16162306a36Sopenharmony_ci	 *
16262306a36Sopenharmony_ci	 * This RCL will block on this submit's BCL, and any previous
16362306a36Sopenharmony_ci	 * RCL submitted on the same FD, but not on any RCL or BCLs
16462306a36Sopenharmony_ci	 * submitted by other clients -- that is left up to the
16562306a36Sopenharmony_ci	 * submitter to control using in_sync_rcl if necessary.
16662306a36Sopenharmony_ci	 */
16762306a36Sopenharmony_ci	__u32 rcl_start;
16862306a36Sopenharmony_ci
16962306a36Sopenharmony_ci	/** End address of the RCL (first byte after the RCL) */
17062306a36Sopenharmony_ci	__u32 rcl_end;
17162306a36Sopenharmony_ci
17262306a36Sopenharmony_ci	/** An optional sync object to wait on before starting the BCL. */
17362306a36Sopenharmony_ci	__u32 in_sync_bcl;
17462306a36Sopenharmony_ci	/** An optional sync object to wait on before starting the RCL. */
17562306a36Sopenharmony_ci	__u32 in_sync_rcl;
17662306a36Sopenharmony_ci	/** An optional sync object to place the completion fence in. */
17762306a36Sopenharmony_ci	__u32 out_sync;
17862306a36Sopenharmony_ci
17962306a36Sopenharmony_ci	/* Offset of the tile alloc memory
18062306a36Sopenharmony_ci	 *
18162306a36Sopenharmony_ci	 * This is optional on V3D 3.3 (where the CL can set the value) but
18262306a36Sopenharmony_ci	 * required on V3D 4.1.
18362306a36Sopenharmony_ci	 */
18462306a36Sopenharmony_ci	__u32 qma;
18562306a36Sopenharmony_ci
18662306a36Sopenharmony_ci	/** Size of the tile alloc memory. */
18762306a36Sopenharmony_ci	__u32 qms;
18862306a36Sopenharmony_ci
18962306a36Sopenharmony_ci	/** Offset of the tile state data array. */
19062306a36Sopenharmony_ci	__u32 qts;
19162306a36Sopenharmony_ci
19262306a36Sopenharmony_ci	/* Pointer to a u32 array of the BOs that are referenced by the job.
19362306a36Sopenharmony_ci	 */
19462306a36Sopenharmony_ci	__u64 bo_handles;
19562306a36Sopenharmony_ci
19662306a36Sopenharmony_ci	/* Number of BO handles passed in (size is that times 4). */
19762306a36Sopenharmony_ci	__u32 bo_handle_count;
19862306a36Sopenharmony_ci
19962306a36Sopenharmony_ci	/* DRM_V3D_SUBMIT_* properties */
20062306a36Sopenharmony_ci	__u32 flags;
20162306a36Sopenharmony_ci
20262306a36Sopenharmony_ci	/* ID of the perfmon to attach to this job. 0 means no perfmon. */
20362306a36Sopenharmony_ci	__u32 perfmon_id;
20462306a36Sopenharmony_ci
20562306a36Sopenharmony_ci	__u32 pad;
20662306a36Sopenharmony_ci
20762306a36Sopenharmony_ci	/* Pointer to an array of ioctl extensions*/
20862306a36Sopenharmony_ci	__u64 extensions;
20962306a36Sopenharmony_ci};
21062306a36Sopenharmony_ci
21162306a36Sopenharmony_ci/**
21262306a36Sopenharmony_ci * struct drm_v3d_wait_bo - ioctl argument for waiting for
21362306a36Sopenharmony_ci * completion of the last DRM_V3D_SUBMIT_CL on a BO.
21462306a36Sopenharmony_ci *
21562306a36Sopenharmony_ci * This is useful for cases where multiple processes might be
21662306a36Sopenharmony_ci * rendering to a BO and you want to wait for all rendering to be
21762306a36Sopenharmony_ci * completed.
21862306a36Sopenharmony_ci */
21962306a36Sopenharmony_cistruct drm_v3d_wait_bo {
22062306a36Sopenharmony_ci	__u32 handle;
22162306a36Sopenharmony_ci	__u32 pad;
22262306a36Sopenharmony_ci	__u64 timeout_ns;
22362306a36Sopenharmony_ci};
22462306a36Sopenharmony_ci
22562306a36Sopenharmony_ci/**
22662306a36Sopenharmony_ci * struct drm_v3d_create_bo - ioctl argument for creating V3D BOs.
22762306a36Sopenharmony_ci *
22862306a36Sopenharmony_ci * There are currently no values for the flags argument, but it may be
22962306a36Sopenharmony_ci * used in a future extension.
23062306a36Sopenharmony_ci */
23162306a36Sopenharmony_cistruct drm_v3d_create_bo {
23262306a36Sopenharmony_ci	__u32 size;
23362306a36Sopenharmony_ci	__u32 flags;
23462306a36Sopenharmony_ci	/** Returned GEM handle for the BO. */
23562306a36Sopenharmony_ci	__u32 handle;
23662306a36Sopenharmony_ci	/**
23762306a36Sopenharmony_ci	 * Returned offset for the BO in the V3D address space.  This offset
23862306a36Sopenharmony_ci	 * is private to the DRM fd and is valid for the lifetime of the GEM
23962306a36Sopenharmony_ci	 * handle.
24062306a36Sopenharmony_ci	 *
24162306a36Sopenharmony_ci	 * This offset value will always be nonzero, since various HW
24262306a36Sopenharmony_ci	 * units treat 0 specially.
24362306a36Sopenharmony_ci	 */
24462306a36Sopenharmony_ci	__u32 offset;
24562306a36Sopenharmony_ci};
24662306a36Sopenharmony_ci
24762306a36Sopenharmony_ci/**
24862306a36Sopenharmony_ci * struct drm_v3d_mmap_bo - ioctl argument for mapping V3D BOs.
24962306a36Sopenharmony_ci *
25062306a36Sopenharmony_ci * This doesn't actually perform an mmap.  Instead, it returns the
25162306a36Sopenharmony_ci * offset you need to use in an mmap on the DRM device node.  This
25262306a36Sopenharmony_ci * means that tools like valgrind end up knowing about the mapped
25362306a36Sopenharmony_ci * memory.
25462306a36Sopenharmony_ci *
25562306a36Sopenharmony_ci * There are currently no values for the flags argument, but it may be
25662306a36Sopenharmony_ci * used in a future extension.
25762306a36Sopenharmony_ci */
25862306a36Sopenharmony_cistruct drm_v3d_mmap_bo {
25962306a36Sopenharmony_ci	/** Handle for the object being mapped. */
26062306a36Sopenharmony_ci	__u32 handle;
26162306a36Sopenharmony_ci	__u32 flags;
26262306a36Sopenharmony_ci	/** offset into the drm node to use for subsequent mmap call. */
26362306a36Sopenharmony_ci	__u64 offset;
26462306a36Sopenharmony_ci};
26562306a36Sopenharmony_ci
26662306a36Sopenharmony_cienum drm_v3d_param {
26762306a36Sopenharmony_ci	DRM_V3D_PARAM_V3D_UIFCFG,
26862306a36Sopenharmony_ci	DRM_V3D_PARAM_V3D_HUB_IDENT1,
26962306a36Sopenharmony_ci	DRM_V3D_PARAM_V3D_HUB_IDENT2,
27062306a36Sopenharmony_ci	DRM_V3D_PARAM_V3D_HUB_IDENT3,
27162306a36Sopenharmony_ci	DRM_V3D_PARAM_V3D_CORE0_IDENT0,
27262306a36Sopenharmony_ci	DRM_V3D_PARAM_V3D_CORE0_IDENT1,
27362306a36Sopenharmony_ci	DRM_V3D_PARAM_V3D_CORE0_IDENT2,
27462306a36Sopenharmony_ci	DRM_V3D_PARAM_SUPPORTS_TFU,
27562306a36Sopenharmony_ci	DRM_V3D_PARAM_SUPPORTS_CSD,
27662306a36Sopenharmony_ci	DRM_V3D_PARAM_SUPPORTS_CACHE_FLUSH,
27762306a36Sopenharmony_ci	DRM_V3D_PARAM_SUPPORTS_PERFMON,
27862306a36Sopenharmony_ci	DRM_V3D_PARAM_SUPPORTS_MULTISYNC_EXT,
27962306a36Sopenharmony_ci};
28062306a36Sopenharmony_ci
28162306a36Sopenharmony_cistruct drm_v3d_get_param {
28262306a36Sopenharmony_ci	__u32 param;
28362306a36Sopenharmony_ci	__u32 pad;
28462306a36Sopenharmony_ci	__u64 value;
28562306a36Sopenharmony_ci};
28662306a36Sopenharmony_ci
28762306a36Sopenharmony_ci/**
28862306a36Sopenharmony_ci * Returns the offset for the BO in the V3D address space for this DRM fd.
28962306a36Sopenharmony_ci * This is the same value returned by drm_v3d_create_bo, if that was called
29062306a36Sopenharmony_ci * from this DRM fd.
29162306a36Sopenharmony_ci */
29262306a36Sopenharmony_cistruct drm_v3d_get_bo_offset {
29362306a36Sopenharmony_ci	__u32 handle;
29462306a36Sopenharmony_ci	__u32 offset;
29562306a36Sopenharmony_ci};
29662306a36Sopenharmony_ci
29762306a36Sopenharmony_cistruct drm_v3d_submit_tfu {
29862306a36Sopenharmony_ci	__u32 icfg;
29962306a36Sopenharmony_ci	__u32 iia;
30062306a36Sopenharmony_ci	__u32 iis;
30162306a36Sopenharmony_ci	__u32 ica;
30262306a36Sopenharmony_ci	__u32 iua;
30362306a36Sopenharmony_ci	__u32 ioa;
30462306a36Sopenharmony_ci	__u32 ios;
30562306a36Sopenharmony_ci	__u32 coef[4];
30662306a36Sopenharmony_ci	/* First handle is the output BO, following are other inputs.
30762306a36Sopenharmony_ci	 * 0 for unused.
30862306a36Sopenharmony_ci	 */
30962306a36Sopenharmony_ci	__u32 bo_handles[4];
31062306a36Sopenharmony_ci	/* sync object to block on before running the TFU job.  Each TFU
31162306a36Sopenharmony_ci	 * job will execute in the order submitted to its FD.  Synchronization
31262306a36Sopenharmony_ci	 * against rendering jobs requires using sync objects.
31362306a36Sopenharmony_ci	 */
31462306a36Sopenharmony_ci	__u32 in_sync;
31562306a36Sopenharmony_ci	/* Sync object to signal when the TFU job is done. */
31662306a36Sopenharmony_ci	__u32 out_sync;
31762306a36Sopenharmony_ci
31862306a36Sopenharmony_ci	__u32 flags;
31962306a36Sopenharmony_ci
32062306a36Sopenharmony_ci	/* Pointer to an array of ioctl extensions*/
32162306a36Sopenharmony_ci	__u64 extensions;
32262306a36Sopenharmony_ci};
32362306a36Sopenharmony_ci
32462306a36Sopenharmony_ci/* Submits a compute shader for dispatch.  This job will block on any
32562306a36Sopenharmony_ci * previous compute shaders submitted on this fd, and any other
32662306a36Sopenharmony_ci * synchronization must be performed with in_sync/out_sync.
32762306a36Sopenharmony_ci */
32862306a36Sopenharmony_cistruct drm_v3d_submit_csd {
32962306a36Sopenharmony_ci	__u32 cfg[7];
33062306a36Sopenharmony_ci	__u32 coef[4];
33162306a36Sopenharmony_ci
33262306a36Sopenharmony_ci	/* Pointer to a u32 array of the BOs that are referenced by the job.
33362306a36Sopenharmony_ci	 */
33462306a36Sopenharmony_ci	__u64 bo_handles;
33562306a36Sopenharmony_ci
33662306a36Sopenharmony_ci	/* Number of BO handles passed in (size is that times 4). */
33762306a36Sopenharmony_ci	__u32 bo_handle_count;
33862306a36Sopenharmony_ci
33962306a36Sopenharmony_ci	/* sync object to block on before running the CSD job.  Each
34062306a36Sopenharmony_ci	 * CSD job will execute in the order submitted to its FD.
34162306a36Sopenharmony_ci	 * Synchronization against rendering/TFU jobs or CSD from
34262306a36Sopenharmony_ci	 * other fds requires using sync objects.
34362306a36Sopenharmony_ci	 */
34462306a36Sopenharmony_ci	__u32 in_sync;
34562306a36Sopenharmony_ci	/* Sync object to signal when the CSD job is done. */
34662306a36Sopenharmony_ci	__u32 out_sync;
34762306a36Sopenharmony_ci
34862306a36Sopenharmony_ci	/* ID of the perfmon to attach to this job. 0 means no perfmon. */
34962306a36Sopenharmony_ci	__u32 perfmon_id;
35062306a36Sopenharmony_ci
35162306a36Sopenharmony_ci	/* Pointer to an array of ioctl extensions*/
35262306a36Sopenharmony_ci	__u64 extensions;
35362306a36Sopenharmony_ci
35462306a36Sopenharmony_ci	__u32 flags;
35562306a36Sopenharmony_ci
35662306a36Sopenharmony_ci	__u32 pad;
35762306a36Sopenharmony_ci};
35862306a36Sopenharmony_ci
35962306a36Sopenharmony_cienum {
36062306a36Sopenharmony_ci	V3D_PERFCNT_FEP_VALID_PRIMTS_NO_PIXELS,
36162306a36Sopenharmony_ci	V3D_PERFCNT_FEP_VALID_PRIMS,
36262306a36Sopenharmony_ci	V3D_PERFCNT_FEP_EZ_NFCLIP_QUADS,
36362306a36Sopenharmony_ci	V3D_PERFCNT_FEP_VALID_QUADS,
36462306a36Sopenharmony_ci	V3D_PERFCNT_TLB_QUADS_STENCIL_FAIL,
36562306a36Sopenharmony_ci	V3D_PERFCNT_TLB_QUADS_STENCILZ_FAIL,
36662306a36Sopenharmony_ci	V3D_PERFCNT_TLB_QUADS_STENCILZ_PASS,
36762306a36Sopenharmony_ci	V3D_PERFCNT_TLB_QUADS_ZERO_COV,
36862306a36Sopenharmony_ci	V3D_PERFCNT_TLB_QUADS_NONZERO_COV,
36962306a36Sopenharmony_ci	V3D_PERFCNT_TLB_QUADS_WRITTEN,
37062306a36Sopenharmony_ci	V3D_PERFCNT_PTB_PRIM_VIEWPOINT_DISCARD,
37162306a36Sopenharmony_ci	V3D_PERFCNT_PTB_PRIM_CLIP,
37262306a36Sopenharmony_ci	V3D_PERFCNT_PTB_PRIM_REV,
37362306a36Sopenharmony_ci	V3D_PERFCNT_QPU_IDLE_CYCLES,
37462306a36Sopenharmony_ci	V3D_PERFCNT_QPU_ACTIVE_CYCLES_VERTEX_COORD_USER,
37562306a36Sopenharmony_ci	V3D_PERFCNT_QPU_ACTIVE_CYCLES_FRAG,
37662306a36Sopenharmony_ci	V3D_PERFCNT_QPU_CYCLES_VALID_INSTR,
37762306a36Sopenharmony_ci	V3D_PERFCNT_QPU_CYCLES_TMU_STALL,
37862306a36Sopenharmony_ci	V3D_PERFCNT_QPU_CYCLES_SCOREBOARD_STALL,
37962306a36Sopenharmony_ci	V3D_PERFCNT_QPU_CYCLES_VARYINGS_STALL,
38062306a36Sopenharmony_ci	V3D_PERFCNT_QPU_IC_HIT,
38162306a36Sopenharmony_ci	V3D_PERFCNT_QPU_IC_MISS,
38262306a36Sopenharmony_ci	V3D_PERFCNT_QPU_UC_HIT,
38362306a36Sopenharmony_ci	V3D_PERFCNT_QPU_UC_MISS,
38462306a36Sopenharmony_ci	V3D_PERFCNT_TMU_TCACHE_ACCESS,
38562306a36Sopenharmony_ci	V3D_PERFCNT_TMU_TCACHE_MISS,
38662306a36Sopenharmony_ci	V3D_PERFCNT_VPM_VDW_STALL,
38762306a36Sopenharmony_ci	V3D_PERFCNT_VPM_VCD_STALL,
38862306a36Sopenharmony_ci	V3D_PERFCNT_BIN_ACTIVE,
38962306a36Sopenharmony_ci	V3D_PERFCNT_RDR_ACTIVE,
39062306a36Sopenharmony_ci	V3D_PERFCNT_L2T_HITS,
39162306a36Sopenharmony_ci	V3D_PERFCNT_L2T_MISSES,
39262306a36Sopenharmony_ci	V3D_PERFCNT_CYCLE_COUNT,
39362306a36Sopenharmony_ci	V3D_PERFCNT_QPU_CYCLES_STALLED_VERTEX_COORD_USER,
39462306a36Sopenharmony_ci	V3D_PERFCNT_QPU_CYCLES_STALLED_FRAGMENT,
39562306a36Sopenharmony_ci	V3D_PERFCNT_PTB_PRIMS_BINNED,
39662306a36Sopenharmony_ci	V3D_PERFCNT_AXI_WRITES_WATCH_0,
39762306a36Sopenharmony_ci	V3D_PERFCNT_AXI_READS_WATCH_0,
39862306a36Sopenharmony_ci	V3D_PERFCNT_AXI_WRITE_STALLS_WATCH_0,
39962306a36Sopenharmony_ci	V3D_PERFCNT_AXI_READ_STALLS_WATCH_0,
40062306a36Sopenharmony_ci	V3D_PERFCNT_AXI_WRITE_BYTES_WATCH_0,
40162306a36Sopenharmony_ci	V3D_PERFCNT_AXI_READ_BYTES_WATCH_0,
40262306a36Sopenharmony_ci	V3D_PERFCNT_AXI_WRITES_WATCH_1,
40362306a36Sopenharmony_ci	V3D_PERFCNT_AXI_READS_WATCH_1,
40462306a36Sopenharmony_ci	V3D_PERFCNT_AXI_WRITE_STALLS_WATCH_1,
40562306a36Sopenharmony_ci	V3D_PERFCNT_AXI_READ_STALLS_WATCH_1,
40662306a36Sopenharmony_ci	V3D_PERFCNT_AXI_WRITE_BYTES_WATCH_1,
40762306a36Sopenharmony_ci	V3D_PERFCNT_AXI_READ_BYTES_WATCH_1,
40862306a36Sopenharmony_ci	V3D_PERFCNT_TLB_PARTIAL_QUADS,
40962306a36Sopenharmony_ci	V3D_PERFCNT_TMU_CONFIG_ACCESSES,
41062306a36Sopenharmony_ci	V3D_PERFCNT_L2T_NO_ID_STALL,
41162306a36Sopenharmony_ci	V3D_PERFCNT_L2T_COM_QUE_STALL,
41262306a36Sopenharmony_ci	V3D_PERFCNT_L2T_TMU_WRITES,
41362306a36Sopenharmony_ci	V3D_PERFCNT_TMU_ACTIVE_CYCLES,
41462306a36Sopenharmony_ci	V3D_PERFCNT_TMU_STALLED_CYCLES,
41562306a36Sopenharmony_ci	V3D_PERFCNT_CLE_ACTIVE,
41662306a36Sopenharmony_ci	V3D_PERFCNT_L2T_TMU_READS,
41762306a36Sopenharmony_ci	V3D_PERFCNT_L2T_CLE_READS,
41862306a36Sopenharmony_ci	V3D_PERFCNT_L2T_VCD_READS,
41962306a36Sopenharmony_ci	V3D_PERFCNT_L2T_TMUCFG_READS,
42062306a36Sopenharmony_ci	V3D_PERFCNT_L2T_SLC0_READS,
42162306a36Sopenharmony_ci	V3D_PERFCNT_L2T_SLC1_READS,
42262306a36Sopenharmony_ci	V3D_PERFCNT_L2T_SLC2_READS,
42362306a36Sopenharmony_ci	V3D_PERFCNT_L2T_TMU_W_MISSES,
42462306a36Sopenharmony_ci	V3D_PERFCNT_L2T_TMU_R_MISSES,
42562306a36Sopenharmony_ci	V3D_PERFCNT_L2T_CLE_MISSES,
42662306a36Sopenharmony_ci	V3D_PERFCNT_L2T_VCD_MISSES,
42762306a36Sopenharmony_ci	V3D_PERFCNT_L2T_TMUCFG_MISSES,
42862306a36Sopenharmony_ci	V3D_PERFCNT_L2T_SLC0_MISSES,
42962306a36Sopenharmony_ci	V3D_PERFCNT_L2T_SLC1_MISSES,
43062306a36Sopenharmony_ci	V3D_PERFCNT_L2T_SLC2_MISSES,
43162306a36Sopenharmony_ci	V3D_PERFCNT_CORE_MEM_WRITES,
43262306a36Sopenharmony_ci	V3D_PERFCNT_L2T_MEM_WRITES,
43362306a36Sopenharmony_ci	V3D_PERFCNT_PTB_MEM_WRITES,
43462306a36Sopenharmony_ci	V3D_PERFCNT_TLB_MEM_WRITES,
43562306a36Sopenharmony_ci	V3D_PERFCNT_CORE_MEM_READS,
43662306a36Sopenharmony_ci	V3D_PERFCNT_L2T_MEM_READS,
43762306a36Sopenharmony_ci	V3D_PERFCNT_PTB_MEM_READS,
43862306a36Sopenharmony_ci	V3D_PERFCNT_PSE_MEM_READS,
43962306a36Sopenharmony_ci	V3D_PERFCNT_TLB_MEM_READS,
44062306a36Sopenharmony_ci	V3D_PERFCNT_GMP_MEM_READS,
44162306a36Sopenharmony_ci	V3D_PERFCNT_PTB_W_MEM_WORDS,
44262306a36Sopenharmony_ci	V3D_PERFCNT_TLB_W_MEM_WORDS,
44362306a36Sopenharmony_ci	V3D_PERFCNT_PSE_R_MEM_WORDS,
44462306a36Sopenharmony_ci	V3D_PERFCNT_TLB_R_MEM_WORDS,
44562306a36Sopenharmony_ci	V3D_PERFCNT_TMU_MRU_HITS,
44662306a36Sopenharmony_ci	V3D_PERFCNT_COMPUTE_ACTIVE,
44762306a36Sopenharmony_ci	V3D_PERFCNT_NUM,
44862306a36Sopenharmony_ci};
44962306a36Sopenharmony_ci
45062306a36Sopenharmony_ci#define DRM_V3D_MAX_PERF_COUNTERS                 32
45162306a36Sopenharmony_ci
45262306a36Sopenharmony_cistruct drm_v3d_perfmon_create {
45362306a36Sopenharmony_ci	__u32 id;
45462306a36Sopenharmony_ci	__u32 ncounters;
45562306a36Sopenharmony_ci	__u8 counters[DRM_V3D_MAX_PERF_COUNTERS];
45662306a36Sopenharmony_ci};
45762306a36Sopenharmony_ci
45862306a36Sopenharmony_cistruct drm_v3d_perfmon_destroy {
45962306a36Sopenharmony_ci	__u32 id;
46062306a36Sopenharmony_ci};
46162306a36Sopenharmony_ci
46262306a36Sopenharmony_ci/*
46362306a36Sopenharmony_ci * Returns the values of the performance counters tracked by this
46462306a36Sopenharmony_ci * perfmon (as an array of ncounters u64 values).
46562306a36Sopenharmony_ci *
46662306a36Sopenharmony_ci * No implicit synchronization is performed, so the user has to
46762306a36Sopenharmony_ci * guarantee that any jobs using this perfmon have already been
46862306a36Sopenharmony_ci * completed  (probably by blocking on the seqno returned by the
46962306a36Sopenharmony_ci * last exec that used the perfmon).
47062306a36Sopenharmony_ci */
47162306a36Sopenharmony_cistruct drm_v3d_perfmon_get_values {
47262306a36Sopenharmony_ci	__u32 id;
47362306a36Sopenharmony_ci	__u32 pad;
47462306a36Sopenharmony_ci	__u64 values_ptr;
47562306a36Sopenharmony_ci};
47662306a36Sopenharmony_ci
47762306a36Sopenharmony_ci#if defined(__cplusplus)
47862306a36Sopenharmony_ci}
47962306a36Sopenharmony_ci#endif
48062306a36Sopenharmony_ci
48162306a36Sopenharmony_ci#endif /* _V3D_DRM_H_ */
482