• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright © 2020 Google, Inc.
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a
5  * copy of this software and associated documentation files (the "Software"),
6  * to deal in the Software without restriction, including without limitation
7  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8  * and/or sell copies of the Software, and to permit persons to whom the
9  * Software is furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice (including the next
12  * paragraph) shall be included in all copies or substantial portions of the
13  * Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
18  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21  * SOFTWARE.
22  */
23 
24 #ifndef __MAIN_H__
25 #define __MAIN_H__
26 
27 #include <err.h>
28 #include <stdint.h>
29 #include <stdio.h>
30 
31 #include "drm/freedreno_drmif.h"
32 #include "drm/freedreno_ringbuffer.h"
33 
34 #include "adreno_pm4.xml.h"
35 #include "adreno_common.xml.h"
36 
37 #define MAX_BUFS 4
38 
39 struct kernel {
40 	/* filled in by backend when shader is assembled: */
41 	uint32_t local_size[3];
42 	uint32_t num_bufs;
43 	uint32_t buf_sizes[MAX_BUFS]; /* size in dwords */
44 
45 	/* filled in by frontend before launching grid: */
46 	struct fd_bo *bufs[MAX_BUFS];
47 };
48 
49 struct perfcntr {
50 	const char *name;
51 
52 	/* for backend to configure/read the counter, describes
53 	 * the selected counter:
54 	 */
55 	unsigned select_reg;
56 	unsigned counter_reg_lo;
57 	unsigned counter_reg_hi;
58 	/* and selected countable:
59 	 */
60 	unsigned selector;
61 };
62 
63 /* per-generation entry-points: */
64 struct backend {
65 	struct kernel *(*assemble)(struct backend *b, FILE *in);
66 	void (*disassemble)(struct kernel *kernel, FILE *out);
67 	void (*emit_grid)(struct kernel *kernel, uint32_t grid[3],
68 			struct fd_submit *submit);
69 
70 	/* performance-counter API: */
71 	void (*set_perfcntrs)(struct backend *b, const struct perfcntr *perfcntrs,
72 			unsigned num_perfcntrs);
73 	void (*read_perfcntrs)(struct backend *b, uint64_t *results);
74 };
75 
76 #define define_cast(_from, _to)	\
77 static inline struct _to *		\
78 to_ ## _to(struct _from *f)		\
79 { return (struct _to *)f; }
80 
81 struct backend *a6xx_init(struct fd_device *dev, uint32_t gpu_id);
82 
83 /* for conditionally setting boolean flag(s): */
84 #define COND(bool, val) ((bool) ? (val) : 0)
85 
86 #endif /* __MAIN_H__ */
87