From: Jonathan Gray <jsg@jsg.id.au>
To: dri-devel@lists.freedesktop.org
Cc: emil.l.velikov@gmail.com
Subject: [PATCH libdrm 3/5] xf86drm: implement drmParsePciDeviceInfo for OpenBSD
Date: Sat, 26 Nov 2016 11:40:32 +1100 [thread overview]
Message-ID: <20161126004034.53376-3-jsg@jsg.id.au> (raw)
In-Reply-To: <20161126004034.53376-1-jsg@jsg.id.au>
Implement drmParsePciDeviceInfo for OpenBSD by using the new
DRM_IOCTL_GET_PCIINFO ioctl.
Signed-off-by: Jonathan Gray <jsg@jsg.id.au>
---
xf86drm.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 51 insertions(+)
diff --git a/xf86drm.c b/xf86drm.c
index b355c83..581527b 100644
--- a/xf86drm.c
+++ b/xf86drm.c
@@ -102,6 +102,26 @@
#define DRM_MAJOR 226 /* Linux */
#endif
+#ifdef __OpenBSD__
+
+#define X_PRIVSEP
+
+struct drm_pciinfo {
+ uint16_t domain;
+ uint8_t bus;
+ uint8_t dev;
+ uint8_t func;
+ uint16_t vendor_id;
+ uint16_t device_id;
+ uint16_t subvendor_id;
+ uint16_t subdevice_id;
+ uint8_t revision_id;
+};
+
+#define DRM_IOCTL_GET_PCIINFO DRM_IOR(0x15, struct drm_pciinfo)
+
+#endif
+
#define DRM_MSG_VERBOSITY 3
#define memclear(s) memset(&s, 0, sizeof(s))
@@ -2991,6 +3011,37 @@ static int drmParsePciDeviceInfo(const char *d_name,
device->subdevice_id = config[46] | (config[47] << 8);
return 0;
+#elif defined(__OpenBSD__)
+ struct drm_pciinfo pinfo;
+ char buf[PATH_MAX + 1];
+ int fd, n;
+
+ n = snprintf(buf, sizeof(buf), "%s/%s", DRM_DIR_NAME, d_name);
+ if (n == -1 || n >= sizeof(buf))
+ return -errno;
+
+#ifndef X_PRIVSEP
+ fd = open(buf, O_RDWR, 0);
+#else
+ fd = priv_open_device(buf);
+#endif
+
+ if (fd < 0)
+ return -errno;
+
+ if (drmIoctl(fd, DRM_IOCTL_GET_PCIINFO, &pinfo)) {
+ close(fd);
+ return -errno;
+ }
+ close(fd);
+
+ device->vendor_id = pinfo.vendor_id;
+ device->device_id = pinfo.device_id;
+ device->revision_id = pinfo.revision_id;
+ device->subvendor_id = pinfo.subvendor_id;
+ device->subdevice_id = pinfo.subdevice_id;
+
+ return 0;
#else
#warning "Missing implementation of drmParsePciDeviceInfo"
return -EINVAL;
--
2.10.2
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
next prev parent reply other threads:[~2016-11-26 0:47 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-26 0:40 [PATCH libdrm 1/5] xf86drm: implement drmGetMinorNameForFD for non-sysfs Jonathan Gray
2016-11-26 0:40 ` [PATCH libdrm 2/5] xf86drm: implement drmParseSubsystemType for OpenBSD Jonathan Gray
2016-11-29 19:46 ` Emil Velikov
2016-11-30 0:23 ` Jonathan Gray
2016-11-30 16:23 ` Emil Velikov
2016-11-26 0:40 ` Jonathan Gray [this message]
2016-11-29 19:55 ` [PATCH libdrm 3/5] xf86drm: implement drmParsePciDeviceInfo " Emil Velikov
2016-11-30 0:38 ` Jonathan Gray
2016-11-30 16:11 ` Emil Velikov
2016-11-26 0:40 ` [PATCH libdrm 4/5] xf86drm: implement drmParsePciBusInfo " Jonathan Gray
2016-11-26 0:40 ` [PATCH libdrm 5/5] xf86drm: implement an OpenBSD specific drmGetDevice Jonathan Gray
2016-11-29 20:03 ` Emil Velikov
2016-11-30 0:00 ` Jonathan Gray
2016-11-30 16:32 ` Emil Velikov
2016-11-29 19:22 ` [PATCH libdrm 1/5] xf86drm: implement drmGetMinorNameForFD for non-sysfs Emil Velikov
2016-11-30 0:15 ` Jonathan Gray
2016-11-30 16:16 ` Emil Velikov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20161126004034.53376-3-jsg@jsg.id.au \
--to=jsg@jsg.id.au \
--cc=dri-devel@lists.freedesktop.org \
--cc=emil.l.velikov@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox