aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonathan Gray2016-11-30 22:18:41 -0600
committerEmil Velikov2016-12-05 11:53:00 -0600
commitc0ef1d078800a43611136e65be3c9c7472ac9d3f (patch)
tree23401903931f681fbb7ca1ca12a69197da85ca1a /xf86drm.c
parentd05b9f2dde17e60996437332219b4b568f7edefa (diff)
downloadexternal-libgbm-c0ef1d078800a43611136e65be3c9c7472ac9d3f.tar.gz
external-libgbm-c0ef1d078800a43611136e65be3c9c7472ac9d3f.tar.xz
external-libgbm-c0ef1d078800a43611136e65be3c9c7472ac9d3f.zip
xf86drm: implement drmParsePciDeviceInfo for OpenBSD
Implement drmParsePciDeviceInfo for OpenBSD by using the new DRM_IOCTL_GET_PCIINFO ioctl. v2: adapt to drmParsePciDeviceInfo changes and use drmOpenMinor Signed-off-by: Jonathan Gray <jsg@jsg.id.au> Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Diffstat (limited to 'xf86drm.c')
-rw-r--r--xf86drm.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/xf86drm.c b/xf86drm.c
index a889d48d..f0fc4ee2 100644
--- a/xf86drm.c
+++ b/xf86drm.c
@@ -102,6 +102,22 @@
102#define DRM_MAJOR 226 /* Linux */ 102#define DRM_MAJOR 226 /* Linux */
103#endif 103#endif
104 104
105#ifdef __OpenBSD__
106struct drm_pciinfo {
107 uint16_t domain;
108 uint8_t bus;
109 uint8_t dev;
110 uint8_t func;
111 uint16_t vendor_id;
112 uint16_t device_id;
113 uint16_t subvendor_id;
114 uint16_t subdevice_id;
115 uint8_t revision_id;
116};
117
118#define DRM_IOCTL_GET_PCIINFO DRM_IOR(0x15, struct drm_pciinfo)
119#endif
120
105#define DRM_MSG_VERBOSITY 3 121#define DRM_MSG_VERBOSITY 3
106 122
107#define memclear(s) memset(&s, 0, sizeof(s)) 123#define memclear(s) memset(&s, 0, sizeof(s))
@@ -3061,6 +3077,31 @@ static int drmParsePciDeviceInfo(int maj, int min,
3061 return parse_config_sysfs_file(maj, min, device); 3077 return parse_config_sysfs_file(maj, min, device);
3062 3078
3063 return 0; 3079 return 0;
3080#elif defined(__OpenBSD__)
3081 struct drm_pciinfo pinfo;
3082 int fd, type;
3083
3084 type = drmGetMinorType(min);
3085 if (type == -1)
3086 return -ENODEV;
3087
3088 fd = drmOpenMinor(min, 0, type);
3089 if (fd < 0)
3090 return -errno;
3091
3092 if (drmIoctl(fd, DRM_IOCTL_GET_PCIINFO, &pinfo)) {
3093 close(fd);
3094 return -errno;
3095 }
3096 close(fd);
3097
3098 device->vendor_id = pinfo.vendor_id;
3099 device->device_id = pinfo.device_id;
3100 device->revision_id = pinfo.revision_id;
3101 device->subvendor_id = pinfo.subvendor_id;
3102 device->subdevice_id = pinfo.subdevice_id;
3103
3104 return 0;
3064#else 3105#else
3065#warning "Missing implementation of drmParsePciDeviceInfo" 3106#warning "Missing implementation of drmParsePciDeviceInfo"
3066 return -EINVAL; 3107 return -EINVAL;