aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobert Millan2014-01-23 08:46:05 -0600
committerAlex Deucher2014-01-24 16:52:14 -0600
commitcbb31f2d6e674513c0f66484c414475baba09153 (patch)
tree4fad1d79c284c33e1915ffe3043d2a00784e86e0 /xf86drmMode.c
parentce62b8e0596b4805cb7e09a4a4e66de5c7b11cf3 (diff)
downloadexternal-libgbm-cbb31f2d6e674513c0f66484c414475baba09153.tar.gz
external-libgbm-cbb31f2d6e674513c0f66484c414475baba09153.tar.xz
external-libgbm-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>
Diffstat (limited to 'xf86drmMode.c')
-rw-r--r--xf86drmMode.c35
1 files changed, 34 insertions, 1 deletions
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*/
724int drmCheckModesettingSupported(const char *busid) 724int 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