From: "Éric Piel" <E.A.B.Piel@tudelft.nl>
To: Dmitry Torokhov <dmitry.torokhov@gmail.com>,
"linux-input@vger.kernel.org" <linux-input@vger.kernel.org>
Cc: Florian Ragwitz <rafl@debian.org>
Subject: [PATCH 4/7] elantech: implement data check for 6-byte protocol
Date: Mon, 21 Jun 2010 23:04:02 +0200 [thread overview]
Message-ID: <4C1FD3C2.1010201@tudelft.nl> (raw)
In-Reply-To: <4C1FD2B0.1080504@tudelft.nl>
Based on the protocol description, and the source code of the
Dell/Ubuntu driver, the two additional types of data checking for the
6-byte protocol are added. Technically, this is not parity checking, but
to avoid too much change, "paritycheck" is kept to talk about the checks.
In addition, as in the Dell/Ubuntu driver, instead of droping all the
bytes when an error is detected, just drop the first byte, so that
it's possible to re-synchronize quickly.
Signed-off-by: Éric Piel <eric.piel@tremplin-utc.net>
---
drivers/input/mouse/elantech.c | 61 +++++++++++++++++++++++++++++++++++++--
1 files changed, 57 insertions(+), 4 deletions(-)
diff --git a/drivers/input/mouse/elantech.c b/drivers/input/mouse/elantech.c
index f32ffda..b09b458 100644
--- a/drivers/input/mouse/elantech.c
+++ b/drivers/input/mouse/elantech.c
@@ -339,6 +339,57 @@ static int elantech_check_parity_v1(struct psmouse *psmouse)
etd->parity[packet[3]] == p3;
}
+static int elantech_check_parity_ef113(struct psmouse *psmouse)
+{
+ unsigned char *packet = psmouse->packet;
+
+ /* Consistency checks as in the Dell/Ubuntu driver */
+ return !((((packet[0] & 0x3c) != 0x3c) && ((packet[0] & 0xc0) != 0x80)) ||
+ (((packet[0] & 0x0c) != 0x0c) && ((packet[0] & 0xc0) == 0x80)) ||
+ (((packet[0] & 0xc0) != 0x80) && ((packet[1] & 0xf0) != 0x00)) ||
+ (((packet[3] & 0x3e) != 0x38) && ((packet[0] & 0xc0) != 0x80)) ||
+ (((packet[3] & 0x0e) != 0x08) && ((packet[0] & 0xc0) == 0x80)) ||
+ (((packet[0] & 0xc0) != 0x80) && ((packet[4] & 0xf0) != 0x00)));
+}
+
+static int elantech_check_parity_const(struct psmouse *psmouse)
+{
+ unsigned char *packet = psmouse->packet;
+
+ /* Some bits which are constant in the 6 packets */
+ return (((packet[0] & 0x0c) == 0x04) && ((packet[3] & 0x0f) == 0x02));
+}
+
+/*
+ * Returns 0 if an error is detected in the packets.
+ */
+static int elantech_check_parity(struct psmouse *psmouse)
+{
+ struct elantech_data *etd = psmouse->private;
+
+ switch (etd->paritycheck) {
+ case ETP_FULL_PC:
+ return elantech_check_parity_v1(psmouse);
+ case ETP_EF113_CHECK:
+ return elantech_check_parity_ef113(psmouse);
+ case ETP_CONST_CHECK:
+ return elantech_check_parity_const(psmouse);
+ case ETP_NOT_CHECK:
+ default:
+ return 1;
+ }
+}
+
+static void elantech_shift_packets(struct psmouse *psmouse)
+{
+ unsigned char *packet = psmouse->packet;
+ int i;
+
+ for (i = 0; i < (psmouse->pktsize - 1); i++)
+ packet[i] = packet[i + 1];
+ psmouse->pktcnt--;
+}
+
/*
* Process byte stream from mouse and handle complete packets
*/
@@ -352,16 +403,18 @@ static psmouse_ret_t elantech_process_byte(struct psmouse *psmouse)
if (etd->debug > 1)
elantech_packet_dump(psmouse->packet, psmouse->pktsize);
+ if (!elantech_check_parity(psmouse)) {
+ /* Try to re-synchronize */
+ elantech_shift_packets(psmouse);
+ return PSMOUSE_GOOD_DATA;
+ }
+
switch (etd->hw_version) {
case 1:
- if (etd->paritycheck && !elantech_check_parity_v1(psmouse))
- return PSMOUSE_BAD_DATA;
-
elantech_report_absolute_v1(psmouse);
break;
case 2:
- /* We don't know how to check parity in protocol v2 */
elantech_report_absolute_v2(psmouse);
break;
}
--
1.7.1
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2010-06-21 21:08 UTC|newest]
Thread overview: 46+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-06-21 20:59 [PATCH 0/7] elantech: various improvements for 6-byte protocol Éric Piel
2010-06-21 21:01 ` [PATCH 1/7] elantech: Describe further the protocol Éric Piel
2010-06-21 21:02 ` [PATCH 2/7] [NEEDS TEST] elantech: discard the first 2 positions reports for some firmwares Éric Piel
2010-06-21 21:03 ` [PATCH 3/7] elantech: distinguish various hardware/firmware versions Éric Piel
2010-06-21 21:04 ` Éric Piel [this message]
2010-06-21 21:05 ` [PATCH 6/7] elantech: export pressure and width when supported Éric Piel
2010-06-21 21:06 ` [PATCH 7/7] elantech: average the two coordinates when 2 fingers Éric Piel
2010-07-21 3:36 ` Dmitry Torokhov
2010-07-30 18:55 ` Éric Piel
2010-07-30 21:01 ` Henrik Rydberg
2010-07-30 21:41 ` Éric Piel
2010-07-31 9:28 ` Henrik Rydberg
2010-07-31 9:33 ` Dmitry Torokhov
2010-07-31 12:49 ` Henrik Rydberg
2010-07-31 23:00 ` Éric Piel
2010-08-01 7:52 ` Henrik Rydberg
2010-07-31 19:56 ` Chris Bagwell
[not found] ` <AANLkTi=cEEx-5eQPbRYvMMaECvXKQ+i-e0Eaw_g4JY7=@mail.gmail.com>
2010-07-31 23:04 ` Éric Piel
2010-08-01 9:37 ` Henrik Rydberg
2010-08-01 11:28 ` Éric Piel
2010-08-01 13:57 ` Henrik Rydberg
2010-08-02 8:17 ` Éric Piel
2010-08-02 10:02 ` Henrik Rydberg
2010-08-02 11:12 ` Éric Piel
2010-08-02 11:22 ` Henrik Rydberg
2010-08-02 11:33 ` Éric Piel
2010-08-02 11:46 ` Henrik Rydberg
2010-08-02 12:13 ` Éric Piel
2010-08-02 12:29 ` Henrik Rydberg
2010-08-02 12:46 ` Éric Piel
2010-08-02 13:03 ` Henrik Rydberg
2010-08-02 13:23 ` Éric Piel
2010-08-02 14:12 ` Henrik Rydberg
2010-08-02 16:39 ` Dmitry Torokhov
2010-08-02 17:15 ` Henrik Rydberg
2010-08-08 22:51 ` Éric Piel
2010-08-08 22:52 ` [PATCH 07/10] elantech: Report multitouch with proper ABS_MT messages Éric Piel
2010-08-08 22:53 ` [PATCH 08/10] elantech: track finger to distinguish coordinates in 2-finger report Éric Piel
2010-08-08 22:54 ` [PATCH 09/10] elantech: remove support for proprietary X driver Éric Piel
2010-08-08 22:55 ` [PATCH 10/10] elantech: don't take into account the border size in the calculations Éric Piel
2010-08-02 16:26 ` [PATCH 7/7] elantech: average the two coordinates when 2 fingers Dmitry Torokhov
2010-08-02 17:05 ` Henrik Rydberg
2010-08-01 7:36 ` Henrik Rydberg
2010-06-21 21:07 ` [PATCH 5/7] elantech: report position also with 3 fingers Éric Piel
2010-07-21 3:38 ` Dmitry Torokhov
2010-07-30 18:37 ` Éric Piel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4C1FD3C2.1010201@tudelft.nl \
--to=e.a.b.piel@tudelft.nl \
--cc=dmitry.torokhov@gmail.com \
--cc=linux-input@vger.kernel.org \
--cc=rafl@debian.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.