Bug#684593: [libkms]: also build on kfreebsd
Package: src:libdrm
Version: 2.4.33-3.1
Severity: wishlist
Tags: patch
User: debian-bsd@lists.debian.org
Usertags: kfreebsd
X-Debbugs-Cc: debian-bsd@lists.debian.org
Hi!
With the kfreebsd-10 kernel currently in experimental it is possible
to run intel kms drivers also on kfreebsd. A libkms1 is necessary to
make this work. Patch for the source is from upstream FreeBSD [0][1]
with slight modification to also work on kfreebsd.
Regards
Christoph
[0] http://wiki.freebsd.org/Intel_GPU
[1] http://people.freebsd.org/~kib/drm/libdrm.2.patch
-- System Information:
Debian Release: wheezy/sid
APT prefers testing
APT policy: (990, 'testing'), (500, 'unstable'), (1, 'experimental')
Architecture: kfreebsd-amd64 (x86_64)
Kernel: kFreeBSD 10.0-0-amd64
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Versions of packages libkms1 depends on:
ii libc0.1 2.13-33
ii libdrm2 2.4.33-3.1
ii multiarch-support 2.13-33
libkms1 recommends no packages.
libkms1 suggests no packages.
-- no debconf information
--
>From 0cd52e50630c10e8f7b45bca3a1ae634f94b6995 Mon Sep 17 00:00:00 2001
From: Christoph Egger <christoph@debian.org>
Date: Sat, 11 Aug 2012 17:01:25 +0200
Subject: [PATCH] Build libkms also on kfreebsd
---
debian/control | 4 +-
debian/libkms1.symbols.kfreebsd-amd64 | 13 ++++++
debian/libkms1.symbols.kfreebsd-i386 | 13 ++++++
debian/patches/04_build_kms_on_freebsd.diff | 65 +++++++++++++++++++++++++++
debian/patches/series | 1 +
debian/rules | 7 ++-
6 files changed, 100 insertions(+), 3 deletions(-)
create mode 100644 debian/libkms1.symbols.kfreebsd-amd64
create mode 100644 debian/libkms1.symbols.kfreebsd-i386
create mode 100644 debian/patches/04_build_kms_on_freebsd.diff
diff --git a/debian/control b/debian/control
index 5b5d9f6..64a2a62 100644
--- a/debian/control
+++ b/debian/control
@@ -164,7 +164,7 @@ Description: Userspace interface to radeon-specific kernel DRM services -- debug
Package: libkms1
Section: libs
-Architecture: linux-any
+Architecture: linux-any kfreebsd-any
Depends: ${shlibs:Depends}, ${misc:Depends}
Multi-Arch: same
Pre-Depends: ${misc:Pre-Depends}
@@ -175,7 +175,7 @@ Description: Userspace interface to kernel DRM buffer management
Package: libkms1-dbg
Section: debug
Priority: extra
-Architecture: linux-any
+Architecture: linux-any kfreebsd-any
Depends: libkms1 (= ${binary:Version}), ${misc:Depends}
Multi-Arch: same
Description: Userspace interface to kernel DRM buffer management -- debugging symbols
diff --git a/debian/libkms1.symbols.kfreebsd-amd64 b/debian/libkms1.symbols.kfreebsd-amd64
new file mode 100644
index 0000000..3e23666
--- /dev/null
+++ b/debian/libkms1.symbols.kfreebsd-amd64
@@ -0,0 +1,13 @@
+libkms.so.1 libkms1 #MINVER#
+| libkms-private
+ dumb_create@Base 0 1
+ intel_create@Base 0 1
+ kms_bo_create@Base 0
+ kms_bo_destroy@Base 0
+ kms_bo_get_prop@Base 0
+ kms_bo_map@Base 0
+ kms_bo_unmap@Base 0
+ kms_create@Base 0
+ kms_destroy@Base 0
+ kms_get_prop@Base 0
+ linux_create@Base 0 1
diff --git a/debian/libkms1.symbols.kfreebsd-i386 b/debian/libkms1.symbols.kfreebsd-i386
new file mode 100644
index 0000000..3e23666
--- /dev/null
+++ b/debian/libkms1.symbols.kfreebsd-i386
@@ -0,0 +1,13 @@
+libkms.so.1 libkms1 #MINVER#
+| libkms-private
+ dumb_create@Base 0 1
+ intel_create@Base 0 1
+ kms_bo_create@Base 0
+ kms_bo_destroy@Base 0
+ kms_bo_get_prop@Base 0
+ kms_bo_map@Base 0
+ kms_bo_unmap@Base 0
+ kms_create@Base 0
+ kms_destroy@Base 0
+ kms_get_prop@Base 0
+ linux_create@Base 0 1
diff --git a/debian/patches/04_build_kms_on_freebsd.diff b/debian/patches/04_build_kms_on_freebsd.diff
new file mode 100644
index 0000000..c91ff17
--- /dev/null
+++ b/debian/patches/04_build_kms_on_freebsd.diff
@@ -0,0 +1,65 @@
+Index: libdrm/configure.ac
+===================================================================
+--- libdrm.orig/configure.ac 2012-08-11 17:00:45.000000000 +0200
++++ libdrm/configure.ac 2012-08-11 17:01:05.391895625 +0200
+@@ -170,6 +170,7 @@
+ if test "x$LIBKMS" = xauto ; then
+ case $host_os in
+ linux*) LIBKMS="yes" ;;
++ *freebsd*) LIBKMS="yes" ;;
+ *) LIBKMS="no" ;;
+ esac
+ fi
+Index: libdrm/xf86drmMode.c
+===================================================================
+--- libdrm.orig/xf86drmMode.c 2012-08-11 17:00:45.000000000 +0200
++++ libdrm/xf86drmMode.c 2012-08-11 17:01:05.401896741 +0200
+@@ -686,7 +686,7 @@
+ */
+ 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 @@
+ closedir(sysdir);
+ if (found)
+ return 0;
++#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
++ 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);
++ len = sizeof(sbusid);
++ 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;
+
diff --git a/debian/patches/series b/debian/patches/series
index b1a73f8..abec0f5 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -1,3 +1,4 @@
01_default_perms.diff
02_build_libkms_against_in_tree_drm.diff
03_build_against_librt.diff
+04_build_kms_on_freebsd.diff
diff --git a/debian/rules b/debian/rules
index 44926b1..68a5d54 100755
--- a/debian/rules
+++ b/debian/rules
@@ -19,9 +19,14 @@ ifeq (linux, $(DEB_HOST_ARCH_OS))
confflags += --enable-radeon
RADEON = yes
else
- confflags += --disable-udev
+ ifeq (kfreebsd, $(DEB_HOST_ARCH_OS))
+ confflags += --enable-libkms
+ LIBKMS = yes
+ else
confflags += --disable-libkms
LIBKMS = no
+ endif
+ confflags += --disable-udev
confflags += --disable-vmwgfx-experimental-api
confflags += --disable-nouveau-experimental-api
NOUVEAU = no
--
1.7.10.4
Reply to: