summaryrefslogtreecommitdiff
path: root/xserver/hw/xfree86/dri2/dri2.c
diff options
context:
space:
mode:
Diffstat (limited to 'xserver/hw/xfree86/dri2/dri2.c')
-rw-r--r--xserver/hw/xfree86/dri2/dri2.c56
1 files changed, 30 insertions, 26 deletions
diff --git a/xserver/hw/xfree86/dri2/dri2.c b/xserver/hw/xfree86/dri2/dri2.c
index 2165603d9..6619e3aa7 100644
--- a/xserver/hw/xfree86/dri2/dri2.c
+++ b/xserver/hw/xfree86/dri2/dri2.c
@@ -1440,21 +1440,17 @@ get_prime_id(void)
static char *
dri2_probe_driver_name(ScreenPtr pScreen, DRI2InfoPtr info)
{
- ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
- EntityInfoPtr pEnt = xf86GetEntityInfo(pScrn->entityList[0]);
- struct pci_device *pdev = NULL;
+#ifdef WITH_LIBDRM
int i, j;
+ char *driver = NULL;
+ drmDevicePtr dev;
- if (pEnt)
- pdev = xf86GetPciInfoForEntity(pEnt->index);
-
- /* For non-PCI devices, just assume that the 3D driver is named
- * the same as the kernel driver. This is currently true for vc4
- * and msm (freedreno).
+ /* 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).
*/
- if (!pdev) {
+ if (drmGetDevice(info->fd, &dev) || dev->bustype != DRM_BUS_PCI) {
drmVersionPtr version = drmGetVersion(info->fd);
- char *kernel_driver;
if (!version) {
xf86DrvMsg(pScreen->myNum, X_ERROR,
@@ -1463,29 +1459,38 @@ dri2_probe_driver_name(ScreenPtr pScreen, DRI2InfoPtr info)
return NULL;
}
- kernel_driver = strndup(version->name, version->name_len);
+ driver = strndup(version->name, version->name_len);
drmFreeVersion(version);
- return kernel_driver;
+ return driver;
}
for (i = 0; driver_map[i].driver; i++) {
- if (pdev->vendor_id != driver_map[i].vendor_id)
+ if (dev->deviceinfo.pci->vendor_id != driver_map[i].vendor_id)
continue;
- if (driver_map[i].num_chips_ids == -1)
- return strdup(driver_map[i].driver);
+ if (driver_map[i].num_chips_ids == -1) {
+ driver = strdup(driver_map[i].driver);
+ goto out;
+ }
for (j = 0; j < driver_map[i].num_chips_ids; j++) {
- if (driver_map[i].chip_ids[j] == pdev->device_id)
- return strdup(driver_map[i].driver);
+ if (driver_map[i].chip_ids[j] == dev->deviceinfo.pci->device_id) {
+ driver = strdup(driver_map[i].driver);
+ goto out;
+ }
}
}
xf86DrvMsg(pScreen->myNum, X_ERROR,
"[DRI2] No driver mapping found for PCI device "
"0x%04x / 0x%04x\n",
- pdev->vendor_id, pdev->device_id);
+ dev->deviceinfo.pci->vendor_id, dev->deviceinfo.pci->device_id);
+out:
+ drmFreeDevice(&dev);
+ return driver;
+#else
return NULL;
+#endif
}
Bool
@@ -1533,6 +1538,7 @@ DRI2ScreenInit(ScreenPtr pScreen, DRI2InfoPtr info)
ds->CreateBuffer = info->CreateBuffer;
ds->DestroyBuffer = info->DestroyBuffer;
ds->CopyRegion = info->CopyRegion;
+ cur_minor = 1;
if (info->version >= 4) {
ds->ScheduleSwap = info->ScheduleSwap;
@@ -1540,13 +1546,7 @@ DRI2ScreenInit(ScreenPtr pScreen, DRI2InfoPtr info)
ds->GetMSC = info->GetMSC;
cur_minor = 3;
}
- else {
- cur_minor = 1;
- }
- if (info->version >= 8) {
- ds->AuthMagic = info->AuthMagic2;
- }
if (info->version >= 5) {
ds->LegacyAuthMagic = info->AuthMagic;
}
@@ -1561,6 +1561,10 @@ DRI2ScreenInit(ScreenPtr pScreen, DRI2InfoPtr info)
cur_minor = 4;
}
+ if (info->version >= 8) {
+ ds->AuthMagic = info->AuthMagic2;
+ }
+
if (info->version >= 9) {
ds->CreateBuffer2 = info->CreateBuffer2;
if (info->CreateBuffer2 && pScreen->isGPU) {
@@ -1629,7 +1633,7 @@ DRI2ScreenInit(ScreenPtr pScreen, DRI2InfoPtr info)
pScreen->SetWindowPixmap = DRI2SetWindowPixmap;
xf86DrvMsg(pScreen->myNum, X_INFO, "[DRI2] Setup complete\n");
- for (i = 0; i < sizeof(driverTypeNames) / sizeof(driverTypeNames[0]); i++) {
+ for (i = 0; i < ARRAY_SIZE(driverTypeNames); i++) {
if (i < ds->numDrivers && ds->driverNames[i]) {
xf86DrvMsg(pScreen->myNum, X_INFO, "[DRI2] %s driver: %s\n",
driverTypeNames[i], ds->driverNames[i]);