1 | /* |
2 | Simple DirectMedia Layer |
3 | Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org> |
4 | |
5 | This software is provided 'as-is', without any express or implied |
6 | warranty. In no event will the authors be held liable for any damages |
7 | arising from the use of this software. |
8 | |
9 | Permission is granted to anyone to use this software for any purpose, |
10 | including commercial applications, and to alter it and redistribute it |
11 | freely, subject to the following restrictions: |
12 | |
13 | 1. The origin of this software must not be misrepresented; you must not |
14 | claim that you wrote the original software. If you use this software |
15 | in a product, an acknowledgment in the product documentation would be |
16 | appreciated but is not required. |
17 | 2. Altered source versions must be plainly marked as such, and must not be |
18 | misrepresented as being the original software. |
19 | 3. This notice may not be removed or altered from any source distribution. |
20 | */ |
21 | |
22 | /* *INDENT-OFF* */ // clang-format off |
23 | |
24 | #ifndef SDL_KMSDRM_MODULE |
25 | #define SDL_KMSDRM_MODULE(modname) |
26 | #endif |
27 | |
28 | #ifndef SDL_KMSDRM_SYM |
29 | #define SDL_KMSDRM_SYM(rc,fn,params) |
30 | #endif |
31 | |
32 | #ifndef SDL_KMSDRM_SYM_CONST |
33 | #define SDL_KMSDRM_SYM_CONST(type, name) |
34 | #endif |
35 | |
36 | #ifndef SDL_KMSDRM_SYM_OPT |
37 | #define SDL_KMSDRM_SYM_OPT(rc,fn,params) |
38 | #endif |
39 | |
40 | |
41 | SDL_KMSDRM_MODULE(LIBDRM) |
42 | SDL_KMSDRM_SYM(void,drmModeFreeResources,(drmModeResPtr ptr)) |
43 | SDL_KMSDRM_SYM(void,drmModeFreeFB,(drmModeFBPtr ptr)) |
44 | SDL_KMSDRM_SYM(void,drmModeFreeCrtc,(drmModeCrtcPtr ptr)) |
45 | SDL_KMSDRM_SYM(void,drmModeFreeConnector,(drmModeConnectorPtr ptr)) |
46 | SDL_KMSDRM_SYM(void,drmModeFreeEncoder,(drmModeEncoderPtr ptr)) |
47 | SDL_KMSDRM_SYM(int,drmGetCap,(int fd, uint64_t capability, uint64_t *value)) |
48 | SDL_KMSDRM_SYM(int,drmSetMaster,(int fd)) |
49 | SDL_KMSDRM_SYM(int,drmDropMaster,(int fd)) |
50 | SDL_KMSDRM_SYM(int,drmAuthMagic,(int fd, drm_magic_t magic)) |
51 | SDL_KMSDRM_SYM(drmModeResPtr,drmModeGetResources,(int fd)) |
52 | SDL_KMSDRM_SYM(int,drmModeAddFB,(int fd, uint32_t width, uint32_t height, uint8_t depth, |
53 | uint8_t bpp, uint32_t pitch, uint32_t bo_handle, |
54 | uint32_t *buf_id)) |
55 | |
56 | SDL_KMSDRM_SYM_OPT(int,drmModeAddFB2,(int fd, uint32_t width, uint32_t height, |
57 | uint32_t pixel_format, const uint32_t bo_handles[4], |
58 | const uint32_t pitches[4], const uint32_t offsets[4], |
59 | uint32_t *buf_id, uint32_t flags)) |
60 | |
61 | SDL_KMSDRM_SYM_OPT(int,drmModeAddFB2WithModifiers,(int fd, uint32_t width, |
62 | uint32_t height, uint32_t pixel_format, const uint32_t bo_handles[4], |
63 | const uint32_t pitches[4], const uint32_t offsets[4], |
64 | const uint64_t modifier[4], uint32_t *buf_id, uint32_t flags)) |
65 | |
66 | SDL_KMSDRM_SYM_OPT(const char *,drmModeGetConnectorTypeName,(uint32_t connector_type)) |
67 | |
68 | SDL_KMSDRM_SYM(int,drmModeRmFB,(int fd, uint32_t bufferId)) |
69 | SDL_KMSDRM_SYM(drmModeFBPtr,drmModeGetFB,(int fd, uint32_t buf)) |
70 | SDL_KMSDRM_SYM(drmModeCrtcPtr,drmModeGetCrtc,(int fd, uint32_t crtcId)) |
71 | SDL_KMSDRM_SYM(int,drmModeSetCrtc,(int fd, uint32_t crtcId, uint32_t bufferId, |
72 | uint32_t x, uint32_t y, uint32_t *connectors, int count, |
73 | drmModeModeInfoPtr mode)) |
74 | SDL_KMSDRM_SYM(int,drmModeSetCursor,(int fd, uint32_t crtcId, uint32_t bo_handle, |
75 | uint32_t width, uint32_t height)) |
76 | SDL_KMSDRM_SYM(int,drmModeSetCursor2,(int fd, uint32_t crtcId, uint32_t bo_handle, |
77 | uint32_t width, uint32_t height, |
78 | int32_t hot_x, int32_t hot_y)) |
79 | SDL_KMSDRM_SYM(int,drmModeMoveCursor,(int fd, uint32_t crtcId, int x, int y)) |
80 | SDL_KMSDRM_SYM(drmModeEncoderPtr,drmModeGetEncoder,(int fd, uint32_t encoder_id)) |
81 | SDL_KMSDRM_SYM(drmModeConnectorPtr,drmModeGetConnector,(int fd, uint32_t connector_id)) |
82 | SDL_KMSDRM_SYM(int,drmHandleEvent,(int fd,drmEventContextPtr evctx)) |
83 | SDL_KMSDRM_SYM(int,drmModePageFlip,(int fd, uint32_t crtc_id, uint32_t fb_id, |
84 | uint32_t flags, void *user_data)) |
85 | |
86 | // Planes stuff. |
87 | SDL_KMSDRM_SYM(int,drmSetClientCap,(int fd, uint64_t capability, uint64_t value)) |
88 | SDL_KMSDRM_SYM(drmModePlaneResPtr,drmModeGetPlaneResources,(int fd)) |
89 | SDL_KMSDRM_SYM(drmModePlanePtr,drmModeGetPlane,(int fd, uint32_t plane_id)) |
90 | SDL_KMSDRM_SYM(drmModeObjectPropertiesPtr,drmModeObjectGetProperties,(int fd,uint32_t object_id,uint32_t object_type)) |
91 | SDL_KMSDRM_SYM(int,drmModeObjectSetProperty,(int fd, uint32_t object_id, |
92 | uint32_t object_type, uint32_t property_id, |
93 | uint64_t value)) |
94 | SDL_KMSDRM_SYM(drmModePropertyPtr,drmModeGetProperty,(int fd, uint32_t propertyId)) |
95 | |
96 | SDL_KMSDRM_SYM(void,drmModeFreeProperty,(drmModePropertyPtr ptr)) |
97 | SDL_KMSDRM_SYM(void,drmModeFreeObjectProperties,(drmModeObjectPropertiesPtr ptr)) |
98 | SDL_KMSDRM_SYM(void,drmModeFreePlane,(drmModePlanePtr ptr)) |
99 | SDL_KMSDRM_SYM(void,drmModeFreePlaneResources,(drmModePlaneResPtr ptr)) |
100 | SDL_KMSDRM_SYM(int,drmModeSetPlane,(int fd, uint32_t plane_id, uint32_t crtc_id, |
101 | uint32_t fb_id, uint32_t flags, |
102 | int32_t crtc_x, int32_t crtc_y, |
103 | uint32_t crtc_w, uint32_t crtc_h, |
104 | uint32_t src_x, uint32_t src_y, |
105 | uint32_t src_w, uint32_t src_h)) |
106 | // Planes stuff ends. |
107 | |
108 | SDL_KMSDRM_MODULE(GBM) |
109 | SDL_KMSDRM_SYM(int,gbm_device_is_format_supported,(struct gbm_device *gbm, |
110 | uint32_t format, uint32_t usage)) |
111 | SDL_KMSDRM_SYM(void,gbm_device_destroy,(struct gbm_device *gbm)) |
112 | SDL_KMSDRM_SYM(struct gbm_device *,gbm_create_device,(int fd)) |
113 | SDL_KMSDRM_SYM(unsigned int,gbm_bo_get_width,(struct gbm_bo *bo)) |
114 | SDL_KMSDRM_SYM(unsigned int,gbm_bo_get_height,(struct gbm_bo *bo)) |
115 | SDL_KMSDRM_SYM(uint32_t,gbm_bo_get_stride,(struct gbm_bo *bo)) |
116 | SDL_KMSDRM_SYM(uint32_t,gbm_bo_get_format,(struct gbm_bo *bo)) |
117 | SDL_KMSDRM_SYM(union gbm_bo_handle,gbm_bo_get_handle,(struct gbm_bo *bo)) |
118 | SDL_KMSDRM_SYM(int,gbm_bo_write,(struct gbm_bo *bo, const void *buf, size_t count)) |
119 | SDL_KMSDRM_SYM(struct gbm_device *,gbm_bo_get_device,(struct gbm_bo *bo)) |
120 | SDL_KMSDRM_SYM(void,gbm_bo_set_user_data,(struct gbm_bo *bo, void *data, |
121 | void (*destroy_user_data)(struct gbm_bo *, void *))) |
122 | SDL_KMSDRM_SYM(void *,gbm_bo_get_user_data,(struct gbm_bo *bo)) |
123 | SDL_KMSDRM_SYM(void,gbm_bo_destroy,(struct gbm_bo *bo)) |
124 | SDL_KMSDRM_SYM(struct gbm_bo *,gbm_bo_create,(struct gbm_device *gbm, |
125 | uint32_t width, uint32_t height, |
126 | uint32_t format, uint32_t usage)) |
127 | SDL_KMSDRM_SYM(struct gbm_surface *,gbm_surface_create,(struct gbm_device *gbm, |
128 | uint32_t width, uint32_t height, |
129 | uint32_t format, uint32_t flags)) |
130 | SDL_KMSDRM_SYM(void,gbm_surface_destroy,(struct gbm_surface *surf)) |
131 | SDL_KMSDRM_SYM(struct gbm_bo *,gbm_surface_lock_front_buffer,(struct gbm_surface *surf)) |
132 | SDL_KMSDRM_SYM(void,gbm_surface_release_buffer,(struct gbm_surface *surf, struct gbm_bo *bo)) |
133 | |
134 | SDL_KMSDRM_SYM_OPT(uint64_t,gbm_bo_get_modifier,(struct gbm_bo *bo)) |
135 | SDL_KMSDRM_SYM_OPT(int,gbm_bo_get_plane_count,(struct gbm_bo *bo)) |
136 | SDL_KMSDRM_SYM_OPT(uint32_t,gbm_bo_get_offset,(struct gbm_bo *bo, int plane)) |
137 | SDL_KMSDRM_SYM_OPT(uint32_t,gbm_bo_get_stride_for_plane,(struct gbm_bo *bo, int plane)) |
138 | SDL_KMSDRM_SYM_OPT(union gbm_bo_handle,gbm_bo_get_handle_for_plane,(struct gbm_bo *bo, int plane)) |
139 | |
140 | #undef SDL_KMSDRM_MODULE |
141 | #undef SDL_KMSDRM_SYM |
142 | #undef SDL_KMSDRM_SYM_CONST |
143 | #undef SDL_KMSDRM_SYM_OPT |
144 | |
145 | /* *INDENT-ON* */ // clang-format on |
146 | |