Verbosity level 10, because this stuff is really noisy.

Signed-off-by: Peter Hutterer <[email protected]>
---
 src/alpscomm.c |   49 +++++++++--------
 src/ps2comm.c  |  163 +++++++++++++++++++++++++++----------------------------
 src/ps2comm.h  |    2 +-
 3 files changed, 106 insertions(+), 108 deletions(-)

diff --git a/src/alpscomm.c b/src/alpscomm.c
index 8988e6b..81e778f 100644
--- a/src/alpscomm.c
+++ b/src/alpscomm.c
@@ -57,31 +57,31 @@ ALPS_sync(int fd)
  * anyway doesn't seem to hurt.
  */
 static void
-ALPS_initialize(int fd)
+ALPS_initialize(SynapticsPrivate *priv, int fd)
 {
     xf86FlushInput(fd);
-    ps2_putbyte(fd, PS2_CMD_SET_DEFAULT);
-    ps2_putbyte(fd, PS2_CMD_SET_SCALING_2_1);
-    ps2_putbyte(fd, PS2_CMD_SET_SCALING_2_1);
-    ps2_putbyte(fd, PS2_CMD_SET_SCALING_2_1);
-    ps2_putbyte(fd, PS2_CMD_DISABLE);
-
-    ps2_putbyte(fd, PS2_CMD_DISABLE);
-    ps2_putbyte(fd, PS2_CMD_DISABLE);
-    ps2_putbyte(fd, PS2_CMD_DISABLE);
-    ps2_putbyte(fd, PS2_CMD_DISABLE);
-    ps2_putbyte(fd, PS2_CMD_ENABLE);
-
-    ps2_putbyte(fd, PS2_CMD_SET_SCALING_1_1);
-    ps2_putbyte(fd, PS2_CMD_SET_SCALING_1_1);
-    ps2_putbyte(fd, PS2_CMD_SET_SCALING_1_1);
-    ps2_putbyte(fd, PS2_CMD_DISABLE);
-
-    ps2_putbyte(fd, PS2_CMD_DISABLE);
-    ps2_putbyte(fd, PS2_CMD_DISABLE);
-    ps2_putbyte(fd, PS2_CMD_DISABLE);
-    ps2_putbyte(fd, PS2_CMD_DISABLE);
-    ps2_putbyte(fd, PS2_CMD_ENABLE);
+    ps2_putbyte(priv, fd, PS2_CMD_SET_DEFAULT);
+    ps2_putbyte(priv, fd, PS2_CMD_SET_SCALING_2_1);
+    ps2_putbyte(priv, fd, PS2_CMD_SET_SCALING_2_1);
+    ps2_putbyte(priv, fd, PS2_CMD_SET_SCALING_2_1);
+    ps2_putbyte(priv, fd, PS2_CMD_DISABLE);
+
+    ps2_putbyte(priv, fd, PS2_CMD_DISABLE);
+    ps2_putbyte(priv, fd, PS2_CMD_DISABLE);
+    ps2_putbyte(priv, fd, PS2_CMD_DISABLE);
+    ps2_putbyte(priv, fd, PS2_CMD_DISABLE);
+    ps2_putbyte(priv, fd, PS2_CMD_ENABLE);
+
+    ps2_putbyte(priv, fd, PS2_CMD_SET_SCALING_1_1);
+    ps2_putbyte(priv, fd, PS2_CMD_SET_SCALING_1_1);
+    ps2_putbyte(priv, fd, PS2_CMD_SET_SCALING_1_1);
+    ps2_putbyte(priv, fd, PS2_CMD_DISABLE);
+
+    ps2_putbyte(priv, fd, PS2_CMD_DISABLE);
+    ps2_putbyte(priv, fd, PS2_CMD_DISABLE);
+    ps2_putbyte(priv, fd, PS2_CMD_DISABLE);
+    ps2_putbyte(priv, fd, PS2_CMD_DISABLE);
+    ps2_putbyte(priv, fd, PS2_CMD_ENABLE);
 
     ALPS_sync(fd);
 }
@@ -89,7 +89,8 @@ ALPS_initialize(int fd)
 static Bool
 ALPSQueryHardware(InputInfoPtr pInfo)
 {
-    ALPS_initialize(pInfo->fd);
+    SynapticsPrivate *priv = pInfo->private;
+    ALPS_initialize(priv, pInfo->fd);
     return TRUE;
 }
 
diff --git a/src/ps2comm.c b/src/ps2comm.c
index df53604..0dcf8ca 100644
--- a/src/ps2comm.c
+++ b/src/ps2comm.c
@@ -76,12 +76,6 @@
 #define PS2_RES_RESOLUTION(r)  (((r) >> 8) & 0x03)
 #define PS2_RES_SAMPLE_RATE(r) ((r) & 0xff)
 
-#ifdef DEBUG
-#define PS2DBG(...) xf86Msg(X_INFO, __VA_ARGS__)
-#else
-#define PS2DBG(...)
-#endif
-
 /*****************************************************************************
  *     PS/2 Utility functions.
  *     Many parts adapted from tpconfig.c by C. Scott Ananian
@@ -91,17 +85,17 @@
  * Read a byte from the ps/2 port
  */
 static Bool
-ps2_getbyte(int fd, byte *b)
+ps2_getbyte(SynapticsPrivate *priv, int fd, byte *b)
 {
     if (xf86WaitForInput(fd, 50000) > 0) {
        if (xf86ReadSerial(fd, b, 1) != 1) {
-           PS2DBG("ps2_getbyte: No byte read\n");
+           DBG(priv, 10, "No byte read\n");
            return FALSE;
        }
-       PS2DBG("ps2_getbyte: byte %02X read\n", *b);
+       DBG(priv, 10, "byte %02X read\n", *b);
        return TRUE;
     }
-    PS2DBG("ps2_getbyte: timeout xf86WaitForInput\n");
+    DBG(priv, 10, "timeout xf86WaitForInput\n");
     return FALSE;
 }
 
@@ -109,21 +103,21 @@ ps2_getbyte(int fd, byte *b)
  * Write a byte to the ps/2 port, wait for ACK
  */
 Bool
-ps2_putbyte(int fd, byte b)
+ps2_putbyte(SynapticsPrivate *priv, int fd, byte b)
 {
     byte ack;
 
     if (xf86WriteSerial(fd, &b, 1) != 1) {
-       PS2DBG("ps2_putbyte: error xf86WriteSerial\n");
+       DBG(priv, 10, "error xf86WriteSerial\n");
        return FALSE;
     }
-    PS2DBG("ps2_putbyte: byte %02X send\n", b);
+    DBG(priv, 10, "byte %02X send\n", b);
     /* wait for an ACK */
-    if (!ps2_getbyte(fd, &ack)) {
+    if (!ps2_getbyte(priv, fd, &ack)) {
        return FALSE;
     }
     if (ack != PS2_ACK) {
-       PS2DBG("ps2_putbyte: wrong acknowledge 0x%02x\n", ack);
+       DBG(priv, 10, "wrong acknowledge 0x%02x\n", ack);
        return FALSE;
     }
     return TRUE;
@@ -136,18 +130,18 @@ ps2_putbyte(int fd, byte b)
  *                  is the command. A 0xF3 or 0xE9 must follow (see 
ps2_send_cmd, ps2_set_mode)
  */
 static Bool
-ps2_special_cmd(int fd, byte cmd)
+ps2_special_cmd(SynapticsPrivate *priv, int fd, byte cmd)
 {
     int i;
 
     /* initialize with 'inert' command */
-    if (!ps2_putbyte(fd, PS2_CMD_SET_SCALING_1_1))
+    if (!ps2_putbyte(priv, fd, PS2_CMD_SET_SCALING_1_1))
        return FALSE;
 
     /* send 4x 2-bits with set resolution command */
     for (i = 0; i < 4; i++) {
-       if (!ps2_putbyte(fd, PS2_CMD_SET_RESOLUTION) ||
-           !ps2_putbyte(fd, (cmd >> 6) & 0x3))
+       if (!ps2_putbyte(priv, fd, PS2_CMD_SET_RESOLUTION) ||
+           !ps2_putbyte(priv, fd, (cmd >> 6) & 0x3))
            return FALSE;
        cmd <<= 2;
     }
@@ -158,11 +152,11 @@ ps2_special_cmd(int fd, byte cmd)
  * Send a command to the synpatics touchpad by special commands
  */
 static Bool
-ps2_send_cmd(int fd, byte c)
+ps2_send_cmd(SynapticsPrivate *priv, int fd, byte c)
 {
-    PS2DBG("send command: 0x%02X\n", c);
-    return (ps2_special_cmd(fd, c) &&
-           ps2_putbyte(fd, PS2_CMD_STATUS_REQUEST));
+    DBG(priv, 10, "send command: 0x%02X\n", c);
+    return (ps2_special_cmd(priv, fd, c) &&
+           ps2_putbyte(priv, fd, PS2_CMD_STATUS_REQUEST));
 }
 
 /*****************************************************************************
@@ -173,39 +167,39 @@ ps2_send_cmd(int fd, byte c)
  * Set the synaptics touchpad mode byte by special commands
  */
 static Bool
-ps2_synaptics_set_mode(int fd, byte mode)
+ps2_synaptics_set_mode(SynapticsPrivate *priv, int fd, byte mode)
 {
-    PS2DBG("set mode byte to: 0x%02X\n", mode);
-    return (ps2_special_cmd(fd, mode) &&
-           ps2_putbyte(fd, PS2_CMD_SET_SAMPLE_RATE) &&
-           ps2_putbyte(fd, 0x14));
+    DBG(priv, 10, "set mode byte to: 0x%02X\n", mode);
+    return (ps2_special_cmd(priv, fd, mode) &&
+           ps2_putbyte(priv, fd, PS2_CMD_SET_SAMPLE_RATE) &&
+           ps2_putbyte(priv, fd, 0x14));
 }
 
 /*
  * reset the touchpad
  */
 static Bool
-ps2_synaptics_reset(int fd)
+ps2_synaptics_reset(SynapticsPrivate *priv, int fd)
 {
     byte r[2];
 
     xf86FlushInput(fd);
-    PS2DBG("Reset the Touchpad...\n");
-    if (!ps2_putbyte(fd, PS2_CMD_RESET)) {
-       PS2DBG("...failed\n");
+    DBG(priv, 10, "Reset the Touchpad...\n");
+    if (!ps2_putbyte(priv, fd, PS2_CMD_RESET)) {
+       DBG(priv, 10, "...failed\n");
        return FALSE;
     }
     xf86WaitForInput(fd, 4000000);
-    if (ps2_getbyte(fd, &r[0]) && ps2_getbyte(fd, &r[1])) {
+    if (ps2_getbyte(priv, fd, &r[0]) && ps2_getbyte(priv, fd, &r[1])) {
        if (r[0] == 0xAA && r[1] == 0x00) {
-           PS2DBG("...done\n");
+           DBG(priv, 10, "...done\n");
            return TRUE;
        } else {
-           PS2DBG("...failed. Wrong reset ack 0x%02x, 0x%02x\n", r[0], r[1]);
+           DBG(priv, 10, "...failed. Wrong reset ack 0x%02x, 0x%02x\n", r[0], 
r[1]);
            return FALSE;
        }
     }
-    PS2DBG("...failed\n");
+    DBG(priv, 10, "...failed\n");
     return FALSE;
 }
 
@@ -214,23 +208,23 @@ ps2_synaptics_reset(int fd)
  * see also SYN_MODEL_* macros
  */
 static Bool
-ps2_synaptics_model_id(int fd, struct PS2SynapticsHwInfo *synhw)
+ps2_synaptics_model_id(SynapticsPrivate *priv, int fd, struct 
PS2SynapticsHwInfo *synhw)
 {
     byte mi[3];
 
-    PS2DBG("Read mode id...\n");
+    DBG(priv, 10, "Read mode id...\n");
 
     synhw->model_id = 0;
-    if (ps2_send_cmd(fd, SYN_QUE_MODEL) &&
-       ps2_getbyte(fd, &mi[0]) &&
-       ps2_getbyte(fd, &mi[1]) &&
-       ps2_getbyte(fd, &mi[2])) {
+    if (ps2_send_cmd(priv, fd, SYN_QUE_MODEL) &&
+       ps2_getbyte(priv, fd, &mi[0]) &&
+       ps2_getbyte(priv, fd, &mi[1]) &&
+       ps2_getbyte(priv, fd, &mi[2])) {
        synhw->model_id = (mi[0] << 16) | (mi[1] << 8) | mi[2];
-       PS2DBG("model-id %06X\n", synhw->model_id);
-       PS2DBG("...done.\n");
+       DBG(priv, 10, "model-id %06X\n", synhw->model_id);
+       DBG(priv, 10, "...done.\n");
        return TRUE;
     }
-    PS2DBG("...failed.\n");
+    DBG(priv, 10, "...failed.\n");
     return FALSE;
 }
 
@@ -239,38 +233,38 @@ ps2_synaptics_model_id(int fd, struct PS2SynapticsHwInfo 
*synhw)
  * see also the SYN_CAP_* macros
  */
 static Bool
-ps2_synaptics_capability(int fd, struct PS2SynapticsHwInfo *synhw)
+ps2_synaptics_capability(SynapticsPrivate *priv, int fd, struct 
PS2SynapticsHwInfo *synhw)
 {
     byte cap[3];
 
-    PS2DBG("Read capabilites...\n");
+    DBG(priv, 10, "Read capabilites...\n");
 
     synhw->capabilities = 0;
     synhw->ext_cap = 0;
-    if (ps2_send_cmd(fd, SYN_QUE_CAPABILITIES) &&
-       ps2_getbyte(fd, &cap[0]) &&
-       ps2_getbyte(fd, &cap[1]) &&
-       ps2_getbyte(fd, &cap[2])) {
+    if (ps2_send_cmd(priv, fd, SYN_QUE_CAPABILITIES) &&
+       ps2_getbyte(priv, fd, &cap[0]) &&
+       ps2_getbyte(priv, fd, &cap[1]) &&
+       ps2_getbyte(priv, fd, &cap[2])) {
        synhw->capabilities = (cap[0] << 16) | (cap[1] << 8) | cap[2];
-       PS2DBG("capabilities %06X\n", synhw->capabilities);
+       DBG(priv, 10, "capabilities %06X\n", synhw->capabilities);
        if (SYN_CAP_VALID(synhw)) {
            if (SYN_EXT_CAP_REQUESTS(synhw)) {
-               if (ps2_send_cmd(fd, SYN_QUE_EXT_CAPAB) &&
-                   ps2_getbyte(fd, &cap[0]) &&
-                   ps2_getbyte(fd, &cap[1]) &&
-                   ps2_getbyte(fd, &cap[2])) {
+               if (ps2_send_cmd(priv, fd, SYN_QUE_EXT_CAPAB) &&
+                   ps2_getbyte(priv, fd, &cap[0]) &&
+                   ps2_getbyte(priv, fd, &cap[1]) &&
+                   ps2_getbyte(priv, fd, &cap[2])) {
                    synhw->ext_cap = (cap[0] << 16) | (cap[1] << 8) | cap[2];
-                   PS2DBG("ext-capability %06X\n", synhw->ext_cap);
+                   DBG(priv, 10, "ext-capability %06X\n", synhw->ext_cap);
                } else {
-                   PS2DBG("synaptics says, that it has extended-capabilities, "
+                   DBG(priv, 10, "synaptics says, that it has 
extended-capabilities, "
                                  "but I cannot read them.");
                }
            }
-           PS2DBG("...done.\n");
+           DBG(priv, 10, "...done.\n");
            return TRUE;
        }
     }
-    PS2DBG("...failed.\n");
+    DBG(priv, 10, "...failed.\n");
     return FALSE;
 }
 
@@ -279,54 +273,55 @@ ps2_synaptics_capability(int fd, struct 
PS2SynapticsHwInfo *synhw)
  * See also the SYN_ID_* macros
  */
 static Bool
-ps2_synaptics_identify(int fd, struct PS2SynapticsHwInfo *synhw)
+ps2_synaptics_identify(SynapticsPrivate *priv, int fd, struct 
PS2SynapticsHwInfo *synhw)
 {
     byte id[3];
 
-    PS2DBG("Identify Touchpad...\n");
+    DBG(priv, 10, "Identify Touchpad...\n");
 
     synhw->identity = 0;
-    if (ps2_send_cmd(fd, SYN_QUE_IDENTIFY) &&
-       ps2_getbyte(fd, &id[0]) &&
-       ps2_getbyte(fd, &id[1]) &&
-       ps2_getbyte(fd, &id[2])) {
+    if (ps2_send_cmd(priv, fd, SYN_QUE_IDENTIFY) &&
+       ps2_getbyte(priv, fd, &id[0]) &&
+       ps2_getbyte(priv, fd, &id[1]) &&
+       ps2_getbyte(priv, fd, &id[2])) {
        synhw->identity = (id[0] << 16) | (id[1] << 8) | id[2];
-       PS2DBG("ident %06X\n", synhw->identity);
+       DBG(priv, 10, "ident %06X\n", synhw->identity);
        if (SYN_ID_IS_SYNAPTICS(synhw)) {
-           PS2DBG("...done.\n");
+           DBG(priv, 10, "...done.\n");
            return TRUE;
        }
     }
-    PS2DBG("...failed.\n");
+    DBG(priv, 10, "...failed.\n");
     return FALSE;
 }
 
 static Bool
-ps2_synaptics_enable_device(int fd)
+ps2_synaptics_enable_device(SynapticsPrivate *priv, int fd)
 {
-    return ps2_putbyte(fd, PS2_CMD_ENABLE);
+    return ps2_putbyte(priv, fd, PS2_CMD_ENABLE);
 }
 
 static Bool
-ps2_synaptics_disable_device(int fd)
+ps2_synaptics_disable_device(SynapticsPrivate *priv, int fd)
 {
     xf86FlushInput(fd);
-    return ps2_putbyte(fd, PS2_CMD_DISABLE);
+    return ps2_putbyte(priv, fd, PS2_CMD_DISABLE);
 }
 
 static Bool
 ps2_query_is_synaptics(InputInfoPtr pInfo, int fd, struct PS2SynapticsHwInfo* 
synhw)
 {
+    SynapticsPrivate *priv = pInfo->private;
     int i;
 
     for (i = 0; i < 3; i++) {
-       if (ps2_synaptics_disable_device(fd))
+       if (ps2_synaptics_disable_device(priv, fd))
            break;
     }
 
     xf86WaitForInput(fd, 20000);
     xf86FlushInput(fd);
-    if (ps2_synaptics_identify(fd, synhw)) {
+    if (ps2_synaptics_identify(priv, fd, synhw)) {
        return TRUE;
     } else {
        xf86IDrvMsg(pInfo, X_ERROR, "Query no Synaptics: %06X\n", 
synhw->identity);
@@ -372,8 +367,10 @@ ps2_print_ident(InputInfoPtr pInfo, const struct 
PS2SynapticsHwInfo *synhw)
 static Bool
 PS2DeviceOffHook(InputInfoPtr pInfo)
 {
-    ps2_synaptics_reset(pInfo->fd);
-    ps2_synaptics_enable_device(pInfo->fd);
+    SynapticsPrivate *priv = pInfo->private;
+
+    ps2_synaptics_reset(priv, pInfo->fd);
+    ps2_synaptics_enable_device(priv, pInfo->fd);
 
     return TRUE;
 }
@@ -395,16 +392,16 @@ PS2QueryHardware(InputInfoPtr pInfo)
 
     xf86IDrvMsg(pInfo, X_PROBED, "synaptics touchpad found\n");
 
-    if (!ps2_synaptics_reset(pInfo->fd))
+    if (!ps2_synaptics_reset(priv, pInfo->fd))
        xf86IDrvMsg(pInfo, X_ERROR, "reset failed\n");
 
-    if (!ps2_synaptics_identify(pInfo->fd, synhw))
+    if (!ps2_synaptics_identify(priv, pInfo->fd, synhw))
        return FALSE;
 
-    if (!ps2_synaptics_model_id(pInfo->fd, synhw))
+    if (!ps2_synaptics_model_id(priv, pInfo->fd, synhw))
        return FALSE;
 
-    if (!ps2_synaptics_capability(pInfo->fd, synhw))
+    if (!ps2_synaptics_capability(priv, pInfo->fd, synhw))
        return FALSE;
 
     mode = SYN_BIT_ABSOLUTE_MODE | SYN_BIT_HIGH_RATE;
@@ -412,10 +409,10 @@ PS2QueryHardware(InputInfoPtr pInfo)
        mode |= SYN_BIT_DISABLE_GESTURE;
     if (SYN_CAP_EXTENDED(synhw))
        mode |= SYN_BIT_W_MODE;
-    if (!ps2_synaptics_set_mode(pInfo->fd, mode))
+    if (!ps2_synaptics_set_mode(priv, pInfo->fd, mode))
        return FALSE;
 
-    ps2_synaptics_enable_device(pInfo->fd);
+    ps2_synaptics_enable_device(priv, pInfo->fd);
 
     ps2_print_ident(pInfo, synhw);
 
diff --git a/src/ps2comm.h b/src/ps2comm.h
index 1b303ca..055b283 100644
--- a/src/ps2comm.h
+++ b/src/ps2comm.h
@@ -101,7 +101,7 @@ struct PS2SynapticsHwInfo {
     unsigned int identity;             /* Identification */
 };
 
-Bool ps2_putbyte(int fd, byte b);
+Bool ps2_putbyte(SynapticsPrivate *priv, int fd, byte b);
 void ps2_print_ident(InputInfoPtr pInfo, const struct PS2SynapticsHwInfo 
*synhw);
 Bool PS2ReadHwStateProto(InputInfoPtr pInfo,
                        struct SynapticsProtocolOperations *proto_ops,
-- 
1.7.7.6

_______________________________________________
[email protected]: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

Reply via email to