summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexandr Shadchin <alexandr.shadchin@gmail.com>2011-02-28 16:38:28 +0500
committerPeter Hutterer <peter.hutterer@who-t.net>2011-03-01 12:02:05 +1000
commitdce6006f6a851be4147e16731caa453dd0d1ec1c (patch)
tree9fdef7093907520c068eca15b8eb5d8bd00b32d2
parentae19da1266642aa0ba5838e525b2878c1bef49c2 (diff)
Rewrite mechanisn to detect Protocol and Device
Made SetDeviceAndProtocol() does not depend on the protocols, it will make it easier to add new backend. New behavior SetDeviceAndProtocol: 1) If not set Device or Protocol, then try AutoDevProbe 2) Otherwise, look for the appropriate protocol (Device and Protocol must be set) Signed-off-by: Alexandr Shadchin <Alexandr.Shadchin@gmail.com> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
-rw-r--r--src/alpscomm.c8
-rw-r--r--src/ps2comm.c8
-rw-r--r--src/psmcomm.c7
-rw-r--r--src/synaptics.c84
-rw-r--r--src/synproto.h11
5 files changed, 36 insertions, 82 deletions
diff --git a/src/alpscomm.c b/src/alpscomm.c
index 3872f5c..dc76655 100644
--- a/src/alpscomm.c
+++ b/src/alpscomm.c
@@ -220,17 +220,11 @@ ALPSReadHwState(InputInfoPtr pInfo,
return TRUE;
}
-static Bool
-ALPSAutoDevProbe(InputInfoPtr pInfo)
-{
- return FALSE;
-}
-
struct SynapticsProtocolOperations alps_proto_operations = {
NULL,
NULL,
ALPSQueryHardware,
ALPSReadHwState,
- ALPSAutoDevProbe,
+ NULL,
NULL
};
diff --git a/src/ps2comm.c b/src/ps2comm.c
index a6e052c..0e9b861 100644
--- a/src/ps2comm.c
+++ b/src/ps2comm.c
@@ -660,17 +660,11 @@ PS2ReadHwState(InputInfoPtr pInfo,
return PS2ReadHwStateProto(pInfo, &psaux_proto_operations, comm, hwRet);
}
-static Bool
-PS2AutoDevProbe(InputInfoPtr pInfo)
-{
- return FALSE;
-}
-
struct SynapticsProtocolOperations psaux_proto_operations = {
NULL,
PS2DeviceOffHook,
PS2QueryHardware,
PS2ReadHwState,
- PS2AutoDevProbe,
+ NULL,
NULL
};
diff --git a/src/psmcomm.c b/src/psmcomm.c
index eec240c..73ad079 100644
--- a/src/psmcomm.c
+++ b/src/psmcomm.c
@@ -162,16 +162,11 @@ PSMReadHwState(InputInfoPtr pInfo,
return PS2ReadHwStateProto(pInfo, &psm_proto_operations, comm, hwRet);
}
-static Bool PSMAutoDevProbe(InputInfoPtr pInfo)
-{
- return FALSE;
-}
-
struct SynapticsProtocolOperations psm_proto_operations = {
NULL,
NULL,
PSMQueryHardware,
PSMReadHwState,
- PSMAutoDevProbe,
+ NULL,
NULL
};
diff --git a/src/synaptics.c b/src/synaptics.c
index 9980dcc..cdb894b 100644
--- a/src/synaptics.c
+++ b/src/synaptics.c
@@ -136,6 +136,21 @@ void InitDeviceProperties(InputInfoPtr pInfo);
int SetProperty(DeviceIntPtr dev, Atom property, XIPropertyValuePtr prop,
BOOL checkonly);
+const static struct {
+ const char *name;
+ struct SynapticsProtocolOperations *proto_ops;
+} protocols[] = {
+#ifdef BUILD_EVENTCOMM
+ {"event", &event_proto_operations},
+#endif
+#ifdef BUILD_PSMCOMM
+ {"psm", &psm_proto_operations},
+#endif
+ {"psaux", &psaux_proto_operations},
+ {"alps", &alps_proto_operations},
+ {NULL, NULL}
+};
+
InputDriverRec SYNAPTICS = {
1,
"synaptics",
@@ -235,61 +250,24 @@ SanitizeDimensions(InputInfoPtr pInfo)
static void
SetDeviceAndProtocol(InputInfoPtr pInfo)
{
- char *str_par, *device;
SynapticsPrivate *priv = pInfo->private;
- enum SynapticsProtocol proto = SYN_PROTO_PSAUX;
+ char *proto, *device;
+ int i;
+ proto = xf86SetStrOption(pInfo->options, "Protocol", NULL);
device = xf86SetStrOption(pInfo->options, "Device", NULL);
- if (!device) {
- device = xf86SetStrOption(pInfo->options, "Path", NULL);
- if (device) {
- pInfo->options =
- xf86ReplaceStrOption(pInfo->options, "Device", device);
- }
- }
- if (device && strstr(device, "/dev/input/event")) {
-#ifdef BUILD_EVENTCOMM
- proto = SYN_PROTO_EVENT;
-#endif
- } else {
- str_par = xf86FindOptionValue(pInfo->options, "Protocol");
- if (str_par && !strcmp(str_par, "psaux")) {
- /* Already set up */
-#ifdef BUILD_EVENTCOMM
- } else if (str_par && !strcmp(str_par, "event")) {
- proto = SYN_PROTO_EVENT;
-#endif /* BUILD_EVENTCOMM */
-#ifdef BUILD_PSMCOMM
- } else if (str_par && !strcmp(str_par, "psm")) {
- proto = SYN_PROTO_PSM;
-#endif /* BUILD_PSMCOMM */
- } else if (str_par && !strcmp(str_par, "alps")) {
- proto = SYN_PROTO_ALPS;
- } else { /* default to auto-dev */
-#ifdef BUILD_EVENTCOMM
- if (!device && event_proto_operations.AutoDevProbe(pInfo))
- proto = SYN_PROTO_EVENT;
-#endif
- }
- }
- switch (proto) {
- case SYN_PROTO_PSAUX:
- priv->proto_ops = &psaux_proto_operations;
- break;
-#ifdef BUILD_EVENTCOMM
- case SYN_PROTO_EVENT:
- priv->proto_ops = &event_proto_operations;
- break;
-#endif /* BUILD_EVENTCOMM */
-#ifdef BUILD_PSMCOMM
- case SYN_PROTO_PSM:
- priv->proto_ops = &psm_proto_operations;
- break;
-#endif /* BUILD_PSMCOMM */
- case SYN_PROTO_ALPS:
- priv->proto_ops = &alps_proto_operations;
- break;
+ for (i = 0; protocols[i].name; i++) {
+ if ((!device || !proto) &&
+ protocols[i].proto_ops->AutoDevProbe &&
+ protocols[i].proto_ops->AutoDevProbe(pInfo))
+ break;
+ else if (proto && !strcmp(proto, protocols[i].name))
+ break;
}
+ free(proto);
+ free(device);
+
+ priv->proto_ops = protocols[i].proto_ops;
}
/*
@@ -714,6 +692,10 @@ SynapticsPreInit(InputDriverPtr drv, InputInfoPtr pInfo, int flags)
/* may change pInfo->options */
SetDeviceAndProtocol(pInfo);
+ if (priv->proto_ops == NULL) {
+ xf86Msg(X_ERROR, "Synaptics driver unable to detect protocol\n");
+ goto SetupProc_fail;
+ }
/* open the touchpad device */
pInfo->fd = xf86OpenSerial(pInfo->options);
diff --git a/src/synproto.h b/src/synproto.h
index 4b37df0..54a64eb 100644
--- a/src/synproto.h
+++ b/src/synproto.h
@@ -67,17 +67,6 @@ struct CommData {
Bool threeFingers;
};
-enum SynapticsProtocol {
- SYN_PROTO_PSAUX, /* Raw psaux device */
-#ifdef BUILD_EVENTCOMM
- SYN_PROTO_EVENT, /* Linux kernel event interface */
-#endif /* BUILD_EVENTCOMM */
-#ifdef BUILD_PSMCOMM
- SYN_PROTO_PSM, /* FreeBSD psm driver */
-#endif /* BUILD_PSMCOMM */
- SYN_PROTO_ALPS /* ALPS touchpad protocol */
-};
-
struct _SynapticsParameters;
struct SynapticsProtocolOperations {