Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 1 Jul 2012 10:48:29 +0300
From:      Konstantin Belousov <kostikbel@gmail.com>
To:        John Hein <jhein@symmetricom.com>
Cc:        freebsd-x11@freebsd.org
Subject:   Re: Unable to build graphics/dri on amd64 due to missing libdrm_intel
Message-ID:  <20120701074829.GK2337@deviant.kiev.zoral.com.ua>
In-Reply-To: <20463.64990.503041.475861@gromit.timing.com>
References:  <20120630184036.1e1d2cfe@serene.no-ip.org> <20463.64990.503041.475861@gromit.timing.com>

next in thread | previous in thread | raw e-mail | index | archive | help

--NMwIT2wBMwG6kIzG
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Sun, Jul 01, 2012 at 01:35:58AM -0600, John Hein wrote:
> Conrad J. Sabatier wrote at 18:40 -0500 on Jun 30, 2012:
>  > configure: error: Package requirements (libdrm_intel >=3D 2.4.30) were=
 not met:
>=20
> Pretty clear there.  Build the appropriate version of libdrm, which
> (if you peruse libdrm/Makefile) means build it with WITH_NEW_XORG.

I was reminded recently that recent libdrm requires a patch on amd64,
since they do not want to build intel bufmgr on anything not i386
or x86_64. FreeBSD names the later arch as amd64.

Below is the current drop of my diff against upstream libdrm.

diff --git a/configure.ac b/configure.ac
index a1c8c69..ebe06f5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -175,6 +175,7 @@ AC_CANONICAL_HOST
 if test "x$LIBKMS" =3D xauto ; then
 	case $host_os in
 		linux*)		LIBKMS=3D"yes" ;;
+		freebsd*)	LIBKMS=3D"yes" ;;
 		*)		LIBKMS=3D"no" ;;
 	esac
 fi
@@ -273,7 +274,7 @@ if test "x$INTEL" !=3D "xno" -o "x$RADEON" !=3D "xno" -=
o "x$NOUVEAU" !=3D "xno"; then
     else
            if test "x$INTEL" !=3D "xno"; then
                    case $host_cpu in
-                           i?86|x86_64) INTEL=3Dyes ;;
+                           i?86|x86_64|amd64) INTEL=3Dyes ;;
                            *) INTEL=3Dno ;;
                    esac
            fi
diff --git a/xf86drmMode.c b/xf86drmMode.c
index 04fdf1f..f7cae5f 100644
--- a/xf86drmMode.c
+++ b/xf86drmMode.c
@@ -686,7 +686,7 @@ int drmModeConnectorSetProperty(int fd, uint32_t connec=
tor_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;
@@ -736,6 +736,39 @@ 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 =3D sscanf(busid, "pci:%04x:%02x:%02x.%d", &domain, &bus, &dev,
+	    &func);
+	if (ret !=3D 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 =3D 0; i < 16; i++) {
+		snprintf(oid, sizeof(oid), "hw.dri.%d.busid", i);
+		len =3D sizeof(sbusid);
+		ret =3D sysctlbyname(oid, sbusid, &len, NULL, 0);
+		if (ret =3D=3D -1) {
+			if (errno =3D=3D ENOENT)
+				continue;
+			return -EINVAL;
+		}
+		if (strcmp(sbusid, kbusid) !=3D 0)
+			continue;
+		snprintf(oid, sizeof(oid), "hw.dri.%d.modesetting", i);
+		len =3D sizeof(modesetting);
+		ret =3D sysctlbyname(oid, &modesetting, &len, NULL, 0);
+		if (ret =3D=3D -1 || len !=3D sizeof(modesetting))
+			return -EINVAL;
+		return (modesetting ? 0 : -ENOSYS);
+	}
 #endif
 	return -ENOSYS;
=20

--NMwIT2wBMwG6kIzG
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (FreeBSD)

iEYEARECAAYFAk/wAMwACgkQC3+MBN1Mb4hivgCeJpx3ZMIlo8GNyY6UYfZUKnE/
ySsAoLyypy2F4XMVjx529WBjaJBAPT9N
=2qBI
-----END PGP SIGNATURE-----

--NMwIT2wBMwG6kIzG--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20120701074829.GK2337>