1bf215546Sopenharmony_ci/* 2bf215546Sopenharmony_ci * Copyright © 2022 Imagination Technologies Ltd. 3bf215546Sopenharmony_ci * 4bf215546Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a copy 5bf215546Sopenharmony_ci * of this software and associated documentation files (the "Software"), to deal 6bf215546Sopenharmony_ci * in the Software without restriction, including without limitation the rights 7bf215546Sopenharmony_ci * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8bf215546Sopenharmony_ci * copies of the Software, and to permit persons to whom the Software is 9bf215546Sopenharmony_ci * 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 THE 18bf215546Sopenharmony_ci * 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 FROM, 20bf215546Sopenharmony_ci * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21bf215546Sopenharmony_ci * SOFTWARE. 22bf215546Sopenharmony_ci */ 23bf215546Sopenharmony_ci 24bf215546Sopenharmony_ci#ifndef PVR_SRV_H 25bf215546Sopenharmony_ci#define PVR_SRV_H 26bf215546Sopenharmony_ci 27bf215546Sopenharmony_ci#include <stdint.h> 28bf215546Sopenharmony_ci#include <pthread.h> 29bf215546Sopenharmony_ci#include <vulkan/vulkan.h> 30bf215546Sopenharmony_ci 31bf215546Sopenharmony_ci#include "pvr_winsys.h" 32bf215546Sopenharmony_ci#include "util/macros.h" 33bf215546Sopenharmony_ci#include "util/vma.h" 34bf215546Sopenharmony_ci 35bf215546Sopenharmony_ci/******************************************* 36bf215546Sopenharmony_ci Misc defines 37bf215546Sopenharmony_ci *******************************************/ 38bf215546Sopenharmony_ci 39bf215546Sopenharmony_ci/* 64KB is MAX anticipated OS page size */ 40bf215546Sopenharmony_ci#define PVR_SRV_RESERVED_SIZE_GRANULARITY 0x10000 41bf215546Sopenharmony_ci 42bf215546Sopenharmony_ci#define PVR_SRV_DEVMEM_HEAPNAME_MAXLENGTH 160 43bf215546Sopenharmony_ci 44bf215546Sopenharmony_ci#define PVR_SRV_GENERAL_HEAP_IDENT "General" 45bf215546Sopenharmony_ci#define PVR_SRV_PDSCODEDATA_HEAP_IDENT "PDS Code and Data" 46bf215546Sopenharmony_ci#define PVR_SRV_RGNHDR_BRN_63142_HEAP_IDENT "RgnHdr BRN63142" 47bf215546Sopenharmony_ci#define PVR_SRV_TRANSFER_3D_HEAP_IDENT "TQ3DParameters" 48bf215546Sopenharmony_ci#define PVR_SRV_USCCODE_HEAP_IDENT "USC Code" 49bf215546Sopenharmony_ci#define PVR_SRV_VISIBILITY_TEST_HEAP_IDENT "Visibility Test" 50bf215546Sopenharmony_ci 51bf215546Sopenharmony_ci#define FWIF_PDS_HEAP_TOTAL_BYTES 4096 52bf215546Sopenharmony_ci#define FWIF_PDS_HEAP_VDM_SYNC_OFFSET_BYTES 0 53bf215546Sopenharmony_ci#define FWIF_PDS_HEAP_EOT_OFFSET_BYTES 128 54bf215546Sopenharmony_ci#define FWIF_GENERAL_HEAP_TOTAL_BYTES 4096 55bf215546Sopenharmony_ci#define FWIF_USC_HEAP_TOTAL_BYTES 4096 56bf215546Sopenharmony_ci#define FWIF_USC_HEAP_VDM_SYNC_OFFSET_BYTES 0 57bf215546Sopenharmony_ci#define FWIF_GENERAL_HEAP_YUV_CSC_OFFSET_BYTES 128U 58bf215546Sopenharmony_ci 59bf215546Sopenharmony_ci/******************************************* 60bf215546Sopenharmony_ci structure definitions 61bf215546Sopenharmony_ci *******************************************/ 62bf215546Sopenharmony_cistruct pvr_srv_winsys_heap { 63bf215546Sopenharmony_ci struct pvr_winsys_heap base; 64bf215546Sopenharmony_ci 65bf215546Sopenharmony_ci void *server_heap; 66bf215546Sopenharmony_ci}; 67bf215546Sopenharmony_ci 68bf215546Sopenharmony_cistruct pvr_srv_winsys { 69bf215546Sopenharmony_ci struct pvr_winsys base; 70bf215546Sopenharmony_ci 71bf215546Sopenharmony_ci int master_fd; 72bf215546Sopenharmony_ci int render_fd; 73bf215546Sopenharmony_ci 74bf215546Sopenharmony_ci const VkAllocationCallbacks *alloc; 75bf215546Sopenharmony_ci 76bf215546Sopenharmony_ci /* Packed bvnc */ 77bf215546Sopenharmony_ci uint64_t bvnc; 78bf215546Sopenharmony_ci 79bf215546Sopenharmony_ci void *server_memctx; 80bf215546Sopenharmony_ci void *server_memctx_data; 81bf215546Sopenharmony_ci 82bf215546Sopenharmony_ci /* Required heaps */ 83bf215546Sopenharmony_ci struct pvr_srv_winsys_heap general_heap; 84bf215546Sopenharmony_ci struct pvr_srv_winsys_heap pds_heap; 85bf215546Sopenharmony_ci struct pvr_srv_winsys_heap transfer_3d_heap; 86bf215546Sopenharmony_ci struct pvr_srv_winsys_heap usc_heap; 87bf215546Sopenharmony_ci struct pvr_srv_winsys_heap vis_test_heap; 88bf215546Sopenharmony_ci 89bf215546Sopenharmony_ci /* Optional heaps */ 90bf215546Sopenharmony_ci bool rgn_hdr_heap_present; 91bf215546Sopenharmony_ci struct pvr_srv_winsys_heap rgn_hdr_heap; 92bf215546Sopenharmony_ci 93bf215546Sopenharmony_ci /* vma's for reserved memory regions */ 94bf215546Sopenharmony_ci struct pvr_winsys_vma *pds_vma; 95bf215546Sopenharmony_ci struct pvr_winsys_vma *usc_vma; 96bf215546Sopenharmony_ci struct pvr_winsys_vma *general_vma; 97bf215546Sopenharmony_ci 98bf215546Sopenharmony_ci /* Sync block used for allocating sync primitives. */ 99bf215546Sopenharmony_ci void *sync_block_handle; 100bf215546Sopenharmony_ci uint32_t sync_block_size; 101bf215546Sopenharmony_ci uint32_t sync_block_fw_addr; 102bf215546Sopenharmony_ci uint16_t sync_block_offset; 103bf215546Sopenharmony_ci}; 104bf215546Sopenharmony_ci 105bf215546Sopenharmony_cistruct pvr_srv_sync_prim { 106bf215546Sopenharmony_ci struct pvr_srv_winsys *srv_ws; 107bf215546Sopenharmony_ci uint32_t offset; 108bf215546Sopenharmony_ci uint32_t value; 109bf215546Sopenharmony_ci}; 110bf215546Sopenharmony_ci 111bf215546Sopenharmony_ci/******************************************* 112bf215546Sopenharmony_ci helper macros 113bf215546Sopenharmony_ci *******************************************/ 114bf215546Sopenharmony_ci 115bf215546Sopenharmony_ci#define to_pvr_srv_winsys(ws) container_of((ws), struct pvr_srv_winsys, base) 116bf215546Sopenharmony_ci#define to_pvr_srv_winsys_heap(heap) \ 117bf215546Sopenharmony_ci container_of((heap), struct pvr_srv_winsys_heap, base) 118bf215546Sopenharmony_ci 119bf215546Sopenharmony_ci/******************************************* 120bf215546Sopenharmony_ci functions 121bf215546Sopenharmony_ci *******************************************/ 122bf215546Sopenharmony_ci 123bf215546Sopenharmony_cistruct pvr_srv_sync_prim * 124bf215546Sopenharmony_cipvr_srv_sync_prim_alloc(struct pvr_srv_winsys *srv_ws); 125bf215546Sopenharmony_civoid pvr_srv_sync_prim_free(struct pvr_srv_sync_prim *sync_prim); 126bf215546Sopenharmony_ci 127bf215546Sopenharmony_cistatic inline uint32_t 128bf215546Sopenharmony_cipvr_srv_sync_prim_get_fw_addr(const struct pvr_srv_sync_prim *const sync_prim) 129bf215546Sopenharmony_ci{ 130bf215546Sopenharmony_ci return sync_prim->srv_ws->sync_block_fw_addr + sync_prim->offset; 131bf215546Sopenharmony_ci} 132bf215546Sopenharmony_ci 133bf215546Sopenharmony_ci#endif /* PVR_SRV_H */ 134