Files
fml13v01-buildroot/package/mesa3d/0046-egl-null-introduce-NULL_DRM_DISPLAY.patch
Andy Hu 7566503cc1 package/{mesa3d, mesa3d-headers}: bump version to 22.1.3
upgrade the mesa3d and mesa3d-headers to v22.1.3
and copy patch from IMG DDK 1.19

keep the 0002-Force-Mesa-to-use-the-PVR-driver-for-platform-device.patch
to force the pvr driver

Note that the new version mesa3d support gallium driver
and no longer support dri driver

Signed-off-by: Andy Hu <andy.hu@starfivetech.com>
Signed-off-by: Windsome Zeng <Windsome.Zeng@starfivetech.com>
2023-06-01 22:08:04 +08:00

121 lines
3.5 KiB
Diff

From ade2c62537be41361638aa55126c0ee9966ab726 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 46/58] 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 6ca417bf022..86bcbdf30b8 100644
--- a/src/egl/drivers/dri2/platform_null.c
+++ b/src/egl/drivers/dri2/platform_null.c
@@ -1889,6 +1889,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;
@@ -1946,34 +1948,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;
@@ -2071,7 +2095,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