From: Robert Millan <rmh@freebsd.org>
To: dri-devel@lists.freedesktop.org
Cc: Konstantin Belousov <kib@freebsd.org>
Subject: [PATCH] drm: Implement drmCheckModesettingSupported() for FreeBSD
Date: Thu, 23 Jan 2014 14:50:21 +0000 [thread overview]
Message-ID: <20140123145021.GA23627@master.debian.org> (raw)
[-- Attachment #1: Type: text/plain, Size: 1 bytes --]
[-- Attachment #2: 0001-drm-Implement-drmCheckModesettingSupported-for-FreeB.patch --]
[-- Type: text/x-diff, Size: 2501 bytes --]
>From c02dd827c928fc68526bc41116ea2e06ce3e838b Mon Sep 17 00:00:00 2001
From: Robert Millan <rmh@freebsd.org>
Date: Thu, 23 Jan 2014 14:46:05 +0000
Subject: [PATCH] drm: Implement drmCheckModesettingSupported() for FreeBSD
Add the missing implementation of drmCheckModesettingSupported()
to detect KMS support on FreeBSD (and GNU/kFreeBSD).
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=72847
Signed-off-by: Konstantin Belousov <kib@freebsd.org>
Signed-off-by: Robert Millan <rmh@freebsd.org>
---
configure.ac | 2 ++
xf86drmMode.c | 35 ++++++++++++++++++++++++++++++++++-
2 files changed, 36 insertions(+), 1 deletion(-)
diff --git a/configure.ac b/configure.ac
index 969fb83..d2d19d6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -185,6 +185,8 @@ AC_CANONICAL_HOST
if test "x$LIBKMS" = xauto ; then
case $host_os in
linux*) LIBKMS="yes" ;;
+ freebsd* | kfreebsd*-gnu)
+ LIBKMS="yes" ;;
*) LIBKMS="no" ;;
esac
fi
diff --git a/xf86drmMode.c b/xf86drmMode.c
index dd7966e..a6bb2ee 100644
--- a/xf86drmMode.c
+++ b/xf86drmMode.c
@@ -723,7 +723,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;
@@ -773,6 +773,39 @@ int drmCheckModesettingSupported(const char *busid)
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;
--
1.7.10.4
[-- Attachment #3: Type: text/plain, Size: 159 bytes --]
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel
next reply other threads:[~2014-01-23 14:50 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-01-23 14:50 Robert Millan [this message]
2014-01-24 14:43 ` [PATCH] drm: Implement drmCheckModesettingSupported() for FreeBSD Robert Millan
2014-01-24 22:54 ` Alex Deucher
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20140123145021.GA23627@master.debian.org \
--to=rmh@freebsd.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=kib@freebsd.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.