[PATCH 06/12] xf86Xinput: Modify API for server-managed fd support
Hans de Goede
hdegoede at redhat.com
Wed Jan 15 06:32:20 PST 2014
With systemd-logind support, the xserver, rather then the drivers will be
responsible for opening/closing the fd for input devices.
This commit adds a new XI86_SERVER_FD flag to indicate to drivers when the
server is managing the fd and they should not open/close it.
This commit also bumps the input ABI major, as drivers which don't know
about the XI86_SERVER_FD flag cannot be used when server managed fds are used.
systemd-logind tracks devices by their chardev major + minor numbers, since
we are breaking ABI anyways also add major and minor fields for easy storage /
retreival of these.
Signed-off-by: Hans de Goede <hdegoede at redhat.com>
---
hw/xfree86/common/xf86Module.h | 2 +-
hw/xfree86/common/xf86Xinput.c | 16 ++++++++++++++++
hw/xfree86/common/xf86Xinput.h | 3 +++
3 files changed, 20 insertions(+), 1 deletion(-)
diff --git a/hw/xfree86/common/xf86Module.h b/hw/xfree86/common/xf86Module.h
index b6ec19d..96ac3b0 100644
--- a/hw/xfree86/common/xf86Module.h
+++ b/hw/xfree86/common/xf86Module.h
@@ -81,7 +81,7 @@ typedef enum {
*/
#define ABI_ANSIC_VERSION SET_ABI_VERSION(0, 4)
#define ABI_VIDEODRV_VERSION SET_ABI_VERSION(15, 0)
-#define ABI_XINPUT_VERSION SET_ABI_VERSION(20, 0)
+#define ABI_XINPUT_VERSION SET_ABI_VERSION(21, 0)
#define ABI_EXTENSION_VERSION SET_ABI_VERSION(8, 0)
#define ABI_FONT_VERSION SET_ABI_VERSION(0, 6)
diff --git a/hw/xfree86/common/xf86Xinput.c b/hw/xfree86/common/xf86Xinput.c
index 3a01513..3a9e8ae 100644
--- a/hw/xfree86/common/xf86Xinput.c
+++ b/hw/xfree86/common/xf86Xinput.c
@@ -80,6 +80,7 @@
#include <stdarg.h>
#include <stdint.h> /* for int64_t */
+#include <unistd.h>
#include "mi.h"
@@ -773,6 +774,9 @@ xf86DeleteInput(InputInfoPtr pInp, int flags)
/* Else the entry wasn't in the xf86InputDevs list (ignore this). */
}
+ if (pInp->flags & XI86_SERVER_FD)
+ close(pInp->fd);
+
free((void *) pInp->driver);
free((void *) pInp->name);
xf86optionListFree(pInp->options);
@@ -949,6 +953,15 @@ NewInputDeviceRequest(InputOption *options, InputAttributes * attrs,
goto unwind;
}
}
+
+ if (strcmp(key, "fd") == 0)
+ pInfo->fd = atoi(value);
+
+ if (strcmp(key, "major") == 0)
+ pInfo->major = atoi(value);
+
+ if (strcmp(key, "minor") == 0)
+ pInfo->minor = atoi(value);
}
nt_list_for_each_entry(option, options, list.next) {
@@ -986,6 +999,9 @@ NewInputDeviceRequest(InputOption *options, InputAttributes * attrs,
goto unwind;
}
+ if (pInfo->fd != -1)
+ pInfo->flags |= XI86_SERVER_FD;
+
rval = xf86NewInputDevice(pInfo, pdev,
(!is_auto ||
(is_auto && xf86Info.autoEnableDevices)));
diff --git a/hw/xfree86/common/xf86Xinput.h b/hw/xfree86/common/xf86Xinput.h
index f94261a..fb1ad23 100644
--- a/hw/xfree86/common/xf86Xinput.h
+++ b/hw/xfree86/common/xf86Xinput.h
@@ -64,6 +64,7 @@
/* 0x08 is reserved for legacy XI86_SEND_DRAG_EVENTS, do not use for now */
/* server-internal only */
#define XI86_DEVICE_DISABLED 0x10 /* device was disabled before vt switch */
+#define XI86_SERVER_FD 0x20 /* fd is managed by xserver */
/* This holds the input driver entry and module information. */
typedef struct _InputDriverRec {
@@ -96,6 +97,8 @@ typedef struct _InputInfoRec {
int *valuators, int first_valuator, int num_valuators);
int fd;
+ int major;
+ int minor;
DeviceIntPtr dev;
void *private;
const char *type_name;
--
1.8.4.2
More information about the xorg-devel
mailing list