xf86drm: implement drmParsePciBusInfo for OpenBSD

Implement drmParsePciBusInfo for OpenBSD by using the new
DRM_IOCTL_GET_PCIINFO ioctl.

v2: use drmGetMinorType to get node type instead of always
    using DRM_NODE_PRIMARY.

Signed-off-by: Jonathan Gray <jsg@jsg.id.au>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
main
Jonathan Gray 2016-12-01 15:18:42 +11:00 committed by Emil Velikov
parent c0ef1d0788
commit fd190564da
1 changed files with 24 additions and 0 deletions

View File

@ -2946,6 +2946,30 @@ static int drmParsePciBusInfo(int maj, int min, drmPciBusInfoPtr info)
info->dev = dev;
info->func = func;
return 0;
#elif defined(__OpenBSD__)
struct drm_pciinfo pinfo;
int fd, type;
type = drmGetMinorType(min);
if (type == -1)
return -ENODEV;
fd = drmOpenMinor(min, 0, type);
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"