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 
29 #ifndef EGLDEVICE_INCLUDED
30 #define EGLDEVICE_INCLUDED
31 
32 
33 #include <stdbool.h>
34 #include <stddef.h>
35 #include "egltypedefs.h"
36 
37 #ifdef __cplusplus
38 extern "C" {
39 #endif
40 
41 extern _EGLDevice _eglSoftwareDevice;
42 
43 void
44 _eglFiniDevice(void);
45 
46 EGLBoolean
47 _eglCheckDeviceHandle(EGLDeviceEXT device);
48 
49 static inline _EGLDevice *
_eglLookupDevice(EGLDeviceEXT device)50 _eglLookupDevice(EGLDeviceEXT device)
51 {
52    _EGLDevice *dev = (_EGLDevice *) device;
53    if (!_eglCheckDeviceHandle(device))
54       dev = NULL;
55    return dev;
56 }
57 
58 _EGLDevice *
59 _eglAddDevice(int fd, bool software);
60 
61 enum _egl_device_extension {
62    _EGL_DEVICE_SOFTWARE,
63    _EGL_DEVICE_DRM,
64 };
65 
66 typedef enum _egl_device_extension _EGLDeviceExtension;
67 
68 EGLBoolean
69 _eglDeviceSupports(_EGLDevice *dev, _EGLDeviceExtension ext);
70 
71 const char *
72 _eglGetDRMDeviceRenderNode(_EGLDevice *dev);
73 
74 EGLBoolean
75 _eglQueryDeviceAttribEXT(_EGLDevice *dev, EGLint attribute,
76                          EGLAttrib *value);
77 
78 const char *
79 _eglQueryDeviceStringEXT(_EGLDevice *dev, EGLint name);
80 
81 EGLBoolean
82 _eglQueryDevicesEXT(EGLint max_devices, _EGLDevice **devices,
83                     EGLint *num_devices);
84 
85 #ifdef __cplusplus
86 }
87 #endif
88 
89 #endif /* EGLDEVICE_INCLUDED */
90