2 * Copyright © 2011 Intel Corporation
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
19 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 * DEALINGS IN THE SOFTWARE.
25 * Kristian Høgsberg <krh@bitplanet.net>
37 dri2_drm_authenticate(_EGLDisplay
*disp
, uint32_t id
)
39 struct dri2_egl_display
*dri2_dpy
= dri2_egl_display(disp
);
41 return drmAuthMagic(dri2_dpy
->fd
, id
);
45 dri2_initialize_drm(_EGLDriver
*drv
, _EGLDisplay
*disp
)
47 struct dri2_egl_display
*dri2_dpy
;
50 dri2_dpy
= malloc(sizeof *dri2_dpy
);
52 return _eglError(EGL_BAD_ALLOC
, "eglInitialize");
54 memset(dri2_dpy
, 0, sizeof *dri2_dpy
);
56 disp
->DriverData
= (void *) dri2_dpy
;
57 dri2_dpy
->fd
= (int) (intptr_t) disp
->PlatformDisplay
;
59 dri2_dpy
->driver_name
= dri2_get_driver_for_fd(dri2_dpy
->fd
);
60 if (dri2_dpy
->driver_name
== NULL
)
61 return _eglError(EGL_BAD_ALLOC
, "DRI2: failed to get driver name");
63 dri2_dpy
->device_name
= dri2_get_device_name_for_fd(dri2_dpy
->fd
);
64 if (dri2_dpy
->device_name
== NULL
) {
65 _eglError(EGL_BAD_ALLOC
, "DRI2: failed to get device name");
66 goto cleanup_driver_name
;
69 if (!dri2_load_driver(disp
))
70 goto cleanup_device_name
;
72 dri2_dpy
->extensions
[0] = &image_lookup_extension
.base
;
73 dri2_dpy
->extensions
[1] = &use_invalidate
.base
;
74 dri2_dpy
->extensions
[2] = NULL
;
76 if (!dri2_create_screen(disp
))
79 for (i
= 0; dri2_dpy
->driver_configs
[i
]; i
++)
80 dri2_add_config(disp
, dri2_dpy
->driver_configs
[i
], i
+ 1, 0, 0, NULL
);
82 #ifdef HAVE_WAYLAND_PLATFORM
83 disp
->Extensions
.WL_bind_wayland_display
= EGL_TRUE
;
85 dri2_dpy
->authenticate
= dri2_drm_authenticate
;
87 /* we're supporting EGL 1.4 */
88 disp
->VersionMajor
= 1;
89 disp
->VersionMinor
= 4;
94 dlclose(dri2_dpy
->driver
);
96 free(dri2_dpy
->device_name
);
98 free(dri2_dpy
->driver_name
);