1 /* 2 * Copyright © 2020 Google, Inc. 3 * SPDX-License-Identifier: MIT 4 */ 5 6 #ifndef __MAIN_H__ 7 #define __MAIN_H__ 8 9 #include <err.h> 10 #include <stdint.h> 11 #include <stdio.h> 12 13 #include "drm/freedreno_drmif.h" 14 #include "drm/freedreno_ringbuffer.h" 15 16 #include "adreno_common.xml.h" 17 #include "adreno_pm4.xml.h" 18 19 #define MAX_BUFS 4 20 21 struct kernel { 22 /* filled in by backend when shader is assembled: */ 23 uint32_t local_size[3]; 24 uint32_t num_bufs; 25 uint32_t buf_sizes[MAX_BUFS]; /* size in dwords */ 26 uint32_t buf_addr_regs[MAX_BUFS]; 27 uint32_t *buf_init_data[MAX_BUFS]; 28 29 /* filled in by frontend before launching grid: */ 30 struct fd_bo *bufs[MAX_BUFS]; 31 }; 32 33 struct perfcntr { 34 const char *name; 35 36 /* for backend to configure/read the counter, describes 37 * the selected counter: 38 */ 39 unsigned select_reg; 40 unsigned counter_reg_lo; 41 unsigned counter_reg_hi; 42 /* and selected countable: 43 */ 44 unsigned selector; 45 }; 46 47 /* per-generation entry-points: */ 48 struct backend { 49 struct kernel *(*assemble)(struct backend *b, FILE *in); 50 void (*disassemble)(struct kernel *kernel, FILE *out); 51 void (*emit_grid)(struct kernel *kernel, uint32_t grid[3], 52 struct fd_submit *submit); 53 54 /* performance-counter API: */ 55 void (*set_perfcntrs)(struct backend *b, const struct perfcntr *perfcntrs, 56 unsigned num_perfcntrs); 57 void (*read_perfcntrs)(struct backend *b, uint64_t *results); 58 }; 59 60 #define define_cast(_from, _to) \ 61 static inline struct _to *to_##_to(struct _from *f) \ 62 { \ 63 return (struct _to *)f; \ 64 } 65 66 struct backend *a4xx_init(struct fd_device *dev, const struct fd_dev_id *dev_id); 67 template<chip CHIP> 68 struct backend *a6xx_init(struct fd_device *dev, const struct fd_dev_id *dev_id); 69 70 /* for conditionally setting boolean flag(s): */ 71 #define COND(bool, val) ((bool) ? (val) : 0) 72 73 #endif /* __MAIN_H__ */ 74