[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

xserver-xorg-input-evdev: Changes to 'upstream-experimental'



Rebased ref, commits from common ancestor:
commit 74690817fcd3e91ea384b8f311d8ce5626d8c409
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Wed Jul 4 09:14:41 2012 +1000

    Don't re-open mtdev after PreInit
    
    ==16557== 388,240 (3,520 direct, 384,720 indirect) bytes in 10 blocks are definitely lost in loss record 1,669 of 1,671
    ==16557==    at 0x4A06F18: calloc (vg_replace_malloc.c:566)
    ==16557==    by 0xC3EAD4D: mtdev_new (core.c:345)
    ==16557==    by 0xC3EAE6B: mtdev_new_open (core.c:383)
    ==16557==    by 0xC1E0452: EvdevOpenDevice (evdev.c:2365)
    ==16557==    by 0xC1E068C: EvdevPreInit (evdev.c:2431)
    ==16557==    by 0x4B8304: xf86NewInputDevice (xf86Xinput.c:846)
    ==16557==    by 0x4B8857: NewInputDeviceRequest (xf86Xinput.c:989)
    ==16557==    by 0x4CCB4C: device_added (udev.c:211)
    ==16557==    by 0x4CCFA6: config_udev_init (udev.c:342)
    ==16557==    by 0x4CBE81: config_init (config.c:48)
    ==16557==    by 0x4A8A9A: InitInput (xf86Init.c:918)
    ==16557==    by 0x4921EE: main (main.c:258)
    
    After PreInit, the fd and mtdev pointer are still valid. We check for the
    fd, but unconditionally allocated another mtdev struct for each device.
    
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
    Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
    (cherry picked from commit 98af2003d48530b2e102cf667a9d40dcb94cb0fe)

diff --git a/src/evdev.c b/src/evdev.c
index dc3cd89..fc7ba88 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -2354,14 +2354,16 @@ EvdevOpenDevice(InputInfoPtr pInfo)
     }
 
 #ifdef MULTITOUCH
-    pEvdev->mtdev = mtdev_new_open(pInfo->fd);
+    if (!pEvdev->mtdev) { /* after PreInit mtdev is still valid */
+        pEvdev->mtdev = mtdev_new_open(pInfo->fd);
+        if (!pEvdev->mtdev) {
+            xf86Msg(X_ERROR, "%s: Couldn't open mtdev device\n", pInfo->name);
+            EvdevCloseDevice(pInfo);
+            return FALSE;
+        }
+    }
     if (pEvdev->mtdev)
         pEvdev->cur_slot = pEvdev->mtdev->caps.slot.value;
-    else {
-        xf86Msg(X_ERROR, "%s: Couldn't open mtdev device\n", pInfo->name);
-        EvdevCloseDevice(pInfo);
-        return FALSE;
-    }
 #endif
 
     /* Check major/minor of device node to avoid adding duplicate devices. */

commit b2cbbb178e9a3650118bdf498e678ca4e12062fe
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Mon May 28 10:08:23 2012 +1000

    Constify InputDriverRec->default_options
    
    Removes a warning, and with the input ABI 18 this is forced to const in the
    server.
    
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
    Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
    (cherry picked from commit 9624f4e2ba7d1973813de066806eed108748a53a)

diff --git a/src/evdev.c b/src/evdev.c
index 37492b5..dc3cd89 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -93,7 +93,7 @@
 #define ABS_MT_TRACKING_ID 0x39
 #endif
 
-static char *evdevDefaults[] = {
+static const char *evdevDefaults[] = {
     "XkbRules",     "evdev",
     "XkbModel",     "evdev",
     "XkbLayout",    "us",

commit 7d91fc7bfcdaaac657aeb7b8876a4002ad0fa68d
Author: Marcin Slusarz <marcin.slusarz@gmail.com>
Date:   Mon May 21 01:22:33 2012 +0200

    Fix some obvious constness-related compile warnings.
    
    Signed-off-by: Marcin Slusarz <marcin.slusarz@gmail.com>
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
    (cherry picked from commit 2c8da280b3ab635d049784345d025d289348687b)

diff --git a/src/emuWheel.c b/src/emuWheel.c
index ae894fa..db989c5 100644
--- a/src/emuWheel.c
+++ b/src/emuWheel.c
@@ -51,7 +51,6 @@ static Atom prop_wheel_timeout  = 0;
 static Atom prop_wheel_button   = 0;
 
 /* Local Funciton Prototypes */
-static BOOL EvdevWheelEmuHandleButtonMap(InputInfoPtr pInfo, WheelAxisPtr pAxis, char *axis_name);
 static int EvdevWheelEmuInertia(InputInfoPtr pInfo, WheelAxisPtr axis, int value);
 
 /* Filter mouse button events */
@@ -197,7 +196,8 @@ EvdevWheelEmuInertia(InputInfoPtr pInfo, WheelAxisPtr axis, int value)
 /* Handle button mapping here to avoid code duplication,
 returns true if a button mapping was found. */
 static BOOL
-EvdevWheelEmuHandleButtonMap(InputInfoPtr pInfo, WheelAxisPtr pAxis, char* axis_name)
+EvdevWheelEmuHandleButtonMap(InputInfoPtr pInfo, WheelAxisPtr pAxis,
+                             const char *axis_name)
 {
     EvdevPtr pEvdev = (EvdevPtr)pInfo->private;
     char *option_string;
diff --git a/src/evdev.c b/src/evdev.c
index b32d617..37492b5 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -278,7 +278,7 @@ EvdevRemoveDevice(InputInfoPtr pInfo)
 
 
 static void
-SetXkbOption(InputInfoPtr pInfo, char *name, char **option)
+SetXkbOption(InputInfoPtr pInfo, const char *name, char **option)
 {
     char *s;
 
@@ -2566,7 +2566,7 @@ EvdevUtilButtonEventToButtonNumber(EvdevPtr pEvdev, int code)
 /* Aligned with linux/input.h.
    Note that there are holes in the ABS_ range, these are simply replaced with
    MISC here */
-static char* abs_labels[] = {
+static const char *abs_labels[] = {
     AXIS_LABEL_PROP_ABS_X,              /* 0x00 */
     AXIS_LABEL_PROP_ABS_Y,              /* 0x01 */
     AXIS_LABEL_PROP_ABS_Z,              /* 0x02 */
@@ -2629,7 +2629,7 @@ static char* abs_labels[] = {
     AXIS_LABEL_PROP_ABS_MT_PRESSURE,    /* 0x3a */
 };
 
-static char* rel_labels[] = {
+static const char *rel_labels[] = {
     AXIS_LABEL_PROP_REL_X,
     AXIS_LABEL_PROP_REL_Y,
     AXIS_LABEL_PROP_REL_Z,
@@ -2642,7 +2642,7 @@ static char* rel_labels[] = {
     AXIS_LABEL_PROP_REL_MISC
 };
 
-static char* btn_labels[][16] = {
+static const char *btn_labels[][16] = {
     { /* BTN_MISC group                 offset 0x100*/
         BTN_LABEL_PROP_BTN_0,           /* 0x00 */
         BTN_LABEL_PROP_BTN_1,           /* 0x01 */
@@ -2727,7 +2727,7 @@ static void EvdevInitAxesLabels(EvdevPtr pEvdev, int mode, int natoms, Atom *ato
 {
     Atom atom;
     int axis;
-    char **labels;
+    const char **labels;
     int labels_len = 0;
 
     if (mode == Absolute)

commit 09987eab9a77aa94127ecacca41498bc5e83c0eb
Author: Daniel Stone <daniel@fooishbar.org>
Date:   Tue Jul 10 00:34:56 2012 +0100

    Fix compilation warnings for non-multitouch builds
    
    Signed-off-by: Daniel Stone <daniel@fooishbar.org>
    Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
    (cherry picked from commit f5ede98085688b59dc56a9cc6592f75552a4e7ed)

diff --git a/src/evdev.c b/src/evdev.c
index a12e97b..b32d617 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -1062,7 +1062,9 @@ EvdevProcessEvent(InputInfoPtr pInfo, struct input_event *ev)
 static void
 EvdevFreeMasks(EvdevPtr pEvdev)
 {
+#ifdef MULTITOUCH
     int i;
+#endif
 
     valuator_mask_free(&pEvdev->vals);
     valuator_mask_free(&pEvdev->old_vals);
@@ -1345,7 +1347,9 @@ EvdevAddAbsValuatorClass(DeviceIntPtr device)
 
     i = 0;
     for (axis = ABS_X; i < MAX_VALUATORS && axis <= ABS_MAX; axis++) {
+#ifdef MULTITOUCH
         int j;
+#endif
         int mapping;
         pEvdev->axis_map[axis] = -1;
         if (!EvdevBitIsSet(pEvdev->abs_bitmask, axis) ||

commit 8af0e6f1ebaf327f735bca507134b34bb24b26c6
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Fri May 25 14:04:22 2012 +1000

    strtol doesn't need a empty string, NULL is good enough.
    
    Fixes:
    evdev.c: In function 'EvdevInitButtonMapping':
    evdev.c:1659:25: warning: initialization discards 'const' qualifier from
    pointer target type [enabled by default]
    
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
    Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
    (cherry picked from commit 61faf2e6e70a4c9ecffe638d46829738dc2e3452)

diff --git a/src/evdev.c b/src/evdev.c
index 56e3b11..a12e97b 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -1660,7 +1660,7 @@ EvdevInitButtonMapping(InputInfoPtr pInfo)
     /* Check for user-defined button mapping */
     if ((mapping = xf86CheckStrOption(pInfo->options, "ButtonMapping", NULL)))
     {
-        char    *map, *s = " ";
+        char    *map, *s = NULL;
         int     btn = 0;
 
         xf86IDrvMsg(pInfo, X_CONFIG, "ButtonMapping '%s'\n", mapping);

commit 56e9a7a248d70fd55ecc3588e72d0172d7c9ad27
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Tue Jul 24 14:05:09 2012 +1000

    evdev 2.7.1
    
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>

diff --git a/configure.ac b/configure.ac
index dff2bcf..13adec7 100644
--- a/configure.ac
+++ b/configure.ac
@@ -23,7 +23,7 @@
 # Initialize Autoconf
 AC_PREREQ([2.60])
 AC_INIT([xf86-input-evdev],
-        [2.7.0],
+        [2.7.1],
         [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg],
         [xf86-input-evdev])
 AC_CONFIG_SRCDIR([Makefile.am])

commit 7df65237741b167b18ff0962a7bfc3db9d4826ed
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Mon May 28 09:50:15 2012 +1000

    Close the fd when mtdev open fails
    
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
    Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
    (cherry picked from commit 8251d7a8ec00b4160b6601a6f2f4f0f5d461cbee)

diff --git a/src/evdev.c b/src/evdev.c
index bd8d9b8..56e3b11 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -2355,6 +2355,7 @@ EvdevOpenDevice(InputInfoPtr pInfo)
         pEvdev->cur_slot = pEvdev->mtdev->caps.slot.value;
     else {
         xf86Msg(X_ERROR, "%s: Couldn't open mtdev device\n", pInfo->name);
+        EvdevCloseDevice(pInfo);
         return FALSE;
     }
 #endif

commit f4e76a4c53f2abe0bd737485e0b32d6d36425118
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Mon May 28 09:08:43 2012 +1000

    Release mtdev data whenever we close the fd
    
    Add a new EvdevCloseDevice() function to unify this.
    We used to leak data
    - PreInit allocates mtdev, but nothing except one error path released it.
    - each DEVICE_ON re-allocates mtdev but it is never released
    
    Reported-by: Zdenek Kabelac <zdenek.kabelac@gmail.com>
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
    Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
    (cherry picked from commit ac5173163d7d1e18d47630a397ece0f26b2568c8)

diff --git a/src/evdev.c b/src/evdev.c
index d7f4492..bd8d9b8 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -119,6 +119,7 @@ static int EvdevSwitchMode(ClientPtr client, DeviceIntPtr device, int mode);
 static BOOL EvdevGrabDevice(InputInfoPtr pInfo, int grab, int ungrab);
 static void EvdevSetCalibration(InputInfoPtr pInfo, int num_calibration, int calibration[4]);
 static int EvdevOpenDevice(InputInfoPtr pInfo);
+static void EvdevCloseDevice(InputInfoPtr pInfo);
 
 static void EvdevInitAxesLabels(EvdevPtr pEvdev, int mode, int natoms, Atom *atoms);
 static void EvdevInitButtonLabels(EvdevPtr pEvdev, int natoms, Atom *atoms);
@@ -1108,8 +1109,7 @@ EvdevReadInput(InputInfoPtr pInfo)
                 EvdevMBEmuFinalize(pInfo);
                 Evdev3BEmuFinalize(pInfo);
                 xf86RemoveEnabledDevice(pInfo);
-                close(pInfo->fd);
-                pInfo->fd = -1;
+                EvdevCloseDevice(pInfo);
             } else if (errno != EAGAIN)
             {
                 /* We use X_NONE here because it doesn't alloc */
@@ -1866,8 +1866,7 @@ EvdevProc(DeviceIntPtr device, int what)
         {
             EvdevGrabDevice(pInfo, 0, 1);
             xf86RemoveEnabledDevice(pInfo);
-            close(pInfo->fd);
-            pInfo->fd = -1;
+            EvdevCloseDevice(pInfo);
         }
         pEvdev->min_maj = 0;
         pEvdev->flags &= ~EVDEV_INITIALIZED;
@@ -1876,10 +1875,7 @@ EvdevProc(DeviceIntPtr device, int what)
 
     case DEVICE_CLOSE:
 	xf86IDrvMsg(pInfo, X_INFO, "Close\n");
-        if (pInfo->fd != -1) {
-            close(pInfo->fd);
-            pInfo->fd = -1;
-        }
+        EvdevCloseDevice(pInfo);
         EvdevFreeMasks(pEvdev);
         EvdevRemoveDevice(pInfo);
         pEvdev->min_maj = 0;
@@ -2368,17 +2364,34 @@ EvdevOpenDevice(InputInfoPtr pInfo)
     if (EvdevIsDuplicate(pInfo))
     {
         xf86IDrvMsg(pInfo, X_WARNING, "device file is duplicate. Ignoring.\n");
+        EvdevCloseDevice(pInfo);
+        return BadMatch;
+    }
+
+    return Success;
+}
+
+static void
+EvdevCloseDevice(InputInfoPtr pInfo)
+{
+    EvdevPtr pEvdev = pInfo->private;
+    if (pInfo->fd >= 0)
+    {
         close(pInfo->fd);
+        pInfo->fd = -1;
+    }
+
 #ifdef MULTITOUCH
+    if (pEvdev->mtdev)
+    {
         mtdev_close_delete(pEvdev->mtdev);
         pEvdev->mtdev = NULL;
-#endif
-        return BadMatch;
     }
+#endif
 
-    return Success;
 }
 
+
 static void
 EvdevUnInit(InputDriverPtr drv, InputInfoPtr pInfo, int flags)
 {
@@ -2459,8 +2472,7 @@ EvdevPreInit(InputDriverPtr drv, InputInfoPtr pInfo, int flags)
     return Success;
 
 error:
-    if (pInfo->fd >= 0)
-        close(pInfo->fd);
+    EvdevCloseDevice(pInfo);
     return rc;
 }
 

commit ac772cde9469c406564433d6d41416fa2279fbf9
Author: Chase Douglas <chase.douglas@canonical.com>
Date:   Wed Jun 6 12:07:12 2012 -0700

    Fix buffer overrun when populating axis label property array
    
    The axis label property array currently only has enough elements for the
    non-multitouch axes. This change allocates enough space for all axes,
    which prevents an array overrun write. This may manifest as stack
    corruption on some platforms.
    
    Signed-off-by: Chase Douglas <chase.douglas@canonical.com>
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
    (cherry picked from commit 4145fe1c087708bf5d6608e328342282ecb93ab0)

diff --git a/src/evdev.c b/src/evdev.c
index 8527eb3..d7f4492 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -1304,6 +1304,7 @@ EvdevAddAbsValuatorClass(DeviceIntPtr device)
     }
 #ifdef MULTITOUCH
     if (num_mt_axes_total > 0) {
+        pEvdev->num_mt_vals = num_mt_axes_total;
         pEvdev->mt_mask = valuator_mask_new(num_mt_axes_total);
         if (!pEvdev->mt_mask) {
             xf86Msg(X_ERROR, "%s: failed to allocate MT valuator mask.\n",
@@ -2879,7 +2880,8 @@ EvdevInitProperty(DeviceIntPtr dev)
         if ((pEvdev->num_vals > 0) && (prop_axis_label = XIGetKnownProperty(AXIS_LABEL_PROP)))
         {
             int mode;
-            Atom atoms[pEvdev->num_vals];
+            int num_axes = pEvdev->num_vals + pEvdev->num_mt_vals;
+            Atom atoms[num_axes];
 
             if (pEvdev->flags & EVDEV_ABSOLUTE_EVENTS)
                 mode = Absolute;
@@ -2890,9 +2892,9 @@ EvdevInitProperty(DeviceIntPtr dev)
                 mode = Absolute;
             }
 
-            EvdevInitAxesLabels(pEvdev, mode, pEvdev->num_vals, atoms);
+            EvdevInitAxesLabels(pEvdev, mode, num_axes, atoms);
             XIChangeDeviceProperty(dev, prop_axis_label, XA_ATOM, 32,
-                                   PropModeReplace, pEvdev->num_vals, atoms, FALSE);
+                                   PropModeReplace, num_axes, atoms, FALSE);
             XISetDevicePropertyDeletable(dev, prop_axis_label, FALSE);
         }
         /* Button labelling */
diff --git a/src/evdev.h b/src/evdev.h
index 309b215..c2f9246 100644
--- a/src/evdev.h
+++ b/src/evdev.h
@@ -153,6 +153,7 @@ typedef struct {
     int grabDevice;         /* grab the event device? */
 
     int num_vals;           /* number of valuators */
+    int num_mt_vals;        /* number of multitouch valuators */
     int axis_map[max(ABS_CNT, REL_CNT)]; /* Map evdev <axis> to index */
     ValuatorMask *vals;     /* new values coming in */
     ValuatorMask *old_vals; /* old values for calculating relative motion */

commit 774915924102c348ce7045ffa07905d1079f447c
Author: Chase Douglas <chase.douglas@canonical.com>
Date:   Thu May 24 10:48:38 2012 -0700

    Report the correct number of touches for MT protocol B devices
    
    Protocol B devices report the number of touches by giving a maximum and
    minimum slot value. The current code ignores the minimum value, which is
    usually 0, and underreports the number of touches by 1.
    
    Signed-off-by: Chase Douglas <chase.douglas@canonical.com>
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
    (cherry picked from commit 9ce068e760e1282183c7aa1b4cc6b0fcb6b494dd)

diff --git a/src/evdev.c b/src/evdev.c
index 140a633..8527eb3 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -1384,7 +1384,8 @@ EvdevAddAbsValuatorClass(DeviceIntPtr device)
             XIDependentTouch : XIDirectTouch;
 
         if (pEvdev->mtdev->caps.slot.maximum > 0)
-            num_touches = pEvdev->mtdev->caps.slot.maximum;
+            num_touches = pEvdev->mtdev->caps.slot.maximum -
+                          pEvdev->mtdev->caps.slot.minimum + 1;
 
         if (!InitTouchClassDeviceStruct(device, num_touches, mode,
                                         num_mt_axes_total)) {

commit 833fc517d75934797bdadbf043b18a1c94fc1293
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Fri Apr 27 15:42:17 2012 +1000

    Devices configured as mice need REL_X/Y
    
    Some keyboards export scroll axes and any absolute axis possible in 11
    dimensions. All these axes are mute, except possibly for the scroll wheels.
    
    So if a device has a scroll axis, and we're configuring it as mouse, force
    the x/y axes into existence. This stops the logspam complaining about not
    enough axes on pointer movement after a xrandr change.
    
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
    Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
    (cherry picked from commit f28507e8ce2bd45b51c28f024baebd9711c28fc3)

diff --git a/src/evdev.c b/src/evdev.c
index 8cf630c..140a633 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -2271,6 +2271,9 @@ EvdevProbe(InputInfoPtr pInfo)
             xf86IDrvMsg(pInfo, X_INFO, "Configuring as touchscreen\n");
             pInfo->type_name = XI_TOUCHSCREEN;
 	} else {
+            if (!EvdevBitIsSet(pEvdev->rel_bitmask, REL_X) ||
+                !EvdevBitIsSet(pEvdev->rel_bitmask, REL_Y))
+                EvdevForceXY(pInfo, Relative);
 	    xf86IDrvMsg(pInfo, X_INFO, "Configuring as mouse\n");
 	    pInfo->type_name = XI_MOUSE;
 	}

commit 4d698d8ece86a8e39b41c03b9b4c427b20b15449
Author: Peter Hutterer <peter.hutterer@who-t.net>
Date:   Thu Mar 15 15:46:32 2012 +1000

    Fix inverted horizontal scroll (#46205)
    
    REL_HWHEEL has a positive increment, not a negative one like REL_WHEEL.
    
    X.Org Bug 46205 <http://bugs.freedesktop.org/show_bug.cgi?id=46205>
    
    Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
    Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
    (cherry picked from commit 99340147b9092a5aaec997eca407282a51e1f063)

diff --git a/src/evdev.c b/src/evdev.c
index d540b87..8cf630c 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -1600,7 +1600,7 @@ EvdevAddRelValuatorClass(DeviceIntPtr device)
         else if (axis == REL_DIAL)
             SetScrollValuator(device, axnum, SCROLL_TYPE_VERTICAL, -1.0, SCROLL_FLAG_NONE);
         else if (axis == REL_HWHEEL)
-            SetScrollValuator(device, axnum, SCROLL_TYPE_HORIZONTAL, -1.0, SCROLL_FLAG_NONE);
+            SetScrollValuator(device, axnum, SCROLL_TYPE_HORIZONTAL, 1.0, SCROLL_FLAG_NONE);
 #endif
     }
 


Reply to: