pkgsrc-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[pkgsrc/trunk]: pkgsrc/x11/libdrm libdrm: Implement drmParseSubsystemType, dr...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/ca0a4a69f8a7
branches:  trunk
changeset: 385009:ca0a4a69f8a7
user:      maya <maya%pkgsrc.org@localhost>
date:      Sun Sep 09 04:04:56 2018 +0000

description:
libdrm: Implement drmParseSubsystemType, drmParsePciBusInfo for NetBSD

Needed for mesalib update, from riastradh.

diffstat:

 x11/libdrm/Makefile                |    5 +-
 x11/libdrm/distinfo                |    3 +-
 x11/libdrm/patches/patch-xf86drm.c |  198 +++++++++++++++++++++++++++++++++++++
 3 files changed, 204 insertions(+), 2 deletions(-)

diffs (240 lines):

diff -r c1c5e2433859 -r ca0a4a69f8a7 x11/libdrm/Makefile
--- a/x11/libdrm/Makefile       Sun Sep 09 00:47:40 2018 +0000
+++ b/x11/libdrm/Makefile       Sun Sep 09 04:04:56 2018 +0000
@@ -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+=       --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 -r c1c5e2433859 -r ca0a4a69f8a7 x11/libdrm/distinfo
--- a/x11/libdrm/distinfo       Sun Sep 09 00:47:40 2018 +0000
+++ b/x11/libdrm/distinfo       Sun Sep 09 04:04:56 2018 +0000
@@ -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-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 -r c1c5e2433859 -r ca0a4a69f8a7 x11/libdrm/patches/patch-xf86drm.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/x11/libdrm/patches/patch-xf86drm.c        Sun Sep 09 04:04:56 2018 +0000
@@ -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;



Home | Main Index | Thread Index | Old Index