• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_WINSYS_HELPER_H
25 #define PVR_WINSYS_HELPER_H
26 
27 #include <stdbool.h>
28 #include <stdint.h>
29 
30 #include "pvr_types.h"
31 
32 struct pvr_winsys;
33 struct pvr_winsys_heap;
34 struct pvr_winsys_static_data_offsets;
35 struct pvr_winsys_vma;
36 
37 typedef struct pvr_winsys_vma *(*const heap_alloc_reserved_func)(
38    struct pvr_winsys_heap *const heap,
39    const pvr_dev_addr_t reserved_dev_addr,
40    uint64_t size,
41    uint64_t alignment);
42 
43 int pvr_winsys_helper_display_buffer_create(int master_fd,
44                                             uint64_t size,
45                                             uint32_t *const handle_out);
46 int pvr_winsys_helper_display_buffer_destroy(int master_fd, uint32_t handle);
47 
48 VkResult pvr_winsys_helper_winsys_heap_init(
49    struct pvr_winsys *const ws,
50    pvr_dev_addr_t base_address,
51    uint64_t size,
52    pvr_dev_addr_t reserved_address,
53    uint64_t reserved_size,
54    uint32_t log2_page_size,
55    const struct pvr_winsys_static_data_offsets *const static_data_offsets,
56    struct pvr_winsys_heap *const heap);
57 bool pvr_winsys_helper_winsys_heap_finish(struct pvr_winsys_heap *const heap);
58 
59 bool pvr_winsys_helper_heap_alloc(struct pvr_winsys_heap *const heap,
60                                   uint64_t size,
61                                   uint64_t alignment,
62                                   struct pvr_winsys_vma *const vma);
63 void pvr_winsys_helper_heap_free(struct pvr_winsys_vma *const vma);
64 
65 VkResult pvr_winsys_helper_allocate_static_memory(
66    struct pvr_winsys *const ws,
67    heap_alloc_reserved_func heap_alloc_reserved,
68    struct pvr_winsys_heap *const general_heap,
69    struct pvr_winsys_heap *const pds_heap,
70    struct pvr_winsys_heap *const usc_heap,
71    struct pvr_winsys_vma **const general_vma_out,
72    struct pvr_winsys_vma **const pds_vma_out,
73    struct pvr_winsys_vma **const usc_vma_out);
74 void pvr_winsys_helper_free_static_memory(
75    struct pvr_winsys_vma *const general_vma,
76    struct pvr_winsys_vma *const pds_vma,
77    struct pvr_winsys_vma *const usc_vma);
78 
79 VkResult
80 pvr_winsys_helper_fill_static_memory(struct pvr_winsys *const ws,
81                                      struct pvr_winsys_vma *const general_vma,
82                                      struct pvr_winsys_vma *const pds_vma,
83                                      struct pvr_winsys_vma *const usc_vma);
84 
85 #endif /* PVR_WINSYS_HELPER_H */
86