summaryrefslogtreecommitdiff
path: root/hw
diff options
context:
space:
mode:
authorKenneth Graunke <kenneth@whitecape.org>2019-11-21 23:03:50 -0800
committerKenneth Graunke <kenneth@whitecape.org>2019-11-26 01:36:10 -0800
commit8d4be7f6c4f7c673d7ec1a6bfdef944907a3916e (patch)
tree526c55843e5fe945833564c5cf57144b0213f5f8 /hw
parent195c2ef8f9f07b9bdabc0f554a9033b7857b99c7 (diff)
modesetting: Use EGL_MESA_query_driver to select DRI driver if possible
New now ask Glamor to use EGL_MESA_query_driver to obtain the DRI driver name; if successful, we use that as the DRI driver name. Following the existing dri2.c logic, we also use the same name for the VDPAU driver, except for i965 (and now iris), where we switch to the "va_gl" fallback. This allows us to bypass the PCI ID lists in xserver and centralize the driver selection mechanism inside Mesa. The hope is that we no longer have to update these lists for any future hardware.
Diffstat (limited to 'hw')
-rw-r--r--hw/xfree86/common/xf86Module.h2
-rw-r--r--hw/xfree86/drivers/modesetting/dri2.c29
-rw-r--r--hw/xfree86/drivers/modesetting/driver.c1
-rw-r--r--hw/xfree86/drivers/modesetting/driver.h1
4 files changed, 29 insertions, 4 deletions
diff --git a/hw/xfree86/common/xf86Module.h b/hw/xfree86/common/xf86Module.h
index ef1e70f87..c590ffec4 100644
--- a/hw/xfree86/common/xf86Module.h
+++ b/hw/xfree86/common/xf86Module.h
@@ -74,7 +74,7 @@
* mask is 0xFFFF0000.
*/
#define ABI_ANSIC_VERSION SET_ABI_VERSION(0, 4)
-#define ABI_VIDEODRV_VERSION SET_ABI_VERSION(25, 0)
+#define ABI_VIDEODRV_VERSION SET_ABI_VERSION(25, 1)
#define ABI_XINPUT_VERSION SET_ABI_VERSION(24, 1)
#define ABI_EXTENSION_VERSION SET_ABI_VERSION(10, 0)
diff --git a/hw/xfree86/drivers/modesetting/dri2.c b/hw/xfree86/drivers/modesetting/dri2.c
index ccb9d04c9..e893da422 100644
--- a/hw/xfree86/drivers/modesetting/dri2.c
+++ b/hw/xfree86/drivers/modesetting/dri2.c
@@ -1037,6 +1037,7 @@ ms_dri2_screen_init(ScreenPtr screen)
ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
modesettingPtr ms = modesettingPTR(scrn);
DRI2InfoRec info;
+ const char *driver_names[2] = { NULL, NULL };
if (!ms->glamor.supports_pixmap_import_export(screen)) {
xf86DrvMsg(scrn->scrnIndex, X_WARNING,
@@ -1075,9 +1076,31 @@ ms_dri2_screen_init(ScreenPtr screen)
info.DestroyBuffer2 = ms_dri2_destroy_buffer2;
info.CopyRegion2 = ms_dri2_copy_region2;
- /* These two will be filled in by dri2.c */
- info.numDrivers = 0;
- info.driverNames = NULL;
+ /* Ask Glamor to obtain the DRI driver name via EGL_MESA_query_driver, */
+ if (ms->glamor.egl_get_driver_name)
+ driver_names[0] = ms->glamor.egl_get_driver_name(screen);
+
+ if (driver_names[0]) {
+ /* There is no VDPAU driver for Intel, fallback to the generic
+ * OpenGL/VAAPI va_gl backend to emulate VDPAU. Otherwise,
+ * guess that the DRI and VDPAU drivers have the same name.
+ */
+ if (strcmp(driver_names[0], "i965") == 0 ||
+ strcmp(driver_names[0], "iris") == 0) {
+ driver_names[1] = "va_gl";
+ } else {
+ driver_names[1] = driver_names[0];
+ }
+
+ info.numDrivers = 2;
+ info.driverNames = driver_names;
+ } else {
+ /* EGL_MESA_query_driver was unavailable; let dri2.c select the
+ * driver and fill in these fields for us.
+ */
+ info.numDrivers = 0;
+ info.driverNames = NULL;
+ }
return DRI2ScreenInit(screen, &info);
}
diff --git a/hw/xfree86/drivers/modesetting/driver.c b/hw/xfree86/drivers/modesetting/driver.c
index 6c7d7eaf0..de7280084 100644
--- a/hw/xfree86/drivers/modesetting/driver.c
+++ b/hw/xfree86/drivers/modesetting/driver.c
@@ -762,6 +762,7 @@ bind_glamor_api(void *mod, modesettingPtr ms)
ms->glamor.shareable_fd_from_pixmap = LoaderSymbolFromModule(mod, "glamor_shareable_fd_from_pixmap");
ms->glamor.supports_pixmap_import_export = LoaderSymbolFromModule(mod, "glamor_supports_pixmap_import_export");
ms->glamor.xv_init = LoaderSymbolFromModule(mod, "glamor_xv_init");
+ ms->glamor.egl_get_driver_name = LoaderSymbolFromModule(mod, "glamor_egl_get_driver_name");
}
static void
diff --git a/hw/xfree86/drivers/modesetting/driver.h b/hw/xfree86/drivers/modesetting/driver.h
index 5909829a0..60e4aaa96 100644
--- a/hw/xfree86/drivers/modesetting/driver.h
+++ b/hw/xfree86/drivers/modesetting/driver.h
@@ -155,6 +155,7 @@ typedef struct _modesettingRec {
CARD32 *);
Bool (*supports_pixmap_import_export)(ScreenPtr);
XF86VideoAdaptorPtr (*xv_init)(ScreenPtr, int);
+ const char *(*egl_get_driver_name)(ScreenPtr);
} glamor;
} modesettingRec, *modesettingPtr;