From 3346166a6596115421702c1f7e2732215674ab8e Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Mon, 13 Jan 2014 11:57:38 +0100 Subject: [PATCH] xf86Xinput: Modify API for server-managed fd support With systemd-logind support, the xserver, rather than the drivers will be responsible for opening/closing the fd for input devices. This commit adds a new capabilities field to the InputDriverRec and a XI86_DRV_CAP_SERVER_FD flag for drivers to indicate that they support server managed fds. 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. Note that even if drivers declare they support server managed fds there is no guarantee they will actually get them. Since this changes the input driver ABI, this commit bumps it. 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 / retrieval of these. Signed-off-by: Hans de Goede Reviewed-by: Peter Hutterer --- hw/xfree86/common/xf86Module.h | 2 +- hw/xfree86/common/xf86Xinput.c | 6 ++++++ hw/xfree86/common/xf86Xinput.h | 7 +++++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/hw/xfree86/common/xf86Module.h b/hw/xfree86/common/xf86Module.h index b6ec19d13..96ac3b0d3 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 f6f2b90dd..7d13f7597 100644 --- a/hw/xfree86/common/xf86Xinput.c +++ b/hw/xfree86/common/xf86Xinput.c @@ -949,6 +949,12 @@ NewInputDeviceRequest(InputOption *options, InputAttributes * attrs, goto unwind; } } + + 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) { diff --git a/hw/xfree86/common/xf86Xinput.h b/hw/xfree86/common/xf86Xinput.h index b6d125128..784e14e5c 100644 --- a/hw/xfree86/common/xf86Xinput.h +++ b/hw/xfree86/common/xf86Xinput.h @@ -64,6 +64,10 @@ /* 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 */ + +/* Input device driver capabilities */ +#define XI86_DRV_CAP_SERVER_FD 0x01 /* This holds the input driver entry and module information. */ typedef struct _InputDriverRec { @@ -76,6 +80,7 @@ typedef struct _InputDriverRec { struct _InputInfoRec * pInfo, int flags); void *module; const char **default_options; + int capabilities; } InputDriverRec, *InputDriverPtr; /* This is to input devices what the ScrnInfoRec is to screens. */ @@ -96,6 +101,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;