From ae4db652377d8add444fa2d9dfe5a398d7f64a80 Mon Sep 17 00:00:00 2001 From: kostikbel Date: Thu, 21 Feb 2013 20:02:00 +0000 Subject: [PATCH 2/3] =?UTF-8?q?drm:=20Add=20support=20for=20FreeBSD=E2=80=99?= =?UTF-8?q?s=20libkms?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Patch from http://people.freebsd.org/~kib/drm/libdrm.2.patch --- configure.ac | 1 + xf86drmMode.c | 32 +++++++++++++++++++++++++++++++- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 3e7c214..8f32f2b 100644 --- a/configure.ac +++ b/configure.ac @@ -196,6 +196,7 @@ AC_CANONICAL_HOST if test "x$LIBKMS" = xauto ; then case $host_os in linux*) LIBKMS="yes" ;; + freebsd*) LIBKMS="yes" ;; *) LIBKMS="no" ;; esac fi diff --git a/xf86drmMode.c b/xf86drmMode.c index f603ceb..36ae139 100644 --- a/xf86drmMode.c +++ b/xf86drmMode.c @@ -689,7 +689,7 @@ int drmModeConnectorSetProperty(int fd, uint32_t connector_id, uint32_t property */ int drmCheckModesettingSupported(const char *busid) { -#ifdef __linux__ +#if defined (__linux__) char pci_dev_dir[1024]; int domain, bus, dev, func; DIR *sysdir; @@ -739,6 +739,36 @@ int drmCheckModesettingSupported(const char *busid) closedir(sysdir); if (found) return 0; +#elif defined (__FreeBSD__) + char kbusid[1024], sbusid[1024]; + char oid[128]; + int domain, bus, dev, func; + int i, modesetting, ret; + size_t len; + + ret = sscanf(busid, "pci:%04x:%02x:%02x.%d", &domain, &bus, &dev, &func); + if (ret != 4) + return -EINVAL; + snprintf(kbusid, sizeof(kbusid), "pci:%04x:%02x:%02x.%d", domain, bus, dev, func); + + /* How many GPUs do we expect in the machine? */ + for (i = 0; i < 16; i++) { + snprintf(oid, sizeof(oid), "hw.dri.%d.busid", i); + ret = sysctlbyname(oid, sbusid, &len, NULL, 0); + if (ret == -1) { + if (errno == ENOENT) + continue; + return -EINVAL; + } + if (strcmp(sbusid, kbusid) != 0) + continue; + snprintf(oid, sizeof(oid), "hw.dri.%d.modesetting", i); + len = sizeof(modesetting); + ret = sysctlbyname(oid, &modesetting, &len, NULL, 0); + if (ret == -1 || len != sizeof(modesetting)) + return -EINVAL; + return (modesetting ? 0 : -ENOSYS); + } #endif return -ENOSYS; -- 1.7.11.7