xf86drm: drop control nodes implementation

Drop support for control nodes. The kernel never returns such
nodes. Stop trying to detect and handle them, and always return
an error when a caller tries to open them.

The header is left untouched to avoid breaking libdrm's API.

Signed-off-by: Simon Ser <contact@emersion.fr>
main
Simon Ser 2023-07-14 12:04:59 +02:00
parent 4b51e34d1a
commit 4de32c8609
2 changed files with 9 additions and 25 deletions

View File

@ -829,8 +829,6 @@ static const char *drmGetDeviceName(int type)
switch (type) { switch (type) {
case DRM_NODE_PRIMARY: case DRM_NODE_PRIMARY:
return DRM_DEV_NAME; return DRM_DEV_NAME;
case DRM_NODE_CONTROL:
return DRM_CONTROL_DEV_NAME;
case DRM_NODE_RENDER: case DRM_NODE_RENDER:
return DRM_RENDER_DEV_NAME; return DRM_RENDER_DEV_NAME;
} }
@ -1026,8 +1024,6 @@ static int drmGetMinorBase(int type)
switch (type) { switch (type) {
case DRM_NODE_PRIMARY: case DRM_NODE_PRIMARY:
return 0; return 0;
case DRM_NODE_CONTROL:
return 64;
case DRM_NODE_RENDER: case DRM_NODE_RENDER:
return 128; return 128;
default: default:
@ -1048,8 +1044,6 @@ static int drmGetMinorType(int major, int minor)
// If not in /dev/drm/ we have the type in the name // If not in /dev/drm/ we have the type in the name
if (sscanf(name, "dri/card%d\n", &id) >= 1) if (sscanf(name, "dri/card%d\n", &id) >= 1)
return DRM_NODE_PRIMARY; return DRM_NODE_PRIMARY;
else if (sscanf(name, "dri/control%d\n", &id) >= 1)
return DRM_NODE_CONTROL;
else if (sscanf(name, "dri/renderD%d\n", &id) >= 1) else if (sscanf(name, "dri/renderD%d\n", &id) >= 1)
return DRM_NODE_RENDER; return DRM_NODE_RENDER;
return -1; return -1;
@ -1064,7 +1058,6 @@ static int drmGetMinorType(int major, int minor)
switch (type) { switch (type) {
case DRM_NODE_PRIMARY: case DRM_NODE_PRIMARY:
case DRM_NODE_CONTROL:
case DRM_NODE_RENDER: case DRM_NODE_RENDER:
return type; return type;
default: default:
@ -1077,8 +1070,6 @@ static const char *drmGetMinorName(int type)
switch (type) { switch (type) {
case DRM_NODE_PRIMARY: case DRM_NODE_PRIMARY:
return DRM_PRIMARY_MINOR_NAME; return DRM_PRIMARY_MINOR_NAME;
case DRM_NODE_CONTROL:
return DRM_CONTROL_MINOR_NAME;
case DRM_NODE_RENDER: case DRM_NODE_RENDER:
return DRM_RENDER_MINOR_NAME; return DRM_RENDER_MINOR_NAME;
default: default:
@ -1265,7 +1256,7 @@ drm_public int drmOpen(const char *name, const char *busid)
* *
* \param name driver name. Not referenced if bus ID is supplied. * \param name driver name. Not referenced if bus ID is supplied.
* \param busid bus ID. Zero if not known. * \param busid bus ID. Zero if not known.
* \param type the device node type to open, PRIMARY, CONTROL or RENDER * \param type the device node type to open, PRIMARY or RENDER
* *
* \return a file descriptor on success, or a negative value on error. * \return a file descriptor on success, or a negative value on error.
* *
@ -1298,7 +1289,7 @@ drm_public int drmOpenWithType(const char *name, const char *busid, int type)
drm_public int drmOpenControl(int minor) drm_public int drmOpenControl(int minor)
{ {
return drmOpenMinor(minor, 0, DRM_NODE_CONTROL); return -EINVAL;
} }
drm_public int drmOpenRender(int minor) drm_public int drmOpenRender(int minor)
@ -3704,9 +3695,6 @@ static int get_sysctl_pci_bus_info(int maj, int min, drmPciBusInfoPtr info)
switch (type) { switch (type) {
case DRM_NODE_PRIMARY: case DRM_NODE_PRIMARY:
break; break;
case DRM_NODE_CONTROL:
id -= 64;
break;
case DRM_NODE_RENDER: case DRM_NODE_RENDER:
id -= 128; id -= 128;
break; break;
@ -3821,10 +3809,6 @@ drm_public int drmDevicesEqual(drmDevicePtr a, drmDevicePtr b)
static int drmGetNodeType(const char *name) static int drmGetNodeType(const char *name)
{ {
if (strncmp(name, DRM_CONTROL_MINOR_NAME,
sizeof(DRM_CONTROL_MINOR_NAME ) - 1) == 0)
return DRM_NODE_CONTROL;
if (strncmp(name, DRM_RENDER_MINOR_NAME, if (strncmp(name, DRM_RENDER_MINOR_NAME,
sizeof(DRM_RENDER_MINOR_NAME) - 1) == 0) sizeof(DRM_RENDER_MINOR_NAME) - 1) == 0)
return DRM_NODE_RENDER; return DRM_NODE_RENDER;

View File

@ -79,18 +79,18 @@ extern "C" {
#ifdef __OpenBSD__ #ifdef __OpenBSD__
#define DRM_DIR_NAME "/dev" #define DRM_DIR_NAME "/dev"
#define DRM_PRIMARY_MINOR_NAME "drm" #define DRM_PRIMARY_MINOR_NAME "drm"
#define DRM_CONTROL_MINOR_NAME "drmC" #define DRM_CONTROL_MINOR_NAME "drmC" /* deprecated */
#define DRM_RENDER_MINOR_NAME "drmR" #define DRM_RENDER_MINOR_NAME "drmR"
#else #else
#define DRM_DIR_NAME "/dev/dri" #define DRM_DIR_NAME "/dev/dri"
#define DRM_PRIMARY_MINOR_NAME "card" #define DRM_PRIMARY_MINOR_NAME "card"
#define DRM_CONTROL_MINOR_NAME "controlD" #define DRM_CONTROL_MINOR_NAME "controlD" /* deprecated */
#define DRM_RENDER_MINOR_NAME "renderD" #define DRM_RENDER_MINOR_NAME "renderD"
#define DRM_PROC_NAME "/proc/dri/" /* For backward Linux compatibility */ #define DRM_PROC_NAME "/proc/dri/" /* For backward Linux compatibility */
#endif #endif
#define DRM_DEV_NAME "%s/" DRM_PRIMARY_MINOR_NAME "%d" #define DRM_DEV_NAME "%s/" DRM_PRIMARY_MINOR_NAME "%d"
#define DRM_CONTROL_DEV_NAME "%s/" DRM_CONTROL_MINOR_NAME "%d" #define DRM_CONTROL_DEV_NAME "%s/" DRM_CONTROL_MINOR_NAME "%d" /* deprecated */
#define DRM_RENDER_DEV_NAME "%s/" DRM_RENDER_MINOR_NAME "%d" #define DRM_RENDER_DEV_NAME "%s/" DRM_RENDER_MINOR_NAME "%d"
#define DRM_NODE_NAME_MAX \ #define DRM_NODE_NAME_MAX \
@ -596,14 +596,14 @@ extern int drmAvailable(void);
extern int drmOpen(const char *name, const char *busid); extern int drmOpen(const char *name, const char *busid);
#define DRM_NODE_PRIMARY 0 #define DRM_NODE_PRIMARY 0
#define DRM_NODE_CONTROL 1 #define DRM_NODE_CONTROL 1 /* deprecated: never returned */
#define DRM_NODE_RENDER 2 #define DRM_NODE_RENDER 2
#define DRM_NODE_MAX 3 #define DRM_NODE_MAX 3
extern int drmOpenWithType(const char *name, const char *busid, extern int drmOpenWithType(const char *name, const char *busid,
int type); int type);
extern int drmOpenControl(int minor); extern int drmOpenControl(int minor); /* deprecated: always fails */
extern int drmOpenRender(int minor); extern int drmOpenRender(int minor);
extern int drmClose(int fd); extern int drmClose(int fd);
extern drmVersionPtr drmGetVersion(int fd); extern drmVersionPtr drmGetVersion(int fd);
@ -808,7 +808,7 @@ extern int drmHandleEvent(int fd, drmEventContextPtr evctx);
extern char *drmGetDeviceNameFromFd(int fd); extern char *drmGetDeviceNameFromFd(int fd);
/* Improved version of drmGetDeviceNameFromFd which attributes for any type of /* Improved version of drmGetDeviceNameFromFd which attributes for any type of
* device/node - card, control or renderD. * device/node - card or renderD.
*/ */
extern char *drmGetDeviceNameFromFd2(int fd); extern char *drmGetDeviceNameFromFd2(int fd);
extern int drmGetNodeTypeFromFd(int fd); extern int drmGetNodeTypeFromFd(int fd);