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
parent
7130cb163e
commit
3bc3cca230
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…
Reference in New Issue