xf86drmMode: add drmIsKMS
If a device has a primary node, it doesn't necessarily mean it's
suitable for KMS usage. For instance, render-only drivers also
expose primary nodes.
The check is extracted from Weston [1].
The motivation for this new function is two-fold:
- Avoid an unnecessary GETRESOURCES call. To check whether a
primary node is suitable for KMS, we don't actually need to
retrieve the object IDs we just need to check the counts.
- Avoid confusion in user-space and make sure user-space implements
the check properly. For instance, wlroots doesn't [2]: it uses
drmGetVersion which succeeds with render-only drivers.
[1]: https://gitlab.freedesktop.org/wayland/weston/-/blob/master/libweston/backend-drm/drm.c#L2689
[2]: a290d7a78d/backend/session/session.c (L268)
Signed-off-by: Simon Ser <contact@emersion.fr>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.com>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
main
parent
1225171bd5
commit
523b3658aa
|
@ -83,6 +83,7 @@ drmHashInsert
|
|||
drmHashLookup
|
||||
drmHashNext
|
||||
drmIoctl
|
||||
drmIsKMS
|
||||
drmIsMaster
|
||||
drmMalloc
|
||||
drmMap
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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.
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue