diff options
author | Simon Ser <contact@emersion.fr> | 2023-10-04 11:21:34 +0200 |
---|---|---|
committer | Simon Ser <contact@emersion.fr> | 2023-11-20 12:22:10 +0000 |
commit | 15b7fbf3e7f111140457dadc55a723cb84f0dec4 (patch) | |
tree | 85b17e3554ddcc35f927af70dcec8c2bcb9910a8 | |
parent | 6acadd495c30678f603c69b8bca456aa3cc8bf38 (diff) |
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>
-rw-r--r-- | core-symbols.txt | 1 | ||||
-rw-r--r-- | xf86drm.c | 17 | ||||
-rw-r--r-- | xf86drm.h | 7 |
3 files changed, 25 insertions, 0 deletions
diff --git a/core-symbols.txt b/core-symbols.txt index 0d3464e9..8b22f3a1 100644 --- a/core-symbols.txt +++ b/core-symbols.txt @@ -70,6 +70,7 @@ drmGetLibVersion drmGetLock drmGetMagic drmGetMap +drmGetNodeTypeFromDevId drmGetNodeTypeFromFd drmGetPrimaryDeviceNameFromFd drmGetRenderDeviceNameFromFd @@ -4687,6 +4687,23 @@ drm_public int drmGetDeviceFromDevId(dev_t find_rdev, uint32_t flags, drmDeviceP #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 * @@ -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); +/** + * 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 drmSyncobjCreate(int fd, uint32_t flags, uint32_t *handle); |