xf86drm: add drmGetNodeTypeFromDevId

This is useful to figure out whether the dev_t refers to a primary
node or a render node. Indeed, drmGetDeviceFromDevId returns a
drmDevice, which holds both the primary and render nodes.

Signed-off-by: Simon Ser <contact@emersion.fr>
main
Simon Ser 2023-10-04 11:21:34 +02:00
parent 6acadd495c
commit 15b7fbf3e7
3 changed files with 25 additions and 0 deletions

View File

@ -70,6 +70,7 @@ drmGetLibVersion
drmGetLock drmGetLock
drmGetMagic drmGetMagic
drmGetMap drmGetMap
drmGetNodeTypeFromDevId
drmGetNodeTypeFromFd drmGetNodeTypeFromFd
drmGetPrimaryDeviceNameFromFd drmGetPrimaryDeviceNameFromFd
drmGetRenderDeviceNameFromFd drmGetRenderDeviceNameFromFd

View File

@ -4687,6 +4687,23 @@ drm_public int drmGetDeviceFromDevId(dev_t find_rdev, uint32_t flags, drmDeviceP
#endif #endif
} }
drm_public int drmGetNodeTypeFromDevId(dev_t devid)
{
int maj, min, node_type;
maj = major(devid);
min = minor(devid);
if (!drmNodeIsDRM(maj, min))
return -EINVAL;
node_type = drmGetMinorType(maj, min);
if (node_type == -1)
return -ENODEV;
return node_type;
}
/** /**
* Get information about the opened drm device * Get information about the opened drm device
* *

View File

@ -919,6 +919,13 @@ extern int drmGetDevices2(uint32_t flags, drmDevicePtr devices[], int max_device
extern int drmGetDeviceFromDevId(dev_t dev_id, uint32_t flags, drmDevicePtr *device); extern int drmGetDeviceFromDevId(dev_t dev_id, uint32_t flags, drmDevicePtr *device);
/**
* Get the node type (DRM_NODE_PRIMARY or DRM_NODE_RENDER) from a device ID.
*
* Returns negative errno on error.
*/
extern int drmGetNodeTypeFromDevId(dev_t devid);
extern int drmDevicesEqual(drmDevicePtr a, drmDevicePtr b); extern int drmDevicesEqual(drmDevicePtr a, drmDevicePtr b);
extern int drmSyncobjCreate(int fd, uint32_t flags, uint32_t *handle); extern int drmSyncobjCreate(int fd, uint32_t flags, uint32_t *handle);