1 /**************************************************************************
2 *
3 * Copyright (C) 2022 Collabora Ltd
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice shall be included
13 * in all copies or substantial portions of the Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
16 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
19 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
20 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
21 * OTHER DEALINGS IN THE SOFTWARE.
22 *
23 **************************************************************************/
24
25 #ifndef VKR_ALLOCATOR_H
26 #define VKR_ALLOCATOR_H
27
28 #include <stdint.h>
29
30 struct virgl_resource;
31
32 #ifdef ENABLE_VENUS
33
34 int
35 vkr_allocator_init(void);
36 void
37 vkr_allocator_fini(void);
38
39 int
40 vkr_allocator_resource_map(struct virgl_resource *res, void **map, uint64_t *out_size);
41 int
42 vkr_allocator_resource_unmap(struct virgl_resource *res);
43
44 #else /* ENABLE_VENUS */
45
46 #include "util/macros.h"
47
48 static inline int
vkr_allocator_init(void)49 vkr_allocator_init(void)
50 {
51 return -1;
52 }
53
54 static inline void
vkr_allocator_fini(void)55 vkr_allocator_fini(void)
56 {
57 }
58
59 static inline int
vkr_allocator_resource_map(UNUSED struct virgl_resource * res,UNUSED void ** map,UNUSED uint64_t * out_size)60 vkr_allocator_resource_map(UNUSED struct virgl_resource *res,
61 UNUSED void **map,
62 UNUSED uint64_t *out_size)
63 {
64 return -1;
65 }
66
67 static inline int
vkr_allocator_resource_unmap(UNUSED struct virgl_resource * res)68 vkr_allocator_resource_unmap(UNUSED struct virgl_resource *res)
69 {
70 return -1;
71 }
72
73 #endif /* ENABLE_VENUS */
74
75 #endif /* VKR_ALLOCATOR_H */
76