[PATCH:synaptics 4/5] eventcomm: don't use the Xisb buffers for reading.
Peter Hutterer
peter.hutterer at who-t.net
Mon Nov 2 19:49:12 PST 2009
The kernel promises to give us 32 bytes for each event, so we don't have to
juggle the Xisb buffers around for the eventcomm devices.
This leaves the Xisb buffers hanging around but useless (they are
initialized regardless). Task for a later cleanup.
Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
---
src/eventcomm.c | 28 ++++++++++++++++------------
1 files changed, 16 insertions(+), 12 deletions(-)
diff --git a/src/eventcomm.c b/src/eventcomm.c
index 8287ca2..d00d810 100644
--- a/src/eventcomm.c
+++ b/src/eventcomm.c
@@ -270,19 +270,23 @@ EventQueryHardware(LocalDevicePtr local)
}
static Bool
-SynapticsReadEvent(struct CommData *comm, struct input_event *ev)
+SynapticsReadEvent(LocalDevicePtr local, struct input_event *ev)
{
- int i, c;
- unsigned char *pBuf, u;
-
- for (i = 0; i < sizeof(struct input_event); i++) {
- if ((c = XisbRead(comm->buffer)) < 0)
- return FALSE;
- u = (unsigned char)c;
- pBuf = (unsigned char *)ev;
- pBuf[i] = u;
+ int rc = TRUE;
+ ssize_t len;
+
+ len = read(local->fd, ev, sizeof(*ev));
+ if (len <= 0)
+ {
+ /* We use X_NONE here because it doesn't alloc */
+ if (errno != EAGAIN)
+ xf86MsgVerb(X_NONE, 0, "%s: Read error %s\n", local->name, strerror(errno));
+ rc = FALSE;
+ } else if (len % sizeof(*ev)) {
+ xf86MsgVerb(X_NONE, 0, "%s: Read error, invalid number of bytes.", local->name);
+ rc = FALSE;
}
- return TRUE;
+ return rc;
}
static Bool
@@ -296,7 +300,7 @@ EventReadHwState(LocalDevicePtr local,
SynapticsPrivate *priv = (SynapticsPrivate *)local->private;
SynapticsParameters *para = &priv->synpara;
- while (SynapticsReadEvent(comm, &ev)) {
+ while (SynapticsReadEvent(local, &ev)) {
switch (ev.type) {
case EV_SYN:
switch (ev.code) {
--
1.6.5.1
More information about the xorg-devel
mailing list