[PATCH synaptics 4/4] eventcomm: drop mtdev

Peter Hutterer peter.hutterer at who-t.net
Mon Mar 10 22:27:45 PDT 2014


All kernel touchpad devices now support slots, there isn't really a need to
support protocol A devices in synaptics. If such devices exist, we just treat
them as non-multitouch devices.

Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
 configure.ac    |   3 --
 src/Makefile.am |   1 -
 src/eventcomm.c | 112 +++++++++++++++++++-------------------------------------
 3 files changed, 37 insertions(+), 79 deletions(-)

diff --git a/configure.ac b/configure.ac
index 77edbb2..865d4b4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -116,9 +116,6 @@ case "${host}" in
 esac
 if test "x$BUILD_EVENTCOMM" = xyes; then
     AC_DEFINE(BUILD_EVENTCOMM, 1, [Optional backend eventcomm enabled])
-
-    # Obtain compiler/linker options for mtdev
-    PKG_CHECK_MODULES(MTDEV, mtdev)
     PKG_CHECK_MODULES(LIBEVDEV, [libevdev >= 0.4])
 fi
 if test "x$BUILD_PSMCOMM" = xyes; then
diff --git a/src/Makefile.am b/src/Makefile.am
index 69ef453..726c2de 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -48,7 +48,6 @@ if BUILD_EVENTCOMM
 synaptics_drv_la_SOURCES += \
 	eventcomm.c eventcomm.h
 synaptics_drv_la_LIBADD = \
-	$(MTDEV_LIBS) \
 	$(LIBEVDEV_LIBS)
 AM_CPPFLAGS += $(LIBEVDEV_CFLAGS)
 endif
diff --git a/src/eventcomm.c b/src/eventcomm.c
index 938547f..050658a 100644
--- a/src/eventcomm.c
+++ b/src/eventcomm.c
@@ -42,7 +42,6 @@
 #include "synproto.h"
 #include "synapticsstr.h"
 #include <xf86.h>
-#include <mtdev-plumbing.h>
 #include <libevdev/libevdev.h>
 
 #ifndef INPUT_PROP_BUTTONPAD
@@ -76,7 +75,6 @@ struct eventcomm_proto_data {
     BOOL need_grab;
     int st_to_mt_offset[2];
     double st_to_mt_scale[2];
-    struct mtdev *mtdev;
     int axis_map[ABS_MT_CNT];
     int cur_slot;
     ValuatorMask **last_mt_vals;
@@ -138,8 +136,6 @@ UninitializeTouch(InputInfoPtr pInfo)
         proto_data->last_mt_vals = NULL;
     }
 
-    mtdev_close_delete(proto_data->mtdev);
-    proto_data->mtdev = NULL;
     proto_data->num_touches = 0;
 }
 
@@ -154,14 +150,7 @@ InitializeTouch(InputInfoPtr pInfo)
     if (!priv->has_touch)
         return;
 
-    proto_data->mtdev = mtdev_new_open(pInfo->fd);
-    if (!proto_data->mtdev) {
-        xf86IDrvMsg(pInfo, X_WARNING,
-                    "failed to create mtdev instance, ignoring touch events\n");
-        return;
-    }
-
-    proto_data->cur_slot = proto_data->mtdev->caps.slot.value;
+    proto_data->cur_slot = libevdev_get_current_slot(proto_data->evdev);
     proto_data->num_touches = 0;
 
     proto_data->last_mt_vals = calloc(priv->num_slots, sizeof(ValuatorMask *));
@@ -502,58 +491,33 @@ SynapticsReadEvent(InputInfoPtr pInfo, struct input_event *ev)
     SynapticsPrivate *priv = (SynapticsPrivate *) pInfo->private;
     struct eventcomm_proto_data *proto_data = priv->proto_data;
     int rc;
-    int have_events = TRUE;
     static struct timeval last_event_time;
 
-    /* empty mtdev queue first */
-    if (proto_data->mtdev && !mtdev_empty(proto_data->mtdev)) {
-        mtdev_get_event(proto_data->mtdev, ev);
-        return TRUE;
-    }
-
-    do {
-        rc = libevdev_next_event(proto_data->evdev, proto_data->read_flag, ev);
-        if (rc < 0) {
-            if (rc != -EAGAIN) {
-                LogMessageVerbSigSafe(X_ERROR, 0, "%s: Read error %d\n", pInfo->name,
-                        errno);
-            } else if (proto_data->read_flag == LIBEVDEV_READ_FLAG_SYNC)
-                proto_data->read_flag = LIBEVDEV_READ_FLAG_NORMAL;
-            have_events = FALSE;
-        } else {
-            have_events = TRUE;
-
-            /* SYN_DROPPED received in normal mode. Create a normal EV_SYN
-               so we process what's in the queue atm, then ensure we sync
-               next time */
-            if (rc == LIBEVDEV_READ_STATUS_SYNC &&
-                proto_data->read_flag == LIBEVDEV_READ_FLAG_NORMAL) {
-                proto_data->read_flag = LIBEVDEV_READ_FLAG_SYNC;
-                ev->type = EV_SYN;
-                ev->code = SYN_REPORT;
-                ev->value = 0;
-                ev->time = last_event_time;
-            } else if (ev->type == EV_SYN)
-                last_event_time = ev->time;
+    rc = libevdev_next_event(proto_data->evdev, proto_data->read_flag, ev);
+    if (rc < 0) {
+        if (rc != -EAGAIN) {
+            LogMessageVerbSigSafe(X_ERROR, 0, "%s: Read error %d\n", pInfo->name,
+                    errno);
+        } else if (proto_data->read_flag == LIBEVDEV_READ_FLAG_SYNC)
+            proto_data->read_flag = LIBEVDEV_READ_FLAG_NORMAL;
 
-            /* feed mtdev. nomnomnomnom */
-            if (proto_data->mtdev)
-                mtdev_put_event(proto_data->mtdev, ev);
-        }
-    } while (have_events && proto_data->mtdev && mtdev_empty(proto_data->mtdev));
-
-    /* loop exits if:
-       - we don't have mtdev, ev is valid, rc is TRUE, let's return it
-       - we have mtdev and it has events for us, get those
-       - we don't have a new event and mtdev doesn't have events either.
-     */
-    if (have_events && proto_data->mtdev) {
-        have_events = !mtdev_empty(proto_data->mtdev);
-        if (have_events)
-            mtdev_get_event(proto_data->mtdev, ev);
+        return FALSE;
     }
 
-    return have_events;
+    /* SYN_DROPPED received in normal mode. Create a normal EV_SYN
+       so we process what's in the queue atm, then ensure we sync
+       next time */
+    if (rc == LIBEVDEV_READ_STATUS_SYNC &&
+        proto_data->read_flag == LIBEVDEV_READ_FLAG_NORMAL) {
+        proto_data->read_flag = LIBEVDEV_READ_FLAG_SYNC;
+        ev->type = EV_SYN;
+        ev->code = SYN_REPORT;
+        ev->value = 0;
+        ev->time = last_event_time;
+    } else if (ev->type == EV_SYN)
+        last_event_time = ev->time;
+
+    return TRUE;
 }
 
 static Bool
@@ -806,20 +770,22 @@ event_query_touch(InputInfoPtr pInfo)
 #endif
 
 
-    for (axis = ABS_MT_SLOT + 1; axis <= ABS_MT_MAX; axis++) {
-        if (!libevdev_has_event_code(dev, EV_ABS, axis))
-            continue;
+    if (libevdev_has_event_code(dev, EV_ABS, ABS_MT_SLOT)) {
+        for (axis = ABS_MT_SLOT + 1; axis <= ABS_MT_MAX; axis++) {
+            if (!libevdev_has_event_code(dev, EV_ABS, axis))
+                continue;
 
-        priv->has_touch = TRUE;
+            priv->has_touch = TRUE;
 
-        /* X and Y axis info is handled by synaptics already and we don't
-           expose the tracking ID */
-        if (axis == ABS_MT_POSITION_X ||
-            axis == ABS_MT_POSITION_Y ||
-            axis == ABS_MT_TRACKING_ID)
-            continue;
+            /* X and Y axis info is handled by synaptics already and we don't
+               expose the tracking ID */
+            if (axis == ABS_MT_POSITION_X ||
+                axis == ABS_MT_POSITION_Y ||
+                axis == ABS_MT_TRACKING_ID)
+                continue;
 
-        priv->num_mt_axes++;
+            priv->num_mt_axes++;
+        }
     }
 
     if (priv->has_touch) {
@@ -839,11 +805,7 @@ event_query_touch(InputInfoPtr pInfo)
             AXIS_LABEL_PROP_ABS_MT_PRESSURE,
         };
 
-        if (libevdev_has_event_code(dev, EV_ABS, ABS_MT_SLOT))
-            priv->max_touches = libevdev_get_num_slots(dev);
-        else
-            priv->max_touches = SYNAPTICS_MAX_TOUCHES;
-
+        priv->max_touches = libevdev_get_num_slots(dev);
         priv->touch_axes = malloc(priv->num_mt_axes *
                                   sizeof(SynapticsTouchAxisRec));
         if (!priv->touch_axes) {
-- 
1.8.5.3



More information about the xorg-devel mailing list