Received: by mail.netbsd.org (Postfix, from userid 605) id 90C3C84DE1; Sun, 9 Sep 2018 04:04:59 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by mail.netbsd.org (Postfix) with ESMTP id 9284184C8D for ; Sun, 9 Sep 2018 04:04:58 +0000 (UTC) X-Virus-Scanned: amavisd-new at netbsd.org Received: from mail.netbsd.org ([IPv6:::1]) by localhost (mail.netbsd.org [IPv6:::1]) (amavisd-new, port 10025) with ESMTP id AIGzEF8pRwnE for ; Sun, 9 Sep 2018 04:04:57 +0000 (UTC) Received: from cvs.NetBSD.org (ivanova.netbsd.org [199.233.217.197]) by mail.netbsd.org (Postfix) with ESMTP id 4430F84CD6 for ; Sun, 9 Sep 2018 04:04:57 +0000 (UTC) Received: by cvs.NetBSD.org (Postfix, from userid 500) id 3D616FBF8; Sun, 9 Sep 2018 04:04:57 +0000 (UTC) Content-Transfer-Encoding: 7bit Content-Type: multipart/mixed; boundary="_----------=_1536465897105220" MIME-Version: 1.0 Date: Sun, 9 Sep 2018 04:04:57 +0000 From: "Maya Rashish" Subject: CVS commit: pkgsrc/x11/libdrm To: pkgsrc-changes@NetBSD.org Reply-To: maya@netbsd.org X-Mailer: log_accum Message-Id: <20180909040457.3D616FBF8@cvs.NetBSD.org> Sender: pkgsrc-changes-owner@NetBSD.org List-Id: pkgsrc-changes.NetBSD.org Precedence: bulk List-Unsubscribe: This is a multi-part message in MIME format. --_----------=_1536465897105220 Content-Disposition: inline Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII" Module Name: pkgsrc Committed By: maya Date: Sun Sep 9 04:04:57 UTC 2018 Modified Files: pkgsrc/x11/libdrm: Makefile distinfo Added Files: pkgsrc/x11/libdrm/patches: patch-xf86drm.c Log Message: libdrm: Implement drmParseSubsystemType, drmParsePciBusInfo for NetBSD Needed for mesalib update, from riastradh. To generate a diff of this commit: cvs rdiff -u -r1.83 -r1.84 pkgsrc/x11/libdrm/Makefile \ pkgsrc/x11/libdrm/distinfo cvs rdiff -u -r0 -r1.1 pkgsrc/x11/libdrm/patches/patch-xf86drm.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. --_----------=_1536465897105220 Content-Disposition: inline Content-Length: 7615 Content-Transfer-Encoding: binary Content-Type: text/x-diff; charset=us-ascii Modified files: Index: pkgsrc/x11/libdrm/Makefile diff -u pkgsrc/x11/libdrm/Makefile:1.83 pkgsrc/x11/libdrm/Makefile:1.84 --- pkgsrc/x11/libdrm/Makefile:1.83 Sun Sep 2 08:34:34 2018 +++ pkgsrc/x11/libdrm/Makefile Sun Sep 9 04:04:56 2018 @@ -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$ 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, Index: pkgsrc/x11/libdrm/distinfo diff -u pkgsrc/x11/libdrm/distinfo:1.83 pkgsrc/x11/libdrm/distinfo:1.84 --- pkgsrc/x11/libdrm/distinfo:1.83 Sun Sep 2 08:34:34 2018 +++ pkgsrc/x11/libdrm/distinfo Sun Sep 9 04:04:56 2018 @@ -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) = 48a912f 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 Added files: Index: pkgsrc/x11/libdrm/patches/patch-xf86drm.c diff -u /dev/null pkgsrc/x11/libdrm/patches/patch-xf86drm.c:1.1 --- /dev/null Sun Sep 9 04:04:57 2018 +++ pkgsrc/x11/libdrm/patches/patch-xf86drm.c Sun Sep 9 04:04:57 2018 @@ -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 ++#include ++#include + #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; --_----------=_1536465897105220--