xref: /aosp_15_r20/external/mesa3d/src/imagination/vulkan/winsys/pvrsrvkm/pvr_srv.h (revision 6104692788411f58d303aa86923a9ff6ecaded22)
1 /*
2  * Copyright © 2022 Imagination Technologies Ltd.
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a copy
5  * of this software and associated documentation files (the "Software"), to deal
6  * in the Software without restriction, including without limitation the rights
7  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8  * copies of the Software, and to permit persons to whom the Software is
9  * 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 THE
18  * 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 PVR_SRV_H
25 #define PVR_SRV_H
26 
27 #include <stdint.h>
28 #include <pthread.h>
29 #include <vulkan/vulkan.h>
30 
31 #include "pvr_srv_sync.h"
32 #include "pvr_srv_sync_prim.h"
33 #include "pvr_winsys.h"
34 #include "util/macros.h"
35 #include "util/vma.h"
36 
37 /*******************************************
38    Misc defines
39  *******************************************/
40 
41 /* 64KB is MAX anticipated OS page size */
42 #define PVR_SRV_CARVEOUT_SIZE_GRANULARITY 0x10000
43 
44 #define PVR_SRV_DEVMEM_HEAPNAME_MAXLENGTH 160
45 
46 #define PVR_SRV_GENERAL_HEAP_IDENT "General"
47 #define PVR_SRV_PDSCODEDATA_HEAP_IDENT "PDS Code and Data"
48 #define PVR_SRV_RGNHDR_BRN_63142_HEAP_IDENT "RgnHdr BRN63142"
49 #define PVR_SRV_TRANSFER_3D_HEAP_IDENT "TQ3DParameters"
50 #define PVR_SRV_USCCODE_HEAP_IDENT "USC Code"
51 #define PVR_SRV_VISIBILITY_TEST_HEAP_IDENT "Visibility Test"
52 
53 #define FWIF_PDS_HEAP_TOTAL_BYTES 4096
54 #define FWIF_PDS_HEAP_VDM_SYNC_OFFSET_BYTES 0
55 #define FWIF_PDS_HEAP_EOT_OFFSET_BYTES 128
56 #define FWIF_GENERAL_HEAP_TOTAL_BYTES 4096
57 #define FWIF_USC_HEAP_TOTAL_BYTES 4096
58 #define FWIF_USC_HEAP_VDM_SYNC_OFFSET_BYTES 0
59 #define FWIF_GENERAL_HEAP_YUV_CSC_OFFSET_BYTES 128U
60 
61 /*******************************************
62     structure definitions
63  *******************************************/
64 struct pvr_srv_winsys_heap {
65    struct pvr_winsys_heap base;
66 
67    void *server_heap;
68 };
69 
70 struct pvr_srv_winsys {
71    struct pvr_winsys base;
72 
73    struct pvr_device *presignaled_sync_device;
74    struct pvr_srv_sync *presignaled_sync;
75 
76    /* Packed bvnc */
77    uint64_t bvnc;
78 
79    void *server_memctx;
80    void *server_memctx_data;
81 
82    /* Required heaps */
83    struct pvr_srv_winsys_heap general_heap;
84    struct pvr_srv_winsys_heap pds_heap;
85    struct pvr_srv_winsys_heap transfer_3d_heap;
86    struct pvr_srv_winsys_heap usc_heap;
87    struct pvr_srv_winsys_heap vis_test_heap;
88 
89    /* Optional heaps */
90    bool rgn_hdr_heap_present;
91    struct pvr_srv_winsys_heap rgn_hdr_heap;
92 
93    /* vma's for carveout memory regions */
94    struct pvr_winsys_vma *pds_vma;
95    struct pvr_winsys_vma *usc_vma;
96    struct pvr_winsys_vma *general_vma;
97 
98    struct pvr_srv_sync_prim_ctx sync_prim_ctx;
99 };
100 
101 /*******************************************
102     helper macros
103  *******************************************/
104 
105 #define to_pvr_srv_winsys(ws) container_of((ws), struct pvr_srv_winsys, base)
106 #define to_pvr_srv_winsys_heap(heap) \
107    container_of((heap), struct pvr_srv_winsys_heap, base)
108 
109 /*******************************************
110     functions
111  *******************************************/
112 
113 VkResult pvr_srv_sync_get_presignaled_sync(struct pvr_device *device,
114                                            struct pvr_srv_sync **out_sync);
115 
116 #endif /* PVR_SRV_H */
117