diff --git a/core-symbols.txt b/core-symbols.txt index 1ff4ecaa..410054b3 100644 --- a/core-symbols.txt +++ b/core-symbols.txt @@ -83,6 +83,7 @@ drmHashInsert drmHashLookup drmHashNext drmIoctl +drmIsKMS drmIsMaster drmMalloc drmMap diff --git a/xf86drmMode.c b/xf86drmMode.c index 3d6bdfd6..c3920b91 100644 --- a/xf86drmMode.c +++ b/xf86drmMode.c @@ -146,6 +146,16 @@ drm_public void drmModeFreeEncoder(drmModeEncoderPtr ptr) * ModeSetting functions. */ +drm_public int drmIsKMS(int fd) +{ + struct drm_mode_card_res res = {0}; + + if (drmIoctl(fd, DRM_IOCTL_MODE_GETRESOURCES, &res) != 0) + return 0; + + return res.count_crtcs > 0 && res.count_connectors > 0 && res.count_encoders > 0; +} + drm_public drmModeResPtr drmModeGetResources(int fd) { struct drm_mode_card_res res, counts; diff --git a/xf86drmMode.h b/xf86drmMode.h index baf3d5dc..72696782 100644 --- a/xf86drmMode.h +++ b/xf86drmMode.h @@ -259,6 +259,13 @@ extern void drmModeFreeEncoder( drmModeEncoderPtr ptr ); extern void drmModeFreePlane( drmModePlanePtr ptr ); extern void drmModeFreePlaneResources(drmModePlaneResPtr ptr); +/** + * Check whether the DRM node supports Kernel Mode-Setting. + * + * Returns 1 if suitable for KMS, 0 otherwise. + */ +extern int drmIsKMS(int fd); + /** * Retrieves all of the resources associated with a card. */