xref: /aosp_15_r20/external/mesa3d/src/egl/main/egldevice.h (revision 6104692788411f58d303aa86923a9ff6ecaded22)
1 /**************************************************************************
2  *
3  * Copyright 2015, 2018 Collabora
4  * All Rights Reserved.
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a
7  * copy of this software and associated documentation files (the
8  * "Software"), to deal in the Software without restriction, including
9  * without limitation the rights to use, copy, modify, merge, publish,
10  * distribute, sub license, and/or sell copies of the Software, and to
11  * permit persons to whom the Software is furnished to do so, subject to
12  * the following conditions:
13  *
14  * The above copyright notice and this permission notice (including the
15  * next paragraph) shall be included in all copies or substantial portions
16  * of the Software.
17  *
18  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
21  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
24  * DEALINGS IN THE SOFTWARE.
25  *
26  **************************************************************************/
27 
28 #ifndef EGLDEVICE_INCLUDED
29 #define EGLDEVICE_INCLUDED
30 
31 #include <stdbool.h>
32 #include <stddef.h>
33 #ifdef HAVE_LIBDRM
34 #include <xf86drm.h>
35 #endif
36 
37 #include "egltypedefs.h"
38 
39 #ifdef __cplusplus
40 extern "C" {
41 #endif
42 
43 extern _EGLDevice _eglSoftwareDevice;
44 
45 void
46 _eglFiniDevice(void);
47 
48 EGLBoolean
49 _eglCheckDeviceHandle(EGLDeviceEXT device);
50 
51 static inline _EGLDevice *
_eglLookupDevice(EGLDeviceEXT device)52 _eglLookupDevice(EGLDeviceEXT device)
53 {
54    _EGLDevice *dev = (_EGLDevice *)device;
55    if (!_eglCheckDeviceHandle(device))
56       dev = NULL;
57    return dev;
58 }
59 
60 _EGLDevice *
61 _eglFindDevice(int fd, bool software);
62 
63 enum _egl_device_extension {
64    _EGL_DEVICE_SOFTWARE,
65    _EGL_DEVICE_DRM,
66    _EGL_DEVICE_DRM_RENDER_NODE,
67 };
68 
69 typedef enum _egl_device_extension _EGLDeviceExtension;
70 
71 #ifdef HAVE_LIBDRM
72 drmDevicePtr
73 _eglDeviceDrm(_EGLDevice *dev);
74 #else
75 #define _eglDeviceDrm(dev) NULL
76 #endif
77 
78 _EGLDevice *
79 _eglDeviceNext(_EGLDevice *dev);
80 
81 EGLBoolean
82 _eglDeviceSupports(_EGLDevice *dev, _EGLDeviceExtension ext);
83 
84 int
85 _eglDeviceRefreshList(void);
86 
87 EGLBoolean
88 _eglQueryDeviceAttribEXT(_EGLDevice *dev, EGLint attribute, EGLAttrib *value);
89 
90 const char *
91 _eglQueryDeviceStringEXT(_EGLDevice *dev, EGLint name);
92 
93 EGLBoolean
94 _eglQueryDevicesEXT(EGLint max_devices, _EGLDevice **devices,
95                     EGLint *num_devices);
96 
97 #ifdef __cplusplus
98 }
99 #endif
100 
101 #endif /* EGLDEVICE_INCLUDED */
102