xf86drm: use drm device name to identify drm node type

Currently drm node's minor range is used to identify node's type.
Since kernel drm uses node type name and minor to generate drm
device name, It will be more general to use drm device name to
identify drm node type.

Signed-off-by: James Zhu <James.Zhu@amd.com>
Reviewed-by: Simon Ser <contact@emersion.fr>
main
James Zhu 2023-08-07 10:14:18 -04:00 committed by Marek Olšák
parent 7130cb163e
commit 3bc3cca230
1 changed files with 12 additions and 10 deletions

View File

@ -1051,18 +1051,20 @@ static int drmGetMinorType(int major, int minor)
minor = id; minor = id;
#endif #endif
int type = minor >> 6; char path[DRM_NODE_NAME_MAX];
const char *dev_name;
int i;
if (minor < 0) for (i = DRM_NODE_PRIMARY; i < DRM_NODE_MAX; i++) {
return -1; dev_name = drmGetDeviceName(i);
if (!dev_name)
switch (type) { continue;
case DRM_NODE_PRIMARY: snprintf(path, sizeof(path), dev_name, DRM_DIR_NAME, minor);
case DRM_NODE_RENDER: if (!access(path, F_OK))
return type; return i;
default:
return -1;
} }
return -1;
} }
static const char *drmGetMinorName(int type) static const char *drmGetMinorName(int type)