17ec681f3Smrg/* 27ec681f3Smrg * Copyright © 2020 Google, Inc. 37ec681f3Smrg * 47ec681f3Smrg * Permission is hereby granted, free of charge, to any person obtaining a 57ec681f3Smrg * copy of this software and associated documentation files (the "Software"), 67ec681f3Smrg * to deal in the Software without restriction, including without limitation 77ec681f3Smrg * the rights to use, copy, modify, merge, publish, distribute, sublicense, 87ec681f3Smrg * and/or sell copies of the Software, and to permit persons to whom the 97ec681f3Smrg * Software is furnished to do so, subject to the following conditions: 107ec681f3Smrg * 117ec681f3Smrg * The above copyright notice and this permission notice (including the next 127ec681f3Smrg * paragraph) shall be included in all copies or substantial portions of the 137ec681f3Smrg * Software. 147ec681f3Smrg * 157ec681f3Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 167ec681f3Smrg * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 177ec681f3Smrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 187ec681f3Smrg * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 197ec681f3Smrg * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 207ec681f3Smrg * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 217ec681f3Smrg * SOFTWARE. 227ec681f3Smrg */ 237ec681f3Smrg 247ec681f3Smrg#ifndef __MAIN_H__ 257ec681f3Smrg#define __MAIN_H__ 267ec681f3Smrg 277ec681f3Smrg#include <err.h> 287ec681f3Smrg#include <stdint.h> 297ec681f3Smrg#include <stdio.h> 307ec681f3Smrg 317ec681f3Smrg#include "drm/freedreno_drmif.h" 327ec681f3Smrg#include "drm/freedreno_ringbuffer.h" 337ec681f3Smrg 347ec681f3Smrg#include "adreno_common.xml.h" 357ec681f3Smrg#include "adreno_pm4.xml.h" 367ec681f3Smrg 377ec681f3Smrg#define MAX_BUFS 4 387ec681f3Smrg 397ec681f3Smrgstruct kernel { 407ec681f3Smrg /* filled in by backend when shader is assembled: */ 417ec681f3Smrg uint32_t local_size[3]; 427ec681f3Smrg uint32_t num_bufs; 437ec681f3Smrg uint32_t buf_sizes[MAX_BUFS]; /* size in dwords */ 447ec681f3Smrg uint32_t buf_addr_regs[MAX_BUFS]; 457ec681f3Smrg 467ec681f3Smrg /* filled in by frontend before launching grid: */ 477ec681f3Smrg struct fd_bo *bufs[MAX_BUFS]; 487ec681f3Smrg}; 497ec681f3Smrg 507ec681f3Smrgstruct perfcntr { 517ec681f3Smrg const char *name; 527ec681f3Smrg 537ec681f3Smrg /* for backend to configure/read the counter, describes 547ec681f3Smrg * the selected counter: 557ec681f3Smrg */ 567ec681f3Smrg unsigned select_reg; 577ec681f3Smrg unsigned counter_reg_lo; 587ec681f3Smrg unsigned counter_reg_hi; 597ec681f3Smrg /* and selected countable: 607ec681f3Smrg */ 617ec681f3Smrg unsigned selector; 627ec681f3Smrg}; 637ec681f3Smrg 647ec681f3Smrg/* per-generation entry-points: */ 657ec681f3Smrgstruct backend { 667ec681f3Smrg struct kernel *(*assemble)(struct backend *b, FILE *in); 677ec681f3Smrg void (*disassemble)(struct kernel *kernel, FILE *out); 687ec681f3Smrg void (*emit_grid)(struct kernel *kernel, uint32_t grid[3], 697ec681f3Smrg struct fd_submit *submit); 707ec681f3Smrg 717ec681f3Smrg /* performance-counter API: */ 727ec681f3Smrg void (*set_perfcntrs)(struct backend *b, const struct perfcntr *perfcntrs, 737ec681f3Smrg unsigned num_perfcntrs); 747ec681f3Smrg void (*read_perfcntrs)(struct backend *b, uint64_t *results); 757ec681f3Smrg}; 767ec681f3Smrg 777ec681f3Smrg#define define_cast(_from, _to) \ 787ec681f3Smrg static inline struct _to *to_##_to(struct _from *f) \ 797ec681f3Smrg { \ 807ec681f3Smrg return (struct _to *)f; \ 817ec681f3Smrg } 827ec681f3Smrg 837ec681f3Smrgstruct backend *a4xx_init(struct fd_device *dev, const struct fd_dev_id *dev_id); 847ec681f3Smrgstruct backend *a6xx_init(struct fd_device *dev, const struct fd_dev_id *dev_id); 857ec681f3Smrg 867ec681f3Smrg/* for conditionally setting boolean flag(s): */ 877ec681f3Smrg#define COND(bool, val) ((bool) ? (val) : 0) 887ec681f3Smrg 897ec681f3Smrg#endif /* __MAIN_H__ */ 90