xref: /openbmc/linux/drivers/gpu/drm/vc4/vc4_drv.h (revision 766cc6b1)
1c8b75bcaSEric Anholt /*
2c8b75bcaSEric Anholt  * Copyright (C) 2015 Broadcom
3c8b75bcaSEric Anholt  *
4c8b75bcaSEric Anholt  * This program is free software; you can redistribute it and/or modify
5c8b75bcaSEric Anholt  * it under the terms of the GNU General Public License version 2 as
6c8b75bcaSEric Anholt  * published by the Free Software Foundation.
7c8b75bcaSEric Anholt  */
8c8b75bcaSEric Anholt 
9cdec4d36SEric Anholt #include <linux/reservation.h>
10b7e8e25bSMasahiro Yamada #include <drm/drmP.h>
119338203cSLaurent Pinchart #include <drm/drm_encoder.h>
12b7e8e25bSMasahiro Yamada #include <drm/drm_gem_cma_helper.h>
13766cc6b1SStefan Schake #include <drm/drm_atomic.h>
149338203cSLaurent Pinchart 
1565101d8cSBoris Brezillon #include "uapi/drm/vc4_drm.h"
1665101d8cSBoris Brezillon 
17f3099462SEric Anholt /* Don't forget to update vc4_bo.c: bo_type_names[] when adding to
18f3099462SEric Anholt  * this.
19f3099462SEric Anholt  */
20f3099462SEric Anholt enum vc4_kernel_bo_type {
21f3099462SEric Anholt 	/* Any kernel allocation (gem_create_object hook) before it
22f3099462SEric Anholt 	 * gets another type set.
23f3099462SEric Anholt 	 */
24f3099462SEric Anholt 	VC4_BO_TYPE_KERNEL,
25f3099462SEric Anholt 	VC4_BO_TYPE_V3D,
26f3099462SEric Anholt 	VC4_BO_TYPE_V3D_SHADER,
27f3099462SEric Anholt 	VC4_BO_TYPE_DUMB,
28f3099462SEric Anholt 	VC4_BO_TYPE_BIN,
29f3099462SEric Anholt 	VC4_BO_TYPE_RCL,
30f3099462SEric Anholt 	VC4_BO_TYPE_BCL,
31f3099462SEric Anholt 	VC4_BO_TYPE_KERNEL_CACHE,
32f3099462SEric Anholt 	VC4_BO_TYPE_COUNT
33f3099462SEric Anholt };
34f3099462SEric Anholt 
3565101d8cSBoris Brezillon /* Performance monitor object. The perform lifetime is controlled by userspace
3665101d8cSBoris Brezillon  * using perfmon related ioctls. A perfmon can be attached to a submit_cl
3765101d8cSBoris Brezillon  * request, and when this is the case, HW perf counters will be activated just
3865101d8cSBoris Brezillon  * before the submit_cl is submitted to the GPU and disabled when the job is
3965101d8cSBoris Brezillon  * done. This way, only events related to a specific job will be counted.
4065101d8cSBoris Brezillon  */
4165101d8cSBoris Brezillon struct vc4_perfmon {
4265101d8cSBoris Brezillon 	/* Tracks the number of users of the perfmon, when this counter reaches
4365101d8cSBoris Brezillon 	 * zero the perfmon is destroyed.
4465101d8cSBoris Brezillon 	 */
4565101d8cSBoris Brezillon 	refcount_t refcnt;
4665101d8cSBoris Brezillon 
4765101d8cSBoris Brezillon 	/* Number of counters activated in this perfmon instance
4865101d8cSBoris Brezillon 	 * (should be less than DRM_VC4_MAX_PERF_COUNTERS).
4965101d8cSBoris Brezillon 	 */
5065101d8cSBoris Brezillon 	u8 ncounters;
5165101d8cSBoris Brezillon 
5265101d8cSBoris Brezillon 	/* Events counted by the HW perf counters. */
5365101d8cSBoris Brezillon 	u8 events[DRM_VC4_MAX_PERF_COUNTERS];
5465101d8cSBoris Brezillon 
5565101d8cSBoris Brezillon 	/* Storage for counter values. Counters are incremented by the HW
5665101d8cSBoris Brezillon 	 * perf counter values every time the perfmon is attached to a GPU job.
5765101d8cSBoris Brezillon 	 * This way, perfmon users don't have to retrieve the results after
5865101d8cSBoris Brezillon 	 * each job if they want to track events covering several submissions.
5965101d8cSBoris Brezillon 	 * Note that counter values can't be reset, but you can fake a reset by
6065101d8cSBoris Brezillon 	 * destroying the perfmon and creating a new one.
6165101d8cSBoris Brezillon 	 */
6265101d8cSBoris Brezillon 	u64 counters[0];
6365101d8cSBoris Brezillon };
6465101d8cSBoris Brezillon 
65c8b75bcaSEric Anholt struct vc4_dev {
66c8b75bcaSEric Anholt 	struct drm_device *dev;
67c8b75bcaSEric Anholt 
68c8b75bcaSEric Anholt 	struct vc4_hdmi *hdmi;
69c8b75bcaSEric Anholt 	struct vc4_hvs *hvs;
70d3f5168aSEric Anholt 	struct vc4_v3d *v3d;
7108302c35SEric Anholt 	struct vc4_dpi *dpi;
724078f575SEric Anholt 	struct vc4_dsi *dsi1;
73e4b81f8cSBoris Brezillon 	struct vc4_vec *vec;
7448666d56SDerek Foreman 
7521461365SEric Anholt 	struct vc4_hang_state *hang_state;
7621461365SEric Anholt 
77c826a6e1SEric Anholt 	/* The kernel-space BO cache.  Tracks buffers that have been
78c826a6e1SEric Anholt 	 * unreferenced by all other users (refcounts of 0!) but not
79c826a6e1SEric Anholt 	 * yet freed, so we can do cheap allocations.
80c826a6e1SEric Anholt 	 */
81c826a6e1SEric Anholt 	struct vc4_bo_cache {
82c826a6e1SEric Anholt 		/* Array of list heads for entries in the BO cache,
83c826a6e1SEric Anholt 		 * based on number of pages, so we can do O(1) lookups
84c826a6e1SEric Anholt 		 * in the cache when allocating.
85c826a6e1SEric Anholt 		 */
86c826a6e1SEric Anholt 		struct list_head *size_list;
87c826a6e1SEric Anholt 		uint32_t size_list_size;
88c826a6e1SEric Anholt 
89c826a6e1SEric Anholt 		/* List of all BOs in the cache, ordered by age, so we
90c826a6e1SEric Anholt 		 * can do O(1) lookups when trying to free old
91c826a6e1SEric Anholt 		 * buffers.
92c826a6e1SEric Anholt 		 */
93c826a6e1SEric Anholt 		struct list_head time_list;
94c826a6e1SEric Anholt 		struct work_struct time_work;
95c826a6e1SEric Anholt 		struct timer_list time_timer;
96c826a6e1SEric Anholt 	} bo_cache;
97c826a6e1SEric Anholt 
98f3099462SEric Anholt 	u32 num_labels;
99f3099462SEric Anholt 	struct vc4_label {
100f3099462SEric Anholt 		const char *name;
101c826a6e1SEric Anholt 		u32 num_allocated;
102c826a6e1SEric Anholt 		u32 size_allocated;
103f3099462SEric Anholt 	} *bo_labels;
104c826a6e1SEric Anholt 
105f3099462SEric Anholt 	/* Protects bo_cache and bo_labels. */
106c826a6e1SEric Anholt 	struct mutex bo_lock;
107d5b1a78aSEric Anholt 
108b9f19259SBoris Brezillon 	/* Purgeable BO pool. All BOs in this pool can have their memory
109b9f19259SBoris Brezillon 	 * reclaimed if the driver is unable to allocate new BOs. We also
110b9f19259SBoris Brezillon 	 * keep stats related to the purge mechanism here.
111b9f19259SBoris Brezillon 	 */
112b9f19259SBoris Brezillon 	struct {
113b9f19259SBoris Brezillon 		struct list_head list;
114b9f19259SBoris Brezillon 		unsigned int num;
115b9f19259SBoris Brezillon 		size_t size;
116b9f19259SBoris Brezillon 		unsigned int purged_num;
117b9f19259SBoris Brezillon 		size_t purged_size;
118b9f19259SBoris Brezillon 		struct mutex lock;
119b9f19259SBoris Brezillon 	} purgeable;
120b9f19259SBoris Brezillon 
121cdec4d36SEric Anholt 	uint64_t dma_fence_context;
122cdec4d36SEric Anholt 
123ca26d28bSVarad Gautam 	/* Sequence number for the last job queued in bin_job_list.
124d5b1a78aSEric Anholt 	 * Starts at 0 (no jobs emitted).
125d5b1a78aSEric Anholt 	 */
126d5b1a78aSEric Anholt 	uint64_t emit_seqno;
127d5b1a78aSEric Anholt 
128d5b1a78aSEric Anholt 	/* Sequence number for the last completed job on the GPU.
129d5b1a78aSEric Anholt 	 * Starts at 0 (no jobs completed).
130d5b1a78aSEric Anholt 	 */
131d5b1a78aSEric Anholt 	uint64_t finished_seqno;
132d5b1a78aSEric Anholt 
133ca26d28bSVarad Gautam 	/* List of all struct vc4_exec_info for jobs to be executed in
134ca26d28bSVarad Gautam 	 * the binner.  The first job in the list is the one currently
135ca26d28bSVarad Gautam 	 * programmed into ct0ca for execution.
136d5b1a78aSEric Anholt 	 */
137ca26d28bSVarad Gautam 	struct list_head bin_job_list;
138ca26d28bSVarad Gautam 
139ca26d28bSVarad Gautam 	/* List of all struct vc4_exec_info for jobs that have
140ca26d28bSVarad Gautam 	 * completed binning and are ready for rendering.  The first
141ca26d28bSVarad Gautam 	 * job in the list is the one currently programmed into ct1ca
142ca26d28bSVarad Gautam 	 * for execution.
143ca26d28bSVarad Gautam 	 */
144ca26d28bSVarad Gautam 	struct list_head render_job_list;
145ca26d28bSVarad Gautam 
146d5b1a78aSEric Anholt 	/* List of the finished vc4_exec_infos waiting to be freed by
147d5b1a78aSEric Anholt 	 * job_done_work.
148d5b1a78aSEric Anholt 	 */
149d5b1a78aSEric Anholt 	struct list_head job_done_list;
150d5b1a78aSEric Anholt 	/* Spinlock used to synchronize the job_list and seqno
151d5b1a78aSEric Anholt 	 * accesses between the IRQ handler and GEM ioctls.
152d5b1a78aSEric Anholt 	 */
153d5b1a78aSEric Anholt 	spinlock_t job_lock;
154d5b1a78aSEric Anholt 	wait_queue_head_t job_wait_queue;
155d5b1a78aSEric Anholt 	struct work_struct job_done_work;
156d5b1a78aSEric Anholt 
15765101d8cSBoris Brezillon 	/* Used to track the active perfmon if any. Access to this field is
15865101d8cSBoris Brezillon 	 * protected by job_lock.
15965101d8cSBoris Brezillon 	 */
16065101d8cSBoris Brezillon 	struct vc4_perfmon *active_perfmon;
16165101d8cSBoris Brezillon 
162b501baccSEric Anholt 	/* List of struct vc4_seqno_cb for callbacks to be made from a
163b501baccSEric Anholt 	 * workqueue when the given seqno is passed.
164b501baccSEric Anholt 	 */
165b501baccSEric Anholt 	struct list_head seqno_cb_list;
166b501baccSEric Anholt 
167553c942fSEric Anholt 	/* The memory used for storing binner tile alloc, tile state,
168553c942fSEric Anholt 	 * and overflow memory allocations.  This is freed when V3D
169553c942fSEric Anholt 	 * powers down.
170d5b1a78aSEric Anholt 	 */
171553c942fSEric Anholt 	struct vc4_bo *bin_bo;
172553c942fSEric Anholt 
173553c942fSEric Anholt 	/* Size of blocks allocated within bin_bo. */
174553c942fSEric Anholt 	uint32_t bin_alloc_size;
175553c942fSEric Anholt 
176553c942fSEric Anholt 	/* Bitmask of the bin_alloc_size chunks in bin_bo that are
177553c942fSEric Anholt 	 * used.
178553c942fSEric Anholt 	 */
179553c942fSEric Anholt 	uint32_t bin_alloc_used;
180553c942fSEric Anholt 
181553c942fSEric Anholt 	/* Bitmask of the current bin_alloc used for overflow memory. */
182553c942fSEric Anholt 	uint32_t bin_alloc_overflow;
183553c942fSEric Anholt 
184d5b1a78aSEric Anholt 	struct work_struct overflow_mem_work;
185d5b1a78aSEric Anholt 
18636cb6253SEric Anholt 	int power_refcount;
18736cb6253SEric Anholt 
18836cb6253SEric Anholt 	/* Mutex controlling the power refcount. */
18936cb6253SEric Anholt 	struct mutex power_lock;
19036cb6253SEric Anholt 
191d5b1a78aSEric Anholt 	struct {
192d5b1a78aSEric Anholt 		struct timer_list timer;
193d5b1a78aSEric Anholt 		struct work_struct reset_work;
194d5b1a78aSEric Anholt 	} hangcheck;
195d5b1a78aSEric Anholt 
196d5b1a78aSEric Anholt 	struct semaphore async_modeset;
197766cc6b1SStefan Schake 
198766cc6b1SStefan Schake 	struct drm_modeset_lock ctm_state_lock;
199766cc6b1SStefan Schake 	struct drm_private_obj ctm_manager;
200c8b75bcaSEric Anholt };
201c8b75bcaSEric Anholt 
202c8b75bcaSEric Anholt static inline struct vc4_dev *
203c8b75bcaSEric Anholt to_vc4_dev(struct drm_device *dev)
204c8b75bcaSEric Anholt {
205c8b75bcaSEric Anholt 	return (struct vc4_dev *)dev->dev_private;
206c8b75bcaSEric Anholt }
207c8b75bcaSEric Anholt 
208c8b75bcaSEric Anholt struct vc4_bo {
209c8b75bcaSEric Anholt 	struct drm_gem_cma_object base;
210c826a6e1SEric Anholt 
2117edabee0SEric Anholt 	/* seqno of the last job to render using this BO. */
212d5b1a78aSEric Anholt 	uint64_t seqno;
213d5b1a78aSEric Anholt 
2147edabee0SEric Anholt 	/* seqno of the last job to use the RCL to write to this BO.
2157edabee0SEric Anholt 	 *
2167edabee0SEric Anholt 	 * Note that this doesn't include binner overflow memory
2177edabee0SEric Anholt 	 * writes.
2187edabee0SEric Anholt 	 */
2197edabee0SEric Anholt 	uint64_t write_seqno;
2207edabee0SEric Anholt 
22183753117SEric Anholt 	bool t_format;
22283753117SEric Anholt 
223c826a6e1SEric Anholt 	/* List entry for the BO's position in either
224c826a6e1SEric Anholt 	 * vc4_exec_info->unref_list or vc4_dev->bo_cache.time_list
225c826a6e1SEric Anholt 	 */
226c826a6e1SEric Anholt 	struct list_head unref_head;
227c826a6e1SEric Anholt 
228c826a6e1SEric Anholt 	/* Time in jiffies when the BO was put in vc4->bo_cache. */
229c826a6e1SEric Anholt 	unsigned long free_time;
230c826a6e1SEric Anholt 
231c826a6e1SEric Anholt 	/* List entry for the BO's position in vc4_dev->bo_cache.size_list */
232c826a6e1SEric Anholt 	struct list_head size_head;
233463873d5SEric Anholt 
234463873d5SEric Anholt 	/* Struct for shader validation state, if created by
235463873d5SEric Anholt 	 * DRM_IOCTL_VC4_CREATE_SHADER_BO.
236463873d5SEric Anholt 	 */
237463873d5SEric Anholt 	struct vc4_validated_shader_info *validated_shader;
238cdec4d36SEric Anholt 
239cdec4d36SEric Anholt 	/* normally (resv == &_resv) except for imported bo's */
240cdec4d36SEric Anholt 	struct reservation_object *resv;
241cdec4d36SEric Anholt 	struct reservation_object _resv;
242f3099462SEric Anholt 
243f3099462SEric Anholt 	/* One of enum vc4_kernel_bo_type, or VC4_BO_TYPE_COUNT + i
244f3099462SEric Anholt 	 * for user-allocated labels.
245f3099462SEric Anholt 	 */
246f3099462SEric Anholt 	int label;
247b9f19259SBoris Brezillon 
248b9f19259SBoris Brezillon 	/* Count the number of active users. This is needed to determine
249b9f19259SBoris Brezillon 	 * whether we can move the BO to the purgeable list or not (when the BO
250b9f19259SBoris Brezillon 	 * is used by the GPU or the display engine we can't purge it).
251b9f19259SBoris Brezillon 	 */
252b9f19259SBoris Brezillon 	refcount_t usecnt;
253b9f19259SBoris Brezillon 
254b9f19259SBoris Brezillon 	/* Store purgeable/purged state here */
255b9f19259SBoris Brezillon 	u32 madv;
256b9f19259SBoris Brezillon 	struct mutex madv_lock;
257c8b75bcaSEric Anholt };
258c8b75bcaSEric Anholt 
259c8b75bcaSEric Anholt static inline struct vc4_bo *
260c8b75bcaSEric Anholt to_vc4_bo(struct drm_gem_object *bo)
261c8b75bcaSEric Anholt {
262c8b75bcaSEric Anholt 	return (struct vc4_bo *)bo;
263c8b75bcaSEric Anholt }
264c8b75bcaSEric Anholt 
265cdec4d36SEric Anholt struct vc4_fence {
266cdec4d36SEric Anholt 	struct dma_fence base;
267cdec4d36SEric Anholt 	struct drm_device *dev;
268cdec4d36SEric Anholt 	/* vc4 seqno for signaled() test */
269cdec4d36SEric Anholt 	uint64_t seqno;
270cdec4d36SEric Anholt };
271cdec4d36SEric Anholt 
272cdec4d36SEric Anholt static inline struct vc4_fence *
273cdec4d36SEric Anholt to_vc4_fence(struct dma_fence *fence)
274cdec4d36SEric Anholt {
275cdec4d36SEric Anholt 	return (struct vc4_fence *)fence;
276cdec4d36SEric Anholt }
277cdec4d36SEric Anholt 
278b501baccSEric Anholt struct vc4_seqno_cb {
279b501baccSEric Anholt 	struct work_struct work;
280b501baccSEric Anholt 	uint64_t seqno;
281b501baccSEric Anholt 	void (*func)(struct vc4_seqno_cb *cb);
282b501baccSEric Anholt };
283b501baccSEric Anholt 
284d3f5168aSEric Anholt struct vc4_v3d {
285001bdb55SEric Anholt 	struct vc4_dev *vc4;
286d3f5168aSEric Anholt 	struct platform_device *pdev;
287d3f5168aSEric Anholt 	void __iomem *regs;
288b72a2816SEric Anholt 	struct clk *clk;
289d3f5168aSEric Anholt };
290d3f5168aSEric Anholt 
291c8b75bcaSEric Anholt struct vc4_hvs {
292c8b75bcaSEric Anholt 	struct platform_device *pdev;
293c8b75bcaSEric Anholt 	void __iomem *regs;
294d8dbf44fSEric Anholt 	u32 __iomem *dlist;
295d8dbf44fSEric Anholt 
296d8dbf44fSEric Anholt 	/* Memory manager for CRTCs to allocate space in the display
297d8dbf44fSEric Anholt 	 * list.  Units are dwords.
298d8dbf44fSEric Anholt 	 */
299d8dbf44fSEric Anholt 	struct drm_mm dlist_mm;
30021af94cfSEric Anholt 	/* Memory manager for the LBM memory used by HVS scaling. */
30121af94cfSEric Anholt 	struct drm_mm lbm_mm;
302d8dbf44fSEric Anholt 	spinlock_t mm_lock;
30321af94cfSEric Anholt 
30421af94cfSEric Anholt 	struct drm_mm_node mitchell_netravali_filter;
305c8b75bcaSEric Anholt };
306c8b75bcaSEric Anholt 
307c8b75bcaSEric Anholt struct vc4_plane {
308c8b75bcaSEric Anholt 	struct drm_plane base;
309c8b75bcaSEric Anholt };
310c8b75bcaSEric Anholt 
311c8b75bcaSEric Anholt static inline struct vc4_plane *
312c8b75bcaSEric Anholt to_vc4_plane(struct drm_plane *plane)
313c8b75bcaSEric Anholt {
314c8b75bcaSEric Anholt 	return (struct vc4_plane *)plane;
315c8b75bcaSEric Anholt }
316c8b75bcaSEric Anholt 
31782364698SStefan Schake enum vc4_scaling_mode {
31882364698SStefan Schake 	VC4_SCALING_NONE,
31982364698SStefan Schake 	VC4_SCALING_TPZ,
32082364698SStefan Schake 	VC4_SCALING_PPF,
32182364698SStefan Schake };
32282364698SStefan Schake 
32382364698SStefan Schake struct vc4_plane_state {
32482364698SStefan Schake 	struct drm_plane_state base;
32582364698SStefan Schake 	/* System memory copy of the display list for this element, computed
32682364698SStefan Schake 	 * at atomic_check time.
32782364698SStefan Schake 	 */
32882364698SStefan Schake 	u32 *dlist;
32982364698SStefan Schake 	u32 dlist_size; /* Number of dwords allocated for the display list */
33082364698SStefan Schake 	u32 dlist_count; /* Number of used dwords in the display list. */
33182364698SStefan Schake 
33282364698SStefan Schake 	/* Offset in the dlist to various words, for pageflip or
33382364698SStefan Schake 	 * cursor updates.
33482364698SStefan Schake 	 */
33582364698SStefan Schake 	u32 pos0_offset;
33682364698SStefan Schake 	u32 pos2_offset;
33782364698SStefan Schake 	u32 ptr0_offset;
33882364698SStefan Schake 
33982364698SStefan Schake 	/* Offset where the plane's dlist was last stored in the
34082364698SStefan Schake 	 * hardware at vc4_crtc_atomic_flush() time.
34182364698SStefan Schake 	 */
34282364698SStefan Schake 	u32 __iomem *hw_dlist;
34382364698SStefan Schake 
34482364698SStefan Schake 	/* Clipped coordinates of the plane on the display. */
34582364698SStefan Schake 	int crtc_x, crtc_y, crtc_w, crtc_h;
34682364698SStefan Schake 	/* Clipped area being scanned from in the FB. */
34782364698SStefan Schake 	u32 src_x, src_y;
34882364698SStefan Schake 
34982364698SStefan Schake 	u32 src_w[2], src_h[2];
35082364698SStefan Schake 
35182364698SStefan Schake 	/* Scaling selection for the RGB/Y plane and the Cb/Cr planes. */
35282364698SStefan Schake 	enum vc4_scaling_mode x_scaling[2], y_scaling[2];
35382364698SStefan Schake 	bool is_unity;
35482364698SStefan Schake 	bool is_yuv;
35582364698SStefan Schake 
35682364698SStefan Schake 	/* Offset to start scanning out from the start of the plane's
35782364698SStefan Schake 	 * BO.
35882364698SStefan Schake 	 */
35982364698SStefan Schake 	u32 offsets[3];
36082364698SStefan Schake 
36182364698SStefan Schake 	/* Our allocation in LBM for temporary storage during scaling. */
36282364698SStefan Schake 	struct drm_mm_node lbm;
36382364698SStefan Schake 
36482364698SStefan Schake 	/* Set when the plane has per-pixel alpha content or does not cover
36582364698SStefan Schake 	 * the entire screen. This is a hint to the CRTC that it might need
36682364698SStefan Schake 	 * to enable background color fill.
36782364698SStefan Schake 	 */
36882364698SStefan Schake 	bool needs_bg_fill;
36982364698SStefan Schake };
37082364698SStefan Schake 
37182364698SStefan Schake static inline struct vc4_plane_state *
37282364698SStefan Schake to_vc4_plane_state(struct drm_plane_state *state)
37382364698SStefan Schake {
37482364698SStefan Schake 	return (struct vc4_plane_state *)state;
37582364698SStefan Schake }
37682364698SStefan Schake 
377c8b75bcaSEric Anholt enum vc4_encoder_type {
378ab8df60eSBoris Brezillon 	VC4_ENCODER_TYPE_NONE,
379c8b75bcaSEric Anholt 	VC4_ENCODER_TYPE_HDMI,
380c8b75bcaSEric Anholt 	VC4_ENCODER_TYPE_VEC,
381c8b75bcaSEric Anholt 	VC4_ENCODER_TYPE_DSI0,
382c8b75bcaSEric Anholt 	VC4_ENCODER_TYPE_DSI1,
383c8b75bcaSEric Anholt 	VC4_ENCODER_TYPE_SMI,
384c8b75bcaSEric Anholt 	VC4_ENCODER_TYPE_DPI,
385c8b75bcaSEric Anholt };
386c8b75bcaSEric Anholt 
387c8b75bcaSEric Anholt struct vc4_encoder {
388c8b75bcaSEric Anholt 	struct drm_encoder base;
389c8b75bcaSEric Anholt 	enum vc4_encoder_type type;
390c8b75bcaSEric Anholt 	u32 clock_select;
391c8b75bcaSEric Anholt };
392c8b75bcaSEric Anholt 
393c8b75bcaSEric Anholt static inline struct vc4_encoder *
394c8b75bcaSEric Anholt to_vc4_encoder(struct drm_encoder *encoder)
395c8b75bcaSEric Anholt {
396c8b75bcaSEric Anholt 	return container_of(encoder, struct vc4_encoder, base);
397c8b75bcaSEric Anholt }
398c8b75bcaSEric Anholt 
39979271807SStefan Schake struct vc4_crtc_data {
40079271807SStefan Schake 	/* Which channel of the HVS this pixelvalve sources from. */
40179271807SStefan Schake 	int hvs_channel;
40279271807SStefan Schake 
40379271807SStefan Schake 	enum vc4_encoder_type encoder_types[4];
40479271807SStefan Schake };
40579271807SStefan Schake 
40679271807SStefan Schake struct vc4_crtc {
40779271807SStefan Schake 	struct drm_crtc base;
40879271807SStefan Schake 	const struct vc4_crtc_data *data;
40979271807SStefan Schake 	void __iomem *regs;
41079271807SStefan Schake 
41179271807SStefan Schake 	/* Timestamp at start of vblank irq - unaffected by lock delays. */
41279271807SStefan Schake 	ktime_t t_vblank;
41379271807SStefan Schake 
41479271807SStefan Schake 	/* Which HVS channel we're using for our CRTC. */
41579271807SStefan Schake 	int channel;
41679271807SStefan Schake 
41779271807SStefan Schake 	u8 lut_r[256];
41879271807SStefan Schake 	u8 lut_g[256];
41979271807SStefan Schake 	u8 lut_b[256];
42079271807SStefan Schake 	/* Size in pixels of the COB memory allocated to this CRTC. */
42179271807SStefan Schake 	u32 cob_size;
42279271807SStefan Schake 
42379271807SStefan Schake 	struct drm_pending_vblank_event *event;
42479271807SStefan Schake };
42579271807SStefan Schake 
42679271807SStefan Schake static inline struct vc4_crtc *
42779271807SStefan Schake to_vc4_crtc(struct drm_crtc *crtc)
42879271807SStefan Schake {
42979271807SStefan Schake 	return (struct vc4_crtc *)crtc;
43079271807SStefan Schake }
43179271807SStefan Schake 
432d3f5168aSEric Anholt #define V3D_READ(offset) readl(vc4->v3d->regs + offset)
433d3f5168aSEric Anholt #define V3D_WRITE(offset, val) writel(val, vc4->v3d->regs + offset)
434c8b75bcaSEric Anholt #define HVS_READ(offset) readl(vc4->hvs->regs + offset)
435c8b75bcaSEric Anholt #define HVS_WRITE(offset, val) writel(val, vc4->hvs->regs + offset)
436c8b75bcaSEric Anholt 
437d5b1a78aSEric Anholt struct vc4_exec_info {
438d5b1a78aSEric Anholt 	/* Sequence number for this bin/render job. */
439d5b1a78aSEric Anholt 	uint64_t seqno;
440d5b1a78aSEric Anholt 
4417edabee0SEric Anholt 	/* Latest write_seqno of any BO that binning depends on. */
4427edabee0SEric Anholt 	uint64_t bin_dep_seqno;
4437edabee0SEric Anholt 
444cdec4d36SEric Anholt 	struct dma_fence *fence;
445cdec4d36SEric Anholt 
446c4ce60dcSEric Anholt 	/* Last current addresses the hardware was processing when the
447c4ce60dcSEric Anholt 	 * hangcheck timer checked on us.
448c4ce60dcSEric Anholt 	 */
449c4ce60dcSEric Anholt 	uint32_t last_ct0ca, last_ct1ca;
450c4ce60dcSEric Anholt 
451d5b1a78aSEric Anholt 	/* Kernel-space copy of the ioctl arguments */
452d5b1a78aSEric Anholt 	struct drm_vc4_submit_cl *args;
453d5b1a78aSEric Anholt 
454d5b1a78aSEric Anholt 	/* This is the array of BOs that were looked up at the start of exec.
455d5b1a78aSEric Anholt 	 * Command validation will use indices into this array.
456d5b1a78aSEric Anholt 	 */
457d5b1a78aSEric Anholt 	struct drm_gem_cma_object **bo;
458d5b1a78aSEric Anholt 	uint32_t bo_count;
459d5b1a78aSEric Anholt 
4607edabee0SEric Anholt 	/* List of BOs that are being written by the RCL.  Other than
4617edabee0SEric Anholt 	 * the binner temporary storage, this is all the BOs written
4627edabee0SEric Anholt 	 * by the job.
4637edabee0SEric Anholt 	 */
4647edabee0SEric Anholt 	struct drm_gem_cma_object *rcl_write_bo[4];
4657edabee0SEric Anholt 	uint32_t rcl_write_bo_count;
4667edabee0SEric Anholt 
467d5b1a78aSEric Anholt 	/* Pointers for our position in vc4->job_list */
468d5b1a78aSEric Anholt 	struct list_head head;
469d5b1a78aSEric Anholt 
470d5b1a78aSEric Anholt 	/* List of other BOs used in the job that need to be released
471d5b1a78aSEric Anholt 	 * once the job is complete.
472d5b1a78aSEric Anholt 	 */
473d5b1a78aSEric Anholt 	struct list_head unref_list;
474d5b1a78aSEric Anholt 
475d5b1a78aSEric Anholt 	/* Current unvalidated indices into @bo loaded by the non-hardware
476d5b1a78aSEric Anholt 	 * VC4_PACKET_GEM_HANDLES.
477d5b1a78aSEric Anholt 	 */
478d5b1a78aSEric Anholt 	uint32_t bo_index[2];
479d5b1a78aSEric Anholt 
480d5b1a78aSEric Anholt 	/* This is the BO where we store the validated command lists, shader
481d5b1a78aSEric Anholt 	 * records, and uniforms.
482d5b1a78aSEric Anholt 	 */
483d5b1a78aSEric Anholt 	struct drm_gem_cma_object *exec_bo;
484d5b1a78aSEric Anholt 
485d5b1a78aSEric Anholt 	/**
486d5b1a78aSEric Anholt 	 * This tracks the per-shader-record state (packet 64) that
487d5b1a78aSEric Anholt 	 * determines the length of the shader record and the offset
488d5b1a78aSEric Anholt 	 * it's expected to be found at.  It gets read in from the
489d5b1a78aSEric Anholt 	 * command lists.
490d5b1a78aSEric Anholt 	 */
491d5b1a78aSEric Anholt 	struct vc4_shader_state {
492d5b1a78aSEric Anholt 		uint32_t addr;
493d5b1a78aSEric Anholt 		/* Maximum vertex index referenced by any primitive using this
494d5b1a78aSEric Anholt 		 * shader state.
495d5b1a78aSEric Anholt 		 */
496d5b1a78aSEric Anholt 		uint32_t max_index;
497d5b1a78aSEric Anholt 	} *shader_state;
498d5b1a78aSEric Anholt 
499d5b1a78aSEric Anholt 	/** How many shader states the user declared they were using. */
500d5b1a78aSEric Anholt 	uint32_t shader_state_size;
501d5b1a78aSEric Anholt 	/** How many shader state records the validator has seen. */
502d5b1a78aSEric Anholt 	uint32_t shader_state_count;
503d5b1a78aSEric Anholt 
504d5b1a78aSEric Anholt 	bool found_tile_binning_mode_config_packet;
505d5b1a78aSEric Anholt 	bool found_start_tile_binning_packet;
506d5b1a78aSEric Anholt 	bool found_increment_semaphore_packet;
507d5b1a78aSEric Anholt 	bool found_flush;
508d5b1a78aSEric Anholt 	uint8_t bin_tiles_x, bin_tiles_y;
509553c942fSEric Anholt 	/* Physical address of the start of the tile alloc array
510553c942fSEric Anholt 	 * (where each tile's binned CL will start)
511553c942fSEric Anholt 	 */
512d5b1a78aSEric Anholt 	uint32_t tile_alloc_offset;
513553c942fSEric Anholt 	/* Bitmask of which binner slots are freed when this job completes. */
514553c942fSEric Anholt 	uint32_t bin_slots;
515d5b1a78aSEric Anholt 
516d5b1a78aSEric Anholt 	/**
517d5b1a78aSEric Anholt 	 * Computed addresses pointing into exec_bo where we start the
518d5b1a78aSEric Anholt 	 * bin thread (ct0) and render thread (ct1).
519d5b1a78aSEric Anholt 	 */
520d5b1a78aSEric Anholt 	uint32_t ct0ca, ct0ea;
521d5b1a78aSEric Anholt 	uint32_t ct1ca, ct1ea;
522d5b1a78aSEric Anholt 
523d5b1a78aSEric Anholt 	/* Pointer to the unvalidated bin CL (if present). */
524d5b1a78aSEric Anholt 	void *bin_u;
525d5b1a78aSEric Anholt 
526d5b1a78aSEric Anholt 	/* Pointers to the shader recs.  These paddr gets incremented as CL
527d5b1a78aSEric Anholt 	 * packets are relocated in validate_gl_shader_state, and the vaddrs
528d5b1a78aSEric Anholt 	 * (u and v) get incremented and size decremented as the shader recs
529d5b1a78aSEric Anholt 	 * themselves are validated.
530d5b1a78aSEric Anholt 	 */
531d5b1a78aSEric Anholt 	void *shader_rec_u;
532d5b1a78aSEric Anholt 	void *shader_rec_v;
533d5b1a78aSEric Anholt 	uint32_t shader_rec_p;
534d5b1a78aSEric Anholt 	uint32_t shader_rec_size;
535d5b1a78aSEric Anholt 
536d5b1a78aSEric Anholt 	/* Pointers to the uniform data.  These pointers are incremented, and
537d5b1a78aSEric Anholt 	 * size decremented, as each batch of uniforms is uploaded.
538d5b1a78aSEric Anholt 	 */
539d5b1a78aSEric Anholt 	void *uniforms_u;
540d5b1a78aSEric Anholt 	void *uniforms_v;
541d5b1a78aSEric Anholt 	uint32_t uniforms_p;
542d5b1a78aSEric Anholt 	uint32_t uniforms_size;
54365101d8cSBoris Brezillon 
54465101d8cSBoris Brezillon 	/* Pointer to a performance monitor object if the user requested it,
54565101d8cSBoris Brezillon 	 * NULL otherwise.
54665101d8cSBoris Brezillon 	 */
54765101d8cSBoris Brezillon 	struct vc4_perfmon *perfmon;
54865101d8cSBoris Brezillon };
54965101d8cSBoris Brezillon 
55065101d8cSBoris Brezillon /* Per-open file private data. Any driver-specific resource that has to be
55165101d8cSBoris Brezillon  * released when the DRM file is closed should be placed here.
55265101d8cSBoris Brezillon  */
55365101d8cSBoris Brezillon struct vc4_file {
55465101d8cSBoris Brezillon 	struct {
55565101d8cSBoris Brezillon 		struct idr idr;
55665101d8cSBoris Brezillon 		struct mutex lock;
55765101d8cSBoris Brezillon 	} perfmon;
558d5b1a78aSEric Anholt };
559d5b1a78aSEric Anholt 
560d5b1a78aSEric Anholt static inline struct vc4_exec_info *
561ca26d28bSVarad Gautam vc4_first_bin_job(struct vc4_dev *vc4)
562d5b1a78aSEric Anholt {
56357b9f569SMasahiro Yamada 	return list_first_entry_or_null(&vc4->bin_job_list,
56457b9f569SMasahiro Yamada 					struct vc4_exec_info, head);
565ca26d28bSVarad Gautam }
566ca26d28bSVarad Gautam 
567ca26d28bSVarad Gautam static inline struct vc4_exec_info *
568ca26d28bSVarad Gautam vc4_first_render_job(struct vc4_dev *vc4)
569ca26d28bSVarad Gautam {
57057b9f569SMasahiro Yamada 	return list_first_entry_or_null(&vc4->render_job_list,
571ca26d28bSVarad Gautam 					struct vc4_exec_info, head);
572d5b1a78aSEric Anholt }
573d5b1a78aSEric Anholt 
5749326e6f2SEric Anholt static inline struct vc4_exec_info *
5759326e6f2SEric Anholt vc4_last_render_job(struct vc4_dev *vc4)
5769326e6f2SEric Anholt {
5779326e6f2SEric Anholt 	if (list_empty(&vc4->render_job_list))
5789326e6f2SEric Anholt 		return NULL;
5799326e6f2SEric Anholt 	return list_last_entry(&vc4->render_job_list,
5809326e6f2SEric Anholt 			       struct vc4_exec_info, head);
5819326e6f2SEric Anholt }
5829326e6f2SEric Anholt 
583c8b75bcaSEric Anholt /**
584463873d5SEric Anholt  * struct vc4_texture_sample_info - saves the offsets into the UBO for texture
585463873d5SEric Anholt  * setup parameters.
586463873d5SEric Anholt  *
587463873d5SEric Anholt  * This will be used at draw time to relocate the reference to the texture
588463873d5SEric Anholt  * contents in p0, and validate that the offset combined with
589463873d5SEric Anholt  * width/height/stride/etc. from p1 and p2/p3 doesn't sample outside the BO.
590463873d5SEric Anholt  * Note that the hardware treats unprovided config parameters as 0, so not all
591463873d5SEric Anholt  * of them need to be set up for every texure sample, and we'll store ~0 as
592463873d5SEric Anholt  * the offset to mark the unused ones.
593463873d5SEric Anholt  *
594463873d5SEric Anholt  * See the VC4 3D architecture guide page 41 ("Texture and Memory Lookup Unit
595463873d5SEric Anholt  * Setup") for definitions of the texture parameters.
596463873d5SEric Anholt  */
597463873d5SEric Anholt struct vc4_texture_sample_info {
598463873d5SEric Anholt 	bool is_direct;
599463873d5SEric Anholt 	uint32_t p_offset[4];
600463873d5SEric Anholt };
601463873d5SEric Anholt 
602463873d5SEric Anholt /**
603463873d5SEric Anholt  * struct vc4_validated_shader_info - information about validated shaders that
604463873d5SEric Anholt  * needs to be used from command list validation.
605463873d5SEric Anholt  *
606463873d5SEric Anholt  * For a given shader, each time a shader state record references it, we need
607463873d5SEric Anholt  * to verify that the shader doesn't read more uniforms than the shader state
608463873d5SEric Anholt  * record's uniform BO pointer can provide, and we need to apply relocations
609463873d5SEric Anholt  * and validate the shader state record's uniforms that define the texture
610463873d5SEric Anholt  * samples.
611463873d5SEric Anholt  */
612463873d5SEric Anholt struct vc4_validated_shader_info {
613463873d5SEric Anholt 	uint32_t uniforms_size;
614463873d5SEric Anholt 	uint32_t uniforms_src_size;
615463873d5SEric Anholt 	uint32_t num_texture_samples;
616463873d5SEric Anholt 	struct vc4_texture_sample_info *texture_samples;
6176d45c81dSEric Anholt 
6186d45c81dSEric Anholt 	uint32_t num_uniform_addr_offsets;
6196d45c81dSEric Anholt 	uint32_t *uniform_addr_offsets;
620c778cc5dSJonas Pfeil 
621c778cc5dSJonas Pfeil 	bool is_threaded;
622463873d5SEric Anholt };
623463873d5SEric Anholt 
624463873d5SEric Anholt /**
625c8b75bcaSEric Anholt  * _wait_for - magic (register) wait macro
626c8b75bcaSEric Anholt  *
627c8b75bcaSEric Anholt  * Does the right thing for modeset paths when run under kdgb or similar atomic
628c8b75bcaSEric Anholt  * contexts. Note that it's important that we check the condition again after
629c8b75bcaSEric Anholt  * having timed out, since the timeout could be due to preemption or similar and
630c8b75bcaSEric Anholt  * we've never had a chance to check the condition before the timeout.
631c8b75bcaSEric Anholt  */
632c8b75bcaSEric Anholt #define _wait_for(COND, MS, W) ({ \
633c8b75bcaSEric Anholt 	unsigned long timeout__ = jiffies + msecs_to_jiffies(MS) + 1;	\
634c8b75bcaSEric Anholt 	int ret__ = 0;							\
635c8b75bcaSEric Anholt 	while (!(COND)) {						\
636c8b75bcaSEric Anholt 		if (time_after(jiffies, timeout__)) {			\
637c8b75bcaSEric Anholt 			if (!(COND))					\
638c8b75bcaSEric Anholt 				ret__ = -ETIMEDOUT;			\
639c8b75bcaSEric Anholt 			break;						\
640c8b75bcaSEric Anholt 		}							\
641c8b75bcaSEric Anholt 		if (W && drm_can_sleep())  {				\
642c8b75bcaSEric Anholt 			msleep(W);					\
643c8b75bcaSEric Anholt 		} else {						\
644c8b75bcaSEric Anholt 			cpu_relax();					\
645c8b75bcaSEric Anholt 		}							\
646c8b75bcaSEric Anholt 	}								\
647c8b75bcaSEric Anholt 	ret__;								\
648c8b75bcaSEric Anholt })
649c8b75bcaSEric Anholt 
650c8b75bcaSEric Anholt #define wait_for(COND, MS) _wait_for(COND, MS, 1)
651c8b75bcaSEric Anholt 
652c8b75bcaSEric Anholt /* vc4_bo.c */
653c826a6e1SEric Anholt struct drm_gem_object *vc4_create_object(struct drm_device *dev, size_t size);
654c8b75bcaSEric Anholt void vc4_free_object(struct drm_gem_object *gem_obj);
655c826a6e1SEric Anholt struct vc4_bo *vc4_bo_create(struct drm_device *dev, size_t size,
656f3099462SEric Anholt 			     bool from_cache, enum vc4_kernel_bo_type type);
657c8b75bcaSEric Anholt int vc4_dumb_create(struct drm_file *file_priv,
658c8b75bcaSEric Anholt 		    struct drm_device *dev,
659c8b75bcaSEric Anholt 		    struct drm_mode_create_dumb *args);
660c8b75bcaSEric Anholt struct dma_buf *vc4_prime_export(struct drm_device *dev,
661c8b75bcaSEric Anholt 				 struct drm_gem_object *obj, int flags);
662d5bc60f6SEric Anholt int vc4_create_bo_ioctl(struct drm_device *dev, void *data,
663d5bc60f6SEric Anholt 			struct drm_file *file_priv);
664463873d5SEric Anholt int vc4_create_shader_bo_ioctl(struct drm_device *dev, void *data,
665463873d5SEric Anholt 			       struct drm_file *file_priv);
666d5bc60f6SEric Anholt int vc4_mmap_bo_ioctl(struct drm_device *dev, void *data,
667d5bc60f6SEric Anholt 		      struct drm_file *file_priv);
66883753117SEric Anholt int vc4_set_tiling_ioctl(struct drm_device *dev, void *data,
66983753117SEric Anholt 			 struct drm_file *file_priv);
67083753117SEric Anholt int vc4_get_tiling_ioctl(struct drm_device *dev, void *data,
67183753117SEric Anholt 			 struct drm_file *file_priv);
67221461365SEric Anholt int vc4_get_hang_state_ioctl(struct drm_device *dev, void *data,
67321461365SEric Anholt 			     struct drm_file *file_priv);
674f3099462SEric Anholt int vc4_label_bo_ioctl(struct drm_device *dev, void *data,
675f3099462SEric Anholt 		       struct drm_file *file_priv);
676b9f19259SBoris Brezillon int vc4_fault(struct vm_fault *vmf);
677463873d5SEric Anholt int vc4_mmap(struct file *filp, struct vm_area_struct *vma);
678cdec4d36SEric Anholt struct reservation_object *vc4_prime_res_obj(struct drm_gem_object *obj);
679463873d5SEric Anholt int vc4_prime_mmap(struct drm_gem_object *obj, struct vm_area_struct *vma);
680cdec4d36SEric Anholt struct drm_gem_object *vc4_prime_import_sg_table(struct drm_device *dev,
681cdec4d36SEric Anholt 						 struct dma_buf_attachment *attach,
682cdec4d36SEric Anholt 						 struct sg_table *sgt);
683463873d5SEric Anholt void *vc4_prime_vmap(struct drm_gem_object *obj);
684f3099462SEric Anholt int vc4_bo_cache_init(struct drm_device *dev);
685c826a6e1SEric Anholt void vc4_bo_cache_destroy(struct drm_device *dev);
686c826a6e1SEric Anholt int vc4_bo_stats_debugfs(struct seq_file *m, void *arg);
687b9f19259SBoris Brezillon int vc4_bo_inc_usecnt(struct vc4_bo *bo);
688b9f19259SBoris Brezillon void vc4_bo_dec_usecnt(struct vc4_bo *bo);
689b9f19259SBoris Brezillon void vc4_bo_add_to_purgeable_pool(struct vc4_bo *bo);
690b9f19259SBoris Brezillon void vc4_bo_remove_from_purgeable_pool(struct vc4_bo *bo);
691c8b75bcaSEric Anholt 
692c8b75bcaSEric Anholt /* vc4_crtc.c */
693c8b75bcaSEric Anholt extern struct platform_driver vc4_crtc_driver;
694c8b75bcaSEric Anholt int vc4_crtc_debugfs_regs(struct seq_file *m, void *arg);
6951bf6ad62SDaniel Vetter bool vc4_crtc_get_scanoutpos(struct drm_device *dev, unsigned int crtc_id,
6961bf6ad62SDaniel Vetter 			     bool in_vblank_irq, int *vpos, int *hpos,
6971bf59f1dSMario Kleiner 			     ktime_t *stime, ktime_t *etime,
6981bf59f1dSMario Kleiner 			     const struct drm_display_mode *mode);
699c8b75bcaSEric Anholt 
700c8b75bcaSEric Anholt /* vc4_debugfs.c */
701c8b75bcaSEric Anholt int vc4_debugfs_init(struct drm_minor *minor);
702c8b75bcaSEric Anholt 
703c8b75bcaSEric Anholt /* vc4_drv.c */
704c8b75bcaSEric Anholt void __iomem *vc4_ioremap_regs(struct platform_device *dev, int index);
705c8b75bcaSEric Anholt 
70608302c35SEric Anholt /* vc4_dpi.c */
70708302c35SEric Anholt extern struct platform_driver vc4_dpi_driver;
70808302c35SEric Anholt int vc4_dpi_debugfs_regs(struct seq_file *m, void *unused);
70908302c35SEric Anholt 
7104078f575SEric Anholt /* vc4_dsi.c */
7114078f575SEric Anholt extern struct platform_driver vc4_dsi_driver;
7124078f575SEric Anholt int vc4_dsi_debugfs_regs(struct seq_file *m, void *unused);
7134078f575SEric Anholt 
714cdec4d36SEric Anholt /* vc4_fence.c */
715cdec4d36SEric Anholt extern const struct dma_fence_ops vc4_fence_ops;
716cdec4d36SEric Anholt 
717d5b1a78aSEric Anholt /* vc4_gem.c */
718d5b1a78aSEric Anholt void vc4_gem_init(struct drm_device *dev);
719d5b1a78aSEric Anholt void vc4_gem_destroy(struct drm_device *dev);
720d5b1a78aSEric Anholt int vc4_submit_cl_ioctl(struct drm_device *dev, void *data,
721d5b1a78aSEric Anholt 			struct drm_file *file_priv);
722d5b1a78aSEric Anholt int vc4_wait_seqno_ioctl(struct drm_device *dev, void *data,
723d5b1a78aSEric Anholt 			 struct drm_file *file_priv);
724d5b1a78aSEric Anholt int vc4_wait_bo_ioctl(struct drm_device *dev, void *data,
725d5b1a78aSEric Anholt 		      struct drm_file *file_priv);
726ca26d28bSVarad Gautam void vc4_submit_next_bin_job(struct drm_device *dev);
727ca26d28bSVarad Gautam void vc4_submit_next_render_job(struct drm_device *dev);
728ca26d28bSVarad Gautam void vc4_move_job_to_render(struct drm_device *dev, struct vc4_exec_info *exec);
729d5b1a78aSEric Anholt int vc4_wait_for_seqno(struct drm_device *dev, uint64_t seqno,
730d5b1a78aSEric Anholt 		       uint64_t timeout_ns, bool interruptible);
731d5b1a78aSEric Anholt void vc4_job_handle_completed(struct vc4_dev *vc4);
732b501baccSEric Anholt int vc4_queue_seqno_cb(struct drm_device *dev,
733b501baccSEric Anholt 		       struct vc4_seqno_cb *cb, uint64_t seqno,
734b501baccSEric Anholt 		       void (*func)(struct vc4_seqno_cb *cb));
735b9f19259SBoris Brezillon int vc4_gem_madvise_ioctl(struct drm_device *dev, void *data,
736b9f19259SBoris Brezillon 			  struct drm_file *file_priv);
737d5b1a78aSEric Anholt 
738c8b75bcaSEric Anholt /* vc4_hdmi.c */
739c8b75bcaSEric Anholt extern struct platform_driver vc4_hdmi_driver;
740c8b75bcaSEric Anholt int vc4_hdmi_debugfs_regs(struct seq_file *m, void *unused);
741c8b75bcaSEric Anholt 
7429a8d5e4aSBoris Brezillon /* vc4_vec.c */
743e4b81f8cSBoris Brezillon extern struct platform_driver vc4_vec_driver;
744e4b81f8cSBoris Brezillon int vc4_vec_debugfs_regs(struct seq_file *m, void *unused);
745e4b81f8cSBoris Brezillon 
746d5b1a78aSEric Anholt /* vc4_irq.c */
747d5b1a78aSEric Anholt irqreturn_t vc4_irq(int irq, void *arg);
748d5b1a78aSEric Anholt void vc4_irq_preinstall(struct drm_device *dev);
749d5b1a78aSEric Anholt int vc4_irq_postinstall(struct drm_device *dev);
750d5b1a78aSEric Anholt void vc4_irq_uninstall(struct drm_device *dev);
751d5b1a78aSEric Anholt void vc4_irq_reset(struct drm_device *dev);
752d5b1a78aSEric Anholt 
753c8b75bcaSEric Anholt /* vc4_hvs.c */
754c8b75bcaSEric Anholt extern struct platform_driver vc4_hvs_driver;
755c8b75bcaSEric Anholt void vc4_hvs_dump_state(struct drm_device *dev);
756c8b75bcaSEric Anholt int vc4_hvs_debugfs_regs(struct seq_file *m, void *unused);
757c8b75bcaSEric Anholt 
758c8b75bcaSEric Anholt /* vc4_kms.c */
759c8b75bcaSEric Anholt int vc4_kms_load(struct drm_device *dev);
760c8b75bcaSEric Anholt 
761c8b75bcaSEric Anholt /* vc4_plane.c */
762c8b75bcaSEric Anholt struct drm_plane *vc4_plane_init(struct drm_device *dev,
763c8b75bcaSEric Anholt 				 enum drm_plane_type type);
764c8b75bcaSEric Anholt u32 vc4_plane_write_dlist(struct drm_plane *plane, u32 __iomem *dlist);
7652f196b7cSDaniel Vetter u32 vc4_plane_dlist_size(const struct drm_plane_state *state);
766b501baccSEric Anholt void vc4_plane_async_set_fb(struct drm_plane *plane,
767b501baccSEric Anholt 			    struct drm_framebuffer *fb);
768463873d5SEric Anholt 
769d3f5168aSEric Anholt /* vc4_v3d.c */
770d3f5168aSEric Anholt extern struct platform_driver vc4_v3d_driver;
771d3f5168aSEric Anholt int vc4_v3d_debugfs_ident(struct seq_file *m, void *unused);
772d3f5168aSEric Anholt int vc4_v3d_debugfs_regs(struct seq_file *m, void *unused);
773553c942fSEric Anholt int vc4_v3d_get_bin_slot(struct vc4_dev *vc4);
774d5b1a78aSEric Anholt 
775d5b1a78aSEric Anholt /* vc4_validate.c */
776d5b1a78aSEric Anholt int
777d5b1a78aSEric Anholt vc4_validate_bin_cl(struct drm_device *dev,
778d5b1a78aSEric Anholt 		    void *validated,
779d5b1a78aSEric Anholt 		    void *unvalidated,
780d5b1a78aSEric Anholt 		    struct vc4_exec_info *exec);
781d5b1a78aSEric Anholt 
782d5b1a78aSEric Anholt int
783d5b1a78aSEric Anholt vc4_validate_shader_recs(struct drm_device *dev, struct vc4_exec_info *exec);
784d5b1a78aSEric Anholt 
785d5b1a78aSEric Anholt struct drm_gem_cma_object *vc4_use_bo(struct vc4_exec_info *exec,
786d5b1a78aSEric Anholt 				      uint32_t hindex);
787d5b1a78aSEric Anholt 
788d5b1a78aSEric Anholt int vc4_get_rcl(struct drm_device *dev, struct vc4_exec_info *exec);
789d5b1a78aSEric Anholt 
790d5b1a78aSEric Anholt bool vc4_check_tex_size(struct vc4_exec_info *exec,
791d5b1a78aSEric Anholt 			struct drm_gem_cma_object *fbo,
792d5b1a78aSEric Anholt 			uint32_t offset, uint8_t tiling_format,
793d5b1a78aSEric Anholt 			uint32_t width, uint32_t height, uint8_t cpp);
794d3f5168aSEric Anholt 
795463873d5SEric Anholt /* vc4_validate_shader.c */
796463873d5SEric Anholt struct vc4_validated_shader_info *
797463873d5SEric Anholt vc4_validate_shader(struct drm_gem_cma_object *shader_obj);
79865101d8cSBoris Brezillon 
79965101d8cSBoris Brezillon /* vc4_perfmon.c */
80065101d8cSBoris Brezillon void vc4_perfmon_get(struct vc4_perfmon *perfmon);
80165101d8cSBoris Brezillon void vc4_perfmon_put(struct vc4_perfmon *perfmon);
80265101d8cSBoris Brezillon void vc4_perfmon_start(struct vc4_dev *vc4, struct vc4_perfmon *perfmon);
80365101d8cSBoris Brezillon void vc4_perfmon_stop(struct vc4_dev *vc4, struct vc4_perfmon *perfmon,
80465101d8cSBoris Brezillon 		      bool capture);
80565101d8cSBoris Brezillon struct vc4_perfmon *vc4_perfmon_find(struct vc4_file *vc4file, int id);
80665101d8cSBoris Brezillon void vc4_perfmon_open_file(struct vc4_file *vc4file);
80765101d8cSBoris Brezillon void vc4_perfmon_close_file(struct vc4_file *vc4file);
80865101d8cSBoris Brezillon int vc4_perfmon_create_ioctl(struct drm_device *dev, void *data,
80965101d8cSBoris Brezillon 			     struct drm_file *file_priv);
81065101d8cSBoris Brezillon int vc4_perfmon_destroy_ioctl(struct drm_device *dev, void *data,
81165101d8cSBoris Brezillon 			      struct drm_file *file_priv);
81265101d8cSBoris Brezillon int vc4_perfmon_get_values_ioctl(struct drm_device *dev, void *data,
81365101d8cSBoris Brezillon 				 struct drm_file *file_priv);
814