summaryrefslogtreecommitdiff
path: root/x11/libdrm
diff options
context:
space:
mode:
authormaya <maya@pkgsrc.org>2018-09-09 04:04:56 +0000
committermaya <maya@pkgsrc.org>2018-09-09 04:04:56 +0000
commit398c15a236ca2ab875a952c8684b7eb263bad751 (patch)
tree3cc099800ec96bb9393c49d62aa4ae79617c5217 /x11/libdrm
parent7635b51de9e0e39904a439f9657c27119a5dbcf2 (diff)
downloadpkgsrc-398c15a236ca2ab875a952c8684b7eb263bad751.tar.gz
libdrm: Implement drmParseSubsystemType, drmParsePciBusInfo for NetBSD
Needed for mesalib update, from riastradh.
Diffstat (limited to 'x11/libdrm')
-rw-r--r--x11/libdrm/Makefile5
-rw-r--r--x11/libdrm/distinfo3
-rw-r--r--x11/libdrm/patches/patch-xf86drm.c198
3 files changed, 204 insertions, 2 deletions
diff --git a/x11/libdrm/Makefile b/x11/libdrm/Makefile
index bf901719396..0e38b71eb42 100644
--- a/x11/libdrm/Makefile
+++ b/x11/libdrm/Makefile
@@ -1,7 +1,8 @@
-# $NetBSD: Makefile,v 1.83 2018/09/02 08:34:34 wiz Exp $
+# $NetBSD: Makefile,v 1.84 2018/09/09 04:04:56 maya Exp $
DISTNAME= libdrm-2.4.94
CATEGORIES= x11 graphics
+PKGREVISION= 1
MASTER_SITES= http://dri.freedesktop.org/libdrm/
EXTRACT_SUFX= .tar.bz2
@@ -39,6 +40,8 @@ CONFIGURE_ARGS+= PTHREADSTUBS_CFLAGS=-I${PREFIX}/include \
CONFIGURE_ARGS+= --disable-manpages
CONFIGURE_ARGS+= --disable-valgrind
+LDFLAGS.NetBSD+= -lpci
+
PLIST_VARS+= intel arm
.if !empty(MACHINE_ARCH:Mi386) || !empty(MACHINE_ARCH:Mx86_64)
# libpciaccess is needed to build support for the intel KMS API,
diff --git a/x11/libdrm/distinfo b/x11/libdrm/distinfo
index a234f70ed0c..19dcf46f9f2 100644
--- a/x11/libdrm/distinfo
+++ b/x11/libdrm/distinfo
@@ -1,4 +1,4 @@
-$NetBSD: distinfo,v 1.83 2018/09/02 08:34:34 wiz Exp $
+$NetBSD: distinfo,v 1.84 2018/09/09 04:04:56 maya Exp $
SHA1 (libdrm-2.4.94.tar.bz2) = f8daee6cc2e7d2c9eb2dd062a2712172fb9f4e18
RMD160 (libdrm-2.4.94.tar.bz2) = 14d94fa857c53e7d5580d3221c3b1ef310e9ecc2
@@ -10,5 +10,6 @@ SHA1 (patch-include_drm_drm.h) = 48a912f40bf2b2a1c23edbe4446fa7869212f17b
SHA1 (patch-libkms_vmwgfx.c) = d2204c0b79098c6c36b7f282b486c58c6354bd1d
SHA1 (patch-radeon_radeon__bo__gem.c) = 4924fde172b2a2a713d47bf7b60a6b52851d7a8f
SHA1 (patch-radeon_radeon__cs__gem.c) = 516b5dd6408c10a4f33f2815b3719e34a16d863a
+SHA1 (patch-xf86drm.c) = 8626fb9fad16a75a009f7483d9ba3411856134ad
SHA1 (patch-xf86drmMode.c) = 09b2a9292825e6b952ee8ad5d6e4cd2bdc90228d
SHA1 (patch-xf86drmMode.h) = a28b02887389be8670193c119f711901af61a6b2
diff --git a/x11/libdrm/patches/patch-xf86drm.c b/x11/libdrm/patches/patch-xf86drm.c
new file mode 100644
index 00000000000..9a38f89765e
--- /dev/null
+++ b/x11/libdrm/patches/patch-xf86drm.c
@@ -0,0 +1,198 @@
+$NetBSD: patch-xf86drm.c,v 1.1 2018/09/09 04:04:57 maya Exp $
+
+Implement drmParseSubsystemType, drmParsePciBusInfo for NetBSD
+
+--- xf86drm.c.orig 2018-09-09 02:59:41.597386206 +0000
++++ xf86drm.c
+@@ -85,6 +85,9 @@
+
+ #ifdef __NetBSD__
+ #define DRM_MAJOR 180
++#include <sys/param.h>
++#include <dev/pci/pcireg.h>
++#include <pci.h>
+ #endif
+
+ #ifdef __OpenBSD__
+@@ -2990,6 +2993,65 @@ static int drmParseSubsystemType(int maj
+ return DRM_BUS_VIRTIO;
+
+ return -EINVAL;
++#elif defined(__NetBSD__)
++ int type, fd;
++ drmSetVersion sv;
++ char *buf;
++ unsigned domain, bus, dev;
++ int func;
++ int ret;
++
++ /* Get the type of device we're looking for to pick the right pathname. */
++ type = drmGetMinorType(min);
++ if (type == -1)
++ return -ENODEV;
++
++ /* Open the device. Don't try to create it if it's not there. */
++ fd = drmOpenMinor(min, 0, type);
++ if (fd < 0)
++ return -errno;
++
++ /*
++ * Set the interface version to 1.4 or 1.1, which has the effect of
++ * populating the bus id for us.
++ */
++ sv.drm_di_major = 1;
++ sv.drm_di_minor = 4;
++ sv.drm_dd_major = -1;
++ sv.drm_dd_minor = -1;
++ if (drmSetInterfaceVersion(fd, &sv)) {
++ sv.drm_di_major = 1;
++ sv.drm_di_minor = 1;
++ sv.drm_dd_major = -1;
++ sv.drm_dd_minor = -1;
++ if (drmSetInterfaceVersion(fd, &sv)) {
++ /*
++ * We're probably not the master. Hope the master already
++ * set the version to >=1.1 so that we can get the busid.
++ */
++ }
++ }
++
++ /* Get the bus id. */
++ buf = drmGetBusid(fd);
++
++ /* We're done with the device now. */
++ (void)close(fd);
++
++ /* If there is no bus id, fail. */
++ if (buf == NULL)
++ return -ENODEV;
++
++ /* Find a string we know about; otherwise -EINVAL. */
++ ret = -EINVAL;
++ if (strncmp(buf, "pci:", 4) == 0)
++ ret = DRM_BUS_PCI;
++
++ /* We're done with the bus id. */
++ free(buf);
++
++ /* Success or not, we're done. */
++ return ret;
+ #elif defined(__OpenBSD__)
+ return DRM_BUS_PCI;
+ #else
+@@ -3040,6 +3102,73 @@ static int drmParsePciBusInfo(int maj, i
+ info->func = func;
+
+ return 0;
++#elif defined(__NetBSD__)
++ int type, fd;
++ drmSetVersion sv;
++ char *buf;
++ unsigned domain, bus, dev;
++ int func;
++ int ret;
++
++ /* Get the type of device we're looking for to pick the right pathname. */
++ type = drmGetMinorType(min);
++ if (type == -1)
++ return -ENODEV;
++
++ /* Open the device. Don't try to create it if it's not there. */
++ fd = drmOpenMinor(min, 0, type);
++ if (fd < 0)
++ return -errno;
++
++ /*
++ * Set the interface version to 1.4 or 1.1, which has the effect of
++ * populating the bus id for us.
++ */
++ sv.drm_di_major = 1;
++ sv.drm_di_minor = 4;
++ sv.drm_dd_major = -1;
++ sv.drm_dd_minor = -1;
++ if (drmSetInterfaceVersion(fd, &sv)) {
++ sv.drm_di_major = 1;
++ sv.drm_di_minor = 1;
++ sv.drm_dd_major = -1;
++ sv.drm_dd_minor = -1;
++ if (drmSetInterfaceVersion(fd, &sv)) {
++ /*
++ * We're probably not the master. Hope the master already
++ * set the version to >=1.1 so that we can get the busid.
++ */
++ }
++ }
++
++ /* Get the bus id. */
++ buf = drmGetBusid(fd);
++
++ /* We're done with the device now. */
++ (void)close(fd);
++
++ /* If there is no bus id, fail. */
++ if (buf == NULL)
++ return -ENODEV;
++
++ /* Parse the bus id. */
++ ret = sscanf(buf, "pci:%04x:%02x:%02x.%d", &domain, &bus, &dev, &func);
++
++ /* We're done with the bus id. */
++ free(buf);
++
++ /* If scanf didn't return 4 -- domain, bus, dev, func -- then fail. */
++ if (ret != 4)
++ return -ENODEV;
++
++ /* Populate the results. */
++ info->domain = domain;
++ info->bus = bus;
++ info->dev = dev;
++ info->func = func;
++
++ /* Success! */
++ return 0;
+ #elif defined(__OpenBSD__)
+ struct drm_pciinfo pinfo;
+ int fd, type;
+@@ -3209,6 +3338,41 @@ static int drmParsePciDeviceInfo(int maj
+ return parse_config_sysfs_file(maj, min, device);
+
+ return 0;
++#elif defined(__NetBSD__)
++ drmPciBusInfo businfo;
++ char fname[PATH_MAX];
++ int pcifd;
++ pcireg_t id, class, subsys;
++ int ret;
++
++ /* Find where on the bus the device lives. */
++ ret = drmParsePciBusInfo(maj, min, &businfo);
++ if (ret)
++ return ret;
++
++ /* Open the pciN device node to get at its config registers. */
++ if (snprintf(fname, sizeof fname, "/dev/pci%u", businfo.domain)
++ >= sizeof fname)
++ return -ENODEV;
++ if ((pcifd = open(fname, O_RDONLY)) == -1)
++ return -errno;
++
++ /* Read the id and class pci config registers. */
++ if (pcibus_conf_read(pcifd, businfo.bus, businfo.dev, businfo.func,
++ PCI_ID_REG, &id) == -1)
++ return -errno;
++ if (pcibus_conf_read(pcifd, businfo.bus, businfo.dev, businfo.func,
++ PCI_CLASS_REG, &class) == -1)
++ return -errno;
++ if (pcibus_conf_read(pcifd, businfo.bus, businfo.dev, businfo.func,
++ PCI_SUBSYS_ID_REG, &subsys) == -1)
++ return -errno;
++
++ device->vendor_id = PCI_VENDOR(id);
++ device->device_id = PCI_PRODUCT(id);
++ device->subvendor_id = PCI_SUBSYS_VENDOR(subsys);
++ device->subdevice_id = PCI_SUBSYS_ID(subsys);
++ device->revision_id = PCI_REVISION(class);
+ #elif defined(__OpenBSD__)
+ struct drm_pciinfo pinfo;
+ int fd, type;