mirror of
https://gitlab.freedesktop.org/mesa/drm.git
synced 2025-12-25 17:40:11 +01:00
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>
This commit is contained in:
parent
7130cb163e
commit
3bc3cca230
1 changed files with 12 additions and 10 deletions
22
xf86drm.c
22
xf86drm.c
|
|
@ -1051,18 +1051,20 @@ static int drmGetMinorType(int major, int minor)
|
|||
|
||||
minor = id;
|
||||
#endif
|
||||
int type = minor >> 6;
|
||||
char path[DRM_NODE_NAME_MAX];
|
||||
const char *dev_name;
|
||||
int i;
|
||||
|
||||
if (minor < 0)
|
||||
return -1;
|
||||
|
||||
switch (type) {
|
||||
case DRM_NODE_PRIMARY:
|
||||
case DRM_NODE_RENDER:
|
||||
return type;
|
||||
default:
|
||||
return -1;
|
||||
for (i = DRM_NODE_PRIMARY; i < DRM_NODE_MAX; i++) {
|
||||
dev_name = drmGetDeviceName(i);
|
||||
if (!dev_name)
|
||||
continue;
|
||||
snprintf(path, sizeof(path), dev_name, DRM_DIR_NAME, minor);
|
||||
if (!access(path, F_OK))
|
||||
return i;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
static const char *drmGetMinorName(int type)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue