OSDN Git Service

xf86drmMode: Implement drmCheckModesettingSupported() for OpenBSD
authorJonathan Gray <jsg@jsg.id.au>
Sat, 18 Jul 2015 21:20:37 +0000 (07:20 +1000)
committerEmil Velikov <emil.l.velikov@gmail.com>
Wed, 29 Jul 2015 17:04:15 +0000 (18:04 +0100)
This is implemented with kms ioctls so it could also be used as a
generic fallback.

Signed-off-by: Jonathan Gray <jsg@jsg.id.au>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
xf86drmMode.c

index fa21986..fc19504 100644 (file)
@@ -822,8 +822,25 @@ int drmCheckModesettingSupported(const char *busid)
 #elif defined(__DragonFly__)
        return 0;
 #endif
-       return -ENOSYS;
+#ifdef __OpenBSD__
+       int     fd;
+       struct drm_mode_card_res res;
+       drmModeResPtr r = 0;
+
+       if ((fd = drmOpen(NULL, busid)) < 0)
+               return -EINVAL;
+
+       memset(&res, 0, sizeof(struct drm_mode_card_res));
 
+       if (drmIoctl(fd, DRM_IOCTL_MODE_GETRESOURCES, &res)) {
+               drmClose(fd);
+               return -errno;
+       }
+
+       drmClose(fd);
+       return 0;
+#endif
+       return -ENOSYS;
 }
 
 int drmModeCrtcGetGamma(int fd, uint32_t crtc_id, uint32_t size,