diff options
author | Hans de Goede <hdegoede@redhat.com> | 2017-03-23 12:54:07 +0100 |
---|---|---|
committer | Hans de Goede <hdegoede@redhat.com> | 2017-10-08 21:07:25 +0200 |
commit | 98c02d5f2764df6e59f68aa4b7a21b0f2b070e8b (patch) | |
tree | f85bf096402d9dc94a9c30cb665372127bb2c4f8 /hw/xfree86/dri2/dri2.c | |
parent | 0cbd96f8bc6824b31b2a2c45672ff7e5475e924f (diff) |
The modesetting driver (which now often is used with Intel GPUs),
relies on dri2_probe_driver_name() to get the dri and vdpau driver
names, before this commit it would always assign the same name to
the 2 names. But the vdpau driver for i965 GPUs should be va_gl
(i915 does not support vdpau at all).
This commit modifies the used lookup table and dri2_probe_driver_name()
to set the vdpau_driver to va_gl for i965 GPUs, it leaves the 2
names the same for all other GPUs.
Note this commit adds a FIXME comment for a memory leak in
dri2_probe_driver_name(), that leak was already present and fixing
it falls outside of the scope of this commit.
BugLink: https://bugzilla.redhat.com/show_bug.cgi?id=1413733
Cc: kwizart@gmail.com
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Diffstat (limited to 'hw/xfree86/dri2/dri2.c')
-rw-r--r-- | hw/xfree86/dri2/dri2.c | 31 |
1 files changed, 20 insertions, 11 deletions
diff --git a/hw/xfree86/dri2/dri2.c b/hw/xfree86/dri2/dri2.c index 75abc18ac..370beeb22 100644 --- a/hw/xfree86/dri2/dri2.c +++ b/hw/xfree86/dri2/dri2.c @@ -1437,14 +1437,18 @@ get_prime_id(void) #include "pci_ids/pci_id_driver_map.h" -static char * -dri2_probe_driver_name(ScreenPtr pScreen, DRI2InfoPtr info) +static void +dri2_probe_driver_name(ScreenPtr pScreen, DRI2InfoPtr info, + const char **dri_driver_ret, + const char **vdpau_driver_ret) { #ifdef WITH_LIBDRM int i, j; - char *driver = NULL; drmDevicePtr dev; + *dri_driver_ret = NULL; + *vdpau_driver_ret = NULL; + /* For non-PCI devices and drmGetDevice fail, just assume that * the 3D driver is named the same as the kernel driver. This is * currently true for vc4 and msm (freedreno). @@ -1456,12 +1460,14 @@ dri2_probe_driver_name(ScreenPtr pScreen, DRI2InfoPtr info) xf86DrvMsg(pScreen->myNum, X_ERROR, "[DRI2] Couldn't drmGetVersion() on non-PCI device, " "no driver name found.\n"); - return NULL; + return; } - driver = strndup(version->name, version->name_len); + /* FIXME this gets leaked */ + *dri_driver_ret = strndup(version->name, version->name_len); + *vdpau_driver_ret = *dri_driver_ret; drmFreeVersion(version); - return driver; + return; } for (i = 0; driver_map[i].driver; i++) { @@ -1469,13 +1475,15 @@ dri2_probe_driver_name(ScreenPtr pScreen, DRI2InfoPtr info) continue; if (driver_map[i].num_chips_ids == -1) { - driver = strdup(driver_map[i].driver); + *dri_driver_ret = driver_map[i].driver; + *vdpau_driver_ret = driver_map[i].vdpau_driver; goto out; } for (j = 0; j < driver_map[i].num_chips_ids; j++) { if (driver_map[i].chip_ids[j] == dev->deviceinfo.pci->device_id) { - driver = strdup(driver_map[i].driver); + *dri_driver_ret = driver_map[i].driver; + *vdpau_driver_ret = driver_map[i].vdpau_driver; goto out; } } @@ -1487,9 +1495,9 @@ dri2_probe_driver_name(ScreenPtr pScreen, DRI2InfoPtr info) dev->deviceinfo.pci->vendor_id, dev->deviceinfo.pci->device_id); out: drmFreeDevice(&dev); - return driver; #else - return NULL; + *dri_driver_ret = NULL; + *vdpau_driver_ret = NULL; #endif } @@ -1610,7 +1618,8 @@ DRI2ScreenInit(ScreenPtr pScreen, DRI2InfoPtr info) if (info->driverName) { ds->driverNames[0] = info->driverName; } else { - ds->driverNames[0] = ds->driverNames[1] = dri2_probe_driver_name(pScreen, info); + dri2_probe_driver_name(pScreen, info, + &ds->driverNames[0], &ds->driverNames[1]); if (!ds->driverNames[0]) return FALSE; } |