dri2: refine dri2_probe_driver_name (v2)
V2: 1. update comment 2. check bustype if PCI 3. configure add libdrm version check for drmGetDevice Get PCI information from info->fd with drmGetDevice instead of assuming the info->fd is the first entity of scrn which is not true for multi entities scrn. Signed-off-by: Qiang Yu <Qiang.Yu@amd.com> Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
This commit is contained in:
parent
b1a6986395
commit
7617a0a180
|
@ -1338,7 +1338,12 @@ AM_CONDITIONAL(DRI3, test "x$DRI3" = xyes)
|
||||||
if test "x$DRI" = xyes || test "x$DRI2" = xyes || test "x$DRI3" = xyes || test "x$CONFIG_UDEV_KMS" = xyes; then
|
if test "x$DRI" = xyes || test "x$DRI2" = xyes || test "x$DRI3" = xyes || test "x$CONFIG_UDEV_KMS" = xyes; then
|
||||||
if test "x$DRM" = xyes; then
|
if test "x$DRM" = xyes; then
|
||||||
AC_DEFINE(WITH_LIBDRM, 1, [Building with libdrm support])
|
AC_DEFINE(WITH_LIBDRM, 1, [Building with libdrm support])
|
||||||
PKG_CHECK_MODULES([LIBDRM], $LIBDRM)
|
if test "x$DRI2" = xyes; then
|
||||||
|
dnl 2.4.65 is required for drmGetDevice
|
||||||
|
PKG_CHECK_MODULES([LIBDRM], libdrm >= 2.4.65)
|
||||||
|
else
|
||||||
|
PKG_CHECK_MODULES([LIBDRM], $LIBDRM)
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
|
@ -1440,21 +1440,17 @@ get_prime_id(void)
|
||||||
static char *
|
static char *
|
||||||
dri2_probe_driver_name(ScreenPtr pScreen, DRI2InfoPtr info)
|
dri2_probe_driver_name(ScreenPtr pScreen, DRI2InfoPtr info)
|
||||||
{
|
{
|
||||||
ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
|
#ifdef WITH_LIBDRM
|
||||||
EntityInfoPtr pEnt = xf86GetEntityInfo(pScrn->entityList[0]);
|
|
||||||
struct pci_device *pdev = NULL;
|
|
||||||
int i, j;
|
int i, j;
|
||||||
|
char *driver = NULL;
|
||||||
|
drmDevicePtr dev;
|
||||||
|
|
||||||
if (pEnt)
|
/* For non-PCI devices and drmGetDevice fail, just assume that
|
||||||
pdev = xf86GetPciInfoForEntity(pEnt->index);
|
* the 3D driver is named the same as the kernel driver. This is
|
||||||
|
* currently true for vc4 and msm (freedreno).
|
||||||
/* 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).
|
|
||||||
*/
|
*/
|
||||||
if (!pdev) {
|
if (drmGetDevice(info->fd, &dev) || dev->bustype != DRM_BUS_PCI) {
|
||||||
drmVersionPtr version = drmGetVersion(info->fd);
|
drmVersionPtr version = drmGetVersion(info->fd);
|
||||||
char *kernel_driver;
|
|
||||||
|
|
||||||
if (!version) {
|
if (!version) {
|
||||||
xf86DrvMsg(pScreen->myNum, X_ERROR,
|
xf86DrvMsg(pScreen->myNum, X_ERROR,
|
||||||
|
@ -1463,29 +1459,38 @@ dri2_probe_driver_name(ScreenPtr pScreen, DRI2InfoPtr info)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
kernel_driver = strndup(version->name, version->name_len);
|
driver = strndup(version->name, version->name_len);
|
||||||
drmFreeVersion(version);
|
drmFreeVersion(version);
|
||||||
return kernel_driver;
|
return driver;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; driver_map[i].driver; i++) {
|
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;
|
continue;
|
||||||
|
|
||||||
if (driver_map[i].num_chips_ids == -1)
|
if (driver_map[i].num_chips_ids == -1) {
|
||||||
return strdup(driver_map[i].driver);
|
driver = strdup(driver_map[i].driver);
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
for (j = 0; j < driver_map[i].num_chips_ids; j++) {
|
for (j = 0; j < driver_map[i].num_chips_ids; j++) {
|
||||||
if (driver_map[i].chip_ids[j] == pdev->device_id)
|
if (driver_map[i].chip_ids[j] == dev->deviceinfo.pci->device_id) {
|
||||||
return strdup(driver_map[i].driver);
|
driver = strdup(driver_map[i].driver);
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
xf86DrvMsg(pScreen->myNum, X_ERROR,
|
xf86DrvMsg(pScreen->myNum, X_ERROR,
|
||||||
"[DRI2] No driver mapping found for PCI device "
|
"[DRI2] No driver mapping found for PCI device "
|
||||||
"0x%04x / 0x%04x\n",
|
"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;
|
return NULL;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
Bool
|
Bool
|
||||||
|
|
Loading…
Reference in New Issue