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_common.xml.h" 35 #include "adreno_pm4.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 uint32_t buf_addr_regs[MAX_BUFS]; 45 46 /* filled in by frontend before launching grid: */ 47 struct fd_bo *bufs[MAX_BUFS]; 48 }; 49 50 struct perfcntr { 51 const char *name; 52 53 /* for backend to configure/read the counter, describes 54 * the selected counter: 55 */ 56 unsigned select_reg; 57 unsigned counter_reg_lo; 58 unsigned counter_reg_hi; 59 /* and selected countable: 60 */ 61 unsigned selector; 62 }; 63 64 /* per-generation entry-points: */ 65 struct backend { 66 struct kernel *(*assemble)(struct backend *b, FILE *in); 67 void (*disassemble)(struct kernel *kernel, FILE *out); 68 void (*emit_grid)(struct kernel *kernel, uint32_t grid[3], 69 struct fd_submit *submit); 70 71 /* performance-counter API: */ 72 void (*set_perfcntrs)(struct backend *b, const struct perfcntr *perfcntrs, 73 unsigned num_perfcntrs); 74 void (*read_perfcntrs)(struct backend *b, uint64_t *results); 75 }; 76 77 #define define_cast(_from, _to) \ 78 static inline struct _to *to_##_to(struct _from *f) \ 79 { \ 80 return (struct _to *)f; \ 81 } 82 83 struct backend *a4xx_init(struct fd_device *dev, const struct fd_dev_id *dev_id); 84 struct backend *a6xx_init(struct fd_device *dev, const struct fd_dev_id *dev_id); 85 86 /* for conditionally setting boolean flag(s): */ 87 #define COND(bool, val) ((bool) ? (val) : 0) 88 89 #endif /* __MAIN_H__ */ 90