Input: elantech - add support for elantech fast command
authorJJ Ding <jj_ding@emc.com.tw>
Mon, 21 Nov 2011 06:21:45 +0000 (22:21 -0800)
committerDmitry Torokhov <dmitry.torokhov@gmail.com>
Mon, 21 Nov 2011 06:28:30 +0000 (22:28 -0800)
Starting with v3 hardware, the firmware supports this shorter
elantech_send_cmd. Teach the driver to use it.

Signed-off-by: JJ Ding <jj_ding@emc.com.tw>
Reviewed-by: Daniel Kurtz <djkurtz@chromium.org>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
drivers/input/mouse/elantech.c
drivers/input/mouse/elantech.h

index b562392d0cd8aef3480477b80e74c4d323c68e72..24bb2b5f56677859ae5bc8e67aad94d54fef6334 100644 (file)
@@ -42,6 +42,24 @@ static int synaptics_send_cmd(struct psmouse *psmouse, unsigned char c,
        return 0;
 }
 
+/*
+ * V3 and later support this fast command
+ */
+static int elantech_send_cmd(struct psmouse *psmouse, unsigned char c,
+                               unsigned char *param)
+{
+       struct ps2dev *ps2dev = &psmouse->ps2dev;
+
+       if (ps2_command(ps2dev, NULL, ETP_PS2_CUSTOM_COMMAND) ||
+           ps2_command(ps2dev, NULL, c) ||
+           ps2_command(ps2dev, param, PSMOUSE_CMD_GETINFO)) {
+               psmouse_err(psmouse, "%s query 0x%02x failed.\n", __func__, c);
+               return -1;
+       }
+
+       return 0;
+}
+
 /*
  * A retrying version of ps2_command
  */
@@ -863,13 +881,13 @@ static int elantech_set_range(struct psmouse *psmouse,
                        i = (etd->fw_version > 0x020800 &&
                             etd->fw_version < 0x020900) ? 1 : 2;
 
-                       if (synaptics_send_cmd(psmouse, ETP_FW_ID_QUERY, param))
+                       if (etd->send_cmd(psmouse, ETP_FW_ID_QUERY, param))
                                return -1;
 
                        fixed_dpi = param[1] & 0x10;
 
                        if (((etd->fw_version >> 16) == 0x14) && fixed_dpi) {
-                               if (synaptics_send_cmd(psmouse, ETP_SAMPLE_QUERY, param))
+                               if (etd->send_cmd(psmouse, ETP_SAMPLE_QUERY, param))
                                        return -1;
 
                                *x_max = (etd->capabilities[1] - i) * param[1] / 2;
@@ -888,7 +906,7 @@ static int elantech_set_range(struct psmouse *psmouse,
                break;
 
        case 3:
-               if (synaptics_send_cmd(psmouse, ETP_FW_ID_QUERY, param))
+               if (etd->send_cmd(psmouse, ETP_FW_ID_QUERY, param))
                        return -1;
 
                *x_max = (0x0f & param[0]) << 8 | param[1];
@@ -896,7 +914,7 @@ static int elantech_set_range(struct psmouse *psmouse,
                break;
 
        case 4:
-               if (synaptics_send_cmd(psmouse, ETP_FW_ID_QUERY, param))
+               if (etd->send_cmd(psmouse, ETP_FW_ID_QUERY, param))
                        return -1;
 
                *x_max = (0x0f & param[0]) << 8 | param[1];
@@ -1220,9 +1238,11 @@ static int elantech_set_properties(struct elantech_data *etd)
        else
                return -1;
 
-       /*
-        * Turn on packet checking by default.
-        */
+       /* decide which send_cmd we're gonna use early */
+       etd->send_cmd = etd->hw_version >= 3 ? elantech_send_cmd :
+                                              synaptics_send_cmd;
+
+       /* Turn on packet checking by default */
        etd->paritycheck = 1;
 
        /*
@@ -1278,7 +1298,7 @@ int elantech_init(struct psmouse *psmouse)
                     "assuming hardware version %d (with firmware version 0x%02x%02x%02x)\n",
                     etd->hw_version, param[0], param[1], param[2]);
 
-       if (synaptics_send_cmd(psmouse, ETP_CAPABILITIES_QUERY,
+       if (etd->send_cmd(psmouse, ETP_CAPABILITIES_QUERY,
            etd->capabilities)) {
                psmouse_err(psmouse, "failed to query capabilities.\n");
                goto init_fail;
index 9e5f1aabea7e92c2abc48fe7de380c17279873be..08d00bd9d1f8c8d3b4316544840e8359b607ad91 100644 (file)
@@ -135,6 +135,7 @@ struct elantech_data {
        unsigned int width;
        struct finger_pos mt[ETP_MAX_FINGERS];
        unsigned char parity[256];
+       int (*send_cmd)(struct psmouse *psmouse, unsigned char c, unsigned char *param);
 };
 
 #ifdef CONFIG_MOUSE_PS2_ELANTECH