xref: /linux/drivers/gpu/drm/vc4/vc4_drv.h (revision 823646983b5a31732ae82ffa60b74555857eb8a0)
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>
139338203cSLaurent Pinchart 
1465101d8cSBoris Brezillon #include "uapi/drm/vc4_drm.h"
1565101d8cSBoris Brezillon 
16f3099462SEric Anholt /* Don't forget to update vc4_bo.c: bo_type_names[] when adding to
17f3099462SEric Anholt  * this.
18f3099462SEric Anholt  */
19f3099462SEric Anholt enum vc4_kernel_bo_type {
20f3099462SEric Anholt 	/* Any kernel allocation (gem_create_object hook) before it
21f3099462SEric Anholt 	 * gets another type set.
22f3099462SEric Anholt 	 */
23f3099462SEric Anholt 	VC4_BO_TYPE_KERNEL,
24f3099462SEric Anholt 	VC4_BO_TYPE_V3D,
25f3099462SEric Anholt 	VC4_BO_TYPE_V3D_SHADER,
26f3099462SEric Anholt 	VC4_BO_TYPE_DUMB,
27f3099462SEric Anholt 	VC4_BO_TYPE_BIN,
28f3099462SEric Anholt 	VC4_BO_TYPE_RCL,
29f3099462SEric Anholt 	VC4_BO_TYPE_BCL,
30f3099462SEric Anholt 	VC4_BO_TYPE_KERNEL_CACHE,
31f3099462SEric Anholt 	VC4_BO_TYPE_COUNT
32f3099462SEric Anholt };
33f3099462SEric Anholt 
3465101d8cSBoris Brezillon /* Performance monitor object. The perform lifetime is controlled by userspace
3565101d8cSBoris Brezillon  * using perfmon related ioctls. A perfmon can be attached to a submit_cl
3665101d8cSBoris Brezillon  * request, and when this is the case, HW perf counters will be activated just
3765101d8cSBoris Brezillon  * before the submit_cl is submitted to the GPU and disabled when the job is
3865101d8cSBoris Brezillon  * done. This way, only events related to a specific job will be counted.
3965101d8cSBoris Brezillon  */
4065101d8cSBoris Brezillon struct vc4_perfmon {
4165101d8cSBoris Brezillon 	/* Tracks the number of users of the perfmon, when this counter reaches
4265101d8cSBoris Brezillon 	 * zero the perfmon is destroyed.
4365101d8cSBoris Brezillon 	 */
4465101d8cSBoris Brezillon 	refcount_t refcnt;
4565101d8cSBoris Brezillon 
4665101d8cSBoris Brezillon 	/* Number of counters activated in this perfmon instance
4765101d8cSBoris Brezillon 	 * (should be less than DRM_VC4_MAX_PERF_COUNTERS).
4865101d8cSBoris Brezillon 	 */
4965101d8cSBoris Brezillon 	u8 ncounters;
5065101d8cSBoris Brezillon 
5165101d8cSBoris Brezillon 	/* Events counted by the HW perf counters. */
5265101d8cSBoris Brezillon 	u8 events[DRM_VC4_MAX_PERF_COUNTERS];
5365101d8cSBoris Brezillon 
5465101d8cSBoris Brezillon 	/* Storage for counter values. Counters are incremented by the HW
5565101d8cSBoris Brezillon 	 * perf counter values every time the perfmon is attached to a GPU job.
5665101d8cSBoris Brezillon 	 * This way, perfmon users don't have to retrieve the results after
5765101d8cSBoris Brezillon 	 * each job if they want to track events covering several submissions.
5865101d8cSBoris Brezillon 	 * Note that counter values can't be reset, but you can fake a reset by
5965101d8cSBoris Brezillon 	 * destroying the perfmon and creating a new one.
6065101d8cSBoris Brezillon 	 */
6165101d8cSBoris Brezillon 	u64 counters[0];
6265101d8cSBoris Brezillon };
6365101d8cSBoris Brezillon 
64c8b75bcaSEric Anholt struct vc4_dev {
65c8b75bcaSEric Anholt 	struct drm_device *dev;
66c8b75bcaSEric Anholt 
67c8b75bcaSEric Anholt 	struct vc4_hdmi *hdmi;
68c8b75bcaSEric Anholt 	struct vc4_hvs *hvs;
69d3f5168aSEric Anholt 	struct vc4_v3d *v3d;
7008302c35SEric Anholt 	struct vc4_dpi *dpi;
714078f575SEric Anholt 	struct vc4_dsi *dsi1;
72e4b81f8cSBoris Brezillon 	struct vc4_vec *vec;
7348666d56SDerek Foreman 
7421461365SEric Anholt 	struct vc4_hang_state *hang_state;
7521461365SEric Anholt 
76c826a6e1SEric Anholt 	/* The kernel-space BO cache.  Tracks buffers that have been
77c826a6e1SEric Anholt 	 * unreferenced by all other users (refcounts of 0!) but not
78c826a6e1SEric Anholt 	 * yet freed, so we can do cheap allocations.
79c826a6e1SEric Anholt 	 */
80c826a6e1SEric Anholt 	struct vc4_bo_cache {
81c826a6e1SEric Anholt 		/* Array of list heads for entries in the BO cache,
82c826a6e1SEric Anholt 		 * based on number of pages, so we can do O(1) lookups
83c826a6e1SEric Anholt 		 * in the cache when allocating.
84c826a6e1SEric Anholt 		 */
85c826a6e1SEric Anholt 		struct list_head *size_list;
86c826a6e1SEric Anholt 		uint32_t size_list_size;
87c826a6e1SEric Anholt 
88c826a6e1SEric Anholt 		/* List of all BOs in the cache, ordered by age, so we
89c826a6e1SEric Anholt 		 * can do O(1) lookups when trying to free old
90c826a6e1SEric Anholt 		 * buffers.
91c826a6e1SEric Anholt 		 */
92c826a6e1SEric Anholt 		struct list_head time_list;
93c826a6e1SEric Anholt 		struct work_struct time_work;
94c826a6e1SEric Anholt 		struct timer_list time_timer;
95c826a6e1SEric Anholt 	} bo_cache;
96c826a6e1SEric Anholt 
97f3099462SEric Anholt 	u32 num_labels;
98f3099462SEric Anholt 	struct vc4_label {
99f3099462SEric Anholt 		const char *name;
100c826a6e1SEric Anholt 		u32 num_allocated;
101c826a6e1SEric Anholt 		u32 size_allocated;
102f3099462SEric Anholt 	} *bo_labels;
103c826a6e1SEric Anholt 
104f3099462SEric Anholt 	/* Protects bo_cache and bo_labels. */
105c826a6e1SEric Anholt 	struct mutex bo_lock;
106d5b1a78aSEric Anholt 
107b9f19259SBoris Brezillon 	/* Purgeable BO pool. All BOs in this pool can have their memory
108b9f19259SBoris Brezillon 	 * reclaimed if the driver is unable to allocate new BOs. We also
109b9f19259SBoris Brezillon 	 * keep stats related to the purge mechanism here.
110b9f19259SBoris Brezillon 	 */
111b9f19259SBoris Brezillon 	struct {
112b9f19259SBoris Brezillon 		struct list_head list;
113b9f19259SBoris Brezillon 		unsigned int num;
114b9f19259SBoris Brezillon 		size_t size;
115b9f19259SBoris Brezillon 		unsigned int purged_num;
116b9f19259SBoris Brezillon 		size_t purged_size;
117b9f19259SBoris Brezillon 		struct mutex lock;
118b9f19259SBoris Brezillon 	} purgeable;
119b9f19259SBoris Brezillon 
120cdec4d36SEric Anholt 	uint64_t dma_fence_context;
121cdec4d36SEric Anholt 
122ca26d28bSVarad Gautam 	/* Sequence number for the last job queued in bin_job_list.
123d5b1a78aSEric Anholt 	 * Starts at 0 (no jobs emitted).
124d5b1a78aSEric Anholt 	 */
125d5b1a78aSEric Anholt 	uint64_t emit_seqno;
126d5b1a78aSEric Anholt 
127d5b1a78aSEric Anholt 	/* Sequence number for the last completed job on the GPU.
128d5b1a78aSEric Anholt 	 * Starts at 0 (no jobs completed).
129d5b1a78aSEric Anholt 	 */
130d5b1a78aSEric Anholt 	uint64_t finished_seqno;
131d5b1a78aSEric Anholt 
132ca26d28bSVarad Gautam 	/* List of all struct vc4_exec_info for jobs to be executed in
133ca26d28bSVarad Gautam 	 * the binner.  The first job in the list is the one currently
134ca26d28bSVarad Gautam 	 * programmed into ct0ca for execution.
135d5b1a78aSEric Anholt 	 */
136ca26d28bSVarad Gautam 	struct list_head bin_job_list;
137ca26d28bSVarad Gautam 
138ca26d28bSVarad Gautam 	/* List of all struct vc4_exec_info for jobs that have
139ca26d28bSVarad Gautam 	 * completed binning and are ready for rendering.  The first
140ca26d28bSVarad Gautam 	 * job in the list is the one currently programmed into ct1ca
141ca26d28bSVarad Gautam 	 * for execution.
142ca26d28bSVarad Gautam 	 */
143ca26d28bSVarad Gautam 	struct list_head render_job_list;
144ca26d28bSVarad Gautam 
145d5b1a78aSEric Anholt 	/* List of the finished vc4_exec_infos waiting to be freed by
146d5b1a78aSEric Anholt 	 * job_done_work.
147d5b1a78aSEric Anholt 	 */
148d5b1a78aSEric Anholt 	struct list_head job_done_list;
149d5b1a78aSEric Anholt 	/* Spinlock used to synchronize the job_list and seqno
150d5b1a78aSEric Anholt 	 * accesses between the IRQ handler and GEM ioctls.
151d5b1a78aSEric Anholt 	 */
152d5b1a78aSEric Anholt 	spinlock_t job_lock;
153d5b1a78aSEric Anholt 	wait_queue_head_t job_wait_queue;
154d5b1a78aSEric Anholt 	struct work_struct job_done_work;
155d5b1a78aSEric Anholt 
15665101d8cSBoris Brezillon 	/* Used to track the active perfmon if any. Access to this field is
15765101d8cSBoris Brezillon 	 * protected by job_lock.
15865101d8cSBoris Brezillon 	 */
15965101d8cSBoris Brezillon 	struct vc4_perfmon *active_perfmon;
16065101d8cSBoris Brezillon 
161b501baccSEric Anholt 	/* List of struct vc4_seqno_cb for callbacks to be made from a
162b501baccSEric Anholt 	 * workqueue when the given seqno is passed.
163b501baccSEric Anholt 	 */
164b501baccSEric Anholt 	struct list_head seqno_cb_list;
165b501baccSEric Anholt 
166553c942fSEric Anholt 	/* The memory used for storing binner tile alloc, tile state,
167553c942fSEric Anholt 	 * and overflow memory allocations.  This is freed when V3D
168553c942fSEric Anholt 	 * powers down.
169d5b1a78aSEric Anholt 	 */
170553c942fSEric Anholt 	struct vc4_bo *bin_bo;
171553c942fSEric Anholt 
172553c942fSEric Anholt 	/* Size of blocks allocated within bin_bo. */
173553c942fSEric Anholt 	uint32_t bin_alloc_size;
174553c942fSEric Anholt 
175553c942fSEric Anholt 	/* Bitmask of the bin_alloc_size chunks in bin_bo that are
176553c942fSEric Anholt 	 * used.
177553c942fSEric Anholt 	 */
178553c942fSEric Anholt 	uint32_t bin_alloc_used;
179553c942fSEric Anholt 
180553c942fSEric Anholt 	/* Bitmask of the current bin_alloc used for overflow memory. */
181553c942fSEric Anholt 	uint32_t bin_alloc_overflow;
182553c942fSEric Anholt 
183d5b1a78aSEric Anholt 	struct work_struct overflow_mem_work;
184d5b1a78aSEric Anholt 
18536cb6253SEric Anholt 	int power_refcount;
18636cb6253SEric Anholt 
18736cb6253SEric Anholt 	/* Mutex controlling the power refcount. */
18836cb6253SEric Anholt 	struct mutex power_lock;
18936cb6253SEric Anholt 
190d5b1a78aSEric Anholt 	struct {
191d5b1a78aSEric Anholt 		struct timer_list timer;
192d5b1a78aSEric Anholt 		struct work_struct reset_work;
193d5b1a78aSEric Anholt 	} hangcheck;
194d5b1a78aSEric Anholt 
195d5b1a78aSEric Anholt 	struct semaphore async_modeset;
196c8b75bcaSEric Anholt };
197c8b75bcaSEric Anholt 
198c8b75bcaSEric Anholt static inline struct vc4_dev *
199c8b75bcaSEric Anholt to_vc4_dev(struct drm_device *dev)
200c8b75bcaSEric Anholt {
201c8b75bcaSEric Anholt 	return (struct vc4_dev *)dev->dev_private;
202c8b75bcaSEric Anholt }
203c8b75bcaSEric Anholt 
204c8b75bcaSEric Anholt struct vc4_bo {
205c8b75bcaSEric Anholt 	struct drm_gem_cma_object base;
206c826a6e1SEric Anholt 
2077edabee0SEric Anholt 	/* seqno of the last job to render using this BO. */
208d5b1a78aSEric Anholt 	uint64_t seqno;
209d5b1a78aSEric Anholt 
2107edabee0SEric Anholt 	/* seqno of the last job to use the RCL to write to this BO.
2117edabee0SEric Anholt 	 *
2127edabee0SEric Anholt 	 * Note that this doesn't include binner overflow memory
2137edabee0SEric Anholt 	 * writes.
2147edabee0SEric Anholt 	 */
2157edabee0SEric Anholt 	uint64_t write_seqno;
2167edabee0SEric Anholt 
21783753117SEric Anholt 	bool t_format;
21883753117SEric Anholt 
219c826a6e1SEric Anholt 	/* List entry for the BO's position in either
220c826a6e1SEric Anholt 	 * vc4_exec_info->unref_list or vc4_dev->bo_cache.time_list
221c826a6e1SEric Anholt 	 */
222c826a6e1SEric Anholt 	struct list_head unref_head;
223c826a6e1SEric Anholt 
224c826a6e1SEric Anholt 	/* Time in jiffies when the BO was put in vc4->bo_cache. */
225c826a6e1SEric Anholt 	unsigned long free_time;
226c826a6e1SEric Anholt 
227c826a6e1SEric Anholt 	/* List entry for the BO's position in vc4_dev->bo_cache.size_list */
228c826a6e1SEric Anholt 	struct list_head size_head;
229463873d5SEric Anholt 
230463873d5SEric Anholt 	/* Struct for shader validation state, if created by
231463873d5SEric Anholt 	 * DRM_IOCTL_VC4_CREATE_SHADER_BO.
232463873d5SEric Anholt 	 */
233463873d5SEric Anholt 	struct vc4_validated_shader_info *validated_shader;
234cdec4d36SEric Anholt 
235cdec4d36SEric Anholt 	/* normally (resv == &_resv) except for imported bo's */
236cdec4d36SEric Anholt 	struct reservation_object *resv;
237cdec4d36SEric Anholt 	struct reservation_object _resv;
238f3099462SEric Anholt 
239f3099462SEric Anholt 	/* One of enum vc4_kernel_bo_type, or VC4_BO_TYPE_COUNT + i
240f3099462SEric Anholt 	 * for user-allocated labels.
241f3099462SEric Anholt 	 */
242f3099462SEric Anholt 	int label;
243b9f19259SBoris Brezillon 
244b9f19259SBoris Brezillon 	/* Count the number of active users. This is needed to determine
245b9f19259SBoris Brezillon 	 * whether we can move the BO to the purgeable list or not (when the BO
246b9f19259SBoris Brezillon 	 * is used by the GPU or the display engine we can't purge it).
247b9f19259SBoris Brezillon 	 */
248b9f19259SBoris Brezillon 	refcount_t usecnt;
249b9f19259SBoris Brezillon 
250b9f19259SBoris Brezillon 	/* Store purgeable/purged state here */
251b9f19259SBoris Brezillon 	u32 madv;
252b9f19259SBoris Brezillon 	struct mutex madv_lock;
253c8b75bcaSEric Anholt };
254c8b75bcaSEric Anholt 
255c8b75bcaSEric Anholt static inline struct vc4_bo *
256c8b75bcaSEric Anholt to_vc4_bo(struct drm_gem_object *bo)
257c8b75bcaSEric Anholt {
258c8b75bcaSEric Anholt 	return (struct vc4_bo *)bo;
259c8b75bcaSEric Anholt }
260c8b75bcaSEric Anholt 
261cdec4d36SEric Anholt struct vc4_fence {
262cdec4d36SEric Anholt 	struct dma_fence base;
263cdec4d36SEric Anholt 	struct drm_device *dev;
264cdec4d36SEric Anholt 	/* vc4 seqno for signaled() test */
265cdec4d36SEric Anholt 	uint64_t seqno;
266cdec4d36SEric Anholt };
267cdec4d36SEric Anholt 
268cdec4d36SEric Anholt static inline struct vc4_fence *
269cdec4d36SEric Anholt to_vc4_fence(struct dma_fence *fence)
270cdec4d36SEric Anholt {
271cdec4d36SEric Anholt 	return (struct vc4_fence *)fence;
272cdec4d36SEric Anholt }
273cdec4d36SEric Anholt 
274b501baccSEric Anholt struct vc4_seqno_cb {
275b501baccSEric Anholt 	struct work_struct work;
276b501baccSEric Anholt 	uint64_t seqno;
277b501baccSEric Anholt 	void (*func)(struct vc4_seqno_cb *cb);
278b501baccSEric Anholt };
279b501baccSEric Anholt 
280d3f5168aSEric Anholt struct vc4_v3d {
281001bdb55SEric Anholt 	struct vc4_dev *vc4;
282d3f5168aSEric Anholt 	struct platform_device *pdev;
283d3f5168aSEric Anholt 	void __iomem *regs;
284b72a2816SEric Anholt 	struct clk *clk;
285d3f5168aSEric Anholt };
286d3f5168aSEric Anholt 
287c8b75bcaSEric Anholt struct vc4_hvs {
288c8b75bcaSEric Anholt 	struct platform_device *pdev;
289c8b75bcaSEric Anholt 	void __iomem *regs;
290d8dbf44fSEric Anholt 	u32 __iomem *dlist;
291d8dbf44fSEric Anholt 
292d8dbf44fSEric Anholt 	/* Memory manager for CRTCs to allocate space in the display
293d8dbf44fSEric Anholt 	 * list.  Units are dwords.
294d8dbf44fSEric Anholt 	 */
295d8dbf44fSEric Anholt 	struct drm_mm dlist_mm;
29621af94cfSEric Anholt 	/* Memory manager for the LBM memory used by HVS scaling. */
29721af94cfSEric Anholt 	struct drm_mm lbm_mm;
298d8dbf44fSEric Anholt 	spinlock_t mm_lock;
29921af94cfSEric Anholt 
30021af94cfSEric Anholt 	struct drm_mm_node mitchell_netravali_filter;
301c8b75bcaSEric Anholt };
302c8b75bcaSEric Anholt 
303c8b75bcaSEric Anholt struct vc4_plane {
304c8b75bcaSEric Anholt 	struct drm_plane base;
305c8b75bcaSEric Anholt };
306c8b75bcaSEric Anholt 
307c8b75bcaSEric Anholt static inline struct vc4_plane *
308c8b75bcaSEric Anholt to_vc4_plane(struct drm_plane *plane)
309c8b75bcaSEric Anholt {
310c8b75bcaSEric Anholt 	return (struct vc4_plane *)plane;
311c8b75bcaSEric Anholt }
312c8b75bcaSEric Anholt 
313*82364698SStefan Schake enum vc4_scaling_mode {
314*82364698SStefan Schake 	VC4_SCALING_NONE,
315*82364698SStefan Schake 	VC4_SCALING_TPZ,
316*82364698SStefan Schake 	VC4_SCALING_PPF,
317*82364698SStefan Schake };
318*82364698SStefan Schake 
319*82364698SStefan Schake struct vc4_plane_state {
320*82364698SStefan Schake 	struct drm_plane_state base;
321*82364698SStefan Schake 	/* System memory copy of the display list for this element, computed
322*82364698SStefan Schake 	 * at atomic_check time.
323*82364698SStefan Schake 	 */
324*82364698SStefan Schake 	u32 *dlist;
325*82364698SStefan Schake 	u32 dlist_size; /* Number of dwords allocated for the display list */
326*82364698SStefan Schake 	u32 dlist_count; /* Number of used dwords in the display list. */
327*82364698SStefan Schake 
328*82364698SStefan Schake 	/* Offset in the dlist to various words, for pageflip or
329*82364698SStefan Schake 	 * cursor updates.
330*82364698SStefan Schake 	 */
331*82364698SStefan Schake 	u32 pos0_offset;
332*82364698SStefan Schake 	u32 pos2_offset;
333*82364698SStefan Schake 	u32 ptr0_offset;
334*82364698SStefan Schake 
335*82364698SStefan Schake 	/* Offset where the plane's dlist was last stored in the
336*82364698SStefan Schake 	 * hardware at vc4_crtc_atomic_flush() time.
337*82364698SStefan Schake 	 */
338*82364698SStefan Schake 	u32 __iomem *hw_dlist;
339*82364698SStefan Schake 
340*82364698SStefan Schake 	/* Clipped coordinates of the plane on the display. */
341*82364698SStefan Schake 	int crtc_x, crtc_y, crtc_w, crtc_h;
342*82364698SStefan Schake 	/* Clipped area being scanned from in the FB. */
343*82364698SStefan Schake 	u32 src_x, src_y;
344*82364698SStefan Schake 
345*82364698SStefan Schake 	u32 src_w[2], src_h[2];
346*82364698SStefan Schake 
347*82364698SStefan Schake 	/* Scaling selection for the RGB/Y plane and the Cb/Cr planes. */
348*82364698SStefan Schake 	enum vc4_scaling_mode x_scaling[2], y_scaling[2];
349*82364698SStefan Schake 	bool is_unity;
350*82364698SStefan Schake 	bool is_yuv;
351*82364698SStefan Schake 
352*82364698SStefan Schake 	/* Offset to start scanning out from the start of the plane's
353*82364698SStefan Schake 	 * BO.
354*82364698SStefan Schake 	 */
355*82364698SStefan Schake 	u32 offsets[3];
356*82364698SStefan Schake 
357*82364698SStefan Schake 	/* Our allocation in LBM for temporary storage during scaling. */
358*82364698SStefan Schake 	struct drm_mm_node lbm;
359*82364698SStefan Schake 
360*82364698SStefan Schake 	/* Set when the plane has per-pixel alpha content or does not cover
361*82364698SStefan Schake 	 * the entire screen. This is a hint to the CRTC that it might need
362*82364698SStefan Schake 	 * to enable background color fill.
363*82364698SStefan Schake 	 */
364*82364698SStefan Schake 	bool needs_bg_fill;
365*82364698SStefan Schake };
366*82364698SStefan Schake 
367*82364698SStefan Schake static inline struct vc4_plane_state *
368*82364698SStefan Schake to_vc4_plane_state(struct drm_plane_state *state)
369*82364698SStefan Schake {
370*82364698SStefan Schake 	return (struct vc4_plane_state *)state;
371*82364698SStefan Schake }
372*82364698SStefan Schake 
373c8b75bcaSEric Anholt enum vc4_encoder_type {
374ab8df60eSBoris Brezillon 	VC4_ENCODER_TYPE_NONE,
375c8b75bcaSEric Anholt 	VC4_ENCODER_TYPE_HDMI,
376c8b75bcaSEric Anholt 	VC4_ENCODER_TYPE_VEC,
377c8b75bcaSEric Anholt 	VC4_ENCODER_TYPE_DSI0,
378c8b75bcaSEric Anholt 	VC4_ENCODER_TYPE_DSI1,
379c8b75bcaSEric Anholt 	VC4_ENCODER_TYPE_SMI,
380c8b75bcaSEric Anholt 	VC4_ENCODER_TYPE_DPI,
381c8b75bcaSEric Anholt };
382c8b75bcaSEric Anholt 
383c8b75bcaSEric Anholt struct vc4_encoder {
384c8b75bcaSEric Anholt 	struct drm_encoder base;
385c8b75bcaSEric Anholt 	enum vc4_encoder_type type;
386c8b75bcaSEric Anholt 	u32 clock_select;
387c8b75bcaSEric Anholt };
388c8b75bcaSEric Anholt 
389c8b75bcaSEric Anholt static inline struct vc4_encoder *
390c8b75bcaSEric Anholt to_vc4_encoder(struct drm_encoder *encoder)
391c8b75bcaSEric Anholt {
392c8b75bcaSEric Anholt 	return container_of(encoder, struct vc4_encoder, base);
393c8b75bcaSEric Anholt }
394c8b75bcaSEric Anholt 
395d3f5168aSEric Anholt #define V3D_READ(offset) readl(vc4->v3d->regs + offset)
396d3f5168aSEric Anholt #define V3D_WRITE(offset, val) writel(val, vc4->v3d->regs + offset)
397c8b75bcaSEric Anholt #define HVS_READ(offset) readl(vc4->hvs->regs + offset)
398c8b75bcaSEric Anholt #define HVS_WRITE(offset, val) writel(val, vc4->hvs->regs + offset)
399c8b75bcaSEric Anholt 
400d5b1a78aSEric Anholt struct vc4_exec_info {
401d5b1a78aSEric Anholt 	/* Sequence number for this bin/render job. */
402d5b1a78aSEric Anholt 	uint64_t seqno;
403d5b1a78aSEric Anholt 
4047edabee0SEric Anholt 	/* Latest write_seqno of any BO that binning depends on. */
4057edabee0SEric Anholt 	uint64_t bin_dep_seqno;
4067edabee0SEric Anholt 
407cdec4d36SEric Anholt 	struct dma_fence *fence;
408cdec4d36SEric Anholt 
409c4ce60dcSEric Anholt 	/* Last current addresses the hardware was processing when the
410c4ce60dcSEric Anholt 	 * hangcheck timer checked on us.
411c4ce60dcSEric Anholt 	 */
412c4ce60dcSEric Anholt 	uint32_t last_ct0ca, last_ct1ca;
413c4ce60dcSEric Anholt 
414d5b1a78aSEric Anholt 	/* Kernel-space copy of the ioctl arguments */
415d5b1a78aSEric Anholt 	struct drm_vc4_submit_cl *args;
416d5b1a78aSEric Anholt 
417d5b1a78aSEric Anholt 	/* This is the array of BOs that were looked up at the start of exec.
418d5b1a78aSEric Anholt 	 * Command validation will use indices into this array.
419d5b1a78aSEric Anholt 	 */
420d5b1a78aSEric Anholt 	struct drm_gem_cma_object **bo;
421d5b1a78aSEric Anholt 	uint32_t bo_count;
422d5b1a78aSEric Anholt 
4237edabee0SEric Anholt 	/* List of BOs that are being written by the RCL.  Other than
4247edabee0SEric Anholt 	 * the binner temporary storage, this is all the BOs written
4257edabee0SEric Anholt 	 * by the job.
4267edabee0SEric Anholt 	 */
4277edabee0SEric Anholt 	struct drm_gem_cma_object *rcl_write_bo[4];
4287edabee0SEric Anholt 	uint32_t rcl_write_bo_count;
4297edabee0SEric Anholt 
430d5b1a78aSEric Anholt 	/* Pointers for our position in vc4->job_list */
431d5b1a78aSEric Anholt 	struct list_head head;
432d5b1a78aSEric Anholt 
433d5b1a78aSEric Anholt 	/* List of other BOs used in the job that need to be released
434d5b1a78aSEric Anholt 	 * once the job is complete.
435d5b1a78aSEric Anholt 	 */
436d5b1a78aSEric Anholt 	struct list_head unref_list;
437d5b1a78aSEric Anholt 
438d5b1a78aSEric Anholt 	/* Current unvalidated indices into @bo loaded by the non-hardware
439d5b1a78aSEric Anholt 	 * VC4_PACKET_GEM_HANDLES.
440d5b1a78aSEric Anholt 	 */
441d5b1a78aSEric Anholt 	uint32_t bo_index[2];
442d5b1a78aSEric Anholt 
443d5b1a78aSEric Anholt 	/* This is the BO where we store the validated command lists, shader
444d5b1a78aSEric Anholt 	 * records, and uniforms.
445d5b1a78aSEric Anholt 	 */
446d5b1a78aSEric Anholt 	struct drm_gem_cma_object *exec_bo;
447d5b1a78aSEric Anholt 
448d5b1a78aSEric Anholt 	/**
449d5b1a78aSEric Anholt 	 * This tracks the per-shader-record state (packet 64) that
450d5b1a78aSEric Anholt 	 * determines the length of the shader record and the offset
451d5b1a78aSEric Anholt 	 * it's expected to be found at.  It gets read in from the
452d5b1a78aSEric Anholt 	 * command lists.
453d5b1a78aSEric Anholt 	 */
454d5b1a78aSEric Anholt 	struct vc4_shader_state {
455d5b1a78aSEric Anholt 		uint32_t addr;
456d5b1a78aSEric Anholt 		/* Maximum vertex index referenced by any primitive using this
457d5b1a78aSEric Anholt 		 * shader state.
458d5b1a78aSEric Anholt 		 */
459d5b1a78aSEric Anholt 		uint32_t max_index;
460d5b1a78aSEric Anholt 	} *shader_state;
461d5b1a78aSEric Anholt 
462d5b1a78aSEric Anholt 	/** How many shader states the user declared they were using. */
463d5b1a78aSEric Anholt 	uint32_t shader_state_size;
464d5b1a78aSEric Anholt 	/** How many shader state records the validator has seen. */
465d5b1a78aSEric Anholt 	uint32_t shader_state_count;
466d5b1a78aSEric Anholt 
467d5b1a78aSEric Anholt 	bool found_tile_binning_mode_config_packet;
468d5b1a78aSEric Anholt 	bool found_start_tile_binning_packet;
469d5b1a78aSEric Anholt 	bool found_increment_semaphore_packet;
470d5b1a78aSEric Anholt 	bool found_flush;
471d5b1a78aSEric Anholt 	uint8_t bin_tiles_x, bin_tiles_y;
472553c942fSEric Anholt 	/* Physical address of the start of the tile alloc array
473553c942fSEric Anholt 	 * (where each tile's binned CL will start)
474553c942fSEric Anholt 	 */
475d5b1a78aSEric Anholt 	uint32_t tile_alloc_offset;
476553c942fSEric Anholt 	/* Bitmask of which binner slots are freed when this job completes. */
477553c942fSEric Anholt 	uint32_t bin_slots;
478d5b1a78aSEric Anholt 
479d5b1a78aSEric Anholt 	/**
480d5b1a78aSEric Anholt 	 * Computed addresses pointing into exec_bo where we start the
481d5b1a78aSEric Anholt 	 * bin thread (ct0) and render thread (ct1).
482d5b1a78aSEric Anholt 	 */
483d5b1a78aSEric Anholt 	uint32_t ct0ca, ct0ea;
484d5b1a78aSEric Anholt 	uint32_t ct1ca, ct1ea;
485d5b1a78aSEric Anholt 
486d5b1a78aSEric Anholt 	/* Pointer to the unvalidated bin CL (if present). */
487d5b1a78aSEric Anholt 	void *bin_u;
488d5b1a78aSEric Anholt 
489d5b1a78aSEric Anholt 	/* Pointers to the shader recs.  These paddr gets incremented as CL
490d5b1a78aSEric Anholt 	 * packets are relocated in validate_gl_shader_state, and the vaddrs
491d5b1a78aSEric Anholt 	 * (u and v) get incremented and size decremented as the shader recs
492d5b1a78aSEric Anholt 	 * themselves are validated.
493d5b1a78aSEric Anholt 	 */
494d5b1a78aSEric Anholt 	void *shader_rec_u;
495d5b1a78aSEric Anholt 	void *shader_rec_v;
496d5b1a78aSEric Anholt 	uint32_t shader_rec_p;
497d5b1a78aSEric Anholt 	uint32_t shader_rec_size;
498d5b1a78aSEric Anholt 
499d5b1a78aSEric Anholt 	/* Pointers to the uniform data.  These pointers are incremented, and
500d5b1a78aSEric Anholt 	 * size decremented, as each batch of uniforms is uploaded.
501d5b1a78aSEric Anholt 	 */
502d5b1a78aSEric Anholt 	void *uniforms_u;
503d5b1a78aSEric Anholt 	void *uniforms_v;
504d5b1a78aSEric Anholt 	uint32_t uniforms_p;
505d5b1a78aSEric Anholt 	uint32_t uniforms_size;
50665101d8cSBoris Brezillon 
50765101d8cSBoris Brezillon 	/* Pointer to a performance monitor object if the user requested it,
50865101d8cSBoris Brezillon 	 * NULL otherwise.
50965101d8cSBoris Brezillon 	 */
51065101d8cSBoris Brezillon 	struct vc4_perfmon *perfmon;
51165101d8cSBoris Brezillon };
51265101d8cSBoris Brezillon 
51365101d8cSBoris Brezillon /* Per-open file private data. Any driver-specific resource that has to be
51465101d8cSBoris Brezillon  * released when the DRM file is closed should be placed here.
51565101d8cSBoris Brezillon  */
51665101d8cSBoris Brezillon struct vc4_file {
51765101d8cSBoris Brezillon 	struct {
51865101d8cSBoris Brezillon 		struct idr idr;
51965101d8cSBoris Brezillon 		struct mutex lock;
52065101d8cSBoris Brezillon 	} perfmon;
521d5b1a78aSEric Anholt };
522d5b1a78aSEric Anholt 
523d5b1a78aSEric Anholt static inline struct vc4_exec_info *
524ca26d28bSVarad Gautam vc4_first_bin_job(struct vc4_dev *vc4)
525d5b1a78aSEric Anholt {
52657b9f569SMasahiro Yamada 	return list_first_entry_or_null(&vc4->bin_job_list,
52757b9f569SMasahiro Yamada 					struct vc4_exec_info, head);
528ca26d28bSVarad Gautam }
529ca26d28bSVarad Gautam 
530ca26d28bSVarad Gautam static inline struct vc4_exec_info *
531ca26d28bSVarad Gautam vc4_first_render_job(struct vc4_dev *vc4)
532ca26d28bSVarad Gautam {
53357b9f569SMasahiro Yamada 	return list_first_entry_or_null(&vc4->render_job_list,
534ca26d28bSVarad Gautam 					struct vc4_exec_info, head);
535d5b1a78aSEric Anholt }
536d5b1a78aSEric Anholt 
5379326e6f2SEric Anholt static inline struct vc4_exec_info *
5389326e6f2SEric Anholt vc4_last_render_job(struct vc4_dev *vc4)
5399326e6f2SEric Anholt {
5409326e6f2SEric Anholt 	if (list_empty(&vc4->render_job_list))
5419326e6f2SEric Anholt 		return NULL;
5429326e6f2SEric Anholt 	return list_last_entry(&vc4->render_job_list,
5439326e6f2SEric Anholt 			       struct vc4_exec_info, head);
5449326e6f2SEric Anholt }
5459326e6f2SEric Anholt 
546c8b75bcaSEric Anholt /**
547463873d5SEric Anholt  * struct vc4_texture_sample_info - saves the offsets into the UBO for texture
548463873d5SEric Anholt  * setup parameters.
549463873d5SEric Anholt  *
550463873d5SEric Anholt  * This will be used at draw time to relocate the reference to the texture
551463873d5SEric Anholt  * contents in p0, and validate that the offset combined with
552463873d5SEric Anholt  * width/height/stride/etc. from p1 and p2/p3 doesn't sample outside the BO.
553463873d5SEric Anholt  * Note that the hardware treats unprovided config parameters as 0, so not all
554463873d5SEric Anholt  * of them need to be set up for every texure sample, and we'll store ~0 as
555463873d5SEric Anholt  * the offset to mark the unused ones.
556463873d5SEric Anholt  *
557463873d5SEric Anholt  * See the VC4 3D architecture guide page 41 ("Texture and Memory Lookup Unit
558463873d5SEric Anholt  * Setup") for definitions of the texture parameters.
559463873d5SEric Anholt  */
560463873d5SEric Anholt struct vc4_texture_sample_info {
561463873d5SEric Anholt 	bool is_direct;
562463873d5SEric Anholt 	uint32_t p_offset[4];
563463873d5SEric Anholt };
564463873d5SEric Anholt 
565463873d5SEric Anholt /**
566463873d5SEric Anholt  * struct vc4_validated_shader_info - information about validated shaders that
567463873d5SEric Anholt  * needs to be used from command list validation.
568463873d5SEric Anholt  *
569463873d5SEric Anholt  * For a given shader, each time a shader state record references it, we need
570463873d5SEric Anholt  * to verify that the shader doesn't read more uniforms than the shader state
571463873d5SEric Anholt  * record's uniform BO pointer can provide, and we need to apply relocations
572463873d5SEric Anholt  * and validate the shader state record's uniforms that define the texture
573463873d5SEric Anholt  * samples.
574463873d5SEric Anholt  */
575463873d5SEric Anholt struct vc4_validated_shader_info {
576463873d5SEric Anholt 	uint32_t uniforms_size;
577463873d5SEric Anholt 	uint32_t uniforms_src_size;
578463873d5SEric Anholt 	uint32_t num_texture_samples;
579463873d5SEric Anholt 	struct vc4_texture_sample_info *texture_samples;
5806d45c81dSEric Anholt 
5816d45c81dSEric Anholt 	uint32_t num_uniform_addr_offsets;
5826d45c81dSEric Anholt 	uint32_t *uniform_addr_offsets;
583c778cc5dSJonas Pfeil 
584c778cc5dSJonas Pfeil 	bool is_threaded;
585463873d5SEric Anholt };
586463873d5SEric Anholt 
587463873d5SEric Anholt /**
588c8b75bcaSEric Anholt  * _wait_for - magic (register) wait macro
589c8b75bcaSEric Anholt  *
590c8b75bcaSEric Anholt  * Does the right thing for modeset paths when run under kdgb or similar atomic
591c8b75bcaSEric Anholt  * contexts. Note that it's important that we check the condition again after
592c8b75bcaSEric Anholt  * having timed out, since the timeout could be due to preemption or similar and
593c8b75bcaSEric Anholt  * we've never had a chance to check the condition before the timeout.
594c8b75bcaSEric Anholt  */
595c8b75bcaSEric Anholt #define _wait_for(COND, MS, W) ({ \
596c8b75bcaSEric Anholt 	unsigned long timeout__ = jiffies + msecs_to_jiffies(MS) + 1;	\
597c8b75bcaSEric Anholt 	int ret__ = 0;							\
598c8b75bcaSEric Anholt 	while (!(COND)) {						\
599c8b75bcaSEric Anholt 		if (time_after(jiffies, timeout__)) {			\
600c8b75bcaSEric Anholt 			if (!(COND))					\
601c8b75bcaSEric Anholt 				ret__ = -ETIMEDOUT;			\
602c8b75bcaSEric Anholt 			break;						\
603c8b75bcaSEric Anholt 		}							\
604c8b75bcaSEric Anholt 		if (W && drm_can_sleep())  {				\
605c8b75bcaSEric Anholt 			msleep(W);					\
606c8b75bcaSEric Anholt 		} else {						\
607c8b75bcaSEric Anholt 			cpu_relax();					\
608c8b75bcaSEric Anholt 		}							\
609c8b75bcaSEric Anholt 	}								\
610c8b75bcaSEric Anholt 	ret__;								\
611c8b75bcaSEric Anholt })
612c8b75bcaSEric Anholt 
613c8b75bcaSEric Anholt #define wait_for(COND, MS) _wait_for(COND, MS, 1)
614c8b75bcaSEric Anholt 
615c8b75bcaSEric Anholt /* vc4_bo.c */
616c826a6e1SEric Anholt struct drm_gem_object *vc4_create_object(struct drm_device *dev, size_t size);
617c8b75bcaSEric Anholt void vc4_free_object(struct drm_gem_object *gem_obj);
618c826a6e1SEric Anholt struct vc4_bo *vc4_bo_create(struct drm_device *dev, size_t size,
619f3099462SEric Anholt 			     bool from_cache, enum vc4_kernel_bo_type type);
620c8b75bcaSEric Anholt int vc4_dumb_create(struct drm_file *file_priv,
621c8b75bcaSEric Anholt 		    struct drm_device *dev,
622c8b75bcaSEric Anholt 		    struct drm_mode_create_dumb *args);
623c8b75bcaSEric Anholt struct dma_buf *vc4_prime_export(struct drm_device *dev,
624c8b75bcaSEric Anholt 				 struct drm_gem_object *obj, int flags);
625d5bc60f6SEric Anholt int vc4_create_bo_ioctl(struct drm_device *dev, void *data,
626d5bc60f6SEric Anholt 			struct drm_file *file_priv);
627463873d5SEric Anholt int vc4_create_shader_bo_ioctl(struct drm_device *dev, void *data,
628463873d5SEric Anholt 			       struct drm_file *file_priv);
629d5bc60f6SEric Anholt int vc4_mmap_bo_ioctl(struct drm_device *dev, void *data,
630d5bc60f6SEric Anholt 		      struct drm_file *file_priv);
63183753117SEric Anholt int vc4_set_tiling_ioctl(struct drm_device *dev, void *data,
63283753117SEric Anholt 			 struct drm_file *file_priv);
63383753117SEric Anholt int vc4_get_tiling_ioctl(struct drm_device *dev, void *data,
63483753117SEric Anholt 			 struct drm_file *file_priv);
63521461365SEric Anholt int vc4_get_hang_state_ioctl(struct drm_device *dev, void *data,
63621461365SEric Anholt 			     struct drm_file *file_priv);
637f3099462SEric Anholt int vc4_label_bo_ioctl(struct drm_device *dev, void *data,
638f3099462SEric Anholt 		       struct drm_file *file_priv);
639b9f19259SBoris Brezillon int vc4_fault(struct vm_fault *vmf);
640463873d5SEric Anholt int vc4_mmap(struct file *filp, struct vm_area_struct *vma);
641cdec4d36SEric Anholt struct reservation_object *vc4_prime_res_obj(struct drm_gem_object *obj);
642463873d5SEric Anholt int vc4_prime_mmap(struct drm_gem_object *obj, struct vm_area_struct *vma);
643cdec4d36SEric Anholt struct drm_gem_object *vc4_prime_import_sg_table(struct drm_device *dev,
644cdec4d36SEric Anholt 						 struct dma_buf_attachment *attach,
645cdec4d36SEric Anholt 						 struct sg_table *sgt);
646463873d5SEric Anholt void *vc4_prime_vmap(struct drm_gem_object *obj);
647f3099462SEric Anholt int vc4_bo_cache_init(struct drm_device *dev);
648c826a6e1SEric Anholt void vc4_bo_cache_destroy(struct drm_device *dev);
649c826a6e1SEric Anholt int vc4_bo_stats_debugfs(struct seq_file *m, void *arg);
650b9f19259SBoris Brezillon int vc4_bo_inc_usecnt(struct vc4_bo *bo);
651b9f19259SBoris Brezillon void vc4_bo_dec_usecnt(struct vc4_bo *bo);
652b9f19259SBoris Brezillon void vc4_bo_add_to_purgeable_pool(struct vc4_bo *bo);
653b9f19259SBoris Brezillon void vc4_bo_remove_from_purgeable_pool(struct vc4_bo *bo);
654c8b75bcaSEric Anholt 
655c8b75bcaSEric Anholt /* vc4_crtc.c */
656c8b75bcaSEric Anholt extern struct platform_driver vc4_crtc_driver;
657c8b75bcaSEric Anholt int vc4_crtc_debugfs_regs(struct seq_file *m, void *arg);
6581bf6ad62SDaniel Vetter bool vc4_crtc_get_scanoutpos(struct drm_device *dev, unsigned int crtc_id,
6591bf6ad62SDaniel Vetter 			     bool in_vblank_irq, int *vpos, int *hpos,
6601bf59f1dSMario Kleiner 			     ktime_t *stime, ktime_t *etime,
6611bf59f1dSMario Kleiner 			     const struct drm_display_mode *mode);
662c8b75bcaSEric Anholt 
663c8b75bcaSEric Anholt /* vc4_debugfs.c */
664c8b75bcaSEric Anholt int vc4_debugfs_init(struct drm_minor *minor);
665c8b75bcaSEric Anholt 
666c8b75bcaSEric Anholt /* vc4_drv.c */
667c8b75bcaSEric Anholt void __iomem *vc4_ioremap_regs(struct platform_device *dev, int index);
668c8b75bcaSEric Anholt 
66908302c35SEric Anholt /* vc4_dpi.c */
67008302c35SEric Anholt extern struct platform_driver vc4_dpi_driver;
67108302c35SEric Anholt int vc4_dpi_debugfs_regs(struct seq_file *m, void *unused);
67208302c35SEric Anholt 
6734078f575SEric Anholt /* vc4_dsi.c */
6744078f575SEric Anholt extern struct platform_driver vc4_dsi_driver;
6754078f575SEric Anholt int vc4_dsi_debugfs_regs(struct seq_file *m, void *unused);
6764078f575SEric Anholt 
677cdec4d36SEric Anholt /* vc4_fence.c */
678cdec4d36SEric Anholt extern const struct dma_fence_ops vc4_fence_ops;
679cdec4d36SEric Anholt 
680d5b1a78aSEric Anholt /* vc4_gem.c */
681d5b1a78aSEric Anholt void vc4_gem_init(struct drm_device *dev);
682d5b1a78aSEric Anholt void vc4_gem_destroy(struct drm_device *dev);
683d5b1a78aSEric Anholt int vc4_submit_cl_ioctl(struct drm_device *dev, void *data,
684d5b1a78aSEric Anholt 			struct drm_file *file_priv);
685d5b1a78aSEric Anholt int vc4_wait_seqno_ioctl(struct drm_device *dev, void *data,
686d5b1a78aSEric Anholt 			 struct drm_file *file_priv);
687d5b1a78aSEric Anholt int vc4_wait_bo_ioctl(struct drm_device *dev, void *data,
688d5b1a78aSEric Anholt 		      struct drm_file *file_priv);
689ca26d28bSVarad Gautam void vc4_submit_next_bin_job(struct drm_device *dev);
690ca26d28bSVarad Gautam void vc4_submit_next_render_job(struct drm_device *dev);
691ca26d28bSVarad Gautam void vc4_move_job_to_render(struct drm_device *dev, struct vc4_exec_info *exec);
692d5b1a78aSEric Anholt int vc4_wait_for_seqno(struct drm_device *dev, uint64_t seqno,
693d5b1a78aSEric Anholt 		       uint64_t timeout_ns, bool interruptible);
694d5b1a78aSEric Anholt void vc4_job_handle_completed(struct vc4_dev *vc4);
695b501baccSEric Anholt int vc4_queue_seqno_cb(struct drm_device *dev,
696b501baccSEric Anholt 		       struct vc4_seqno_cb *cb, uint64_t seqno,
697b501baccSEric Anholt 		       void (*func)(struct vc4_seqno_cb *cb));
698b9f19259SBoris Brezillon int vc4_gem_madvise_ioctl(struct drm_device *dev, void *data,
699b9f19259SBoris Brezillon 			  struct drm_file *file_priv);
700d5b1a78aSEric Anholt 
701c8b75bcaSEric Anholt /* vc4_hdmi.c */
702c8b75bcaSEric Anholt extern struct platform_driver vc4_hdmi_driver;
703c8b75bcaSEric Anholt int vc4_hdmi_debugfs_regs(struct seq_file *m, void *unused);
704c8b75bcaSEric Anholt 
7059a8d5e4aSBoris Brezillon /* vc4_vec.c */
706e4b81f8cSBoris Brezillon extern struct platform_driver vc4_vec_driver;
707e4b81f8cSBoris Brezillon int vc4_vec_debugfs_regs(struct seq_file *m, void *unused);
708e4b81f8cSBoris Brezillon 
709d5b1a78aSEric Anholt /* vc4_irq.c */
710d5b1a78aSEric Anholt irqreturn_t vc4_irq(int irq, void *arg);
711d5b1a78aSEric Anholt void vc4_irq_preinstall(struct drm_device *dev);
712d5b1a78aSEric Anholt int vc4_irq_postinstall(struct drm_device *dev);
713d5b1a78aSEric Anholt void vc4_irq_uninstall(struct drm_device *dev);
714d5b1a78aSEric Anholt void vc4_irq_reset(struct drm_device *dev);
715d5b1a78aSEric Anholt 
716c8b75bcaSEric Anholt /* vc4_hvs.c */
717c8b75bcaSEric Anholt extern struct platform_driver vc4_hvs_driver;
718c8b75bcaSEric Anholt void vc4_hvs_dump_state(struct drm_device *dev);
719c8b75bcaSEric Anholt int vc4_hvs_debugfs_regs(struct seq_file *m, void *unused);
720c8b75bcaSEric Anholt 
721c8b75bcaSEric Anholt /* vc4_kms.c */
722c8b75bcaSEric Anholt int vc4_kms_load(struct drm_device *dev);
723c8b75bcaSEric Anholt 
724c8b75bcaSEric Anholt /* vc4_plane.c */
725c8b75bcaSEric Anholt struct drm_plane *vc4_plane_init(struct drm_device *dev,
726c8b75bcaSEric Anholt 				 enum drm_plane_type type);
727c8b75bcaSEric Anholt u32 vc4_plane_write_dlist(struct drm_plane *plane, u32 __iomem *dlist);
7282f196b7cSDaniel Vetter u32 vc4_plane_dlist_size(const struct drm_plane_state *state);
729b501baccSEric Anholt void vc4_plane_async_set_fb(struct drm_plane *plane,
730b501baccSEric Anholt 			    struct drm_framebuffer *fb);
731463873d5SEric Anholt 
732d3f5168aSEric Anholt /* vc4_v3d.c */
733d3f5168aSEric Anholt extern struct platform_driver vc4_v3d_driver;
734d3f5168aSEric Anholt int vc4_v3d_debugfs_ident(struct seq_file *m, void *unused);
735d3f5168aSEric Anholt int vc4_v3d_debugfs_regs(struct seq_file *m, void *unused);
736553c942fSEric Anholt int vc4_v3d_get_bin_slot(struct vc4_dev *vc4);
737d5b1a78aSEric Anholt 
738d5b1a78aSEric Anholt /* vc4_validate.c */
739d5b1a78aSEric Anholt int
740d5b1a78aSEric Anholt vc4_validate_bin_cl(struct drm_device *dev,
741d5b1a78aSEric Anholt 		    void *validated,
742d5b1a78aSEric Anholt 		    void *unvalidated,
743d5b1a78aSEric Anholt 		    struct vc4_exec_info *exec);
744d5b1a78aSEric Anholt 
745d5b1a78aSEric Anholt int
746d5b1a78aSEric Anholt vc4_validate_shader_recs(struct drm_device *dev, struct vc4_exec_info *exec);
747d5b1a78aSEric Anholt 
748d5b1a78aSEric Anholt struct drm_gem_cma_object *vc4_use_bo(struct vc4_exec_info *exec,
749d5b1a78aSEric Anholt 				      uint32_t hindex);
750d5b1a78aSEric Anholt 
751d5b1a78aSEric Anholt int vc4_get_rcl(struct drm_device *dev, struct vc4_exec_info *exec);
752d5b1a78aSEric Anholt 
753d5b1a78aSEric Anholt bool vc4_check_tex_size(struct vc4_exec_info *exec,
754d5b1a78aSEric Anholt 			struct drm_gem_cma_object *fbo,
755d5b1a78aSEric Anholt 			uint32_t offset, uint8_t tiling_format,
756d5b1a78aSEric Anholt 			uint32_t width, uint32_t height, uint8_t cpp);
757d3f5168aSEric Anholt 
758463873d5SEric Anholt /* vc4_validate_shader.c */
759463873d5SEric Anholt struct vc4_validated_shader_info *
760463873d5SEric Anholt vc4_validate_shader(struct drm_gem_cma_object *shader_obj);
76165101d8cSBoris Brezillon 
76265101d8cSBoris Brezillon /* vc4_perfmon.c */
76365101d8cSBoris Brezillon void vc4_perfmon_get(struct vc4_perfmon *perfmon);
76465101d8cSBoris Brezillon void vc4_perfmon_put(struct vc4_perfmon *perfmon);
76565101d8cSBoris Brezillon void vc4_perfmon_start(struct vc4_dev *vc4, struct vc4_perfmon *perfmon);
76665101d8cSBoris Brezillon void vc4_perfmon_stop(struct vc4_dev *vc4, struct vc4_perfmon *perfmon,
76765101d8cSBoris Brezillon 		      bool capture);
76865101d8cSBoris Brezillon struct vc4_perfmon *vc4_perfmon_find(struct vc4_file *vc4file, int id);
76965101d8cSBoris Brezillon void vc4_perfmon_open_file(struct vc4_file *vc4file);
77065101d8cSBoris Brezillon void vc4_perfmon_close_file(struct vc4_file *vc4file);
77165101d8cSBoris Brezillon int vc4_perfmon_create_ioctl(struct drm_device *dev, void *data,
77265101d8cSBoris Brezillon 			     struct drm_file *file_priv);
77365101d8cSBoris Brezillon int vc4_perfmon_destroy_ioctl(struct drm_device *dev, void *data,
77465101d8cSBoris Brezillon 			      struct drm_file *file_priv);
77565101d8cSBoris Brezillon int vc4_perfmon_get_values_ioctl(struct drm_device *dev, void *data,
77665101d8cSBoris Brezillon 				 struct drm_file *file_priv);
777