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

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