summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans de Goede <hdegoede@redhat.com>2014-03-08 10:41:14 +0100
committerPeter Hutterer <peter.hutterer@who-t.net>2014-03-11 14:59:15 +1000
commit80efc2f54f11a4d45411951f7055bfec2ed40fee (patch)
tree330408cc3a9227fd11ba686411049dabc5843634
parentc431d900f54696f608312ea51b1fa671839f7d42 (diff)
synaptics: Add support for server managed fds
Signed-off-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
-rw-r--r--src/eventcomm.c10
-rw-r--r--src/synaptics.c62
-rw-r--r--src/synproto.h4
3 files changed, 45 insertions, 31 deletions
diff --git a/src/eventcomm.c b/src/eventcomm.c
index 2bbf411..fb4181e 100644
--- a/src/eventcomm.c
+++ b/src/eventcomm.c
@@ -931,7 +931,11 @@ EventAutoDevProbe(InputInfoPtr pInfo, const char *device)
if (device) {
int fd = -1;
- SYSCALL(fd = open(device, O_RDONLY));
+ if (pInfo->flags & XI86_SERVER_FD)
+ fd = pInfo->fd;
+ else
+ SYSCALL(fd = open(device, O_RDONLY));
+
if (fd >= 0) {
int rc;
struct libevdev *evdev;
@@ -942,7 +946,9 @@ EventAutoDevProbe(InputInfoPtr pInfo, const char *device)
libevdev_free(evdev);
}
- SYSCALL(close(fd));
+ if (!(pInfo->flags & XI86_SERVER_FD))
+ SYSCALL(close(fd));
+
/* if a device is set and not a touchpad (or already grabbed),
* we must return FALSE. Otherwise, we'll add a device that
* wasn't requested for and repeat
diff --git a/src/synaptics.c b/src/synaptics.c
index f778d39..7c73aef 100644
--- a/src/synaptics.c
+++ b/src/synaptics.c
@@ -184,6 +184,10 @@ InputDriverRec SYNAPTICS = {
SynapticsPreInit,
SynapticsUnInit,
NULL,
+ NULL,
+#ifdef XI86_DRV_CAP_SERVER_FD
+ XI86_DRV_CAP_SERVER_FD
+#endif
};
static XF86ModuleVersionInfo VersionRec = {
@@ -215,6 +219,15 @@ _X_EXPORT XF86ModuleData synapticsModuleData = {
/*****************************************************************************
* Function Definitions
****************************************************************************/
+static inline void
+SynapticsCloseFd(InputInfoPtr pInfo)
+{
+ if (pInfo->fd > -1 && !(pInfo->flags & XI86_SERVER_FD)) {
+ xf86CloseSerial(pInfo->fd);
+ pInfo->fd = -1;
+ }
+}
+
/**
* Fill in default dimensions for backends that cannot query the hardware.
* Eventually, we want the edges to be 1900/5400 for x, 1900/4000 for y.
@@ -893,22 +906,16 @@ SynapticsPreInit(InputDriverPtr drv, InputInfoPtr pInfo, int flags)
xf86ProcessCommonOptions(pInfo, pInfo->options);
- if (pInfo->fd != -1) {
- if (priv->comm.buffer) {
- XisbFree(priv->comm.buffer);
- priv->comm.buffer = NULL;
- }
- xf86CloseSerial(pInfo->fd);
+ if (priv->comm.buffer) {
+ XisbFree(priv->comm.buffer);
+ priv->comm.buffer = NULL;
}
- pInfo->fd = -1;
+ SynapticsCloseFd(pInfo);
return Success;
SetupProc_fail:
- if (pInfo->fd >= 0) {
- xf86CloseSerial(pInfo->fd);
- pInfo->fd = -1;
- }
+ SynapticsCloseFd(pInfo);
if (priv->comm.buffer)
XisbFree(priv->comm.buffer);
@@ -989,33 +996,31 @@ DeviceOn(DeviceIntPtr dev)
}
if (priv->proto_ops->DeviceOnHook &&
- !priv->proto_ops->DeviceOnHook(pInfo, &priv->synpara)) {
- xf86CloseSerial(pInfo->fd);
- return !Success;
- }
+ !priv->proto_ops->DeviceOnHook(pInfo, &priv->synpara))
+ goto error;
priv->comm.buffer = XisbNew(pInfo->fd, INPUT_BUFFER_SIZE);
- if (!priv->comm.buffer) {
- xf86CloseSerial(pInfo->fd);
- pInfo->fd = -1;
- return !Success;
- }
+ if (!priv->comm.buffer)
+ goto error;
xf86FlushInput(pInfo->fd);
/* reinit the pad */
- if (!QueryHardware(pInfo)) {
- XisbFree(priv->comm.buffer);
- priv->comm.buffer = NULL;
- xf86CloseSerial(pInfo->fd);
- pInfo->fd = -1;
- return !Success;
- }
+ if (!QueryHardware(pInfo))
+ goto error;
xf86AddEnabledDevice(pInfo);
dev->public.on = TRUE;
return Success;
+
+error:
+ if (priv->comm.buffer) {
+ XisbFree(priv->comm.buffer);
+ priv->comm.buffer = NULL;
+ }
+ SynapticsCloseFd(pInfo);
+ return !Success;
}
static void
@@ -1074,8 +1079,7 @@ DeviceOff(DeviceIntPtr dev)
XisbFree(priv->comm.buffer);
priv->comm.buffer = NULL;
}
- xf86CloseSerial(pInfo->fd);
- pInfo->fd = -1;
+ SynapticsCloseFd(pInfo);
}
dev->public.on = FALSE;
return rc;
diff --git a/src/synproto.h b/src/synproto.h
index f164393..d81ee42 100644
--- a/src/synproto.h
+++ b/src/synproto.h
@@ -36,6 +36,10 @@
#include <xf86Xinput.h>
#include <xisb.h>
+#ifndef XI86_SERVER_FD
+#define XI86_SERVER_FD 0x20
+#endif
+
struct _SynapticsPrivateRec;
typedef struct _SynapticsPrivateRec SynapticsPrivate;