external/mesa
修订版 | da5d83c19f83150b68c31b31b7df5bdcdaf865eb (tree) |
---|---|
时间 | 2019-01-14 19:31:44 |
作者 | Chih-Wei Huang <cwhuang@linu...> |
Commiter | Chih-Wei Huang |
egl/android: determine how to open device at runtime
This allows to build mesa libraries suitable for drm_gralloc and
other grallocs using prime fd.
v3: Handle having hwcomposer case the same as drm_gralloc since
Signed-off-by: Chih-Wei Huang <cwhuang@linux.org.tw>
@@ -1207,6 +1207,7 @@ droid_open_device_drm_gralloc(_EGLDisplay *disp) | ||
1207 | 1207 | { |
1208 | 1208 | struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp); |
1209 | 1209 | int fd = -1, err = -EINVAL; |
1210 | + char buf[PROPERTY_VALUE_MAX]; | |
1210 | 1211 | |
1211 | 1212 | if (dri2_dpy->gralloc->perform) |
1212 | 1213 | err = dri2_dpy->gralloc->perform(dri2_dpy->gralloc, |
@@ -1217,7 +1218,14 @@ droid_open_device_drm_gralloc(_EGLDisplay *disp) | ||
1217 | 1218 | return EGL_FALSE; |
1218 | 1219 | } |
1219 | 1220 | |
1220 | - dri2_dpy->fd = fcntl(fd, F_DUPFD_CLOEXEC, 3); | |
1221 | + if (!strcmp(dri2_dpy->gralloc->common.name, "DRM Memory Allocator") || | |
1222 | + property_get("ro.hardware.hwcomposer", buf, NULL) > 0) { | |
1223 | + dri2_dpy->fd = fcntl(fd, F_DUPFD_CLOEXEC, 3); | |
1224 | + } else { | |
1225 | + const char *device_name = drmGetRenderDeviceNameFromFd(fd); | |
1226 | + dri2_dpy->fd = loader_open_device(device_name); | |
1227 | + free(device_name); | |
1228 | + } | |
1221 | 1229 | if (dri2_dpy->fd < 0) |
1222 | 1230 | return EGL_FALSE; |
1223 | 1231 |
@@ -1453,6 +1461,7 @@ droid_probe_device(_EGLDisplay *disp) | ||
1453 | 1461 | return EGL_TRUE; |
1454 | 1462 | } |
1455 | 1463 | |
1464 | +#ifndef HAVE_DRM_GRALLOC | |
1456 | 1465 | static EGLBoolean |
1457 | 1466 | droid_open_device(_EGLDisplay *disp) |
1458 | 1467 | { |
@@ -1522,6 +1531,7 @@ droid_open_device(_EGLDisplay *disp) | ||
1522 | 1531 | return EGL_TRUE; |
1523 | 1532 | #undef MAX_DRM_DEVICES |
1524 | 1533 | } |
1534 | +#endif | |
1525 | 1535 | |
1526 | 1536 | EGLBoolean |
1527 | 1537 | dri2_initialize_android(_EGLDriver *drv, _EGLDisplay *disp) |