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>
36 dri2_drm_authenticate(_EGLDisplay
*disp
, uint32_t id
)
38 struct dri2_egl_display
*dri2_dpy
= dri2_egl_display(disp
);
40 return drmAuthMagic(dri2_dpy
->fd
, id
);
44 dri2_initialize_drm(_EGLDriver
*drv
, _EGLDisplay
*disp
)
46 struct dri2_egl_display
*dri2_dpy
;
49 dri2_dpy
= malloc(sizeof *dri2_dpy
);
51 return _eglError(EGL_BAD_ALLOC
, "eglInitialize");
53 memset(dri2_dpy
, 0, sizeof *dri2_dpy
);
55 disp
->DriverData
= (void *) dri2_dpy
;
56 dri2_dpy
->fd
= (int) (intptr_t) disp
->PlatformDisplay
;
58 dri2_dpy
->driver_name
= dri2_get_driver_for_fd(dri2_dpy
->fd
);
59 if (dri2_dpy
->driver_name
== NULL
)
60 return _eglError(EGL_BAD_ALLOC
, "DRI2: failed to get driver name");
62 dri2_dpy
->device_name
= dri2_get_device_name_for_fd(dri2_dpy
->fd
);
63 if (dri2_dpy
->device_name
== NULL
) {
64 _eglError(EGL_BAD_ALLOC
, "DRI2: failed to get device name");
65 goto cleanup_driver_name
;
68 if (!dri2_load_driver(disp
))
69 goto cleanup_device_name
;
71 dri2_dpy
->extensions
[0] = &image_lookup_extension
.base
;
72 dri2_dpy
->extensions
[1] = &use_invalidate
.base
;
73 dri2_dpy
->extensions
[2] = NULL
;
75 if (!dri2_create_screen(disp
))
78 for (i
= 0; dri2_dpy
->driver_configs
[i
]; i
++)
79 dri2_add_config(disp
, dri2_dpy
->driver_configs
[i
], i
+ 1, 0, 0, NULL
);
81 #ifdef HAVE_WAYLAND_PLATFORM
82 disp
->Extensions
.WL_bind_wayland_display
= EGL_TRUE
;
84 dri2_dpy
->authenticate
= dri2_drm_authenticate
;
86 /* we're supporting EGL 1.4 */
87 disp
->VersionMajor
= 1;
88 disp
->VersionMinor
= 4;
93 dlclose(dri2_dpy
->driver
);
95 free(dri2_dpy
->device_name
);
97 free(dri2_dpy
->driver_name
);