From: Dmitry Torokhov <dtor_core@ameritech.net>
To: Vojtech Pavlik <vojtech@suse.cz>
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH 3/9] synaptics strict/relaxed protocol checks
Date: Sun, 29 Feb 2004 01:56:51 -0500 [thread overview]
Message-ID: <200402290156.53325.dtor_core@ameritech.net> (raw)
In-Reply-To: <200402290155.46360.dtor_core@ameritech.net>
===================================================================
ChangeSet@1.1687, 2004-02-27 23:44:17-05:00, dtor_core@ameritech.net
Input: Switch between strict/relaxed synaptics protocol checks based on
data in the first full data packet. Having strict checks helps
getting rid of bad data after loosing sync, but not all harware
implements strict protocol.
synaptics.c | 53 +++++++++++++++++++++++++++++++++++++++++------------
synaptics.h | 7 +++++++
2 files changed, 48 insertions(+), 12 deletions(-)
===================================================================
diff -Nru a/drivers/input/mouse/synaptics.c b/drivers/input/mouse/synaptics.c
--- a/drivers/input/mouse/synaptics.c Sun Feb 29 01:16:28 2004
+++ b/drivers/input/mouse/synaptics.c Sun Feb 29 01:16:28 2004
@@ -435,6 +435,8 @@
goto init_fail;
}
+ priv->pkt_type = SYN_MODEL_NEWABS(priv->model_id) ? SYN_NEWABS : SYN_OLDABS;
+
if (SYN_CAP_EXTENDED(priv->capabilities) && SYN_CAP_PASS_THROUGH(priv->capabilities))
synaptics_pt_create(psmouse);
@@ -602,19 +604,42 @@
input_sync(dev);
}
-static int synaptics_validate_byte(struct psmouse *psmouse)
+static int synaptics_validate_byte(unsigned char packet[], int idx, unsigned char pkt_type)
{
- static unsigned char newabs_mask[] = { 0xC0, 0x00, 0x00, 0xC0, 0x00 };
- static unsigned char newabs_rslt[] = { 0x80, 0x00, 0x00, 0xC0, 0x00 };
- static unsigned char oldabs_mask[] = { 0xC0, 0x60, 0x00, 0xC0, 0x60 };
- static unsigned char oldabs_rslt[] = { 0xC0, 0x00, 0x00, 0x80, 0x00 };
- struct synaptics_data *priv = psmouse->private;
- int idx = psmouse->pktcnt - 1;
+ static unsigned char newabs_mask[] = { 0xC8, 0x00, 0x00, 0xC8, 0x00 };
+ static unsigned char newabs_rel_mask[] = { 0xC0, 0x00, 0x00, 0xC0, 0x00 };
+ static unsigned char newabs_rslt[] = { 0x80, 0x00, 0x00, 0xC0, 0x00 };
+ static unsigned char oldabs_mask[] = { 0xC0, 0x60, 0x00, 0xC0, 0x60 };
+ static unsigned char oldabs_rslt[] = { 0xC0, 0x00, 0x00, 0x80, 0x00 };
+
+ switch (pkt_type) {
+ case SYN_NEWABS:
+ case SYN_NEWABS_RELAXED:
+ return (packet[idx] & newabs_rel_mask[idx]) == newabs_rslt[idx];
+
+ case SYN_NEWABS_STRICT:
+ return (packet[idx] & newabs_mask[idx]) == newabs_rslt[idx];
+
+ case SYN_OLDABS:
+ return (packet[idx] & oldabs_mask[idx]) == oldabs_rslt[idx];
- if (SYN_MODEL_NEWABS(priv->model_id))
- return (psmouse->packet[idx] & newabs_mask[idx]) == newabs_rslt[idx];
- else
- return (psmouse->packet[idx] & oldabs_mask[idx]) == oldabs_rslt[idx];
+ default:
+ printk(KERN_ERR "synaptics: unknown packet type %d\n", pkt_type);
+ return 0;
+ }
+}
+
+static unsigned char synaptics_detect_pkt_type(struct psmouse *psmouse)
+{
+ int i;
+
+ for (i = 0; i < 5; i++)
+ if (!synaptics_validate_byte(psmouse->packet, i, SYN_NEWABS_STRICT)) {
+ printk(KERN_INFO "synaptics: using relaxed packet validation\n");
+ return SYN_NEWABS_RELAXED;
+ }
+
+ return SYN_NEWABS_STRICT;
}
void synaptics_process_byte(struct psmouse *psmouse, struct pt_regs *regs)
@@ -630,13 +655,17 @@
printk(KERN_NOTICE "Synaptics driver resynced.\n");
}
+ if (unlikely(priv->pkt_type == SYN_NEWABS))
+ priv->pkt_type = synaptics_detect_pkt_type(psmouse);
+
if (psmouse->ptport && psmouse->ptport->serio.dev && synaptics_is_pt_packet(psmouse->packet))
synaptics_pass_pt_packet(&psmouse->ptport->serio, psmouse->packet);
else
synaptics_process_packet(psmouse);
psmouse->pktcnt = 0;
- } else if (psmouse->pktcnt && !synaptics_validate_byte(psmouse)) {
+ } else if (psmouse->pktcnt &&
+ !synaptics_validate_byte(psmouse->packet, psmouse->pktcnt - 1, priv->pkt_type)) {
printk(KERN_WARNING "Synaptics driver lost sync at byte %d\n", psmouse->pktcnt);
psmouse->pktcnt = 0;
if (++priv->out_of_sync == psmouse_resetafter) {
diff -Nru a/drivers/input/mouse/synaptics.h b/drivers/input/mouse/synaptics.h
--- a/drivers/input/mouse/synaptics.h Sun Feb 29 01:16:28 2004
+++ b/drivers/input/mouse/synaptics.h Sun Feb 29 01:16:28 2004
@@ -70,6 +70,12 @@
#define SYN_PS_SET_MODE2 0x14
#define SYN_PS_CLIENT_CMD 0x28
+/* synaptics packet types */
+#define SYN_NEWABS 0
+#define SYN_NEWABS_STRICT 1
+#define SYN_NEWABS_RELAXED 2
+#define SYN_OLDABS 3
+
/*
* A structure to describe the state of the touchpad hardware (buttons and pad)
*/
@@ -103,6 +109,7 @@
/* Data for normal processing */
unsigned int out_of_sync; /* # of packets out of sync */
int old_w; /* Previous w value */
+ unsigned char pkt_type; /* packet type - old, new, etc */
};
#endif /* _SYNAPTICS_H */
next prev parent reply other threads:[~2004-02-29 7:20 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-02-29 6:53 [PATCH 0/9] New set of input patches Dmitry Torokhov
2004-02-29 6:55 ` [PATCH 1/9] atkbd whitespace fixes Dmitry Torokhov
2004-02-29 6:55 ` [PATCH 2/9] atkbd bad merge Dmitry Torokhov
2004-02-29 6:56 ` Dmitry Torokhov [this message]
2004-02-29 6:58 ` [PATCH 4/9] psmouse whitespace fixes Dmitry Torokhov
2004-02-29 6:58 ` [PATCH 5/9] psmouse broken hardware workaround Dmitry Torokhov
2004-02-29 7:00 ` [PATCH 6/9] introduce module_param_array_named Dmitry Torokhov
2004-02-29 7:01 ` [PATCH 7/9] Move joysticks to the module_param way of handling options Dmitry Torokhov
2004-02-29 7:02 ` [PATCH 8/9] introduce __obsolete_setup Dmitry Torokhov
2004-02-29 7:03 ` [PATCH 9/9] Document removed input options using __obsolete_setup Dmitry Torokhov
2004-03-02 13:02 ` [PATCH 0/9] New set of input patches Vojtech Pavlik
2004-03-02 17:45 ` Dmitry Torokhov
2004-03-02 23:56 ` bkbits hosting (was Re: [PATCH 0/9] New set of input patches) Andy Isaacson
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=200402290156.53325.dtor_core@ameritech.net \
--to=dtor_core@ameritech.net \
--cc=linux-kernel@vger.kernel.org \
--cc=vojtech@suse.cz \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox