Changeset View
Changeset View
Standalone View
Standalone View
head/graphics/libdrm/files/patch-xf86drm.c
Show All 24 Lines | |||||
+#define DRM_MAJOR 65 /* was 145 XXX needs checking */ | +#define DRM_MAJOR 65 /* was 145 XXX needs checking */ | ||||
#endif | #endif | ||||
#ifdef __NetBSD__ | #ifdef __NetBSD__ | ||||
@@ -548,6 +556,7 @@ static int drmGetMinorType(int minor) | @@ -548,6 +556,7 @@ static int drmGetMinorType(int minor) | ||||
} | } | ||||
} | } | ||||
+#if !defined(__FreeBSD__) && !defined(__DragonFly__) | +#if !defined(__FreeBSD__) && !defined(__FreeBSD_kernel__) && !defined(__DragonFly__) | ||||
static const char *drmGetMinorName(int type) | static const char *drmGetMinorName(int type) | ||||
{ | { | ||||
switch (type) { | switch (type) { | ||||
@@ -561,6 +570,7 @@ static const char *drmGetMinorName(int t | @@ -561,6 +570,7 @@ static const char *drmGetMinorName(int t | ||||
return NULL; | return NULL; | ||||
} | } | ||||
} | } | ||||
+#endif | +#endif | ||||
/** | /** | ||||
* Open the device by bus ID. | * Open the device by bus ID. | ||||
@@ -2734,7 +2744,7 @@ int drmGetNodeTypeFromFd(int fd) | |||||
maj = major(sbuf.st_rdev); | |||||
min = minor(sbuf.st_rdev); | |||||
- if (maj != DRM_MAJOR || !S_ISCHR(sbuf.st_mode)) { | |||||
+ if (DRM_MAJOR && maj != DRM_MAJOR || !S_ISCHR(sbuf.st_mode)) { | |||||
errno = EINVAL; | |||||
return -1; | |||||
} | |||||
@@ -2833,6 +2843,15 @@ static char *drmGetMinorNameForFD(int fd | @@ -2833,6 +2843,15 @@ static char *drmGetMinorNameForFD(int fd | ||||
out_close_dir: | out_close_dir: | ||||
closedir(sysdir); | closedir(sysdir); | ||||
+#elif defined(__FreeBSD__) || defined(__DragonFly__) | +#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__) | ||||
+ struct stat buf; | + struct stat buf; | ||||
+ char name[64]; | + char name[64]; | ||||
+ | + | ||||
+ fstat(fd, &buf); | + fstat(fd, &buf); | ||||
+ snprintf(name, sizeof(name), "/dev/%s", | + snprintf(name, sizeof(name), "/dev/%s", | ||||
+ devname(buf.st_rdev, S_IFCHR)); | + devname(buf.st_rdev, S_IFCHR)); | ||||
+ | + | ||||
+ return strdup(name); | + return strdup(name); | ||||
#else | #else | ||||
struct stat sbuf; | struct stat sbuf; | ||||
char buf[PATH_MAX + 1]; | char buf[PATH_MAX + 1]; | ||||
@@ -2960,7 +2979,7 @@ static int drmParseSubsystemType(int maj | @@ -2960,7 +2979,7 @@ static int drmParseSubsystemType(int maj | ||||
return DRM_BUS_HOST1X; | return DRM_BUS_HOST1X; | ||||
return -EINVAL; | return -EINVAL; | ||||
-#elif defined(__OpenBSD__) | -#elif defined(__OpenBSD__) | ||||
+#elif defined(__OpenBSD__) || defined(__FreeBSD__) || defined(__DragonFly__) | +#elif defined(__OpenBSD__) || defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__) | ||||
return DRM_BUS_PCI; | return DRM_BUS_PCI; | ||||
#else | #else | ||||
#warning "Missing implementation of drmParseSubsystemType" | #warning "Missing implementation of drmParseSubsystemType" | ||||
@@ -3023,6 +3042,61 @@ static int drmParsePciBusInfo(int maj, i | @@ -3023,6 +3042,61 @@ static int drmParsePciBusInfo(int maj, i | ||||
#endif | #endif | ||||
} | } | ||||
+#if defined(__FreeBSD__) || defined(__DragonFly__) | +#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__) | ||||
+/* | +/* | ||||
+ * XXX temporary workaround, because FreeBSD doesn't provide | + * XXX temporary workaround, because FreeBSD doesn't provide | ||||
+ * pcibus device sysctl trees for renderD and controlD nodes (yet) | + * pcibus device sysctl trees for renderD and controlD nodes (yet) | ||||
+ */ | + */ | ||||
+static void | +static void | ||||
+drmBSDDeviceNameHack(const char *path, char *hacked_path, int length) | +drmBSDDeviceNameHack(const char *path, char *hacked_path, int length) | ||||
+{ | +{ | ||||
+ int start, number; | + int start, number; | ||||
▲ Show 20 Lines • Show All 45 Lines • ▼ Show 20 Lines | |||||
+ | + | ||||
static int drmCompareBusInfo(drmDevicePtr a, drmDevicePtr b) | static int drmCompareBusInfo(drmDevicePtr a, drmDevicePtr b) | ||||
{ | { | ||||
if (a == NULL || b == NULL) | if (a == NULL || b == NULL) | ||||
@@ -3188,6 +3262,36 @@ static int drmParsePciDeviceInfo(int maj | @@ -3188,6 +3262,36 @@ static int drmParsePciDeviceInfo(int maj | ||||
#endif | #endif | ||||
} | } | ||||
+#if defined(__FreeBSD__) || defined(__DragonFly__) | +#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__) | ||||
+static int drmParsePciDeviceInfoBSD(const char *path, | +static int drmParsePciDeviceInfoBSD(const char *path, | ||||
+ drmPciDeviceInfoPtr device, | + drmPciDeviceInfoPtr device, | ||||
+ uint32_t flags) | + uint32_t flags) | ||||
+{ | +{ | ||||
+ int fd, vendor_id = 0, device_id = 0, subvendor_id = 0, | + int fd, vendor_id = 0, device_id = 0, subvendor_id = 0, | ||||
+ subdevice_id = 0, revision_id = 0; | + subdevice_id = 0, revision_id = 0; | ||||
+ char hacked_path[PATH_MAX + 1]; | + char hacked_path[PATH_MAX + 1]; | ||||
+ | + | ||||
Show All 20 Lines | |||||
+ | + | ||||
static void drmFreePlatformDevice(drmDevicePtr device) | static void drmFreePlatformDevice(drmDevicePtr device) | ||||
{ | { | ||||
if (device->deviceinfo.platform) { | if (device->deviceinfo.platform) { | ||||
@@ -3308,7 +3412,11 @@ static int drmProcessPciDevice(drmDevice | @@ -3308,7 +3412,11 @@ static int drmProcessPciDevice(drmDevice | ||||
dev->businfo.pci = (drmPciBusInfoPtr)addr; | dev->businfo.pci = (drmPciBusInfoPtr)addr; | ||||
+#if defined(__FreeBSD__) || defined(__DragonFly__) | +#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__) | ||||
+ ret = drmParsePciBusInfoBSD(node, dev->businfo.pci); | + ret = drmParsePciBusInfoBSD(node, dev->businfo.pci); | ||||
+#else | +#else | ||||
ret = drmParsePciBusInfo(maj, min, dev->businfo.pci); | ret = drmParsePciBusInfo(maj, min, dev->businfo.pci); | ||||
+#endif | +#endif | ||||
if (ret) | if (ret) | ||||
goto free_device; | goto free_device; | ||||
@@ -3316,8 +3424,11 @@ static int drmProcessPciDevice(drmDevice | @@ -3316,8 +3424,11 @@ static int drmProcessPciDevice(drmDevice | ||||
if (fetch_deviceinfo) { | if (fetch_deviceinfo) { | ||||
addr += sizeof(drmPciBusInfo); | addr += sizeof(drmPciBusInfo); | ||||
dev->deviceinfo.pci = (drmPciDeviceInfoPtr)addr; | dev->deviceinfo.pci = (drmPciDeviceInfoPtr)addr; | ||||
- | - | ||||
+#if defined(__FreeBSD__) || defined(__DragonFly__) | +#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__) | ||||
+ ret = drmParsePciDeviceInfoBSD(node, dev->deviceinfo.pci, flags); | + ret = drmParsePciDeviceInfoBSD(node, dev->deviceinfo.pci, flags); | ||||
+#else | +#else | ||||
ret = drmParsePciDeviceInfo(maj, min, dev->deviceinfo.pci, flags); | ret = drmParsePciDeviceInfo(maj, min, dev->deviceinfo.pci, flags); | ||||
+#endif | +#endif | ||||
if (ret) | if (ret) | ||||
goto free_device; | goto free_device; | ||||
} | } | ||||
@@ -3786,7 +3897,7 @@ int drmGetDevice2(int fd, uint32_t flags | |||||
maj = major(sbuf.st_rdev); | |||||
min = minor(sbuf.st_rdev); | |||||
- if (maj != DRM_MAJOR || !S_ISCHR(sbuf.st_mode)) | |||||
+ if (DRM_MAJOR && maj != DRM_MAJOR || !S_ISCHR(sbuf.st_mode)) | |||||
return -EINVAL; | |||||
subsystem_type = drmParseSubsystemType(maj, min); | |||||
@@ -3814,7 +3925,7 @@ int drmGetDevice2(int fd, uint32_t flags | |||||
maj = major(sbuf.st_rdev); | |||||
min = minor(sbuf.st_rdev); | |||||
- if (maj != DRM_MAJOR || !S_ISCHR(sbuf.st_mode)) | |||||
+ if (DRM_MAJOR && maj != DRM_MAJOR || !S_ISCHR(sbuf.st_mode)) | |||||
continue; | |||||
if (drmParseSubsystemType(maj, min) != subsystem_type) | |||||
@@ -3964,7 +4075,7 @@ int drmGetDevices2(uint32_t flags, drmDe | |||||
maj = major(sbuf.st_rdev); | |||||
min = minor(sbuf.st_rdev); | |||||
- if (maj != DRM_MAJOR || !S_ISCHR(sbuf.st_mode)) | |||||
+ if (DRM_MAJOR && maj != DRM_MAJOR || !S_ISCHR(sbuf.st_mode)) | |||||
continue; | |||||
subsystem_type = drmParseSubsystemType(maj, min); | |||||
@@ -4108,7 +4219,7 @@ char *drmGetDeviceNameFromFd2(int fd) | |||||
maj = major(sbuf.st_rdev); | |||||
min = minor(sbuf.st_rdev); | |||||
- if (maj != DRM_MAJOR || !S_ISCHR(sbuf.st_mode)) | |||||
+ if (DRM_MAJOR && maj != DRM_MAJOR || !S_ISCHR(sbuf.st_mode)) | |||||
return NULL; | |||||
node_type = drmGetMinorType(min); |