[PATCH synaptics 01/10] Bury shm - or what was left of it

Peter Hutterer peter.hutterer at who-t.net
Tue May 8 22:34:29 PDT 2012


SHM configuration was removed in Apr 2009 (c09a3d50e9), since then it has
only been usedful for debugging. And we have better tools (evtest) for
debugging hardware events.

Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
 include/synaptics.h |   14 ------
 man/synaptics.man   |   16 +++----
 src/synaptics.c     |  106 --------------------------------------------
 src/synapticsstr.h  |    4 --
 tools/synclient.c   |  122 +--------------------------------------------------
 5 files changed, 8 insertions(+), 254 deletions(-)

diff --git a/include/synaptics.h b/include/synaptics.h
index 3d4832f..564aab9 100644
--- a/include/synaptics.h
+++ b/include/synaptics.h
@@ -48,20 +48,6 @@ typedef enum {
 
 #define SYN_MAX_BUTTONS 12      /* Max number of mouse buttons */
 
-#define SHM_SYNAPTICS 23947
-typedef struct _SynapticsSHM {
-    int version;                /* Driver version */
-
-    /* Current device state */
-    int x, y;                   /* actual x, y coordinates */
-    int z;                      /* pressure value */
-    int numFingers;             /* number of fingers */
-    int fingerWidth;            /* finger width value */
-    int left, right, up, down;  /* left/right/up/down buttons */
-    Bool multi[8];
-    Bool middle;
-} SynapticsSHM;
-
 /*
  * Minimum and maximum values for scroll_button_repeat
  */
diff --git a/man/synaptics.man b/man/synaptics.man
index ab6e61d..4a9dfc9 100644
--- a/man/synaptics.man
+++ b/man/synaptics.man
@@ -92,11 +92,6 @@ psaux	raw device access (Linux 2.4)
 psm	FreeBSD psm driver
 .TE
 .TP 7
-.BI "Option \*qSHMConfig\*q \*q" boolean \*q
-Switch on/off shared memory for run-time debugging. This option does not
-have an effect on run-time configuration anymore and is only useful for
-hardware event debugging.
-.TP 7
 .BI "Option \*qLeftEdge\*q \*q" integer \*q
 X coordinate for left edge. Property: "Synaptics Edges"
 .TP 7
@@ -563,9 +558,9 @@ Coordinates to the left of LeftEdge are part of the left edge (areas
 1, 4 and 7), coordinates to the left of LeftEdge and above TopEdge
 (area 1) are part of the upper left corner, etc.
 .PP
-A good way to find appropriate edge parameters is to enable the
-SHMConfig option and run "synclient \-m 1" to see the x/y coordinates
-corresponding to different positions on the touchpad.
+A good way to find appropriate edge parameters is to use evtest(1) on the
+device to see the x/y coordinates corresponding to different positions on
+the touchpad.
 .PP
 The perceived physical edges may be adjusted with the AreaLeftEdge,
 AreaRightEdge, AreaTopEdge, and AreaBottomEdge options. If these values are
@@ -795,8 +790,7 @@ area, a right or middle click is performed.
 
 .SH "DEVICE PROPERTIES"
 Synaptics 1.0 and higher support input device properties if the driver is
-running on X server 1.6 or higher. On these driver versions, Option
-"SHMConfig" is not needed to enable run-time configuration. The synclient tool
+running on X server 1.6 or higher. The synclient tool
 shipped with synaptics version 1.1 uses input device properties by default.
 .
 Properties supported:
@@ -1020,6 +1014,8 @@ The following options are no longer part of the driver configuration:
 .BI "Option \*qSpecialScrollAreaRight\*q \*q" boolean \*q
 .TP
 .BI "Option \*qGuestMouseOff\*q \*q" boolean \*q
+.TP
+.BI "Option \*qSHMConfig\*q \*q" boolean \*q
 
 .SH "AUTHORS"
 .LP
diff --git a/src/synaptics.c b/src/synaptics.c
index 809a275..dbe8907 100644
--- a/src/synaptics.c
+++ b/src/synaptics.c
@@ -63,7 +63,6 @@
 #include <unistd.h>
 #include <misc.h>
 #include <xf86.h>
-#include <sys/shm.h>
 #include <math.h>
 #include <stdio.h>
 #include <xf86_OSproc.h>
@@ -297,64 +296,6 @@ SetDeviceAndProtocol(InputInfoPtr pInfo)
     return (priv->proto_ops != NULL);
 }
 
-/*
- * Allocate and initialize read-only memory for the SynapticsParameters data to hold
- * driver settings.
- * The function will allocate shared memory if priv->shm_config is TRUE.
- */
-static Bool
-alloc_shm_data(InputInfoPtr pInfo)
-{
-    int shmid;
-    SynapticsPrivate *priv = pInfo->private;
-
-    if (priv->synshm)
-        return TRUE;            /* Already allocated */
-
-    if (priv->shm_config) {
-        if ((shmid = shmget(SHM_SYNAPTICS, 0, 0)) != -1)
-            shmctl(shmid, IPC_RMID, NULL);
-        if ((shmid = shmget(SHM_SYNAPTICS, sizeof(SynapticsSHM),
-                            0774 | IPC_CREAT)) == -1) {
-            xf86IDrvMsg(pInfo, X_ERROR, "error shmget\n");
-            return FALSE;
-        }
-        if ((priv->synshm = (SynapticsSHM *) shmat(shmid, NULL, 0)) == NULL) {
-            xf86IDrvMsg(pInfo, X_ERROR, "error shmat\n");
-            return FALSE;
-        }
-    }
-    else {
-        priv->synshm = calloc(1, sizeof(SynapticsSHM));
-        if (!priv->synshm)
-            return FALSE;
-    }
-
-    return TRUE;
-}
-
-/*
- * Free SynapticsParameters data previously allocated by alloc_shm_data().
- */
-static void
-free_shm_data(SynapticsPrivate * priv)
-{
-    int shmid;
-
-    if (!priv->synshm)
-        return;
-
-    if (priv->shm_config) {
-        if ((shmid = shmget(SHM_SYNAPTICS, 0, 0)) != -1)
-            shmctl(shmid, IPC_RMID, NULL);
-    }
-    else {
-        free(priv->synshm);
-    }
-
-    priv->synshm = NULL;
-}
-
 static void
 calculate_edge_widths(SynapticsPrivate * priv, int *l, int *r, int *t, int *b)
 {
@@ -608,12 +549,6 @@ set_default_parameters(InputInfoPtr pInfo)
     int horizHyst, vertHyst;
     int middle_button_timeout;
 
-    /* read the parameters */
-    if (priv->synshm)
-        priv->synshm->version =
-            (PACKAGE_VERSION_MAJOR * 10000 + PACKAGE_VERSION_MINOR * 100 +
-             PACKAGE_VERSION_PATCHLEVEL);
-
     /* The synaptics specs specify typical edge widths of 4% on x, and 5.4% on
      * y (page 7) [Synaptics TouchPad Interfacing Guide, 510-000080 - A
      * Second Edition, http://www.synaptics.com/support/dev_support.cfm, 8 Sep
@@ -975,16 +910,10 @@ SynapticsPreInit(InputDriverPtr drv, InputInfoPtr pInfo, int flags)
     /* read hardware dimensions */
     ReadDevDimensions(pInfo);
 
-    /* install shared memory or normal memory for parameters */
-    priv->shm_config = xf86SetBoolOption(pInfo->options, "SHMConfig", FALSE);
-
     set_default_parameters(pInfo);
 
     CalculateScalingCoeffs(priv);
 
-    if (!alloc_shm_data(pInfo))
-        goto SetupProc_fail;
-
     priv->comm.buffer = XisbNew(pInfo->fd, INPUT_BUFFER_SIZE);
 
     if (!QueryHardware(pInfo)) {
@@ -1014,7 +943,6 @@ SynapticsPreInit(InputDriverPtr drv, InputInfoPtr pInfo, int flags)
 
     if (priv->comm.buffer)
         XisbFree(priv->comm.buffer);
-    free_shm_data(priv);
     free(priv->proto_data);
     free(priv->timer);
     free(priv);
@@ -1193,7 +1121,6 @@ DeviceClose(DeviceIntPtr dev)
     RetValue = DeviceOff(dev);
     TimerFree(priv->timer);
     priv->timer = NULL;
-    free_shm_data(priv);
     SynapticsHwStateFree(&priv->hwState);
     SynapticsHwStateFree(&priv->old_hw_state);
     SynapticsHwStateFree(&priv->local_hw_state);
@@ -1471,16 +1398,12 @@ DeviceInit(DeviceIntPtr dev)
 
     priv->comm.hwState = SynapticsHwStateAlloc(priv);
 
-    if (!alloc_shm_data(pInfo))
-        goto fail;
-
     InitDeviceProperties(pInfo);
     XIRegisterPropertyHandler(pInfo->dev, SetProperty, NULL, NULL);
 
     return Success;
 
  fail:
-    free_shm_data(priv);
     free(priv->local_hw_state);
     free(priv->hwState);
 #ifdef HAVE_MULTITOUCH
@@ -2873,33 +2796,6 @@ handle_clickfinger(SynapticsPrivate * priv, struct SynapticsHwState *hw)
     }
 }
 
-/* Update the hardware state in shared memory. This is read-only these days,
- * nothing in the driver reads back from SHM. SHM configuration is a thing of the past.
- */
-static void
-update_shm(const InputInfoPtr pInfo, const struct SynapticsHwState *hw)
-{
-    int i;
-    SynapticsPrivate *priv = (SynapticsPrivate *) (pInfo->private);
-    SynapticsSHM *shm = priv->synshm;
-
-    if (!shm)
-        return;
-
-    shm->x = hw->x;
-    shm->y = hw->y;
-    shm->z = hw->z;
-    shm->numFingers = hw->numFingers;
-    shm->fingerWidth = hw->fingerWidth;
-    shm->left = hw->left;
-    shm->right = hw->right;
-    shm->up = hw->up;
-    shm->down = hw->down;
-    for (i = 0; i < 8; i++)
-        shm->multi[i] = hw->multi[i];
-    shm->middle = hw->middle;
-}
-
 /* Adjust the hardware state according to the extra buttons (if the touchpad
  * has any and not many touchpads do these days). These buttons are up/down
  * tilt buttons and/or left/right buttons that then map into a specific
@@ -3258,8 +3154,6 @@ HandleState(InputInfoPtr pInfo, struct SynapticsHwState *hw, CARD32 now,
     int timeleft;
     Bool inside_active_area;
 
-    update_shm(pInfo, hw);
-
     /* If touchpad is switched off, we skip the whole thing and return delay */
     if (para->touchpad_off == 1) {
         UpdateTouchState(pInfo, hw);
diff --git a/src/synapticsstr.h b/src/synapticsstr.h
index 57ed4ba..2d12261 100644
--- a/src/synapticsstr.h
+++ b/src/synapticsstr.h
@@ -186,8 +186,6 @@ typedef struct _SynapticsParameters {
 struct _SynapticsPrivateRec {
     SynapticsParameters synpara;        /* Default parameter settings, read from
                                            the X config file */
-    SynapticsSHM *synshm;       /* Current parameter settings. Will point to
-                                   shared memory if shm_config is true */
     struct SynapticsProtocolOperations *proto_ops;
     void *proto_data;           /* protocol-specific data */
 
@@ -195,8 +193,6 @@ struct _SynapticsPrivateRec {
     struct SynapticsHwState *old_hw_state;      /* previous logical hw state */
 
     const char *device;         /* device node */
-    Bool shm_config;            /* True when shared memory area allocated */
-
     CARD32 timer_time;          /* when timer last fired */
     OsTimerPtr timer;           /* for up/down-button repeat, tap processing, etc */
 
diff --git a/tools/synclient.c b/tools/synclient.c
index 7ec6923..e91746d 100644
--- a/tools/synclient.c
+++ b/tools/synclient.c
@@ -32,7 +32,6 @@
 #include <stdlib.h>
 #include <sys/types.h>
 #include <sys/ipc.h>
-#include <sys/shm.h>
 #include <sys/time.h>
 #include <unistd.h>
 #include <string.h>
@@ -197,108 +196,6 @@ parse_cmd(char *cmd, struct Parameter **par)
     return 0;
 }
 
-static int
-is_equal(SynapticsSHM * s1, SynapticsSHM * s2)
-{
-    int i;
-
-    if ((s1->x != s2->x) ||
-        (s1->y != s2->y) ||
-        (s1->z != s2->z) ||
-        (s1->numFingers != s2->numFingers) ||
-        (s1->fingerWidth != s2->fingerWidth) ||
-        (s1->left != s2->left) ||
-        (s1->right != s2->right) ||
-        (s1->up != s2->up) ||
-        (s1->down != s2->down) || (s1->middle != s2->middle))
-        return 0;
-
-    for (i = 0; i < 8; i++)
-        if (s1->multi[i] != s2->multi[i])
-            return 0;
-
-    return 1;
-}
-
-static double
-get_time(void)
-{
-    struct timeval tv;
-
-    gettimeofday(&tv, NULL);
-    return tv.tv_sec + tv.tv_usec / 1000000.0;
-}
-
-static void
-shm_monitor(SynapticsSHM * synshm, int delay)
-{
-    int header = 0;
-    SynapticsSHM old;
-    double t0 = get_time();
-
-    memset(&old, 0, sizeof(SynapticsSHM));
-    old.x = -1;                 /* Force first equality test to fail */
-
-    while (1) {
-        SynapticsSHM cur = *synshm;
-
-        if (!is_equal(&old, &cur)) {
-            if (!header) {
-                printf("%8s  %4s %4s %3s %s %2s %2s %s %s %s %s  %8s  "
-                       "%2s %2s %2s %3s %3s\n",
-                       "time", "x", "y", "z", "f", "w", "l", "r", "u", "d", "m",
-                       "multi", "gl", "gm", "gr", "gdx", "gdy");
-                header = 20;
-            }
-            header--;
-            printf
-                ("%8.3f  %4d %4d %3d %d %2d %2d %d %d %d %d  %d%d%d%d%d%d%d%d\n",
-                 get_time() - t0, cur.x, cur.y, cur.z, cur.numFingers,
-                 cur.fingerWidth, cur.left, cur.right, cur.up, cur.down,
-                 cur.middle, cur.multi[0], cur.multi[1], cur.multi[2],
-                 cur.multi[3], cur.multi[4], cur.multi[5], cur.multi[6],
-                 cur.multi[7]);
-            fflush(stdout);
-            old = cur;
-        }
-        usleep(delay * 1000);
-    }
-}
-
-/** Init and return SHM area or NULL on error */
-static SynapticsSHM *
-shm_init()
-{
-    SynapticsSHM *synshm = NULL;
-    int shmid = 0;
-
-    if ((shmid = shmget(SHM_SYNAPTICS, sizeof(SynapticsSHM), 0)) == -1) {
-        if ((shmid = shmget(SHM_SYNAPTICS, 0, 0)) == -1)
-            fprintf(stderr,
-                    "Can't access shared memory area. SHMConfig disabled?\n");
-        else
-            fprintf(stderr,
-                    "Incorrect size of shared memory area. Incompatible driver version?\n");
-    }
-    else if ((synshm = (SynapticsSHM *) shmat(shmid, NULL, SHM_RDONLY)) == NULL)
-        perror("shmat");
-
-    return synshm;
-}
-
-static void
-shm_process_commands(int do_monitor, int delay)
-{
-    SynapticsSHM *synshm = NULL;
-
-    synshm = shm_init();
-    if (!synshm)
-        return;
-
-    if (do_monitor)
-        shm_monitor(synshm, delay);
-}
-
 /** Init display connection or NULL on error */
 static Display *
 dp_init()
@@ -576,11 +473,7 @@ dp_show_settings(Display * dpy, XDevice * dev)
 static void
 usage(void)
 {
-    fprintf(stderr,
-            "Usage: synclient [-s] [-m interval] [-h] [-l] [-V] [-?] [var1=value1 [var2=value2] ...]\n");
-    fprintf(stderr,
-            "  -m monitor changes to the touchpad state (implies -s)\n"
-            "     interval specifies how often (in ms) to poll the touchpad state\n");
+    fprintf(stderr, "Usage: synclient [-s] [-h] [-l] [-V] [-?] [var1=value1 [var2=value2] ...]\n");
     fprintf(stderr, "  -l List current user settings\n");
     fprintf(stderr, "  -V Print synclient version string and exit\n");
     fprintf(stderr, "  -? Show this help message\n");
@@ -592,8 +485,6 @@ int
 main(int argc, char *argv[])
 {
     int c;
-    int delay = -1;
-    int do_monitor = 0;
     int dump_settings = 0;
     int first_cmd;
 
@@ -606,11 +497,6 @@ main(int argc, char *argv[])
     /* Parse command line parameters */
     while ((c = getopt(argc, argv, "sm:hlV")) != -1) {
         switch (c) {
-        case 'm':
-            do_monitor = 1;
-            if ((delay = atoi(optarg)) < 0)
-                usage();
-            break;
         case 'l':
             dump_settings = 1;
             break;
@@ -623,13 +509,9 @@ main(int argc, char *argv[])
     }
 
     first_cmd = optind;
-    if (!do_monitor && !dump_settings && first_cmd == argc)
+    if (!dump_settings && first_cmd == argc)
         usage();
 
-    /* Connect to the shared memory area */
-    if (do_monitor)
-        shm_process_commands(do_monitor, delay);
-
     dpy = dp_init();
     if (!dpy || !(dev = dp_get_device(dpy)))
         return 1;
-- 
1.7.10.1



More information about the xorg-devel mailing list