[mesa3d] Sync all patch files with DDK 1.17.
This commit is contained in:
@@ -0,0 +1,120 @@
|
||||
From 693fff6d87abfcae887afde7f80f402b7ff5c0ab Mon Sep 17 00:00:00 2001
|
||||
From: Brendan King <Brendan.King@imgtec.com>
|
||||
Date: Mon, 28 Jun 2021 16:36:15 +0100
|
||||
Subject: [PATCH 55/67] egl/null: introduce NULL_DRM_DISPLAY
|
||||
|
||||
Introduce the NULL_DRM_DISPLAY environment variable, which allows
|
||||
a particular DRM display to be selected, rather than the first
|
||||
suitable DRM device found.
|
||||
|
||||
To select a particular display, NULL_DRM_DISPLAY should be set to
|
||||
the card number (i.e. minor number) of the DRM device representing
|
||||
the display. For example, NULL_DRM_DISPLAY=2 will select
|
||||
/dev/dri/card2.
|
||||
---
|
||||
src/egl/drivers/dri2/platform_null.c | 65 ++++++++++++++++++++--------
|
||||
1 file changed, 46 insertions(+), 19 deletions(-)
|
||||
|
||||
diff --git a/src/egl/drivers/dri2/platform_null.c b/src/egl/drivers/dri2/platform_null.c
|
||||
index af77ea4dd89..529cc7a2a2f 100644
|
||||
--- a/src/egl/drivers/dri2/platform_null.c
|
||||
+++ b/src/egl/drivers/dri2/platform_null.c
|
||||
@@ -1784,6 +1784,8 @@ dri2_null_try_device(_EGLDisplay *disp)
|
||||
{
|
||||
struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
|
||||
|
||||
+ dri2_dpy->fd = -1;
|
||||
+
|
||||
if (!dri2_null_device_is_kms(dri2_dpy->fd_dpy))
|
||||
return false;
|
||||
|
||||
@@ -1841,34 +1843,56 @@ dri2_null_try_device(_EGLDisplay *disp)
|
||||
}
|
||||
|
||||
static bool
|
||||
-dri2_null_probe_device(_EGLDisplay *disp)
|
||||
+dri2_null_probe_device(_EGLDisplay *disp, unsigned minor)
|
||||
{
|
||||
struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
|
||||
+ char *card_path;
|
||||
|
||||
- dri2_dpy->fd = -1;
|
||||
- dri2_dpy->fd_dpy = -1;
|
||||
+ if (asprintf(&card_path, DRM_DEV_NAME, DRM_DIR_NAME, minor) < 0)
|
||||
+ goto cleanup;
|
||||
|
||||
- for (unsigned i = 0; i <= NULL_CARD_MINOR_MAX; i++) {
|
||||
- char *card_path;
|
||||
+ dri2_dpy->fd_dpy = loader_open_device(card_path);
|
||||
+ free(card_path);
|
||||
+ if (dri2_dpy->fd_dpy < 0)
|
||||
+ goto cleanup;
|
||||
|
||||
- if (asprintf(&card_path, DRM_DEV_NAME, DRM_DIR_NAME, i) < 0)
|
||||
- continue;
|
||||
+ if (dri2_null_try_device(disp))
|
||||
+ return true;
|
||||
|
||||
- dri2_dpy->fd_dpy = loader_open_device(card_path);
|
||||
- free(card_path);
|
||||
- if (dri2_dpy->fd_dpy < 0)
|
||||
- continue;
|
||||
+ close(dri2_dpy->fd_dpy);
|
||||
|
||||
- if (dri2_null_try_device(disp))
|
||||
- return true;
|
||||
+ if (dri2_dpy->fd >= 0 && dri2_dpy->fd != dri2_dpy->fd_dpy)
|
||||
+ close(dri2_dpy->fd);
|
||||
|
||||
- close(dri2_dpy->fd_dpy);
|
||||
+cleanup:
|
||||
+ dri2_dpy->fd_dpy = -1;
|
||||
+ dri2_dpy->fd = -1;
|
||||
|
||||
- if (dri2_dpy->fd >= 0 && dri2_dpy->fd != dri2_dpy->fd_dpy)
|
||||
- close(dri2_dpy->fd);
|
||||
+ return false;
|
||||
+}
|
||||
+
|
||||
+static bool
|
||||
+dri2_null_probe_devices(_EGLDisplay *disp)
|
||||
+{
|
||||
+ const char *null_drm_display = getenv("NULL_DRM_DISPLAY");
|
||||
+
|
||||
+ if (null_drm_display) {
|
||||
+ char *endptr;
|
||||
+ long val = strtol(null_drm_display, &endptr, 10);
|
||||
|
||||
- dri2_dpy->fd_dpy = -1;
|
||||
- dri2_dpy->fd = -1;
|
||||
+ if (endptr != null_drm_display && !*endptr &&
|
||||
+ val >= 0 && val <= NULL_CARD_MINOR_MAX) {
|
||||
+ if (dri2_null_probe_device(disp, (unsigned)val))
|
||||
+ return true;
|
||||
+ } else {
|
||||
+ _eglLog(_EGL_FATAL, "NULL_DRM_DISPLAY is invalid: %s",
|
||||
+ null_drm_display);
|
||||
+ }
|
||||
+ } else {
|
||||
+ for (unsigned i = 0; i <= NULL_CARD_MINOR_MAX; i++) {
|
||||
+ if (dri2_null_probe_device(disp, i))
|
||||
+ return true;
|
||||
+ }
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -1965,7 +1989,10 @@ dri2_initialize_null(_EGLDisplay *disp)
|
||||
|
||||
disp->DriverData = (void *) dri2_dpy;
|
||||
|
||||
- if (!dri2_null_probe_device(disp)) {
|
||||
+ dri2_dpy->fd_dpy = -1;
|
||||
+ dri2_dpy->fd = -1;
|
||||
+
|
||||
+ if (!dri2_null_probe_devices(disp)) {
|
||||
_eglError(EGL_NOT_INITIALIZED, "failed to load driver");
|
||||
goto cleanup;
|
||||
}
|
||||
--
|
||||
2.25.1
|
||||
|
||||
Reference in New Issue
Block a user