diff mbox

[libdrm,4/5] xf86drm: implement drmParsePciBusInfo for OpenBSD

Message ID 20161126004034.53376-4-jsg@jsg.id.au (mailing list archive)
State New, archived
Headers show

Commit Message

Jonathan Gray Nov. 26, 2016, 12:40 a.m. UTC
Implement drmParsePciBusInfo for OpenBSD by using the new
DRM_IOCTL_GET_PCIINFO ioctl.

Signed-off-by: Jonathan Gray <jsg@jsg.id.au>
---
 xf86drm.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
diff mbox

Patch

diff --git a/xf86drm.c b/xf86drm.c
index 581527b..2a60b2e 100644
--- a/xf86drm.c
+++ b/xf86drm.c
@@ -2936,6 +2936,26 @@  static int drmParsePciBusInfo(int maj, int min, drmPciBusInfoPtr info)
     info->func = func;
 
     return 0;
+#elif defined(__OpenBSD__)
+    struct drm_pciinfo pinfo;
+    int fd;
+
+    fd = drmOpenMinor(min, 0, DRM_NODE_PRIMARY);
+    if (fd < 0)
+        return -errno;
+
+    if (drmIoctl(fd, DRM_IOCTL_GET_PCIINFO, &pinfo)) {
+        close(fd);
+        return -errno;
+    }
+    close(fd);
+
+    info->domain = pinfo.domain;
+    info->bus = pinfo.bus;
+    info->dev = pinfo.dev;
+    info->func = pinfo.func;
+
+    return 0;
 #else
 #warning "Missing implementation of drmParsePciBusInfo"
     return -EINVAL;