static Bool radeon_kernel_mode_enabled(ScrnInfoPtr pScrn, struct pci_device *pci_dev) { char *busIdString; int ret; if (!xf86LoaderCheckSymbol("DRICreatePCIBusID")) { xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 0, "[KMS] No DRICreatePCIBusID symbol, no kernel modesetting.\n"); return FALSE; } busIdString = DRICreatePCIBusID(pci_dev); ret = drmCheckModesettingSupported(busIdString); #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) if (ret) { if (xf86LoadKernelModule("radeonkms")) ret = drmCheckModesettingSupported(busIdString); } #endif free(busIdString); if (ret) { xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 0, "[KMS] drm report modesetting isn't supported.\n"); return FALSE; } xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 0, "[KMS] Kernel modesetting enabled.\n"); return TRUE; }
static Bool has_kernel_mode_setting(const struct pci_device *dev) { char id[20]; int ret, fd; snprintf(id, sizeof(id), "pci:%04x:%02x:%02x.%d", dev->domain, dev->bus, dev->dev, dev->func); ret = drmCheckModesettingSupported(id); if (ret) { if (xf86LoadKernelModule("i915")) ret = drmCheckModesettingSupported(id); if (ret) return FALSE; /* Be nice to the user and load fbcon too */ (void)xf86LoadKernelModule("fbcon"); } /* Confirm that this is a i915.ko device with GEM/KMS enabled */ ret = FALSE; fd = drmOpen(NULL, id); if (fd != -1) { drmVersionPtr version = drmGetVersion(fd); if (version) { ret = strcmp ("i915", version->name) == 0; drmFreeVersion(version); } if (ret) { struct drm_i915_getparam gp; gp.param = I915_PARAM_HAS_GEM; gp.value = &ret; if (drmIoctl(fd, DRM_IOCTL_I915_GETPARAM, &gp)) ret = FALSE; } if (ret) { struct drm_mode_card_res res; memset(&res, 0, sizeof(res)); if (drmIoctl(fd, DRM_IOCTL_MODE_GETRESOURCES, &res)) ret = FALSE; } close(fd); } return ret; }
static Bool nouveau_xorg_pci_probe(DriverPtr driver, int entity_num, struct pci_device *device, intptr_t match_data) { ScrnInfoPtr scrn = NULL; struct nouveau_device *dev = NULL; char *busid; int chipset, ret; busid = malloc(64); if (!busid) return FALSE; sprintf(busid, "pci:%04x:%02x:%02x.%d", device->domain, device->bus, device->dev, device->func); ret = drmCheckModesettingSupported(busid); if (ret) { xf86DrvMsg(-1, X_ERROR, "[drm] KMS not enabled\n"); free(busid); return FALSE; } ret = nouveau_device_open(busid, &dev); free(busid); if (ret) { xf86DrvMsg(-1, X_ERROR, "[drm] failed to open device\n"); return FALSE; } chipset = dev->chipset; nouveau_device_del(&dev); switch (chipset & 0xf0) { case 0x00: case 0x10: case 0x20: xf86DrvMsg(-1, X_NOTICE, "Too old chipset: NV%02x\n", chipset); return FALSE; case 0x30: case 0x40: case 0x60: case 0x50: case 0x80: case 0x90: case 0xa0: case 0xc0: case 0xd0: case 0xe0: case 0xf0: xf86DrvMsg(-1, X_INFO, "Detected chipset: NV%02x\n", chipset); break; default: xf86DrvMsg(-1, X_ERROR, "Unknown chipset: NV%02x\n", chipset); return FALSE; } scrn = xf86ConfigPciEntity(scrn, 0, entity_num, nouveau_xorg_pci_devices, NULL, NULL, NULL, NULL, NULL); if (scrn != NULL) { scrn->driverVersion = 1; scrn->driverName = "nouveau"; scrn->name = "nouveau2"; scrn->Probe = NULL; /* Use all the functions from the xorg tracker */ xorg_tracker_set_functions(scrn); } return scrn != NULL; }