diff options
author | Robert Millan <rmh@freebsd.org> | 2014-01-23 14:46:05 +0000 |
---|---|---|
committer | Alex Deucher <alexander.deucher@amd.com> | 2014-01-24 17:52:14 -0500 |
commit | cbb31f2d6e674513c0f66484c414475baba09153 (patch) | |
tree | 4fad1d79c284c33e1915ffe3043d2a00784e86e0 /xf86drmMode.c | |
parent | ce62b8e0596b4805cb7e09a4a4e66de5c7b11cf3 (diff) |
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.c | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/xf86drmMode.c b/xf86drmMode.c index dd7966ef3d9f..a6bb2ee44576 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; |