diff options
author | Tomasz Figa <tfiga@chromium.org> | 2016-11-25 14:51:09 +0200 |
---|---|---|
committer | Sumit Semwal <sumit.semwal@linaro.org> | 2018-04-20 21:58:39 +0530 |
commit | 82a23134cfb95511486b5ed569d0bdabc4f5f397 (patch) | |
tree | e2c2c8377ab7b1ced89f8b0b586f95cadb78cdc1 | |
parent | 8a463f7ca0dda84ce34ddb0a31087134653e4b3d (diff) |
CHROMIUM: egl/android: Support opening render nodes from within EGL
This patch adds support for opening render nodes directly from within
display initialization, Instead of relying on private interfaces
provided by gralloc.
In addition to having better separation from gralloc and being able to
use different render nodes for allocation and rendering, this also fixes
problems encountered when using the same DRI FD for gralloc and Mesa,
when both stepped each over another because of shared GEM handle
namespace.
BUG=b:29036398
TEST=No significant regressions in dEQP inside the container
Test: No significant regressions in dEQP inside the container
Change-Id: I7f901eb9dadbfc2200484666fdc6a2bc0ca42a0c
(cherry picked from commit 4471713aa71d83943eb195868707ebe4e6515bb6)
Signed-off-by: Tomasz Figa <tfiga@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/367215
Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
Signed-off-by: Sumit Semwal <sumit.semwal@linaro.org>
-rw-r--r-- | src/egl/drivers/dri2/platform_android.c | 66 |
1 files changed, 53 insertions, 13 deletions
diff --git a/src/egl/drivers/dri2/platform_android.c b/src/egl/drivers/dri2/platform_android.c index bb2482d2ebb..60aca632e86 100644 --- a/src/egl/drivers/dri2/platform_android.c +++ b/src/egl/drivers/dri2/platform_android.c @@ -990,13 +990,53 @@ droid_open_device(struct dri2_egl_display *dri2_dpy) GRALLOC_MODULE_PERFORM_GET_DRM_FD, &fd); if (err || fd < 0) { - _eglLog(_EGL_WARNING, "fail to get drm fd"); + _eglLog(_EGL_DEBUG, "fail to get drm fd"); fd = -1; } return (fd >= 0) ? fcntl(fd, F_DUPFD_CLOEXEC, 3) : -1; } +#define DRM_RENDER_DEV_NAME "%s/renderD%d" + +static int +droid_probe_device(_EGLDisplay *dpy) +{ + struct dri2_egl_display *dri2_dpy = dpy->DriverData; + const int limit = 64; + const int base = 128; + int fd; + int i; + + for (i = 0; i < limit; ++i) { + char *card_path; + if (asprintf(&card_path, DRM_RENDER_DEV_NAME, DRM_DIR_NAME, base + i) < 0) + continue; + + fd = loader_open_device(card_path); + free(card_path); + if (fd < 0) + continue; + + dri2_dpy->driver_name = loader_get_driver_for_fd(fd); + if (!dri2_dpy->driver_name) { + close(fd); + continue; + } + + dri2_dpy->fd = fd; + if (dri2_load_driver(dpy)) + return 0; + + close(fd); + dri2_dpy->fd = -1; + free(dri2_dpy->driver_name); + dri2_dpy->driver_name = NULL; + } + + return -1; +} + /* support versions < JellyBean */ #ifndef ALOGW #define ALOGW LOGW @@ -1103,22 +1143,22 @@ dri2_initialize_android(_EGLDriver *drv, _EGLDisplay *dpy) dpy->DriverData = (void *) dri2_dpy; dri2_dpy->fd = droid_open_device(dri2_dpy); - if (dri2_dpy->fd < 0) { + if (dri2_dpy->fd >= 0) { + dri2_dpy->driver_name = loader_get_driver_for_fd(dri2_dpy->fd); + if (dri2_dpy->driver_name == NULL) { + err = "DRI2: failed to get driver name"; + goto cleanup_device; + } + + if (!dri2_load_driver(dpy)) { + err = "DRI2: failed to load driver"; + goto cleanup_driver_name; + } + } else if (droid_probe_device(dpy) < 0) { err = "DRI2: failed to open device"; goto cleanup_display; } - dri2_dpy->driver_name = loader_get_driver_for_fd(dri2_dpy->fd); - if (dri2_dpy->driver_name == NULL) { - err = "DRI2: failed to get driver name"; - goto cleanup_device; - } - - if (!dri2_load_driver(dpy)) { - err = "DRI2: failed to load driver"; - goto cleanup_driver_name; - } - dri2_dpy->is_render_node = drmGetNodeTypeFromFd(dri2_dpy->fd) == DRM_NODE_RENDER; /* render nodes cannot use Gem names, and thus do not support |