| 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 * |
| 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 |
_EGL_DEVICE_QUERY_NAME, |
| 68 |
_EGL_DEVICE_PERSISTENT_ID, |
| 69 |
}; |
| 70 |
|
| 71 |
typedef enum _egl_device_extension _EGLDeviceExtension; |
| 72 |
|
| 73 |
#ifdef HAVE_LIBDRM |
| 74 |
drmDevicePtr |
| 75 |
_eglDeviceDrm(_EGLDevice *dev); |
| 76 |
#else |
| 77 |
#define _eglDeviceDrm(dev) NULL |
| 78 |
#endif |
| 79 |
|
| 80 |
_EGLDevice * |
| 81 |
_eglDeviceNext(_EGLDevice *dev); |
| 82 |
|
| 83 |
EGLBoolean |
| 84 |
_eglDeviceSupports(_EGLDevice *dev, _EGLDeviceExtension ext); |
| 85 |
|
| 86 |
int |
| 87 |
_eglDeviceRefreshList(void); |
| 88 |
|
| 89 |
EGLBoolean |
| 90 |
_eglQueryDeviceAttribEXT(_EGLDevice *dev, EGLint attribute, EGLAttrib *value); |
| 91 |
|
| 92 |
const char * |
| 93 |
_eglQueryDeviceStringEXT(_EGLDevice *dev, EGLint name); |
| 94 |
|
| 95 |
EGLBoolean |
| 96 |
_eglQueryDevicesEXT(EGLint max_devices, _EGLDevice **devices, |
| 97 |
EGLint *num_devices); |
| 98 |
|
| 99 |
EGLBoolean |
| 100 |
_eglQueryDeviceBinaryEXT(_EGLDevice* dev, |
| 101 |
EGLint name, |
| 102 |
EGLint max_size, |
| 103 |
void *value, |
| 104 |
EGLint *size); |
| 105 |
|
| 106 |
#ifdef __cplusplus |
| 107 |
} |
| 108 |
#endif |
| 109 |
|
| 110 |
#endif /* EGLDEVICE_INCLUDED */ |