Load kernel modules before using DRM on DFBSD.

On DragonFlyBSD the appropriate kernel drivers need to be loaded before
using DRM, so I added a section that loads them before calling DRM
functions.

Signed-off-by: b-aaz <b-aazbsd@proton.me>
This commit is contained in:
b-aaz
2025-09-13 21:14:21 +00:00
committed by Enrico Weigelt
parent b58ebdbec2
commit 45f03ac5d8
2 changed files with 24 additions and 2 deletions

View File

@@ -58,6 +58,10 @@
#include <X11/extensions/dpms.h>
#endif
#ifdef __DragonFly__
#include <xf86_OSproc.h>
#endif
#include <X11/extensions/damageproto.h>
#include <fb.h>
@@ -1529,6 +1533,24 @@ static int radeon_get_drm_master_fd(ScrnInfoPtr pScrn)
XNFasprintf(&busid, "pci:%04x:%02x:%02x.%d",
dev->domain, dev->bus, dev->dev, dev->func);
#ifdef __DragonFly__
/* On DragonFlyBSD Appropriate kernel drivers need to be loaded before
* accessing DRM facilities */
int loaded=0; /* if we were able to load the module. */
loaded = xf86LoadKernelModule("radeon");
/* EEXIST is set if the module has already been loaded in the kernel */
if (!loaded && errno != EEXIST) {
loaded = xf86LoadKernelModule("radeonkms");
if (!loaded && errno != EEXIST) {
xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
"[drm] Failed to load kernel module for %s: %s\n",
busid, strerror(errno));
free(busid);
return -1;
}
}
#endif
fd = drmOpen(NULL, busid);
if (fd == -1)
xf86DrvMsg(pScrn->scrnIndex, X_ERROR,

View File

@@ -51,7 +51,7 @@
#include <xf86Pci.h>
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__)
#include <xf86_OSproc.h>
#endif
@@ -97,7 +97,7 @@ static Bool radeon_kernel_mode_enabled(ScrnInfoPtr pScrn, struct pci_device *pci
busIdString = DRICreatePCIBusID(pci_dev);
ret = drmCheckModesettingSupported(busIdString);
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__)
if (ret) {
if (xf86LoadKernelModule("radeonkms"))
ret = drmCheckModesettingSupported(busIdString);