diff options
author | Robert Millan | 2014-01-23 08:46:05 -0600 |
---|---|---|
committer | Alex Deucher | 2014-01-24 16:52:14 -0600 |
commit | cbb31f2d6e674513c0f66484c414475baba09153 (patch) | |
tree | 4fad1d79c284c33e1915ffe3043d2a00784e86e0 | |
parent | ce62b8e0596b4805cb7e09a4a4e66de5c7b11cf3 (diff) | |
download | external-libdrm-cbb31f2d6e674513c0f66484c414475baba09153.tar.gz external-libdrm-cbb31f2d6e674513c0f66484c414475baba09153.tar.xz external-libdrm-cbb31f2d6e674513c0f66484c414475baba09153.zip |
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>
-rw-r--r-- | configure.ac | 2 | ||||
-rw-r--r-- | xf86drmMode.c | 35 |
2 files changed, 36 insertions, 1 deletions
diff --git a/configure.ac b/configure.ac index 969fb83b..d2d19d66 100644 --- a/configure.ac +++ b/configure.ac | |||
@@ -185,6 +185,8 @@ AC_CANONICAL_HOST | |||
185 | if test "x$LIBKMS" = xauto ; then | 185 | if test "x$LIBKMS" = xauto ; then |
186 | case $host_os in | 186 | case $host_os in |
187 | linux*) LIBKMS="yes" ;; | 187 | linux*) LIBKMS="yes" ;; |
188 | freebsd* | kfreebsd*-gnu) | ||
189 | LIBKMS="yes" ;; | ||
188 | *) LIBKMS="no" ;; | 190 | *) LIBKMS="no" ;; |
189 | esac | 191 | esac |
190 | fi | 192 | fi |
diff --git a/xf86drmMode.c b/xf86drmMode.c index dd7966ef..a6bb2ee4 100644 --- a/xf86drmMode.c +++ b/xf86drmMode.c | |||
@@ -723,7 +723,7 @@ int drmModeConnectorSetProperty(int fd, uint32_t connector_id, uint32_t property | |||
723 | */ | 723 | */ |
724 | int drmCheckModesettingSupported(const char *busid) | 724 | int drmCheckModesettingSupported(const char *busid) |
725 | { | 725 | { |
726 | #ifdef __linux__ | 726 | #if defined (__linux__) |
727 | char pci_dev_dir[1024]; | 727 | char pci_dev_dir[1024]; |
728 | int domain, bus, dev, func; | 728 | int domain, bus, dev, func; |
729 | DIR *sysdir; | 729 | DIR *sysdir; |
@@ -773,6 +773,39 @@ int drmCheckModesettingSupported(const char *busid) | |||
773 | closedir(sysdir); | 773 | closedir(sysdir); |
774 | if (found) | 774 | if (found) |
775 | return 0; | 775 | return 0; |
776 | #elif defined (__FreeBSD__) || defined (__FreeBSD_kernel__) | ||
777 | char kbusid[1024], sbusid[1024]; | ||
778 | char oid[128]; | ||
779 | int domain, bus, dev, func; | ||
780 | int i, modesetting, ret; | ||
781 | size_t len; | ||
782 | |||
783 | ret = sscanf(busid, "pci:%04x:%02x:%02x.%d", &domain, &bus, &dev, | ||
784 | &func); | ||
785 | if (ret != 4) | ||
786 | return -EINVAL; | ||
787 | snprintf(kbusid, sizeof(kbusid), "pci:%04x:%02x:%02x.%d", domain, bus, | ||
788 | dev, func); | ||
789 | |||
790 | /* How many GPUs do we expect in the machine ? */ | ||
791 | for (i = 0; i < 16; i++) { | ||
792 | snprintf(oid, sizeof(oid), "hw.dri.%d.busid", i); | ||
793 | len = sizeof(sbusid); | ||
794 | ret = sysctlbyname(oid, sbusid, &len, NULL, 0); | ||
795 | if (ret == -1) { | ||
796 | if (errno == ENOENT) | ||
797 | continue; | ||
798 | return -EINVAL; | ||
799 | } | ||
800 | if (strcmp(sbusid, kbusid) != 0) | ||
801 | continue; | ||
802 | snprintf(oid, sizeof(oid), "hw.dri.%d.modesetting", i); | ||
803 | len = sizeof(modesetting); | ||
804 | ret = sysctlbyname(oid, &modesetting, &len, NULL, 0); | ||
805 | if (ret == -1 || len != sizeof(modesetting)) | ||
806 | return -EINVAL; | ||
807 | return (modesetting ? 0 : -ENOSYS); | ||
808 | } | ||
776 | #endif | 809 | #endif |
777 | return -ENOSYS; | 810 | return -ENOSYS; |
778 | 811 | ||