1bf215546Sopenharmony_ci/* 2bf215546Sopenharmony_ci * Copyright (c) 2018 Intel Corporation 3bf215546Sopenharmony_ci * 4bf215546Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a 5bf215546Sopenharmony_ci * copy of this software and associated documentation files (the "Software"), 6bf215546Sopenharmony_ci * to deal in the Software without restriction, including without limitation 7bf215546Sopenharmony_ci * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8bf215546Sopenharmony_ci * and/or sell copies of the Software, and to permit persons to whom the 9bf215546Sopenharmony_ci * Software is furnished to do so, subject to the following conditions: 10bf215546Sopenharmony_ci * 11bf215546Sopenharmony_ci * The above copyright notice and this permission notice (including the next 12bf215546Sopenharmony_ci * paragraph) shall be included in all copies or substantial portions of the 13bf215546Sopenharmony_ci * Software. 14bf215546Sopenharmony_ci * 15bf215546Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16bf215546Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17bf215546Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 18bf215546Sopenharmony_ci * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19bf215546Sopenharmony_ci * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20bf215546Sopenharmony_ci * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 21bf215546Sopenharmony_ci * IN THE SOFTWARE. 22bf215546Sopenharmony_ci */ 23bf215546Sopenharmony_ci 24bf215546Sopenharmony_ci#ifndef INTEL_AUX_MAP_H 25bf215546Sopenharmony_ci#define INTEL_AUX_MAP_H 26bf215546Sopenharmony_ci 27bf215546Sopenharmony_ci#include "intel_buffer_alloc.h" 28bf215546Sopenharmony_ci 29bf215546Sopenharmony_ci#include "isl/isl.h" 30bf215546Sopenharmony_ci 31bf215546Sopenharmony_ci#include <stdint.h> 32bf215546Sopenharmony_ci 33bf215546Sopenharmony_ci#ifdef __cplusplus 34bf215546Sopenharmony_ciextern "C" { 35bf215546Sopenharmony_ci#endif 36bf215546Sopenharmony_ci 37bf215546Sopenharmony_ci/** 38bf215546Sopenharmony_ci * Auxiliary surface mapping implementation 39bf215546Sopenharmony_ci * 40bf215546Sopenharmony_ci * These functions are implemented in common code shared by drivers. 41bf215546Sopenharmony_ci */ 42bf215546Sopenharmony_ci 43bf215546Sopenharmony_cistruct intel_aux_map_context; 44bf215546Sopenharmony_cistruct intel_device_info; 45bf215546Sopenharmony_ci 46bf215546Sopenharmony_ci#define INTEL_AUX_MAP_ADDRESS_MASK 0x0000ffffffffff00ull 47bf215546Sopenharmony_ci#define INTEL_AUX_MAP_FORMAT_BITS_MASK 0xfff0000000000000ull 48bf215546Sopenharmony_ci#define INTEL_AUX_MAP_ENTRY_VALID_BIT 0x1ull 49bf215546Sopenharmony_ci#define INTEL_AUX_MAP_GFX12_CCS_SCALE 256 50bf215546Sopenharmony_ci#define INTEL_AUX_MAP_MAIN_PAGE_SIZE (64 * 1024) 51bf215546Sopenharmony_ci#define INTEL_AUX_MAP_AUX_PAGE_SIZE \ 52bf215546Sopenharmony_ci (INTEL_AUX_MAP_MAIN_PAGE_SIZE / INTEL_AUX_MAP_GFX12_CCS_SCALE) 53bf215546Sopenharmony_ci 54bf215546Sopenharmony_cistruct intel_aux_map_context * 55bf215546Sopenharmony_ciintel_aux_map_init(void *driver_ctx, 56bf215546Sopenharmony_ci struct intel_mapped_pinned_buffer_alloc *buffer_alloc, 57bf215546Sopenharmony_ci const struct intel_device_info *devinfo); 58bf215546Sopenharmony_ci 59bf215546Sopenharmony_civoid 60bf215546Sopenharmony_ciintel_aux_map_finish(struct intel_aux_map_context *ctx); 61bf215546Sopenharmony_ci 62bf215546Sopenharmony_ciuint32_t 63bf215546Sopenharmony_ciintel_aux_map_get_state_num(struct intel_aux_map_context *ctx); 64bf215546Sopenharmony_ci 65bf215546Sopenharmony_ci/** Returns the current number of buffers used by the aux-map tables 66bf215546Sopenharmony_ci * 67bf215546Sopenharmony_ci * When preparing to execute a new batch, use this function to determine how 68bf215546Sopenharmony_ci * many buffers will be required. More buffers may be added by concurrent 69bf215546Sopenharmony_ci * accesses of the aux-map functions, but they won't be required for since 70bf215546Sopenharmony_ci * they involve surfaces not used by this batch. 71bf215546Sopenharmony_ci */ 72bf215546Sopenharmony_ciuint32_t 73bf215546Sopenharmony_ciintel_aux_map_get_num_buffers(struct intel_aux_map_context *ctx); 74bf215546Sopenharmony_ci 75bf215546Sopenharmony_ci/** Fill an array of exec_object2 with aux-map buffer handles 76bf215546Sopenharmony_ci * 77bf215546Sopenharmony_ci * The intel_aux_map_get_num_buffers call should be made, then the driver can 78bf215546Sopenharmony_ci * make sure the `obj` array is large enough before calling this function. 79bf215546Sopenharmony_ci */ 80bf215546Sopenharmony_civoid 81bf215546Sopenharmony_ciintel_aux_map_fill_bos(struct intel_aux_map_context *ctx, void **driver_bos, 82bf215546Sopenharmony_ci uint32_t max_bos); 83bf215546Sopenharmony_ci 84bf215546Sopenharmony_ciuint64_t 85bf215546Sopenharmony_ciintel_aux_map_get_base(struct intel_aux_map_context *ctx); 86bf215546Sopenharmony_ci 87bf215546Sopenharmony_ciuint64_t 88bf215546Sopenharmony_ciintel_aux_map_format_bits(enum isl_tiling tiling, enum isl_format format, 89bf215546Sopenharmony_ci uint8_t plane); 90bf215546Sopenharmony_ci 91bf215546Sopenharmony_ciuint64_t 92bf215546Sopenharmony_ciintel_aux_map_format_bits_for_isl_surf(const struct isl_surf *isl_surf); 93bf215546Sopenharmony_ci 94bf215546Sopenharmony_ciuint64_t * 95bf215546Sopenharmony_ciintel_aux_map_get_entry(struct intel_aux_map_context *ctx, 96bf215546Sopenharmony_ci uint64_t address, 97bf215546Sopenharmony_ci uint64_t *entry_address); 98bf215546Sopenharmony_ci 99bf215546Sopenharmony_civoid 100bf215546Sopenharmony_ciintel_aux_map_add_mapping(struct intel_aux_map_context *ctx, uint64_t address, 101bf215546Sopenharmony_ci uint64_t aux_address, uint64_t main_size_B, 102bf215546Sopenharmony_ci uint64_t format_bits); 103bf215546Sopenharmony_ci 104bf215546Sopenharmony_civoid 105bf215546Sopenharmony_ciintel_aux_map_unmap_range(struct intel_aux_map_context *ctx, uint64_t address, 106bf215546Sopenharmony_ci uint64_t size); 107bf215546Sopenharmony_ci 108bf215546Sopenharmony_ci#ifdef __cplusplus 109bf215546Sopenharmony_ci} 110bf215546Sopenharmony_ci#endif 111bf215546Sopenharmony_ci 112bf215546Sopenharmony_ci#endif /* INTEL_AUX_MAP_H */ 113