From 7211ff08488a9b28c1a750deeb5aa6c661745d8c Mon Sep 17 00:00:00 2001 From: Michael Smith Date: Tue, 15 Dec 2009 15:01:29 -0500 Subject: [PATCH] xf86EloReadInput(): fix xserver unresponsiveness during touch The fix for bug #14109 ensures all bytes are emptied from the OS buffer by looping until xf86WaitForInput returns 0. This patch just changes the timeout from 1 millisecond to 0: we don't want the X server to block if there's no more serial data. It also removes the Vmin and Vtime options, which were making the calls to read() block until a complete 10-byte packet buffer could be filled. At 9600 bps, this could pause the X server for up to 9 ms. The code can already handle partial buffers, so all we have to do is get rid of the Vmin. Also, if xf86EloGetPacket() returns !Success, we should continue rather than break so the xf86WaitForInput call can decide whether to exit, in case there's more data in the buffer. Before the fix, glxgears was giving me about 390 FPS normally and down to 140 FPS when dragging an empty area of the touchscreen. Now it's basically unchanged when the touchscreen is in use (390 -> 385 FPS). X.Org Bug 14109 Signed-off-by: Michael Smith --- src/xf86Elo.c | 11 ++++++----- 1 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/xf86Elo.c b/src/xf86Elo.c index ad88621..dbe1747 100644 --- a/src/xf86Elo.c +++ b/src/xf86Elo.c @@ -421,15 +421,17 @@ xf86EloReadInput(LocalDevicePtr local) #endif DBG(4, ErrorF("Entering ReadInput\n")); + /* - * Try to get a packet. + * Read bytes until there's no data left. We may have more or less than + * one packet worth of data in the OS buffer. */ - while (xf86WaitForInput(local->fd, ELO_MAX_WAIT/100) > 0) { + do { if(xf86EloGetPacket(priv->packet_buf, &priv->packet_buf_p, &priv->checksum, local->fd) != Success) - break; + continue; /* * Process only ELO_TOUCHs here. @@ -488,6 +490,7 @@ xf86EloReadInput(LocalDevicePtr local) (state == ELO_PRESS) ? "Press" : ((state == ELO_RELEASE) ? "Release" : "Stream"))); } } + while (xf86WaitForInput(local->fd, 0) > 0); /* don't wait, just check */ } @@ -1059,8 +1062,6 @@ static const char *default_options[] = { "StopBits", "1", "DataBits", "8", "Parity", "None", - "Vmin", "10", - "Vtime", "1", "FlowControl", "None", NULL }; -- 1.6.3