Blame SOURCES/0001-xf86-dri2-Use-va_gl-as-vdpau_driver-for-Intel-i965-G.patch

f34ecf
From acf5a0100c98a040e5e07a79ecf4a83627da770e Mon Sep 17 00:00:00 2001
f34ecf
From: Hans de Goede <hdegoede@redhat.com>
f34ecf
Date: Thu, 23 Mar 2017 12:54:07 +0100
f34ecf
Subject: [PATCH xserver] xf86: dri2: Use va_gl as vdpau_driver for Intel i965
f34ecf
 GPUs
f34ecf
f34ecf
The modesetting driver (which now often is used with Intel GPUs),
f34ecf
relies on dri2_probe_driver_name() to get the dri and vdpau driver
f34ecf
names, before this commit it would always assign the same name to
f34ecf
the 2 names. But the vdpau driver for i965 GPUs should be va_gl
f34ecf
(i915 does not support vdpau at all).
f34ecf
f34ecf
This commit modifies the used lookup table and dri2_probe_driver_name()
f34ecf
to set the vdpau_driver to va_gl for i965 GPUs, it leaves the 2
f34ecf
names the same for all other GPUs.
f34ecf
f34ecf
Note this commit adds a FIXME comment for a memory leak in
f34ecf
dri2_probe_driver_name(), that leak was already present and fixing
f34ecf
it falls outside of the scope of this commit.
f34ecf
f34ecf
BugLink: https://bugzilla.redhat.com/show_bug.cgi?id=1413733
f34ecf
Cc: kwizart@gmail.com
f34ecf
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
f34ecf
---
f34ecf
 hw/xfree86/dri2/dri2.c                      | 31 +++++++++++++--------
f34ecf
 hw/xfree86/dri2/pci_ids/pci_id_driver_map.h | 21 +++++++-------
f34ecf
 2 files changed, 31 insertions(+), 21 deletions(-)
f34ecf
f34ecf
diff --git a/hw/xfree86/dri2/dri2.c b/hw/xfree86/dri2/dri2.c
f34ecf
index 6619e3aa7..1f8ad14bc 100644
f34ecf
--- a/hw/xfree86/dri2/dri2.c
f34ecf
+++ b/hw/xfree86/dri2/dri2.c
f34ecf
@@ -1437,14 +1437,18 @@ get_prime_id(void)
f34ecf
 
f34ecf
 #include "pci_ids/pci_id_driver_map.h"
f34ecf
 
f34ecf
-static char *
f34ecf
-dri2_probe_driver_name(ScreenPtr pScreen, DRI2InfoPtr info)
f34ecf
+static void
f34ecf
+dri2_probe_driver_name(ScreenPtr pScreen, DRI2InfoPtr info,
f34ecf
+                       const char **dri_driver_ret,
f34ecf
+                       const char **vdpau_driver_ret)
f34ecf
 {
f34ecf
 #ifdef WITH_LIBDRM
f34ecf
     int i, j;
f34ecf
-    char *driver = NULL;
f34ecf
     drmDevicePtr dev;
f34ecf
 
f34ecf
+    *dri_driver_ret = NULL;
f34ecf
+    *vdpau_driver_ret = NULL;
f34ecf
+
f34ecf
     /* For non-PCI devices and drmGetDevice fail, just assume that
f34ecf
      * the 3D driver is named the same as the kernel driver. This is
f34ecf
      * currently true for vc4 and msm (freedreno).
f34ecf
@@ -1456,12 +1460,14 @@ dri2_probe_driver_name(ScreenPtr pScreen, DRI2InfoPtr info)
f34ecf
             xf86DrvMsg(pScreen->myNum, X_ERROR,
f34ecf
                        "[DRI2] Couldn't drmGetVersion() on non-PCI device, "
f34ecf
                        "no driver name found.\n");
f34ecf
-            return NULL;
f34ecf
+            return;
f34ecf
         }
f34ecf
 
f34ecf
-        driver = strndup(version->name, version->name_len);
f34ecf
+        /* FIXME this gets leaked */
f34ecf
+        *dri_driver_ret = strndup(version->name, version->name_len);
f34ecf
+        *vdpau_driver_ret = *dri_driver_ret;
f34ecf
         drmFreeVersion(version);
f34ecf
-        return driver;
f34ecf
+        return;
f34ecf
     }
f34ecf
 
f34ecf
     for (i = 0; driver_map[i].driver; i++) {
f34ecf
@@ -1469,13 +1475,15 @@ dri2_probe_driver_name(ScreenPtr pScreen, DRI2InfoPtr info)
f34ecf
             continue;
f34ecf
 
f34ecf
         if (driver_map[i].num_chips_ids == -1) {
f34ecf
-             driver = strdup(driver_map[i].driver);
f34ecf
+             *dri_driver_ret = driver_map[i].driver;
f34ecf
+             *vdpau_driver_ret = driver_map[i].vdpau_driver;
f34ecf
              goto out;
f34ecf
         }
f34ecf
 
f34ecf
         for (j = 0; j < driver_map[i].num_chips_ids; j++) {
f34ecf
             if (driver_map[i].chip_ids[j] == dev->deviceinfo.pci->device_id) {
f34ecf
-                driver = strdup(driver_map[i].driver);
f34ecf
+                *dri_driver_ret = driver_map[i].driver;
f34ecf
+                *vdpau_driver_ret = driver_map[i].vdpau_driver;
f34ecf
                 goto out;
f34ecf
             }
f34ecf
         }
f34ecf
@@ -1487,9 +1495,9 @@ dri2_probe_driver_name(ScreenPtr pScreen, DRI2InfoPtr info)
f34ecf
                dev->deviceinfo.pci->vendor_id, dev->deviceinfo.pci->device_id);
f34ecf
 out:
f34ecf
     drmFreeDevice(&dev;;
f34ecf
-    return driver;
f34ecf
 #else
f34ecf
-    return NULL;
f34ecf
+    *dri_driver_ret = NULL;
f34ecf
+    *vdpau_driver_ret = NULL;
f34ecf
 #endif
f34ecf
 }
f34ecf
 
f34ecf
@@ -1610,7 +1618,8 @@ DRI2ScreenInit(ScreenPtr pScreen, DRI2InfoPtr info)
f34ecf
         if (info->driverName) {
f34ecf
             ds->driverNames[0] = info->driverName;
f34ecf
         } else {
f34ecf
-            ds->driverNames[0] = ds->driverNames[1] = dri2_probe_driver_name(pScreen, info);
f34ecf
+            dri2_probe_driver_name(pScreen, info,
f34ecf
+                                   &ds->driverNames[0], &ds->driverNames[1]);
f34ecf
             if (!ds->driverNames[0])
f34ecf
                 return FALSE;
f34ecf
         }
f34ecf
diff --git a/hw/xfree86/dri2/pci_ids/pci_id_driver_map.h b/hw/xfree86/dri2/pci_ids/pci_id_driver_map.h
f34ecf
index da7ea1c1e..7036d1003 100644
f34ecf
--- a/hw/xfree86/dri2/pci_ids/pci_id_driver_map.h
f34ecf
+++ b/hw/xfree86/dri2/pci_ids/pci_id_driver_map.h
f34ecf
@@ -66,21 +66,22 @@ static const int vmwgfx_chip_ids[] = {
f34ecf
 static const struct {
f34ecf
    int vendor_id;
f34ecf
    const char *driver;
f34ecf
+   const char *vdpau_driver;
f34ecf
    const int *chip_ids;
f34ecf
    int num_chips_ids;
f34ecf
 } driver_map[] = {
f34ecf
-   { 0x8086, "i915", i915_chip_ids, ARRAY_SIZE(i915_chip_ids) },
f34ecf
-   { 0x8086, "i965", i965_chip_ids, ARRAY_SIZE(i965_chip_ids) },
f34ecf
+   { 0x8086, "i915", "i915", i915_chip_ids, ARRAY_SIZE(i915_chip_ids) },
f34ecf
+   { 0x8086, "i965", "va_gl", i965_chip_ids, ARRAY_SIZE(i965_chip_ids) },
f34ecf
 #ifndef DRIVER_MAP_GALLIUM_ONLY
f34ecf
-   { 0x1002, "radeon", r100_chip_ids, ARRAY_SIZE(r100_chip_ids) },
f34ecf
-   { 0x1002, "r200", r200_chip_ids, ARRAY_SIZE(r200_chip_ids) },
f34ecf
+   { 0x1002, "radeon", "radeon", r100_chip_ids, ARRAY_SIZE(r100_chip_ids) },
f34ecf
+   { 0x1002, "r200", "r200", r200_chip_ids, ARRAY_SIZE(r200_chip_ids) },
f34ecf
 #endif
f34ecf
-   { 0x1002, "r300", r300_chip_ids, ARRAY_SIZE(r300_chip_ids) },
f34ecf
-   { 0x1002, "r600", r600_chip_ids, ARRAY_SIZE(r600_chip_ids) },
f34ecf
-   { 0x1002, "radeonsi", radeonsi_chip_ids, ARRAY_SIZE(radeonsi_chip_ids) },
f34ecf
-   { 0x10de, "nouveau", NULL, -1 },
f34ecf
-   { 0x1af4, "virtio_gpu", virtio_gpu_chip_ids, ARRAY_SIZE(virtio_gpu_chip_ids) },
f34ecf
-   { 0x15ad, "vmwgfx", vmwgfx_chip_ids, ARRAY_SIZE(vmwgfx_chip_ids) },
f34ecf
+   { 0x1002, "r300", "r300", r300_chip_ids, ARRAY_SIZE(r300_chip_ids) },
f34ecf
+   { 0x1002, "r600","r600",  r600_chip_ids, ARRAY_SIZE(r600_chip_ids) },
f34ecf
+   { 0x1002, "radeonsi", "radeonsi", radeonsi_chip_ids, ARRAY_SIZE(radeonsi_chip_ids) },
f34ecf
+   { 0x10de, "nouveau", "nouveau", NULL, -1 },
f34ecf
+   { 0x1af4, "virtio_gpu", "virtio_gpu", virtio_gpu_chip_ids, ARRAY_SIZE(virtio_gpu_chip_ids) },
f34ecf
+   { 0x15ad, "vmwgfx", "vmwgfx", vmwgfx_chip_ids, ARRAY_SIZE(vmwgfx_chip_ids) },
f34ecf
    { 0x0000, NULL, NULL, 0 },
f34ecf
 };
f34ecf
 
f34ecf
-- 
f34ecf
2.19.0
f34ecf