[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[RFC][Patch] Cirumvent appletouch fuzziness


I frequently experience problems with the "fuzziness" of the touchpad
in my iBook, using the appletouch driver. From time to time the
pointer jumps around and clicks randomly and the touchpad becomes
unusable. The only way out is to reload the appletouch module.

Digging around in the appletouch sources, the problems seems to be
that the accumulated xy values increase over time (due to temperature
changes, sweat, or whatever reason ;-) ), eventually become bigger
than ATP_THRESHOLD and start to influence the pointer position.

Now, two main solution ideas come into my mind:

1) Increase ATP_THRESHOLD. This turns out to be a bad idea, as it
mainly just delays the effect and moreover badly affects fine

2) Counteract the slow growth of xy_acc. See appended patch for an
implementation of this idea. The values of xy_acc are slowly decreased
if they are under a certain threshold. To avoid decreasing "real"
values in xy_acc (i.e. values which are actually the result of a
finger on the touchpad, and not some fuzziness problem) big values
(which are more likely caused by some finger) are decreased slowly,
small values (which more probably result from fuzziness) are decreased
a bit faster.

So, some questions for you guys: I have never read a report on this
fuzziness problem. Am I the only one experiencing it? If yes, forget
about my patch, as I'd probably be the only happy user of it. ;)

The current patch should probably be called "ugly but effective": it
kind of helps, but I guess there are better ways to implement this.
So, if someone comes up with some better algorithmic idea, let me

--- linux-2.6.17-rc3.orig/drivers/usb/input/appletouch.c	2006-03-20 06:53:29.000000000 +0100
+++ linux-2.6.17-rc3/drivers/usb/input/appletouch.c	2006-05-02 18:49:31.000000000 +0200
@@ -99,7 +99,10 @@ MODULE_DEVICE_TABLE (usb, atp_table);
  * Threshold for the touchpad sensors. Any change less than ATP_THRESHOLD is
  * ignored.
-#define ATP_THRESHOLD	 5
+#define ATP_THRESHOLD	 3
 /* Structure to hold all of our device specific stuff */
 struct atp {
@@ -118,6 +121,8 @@ struct atp {
 	signed char		xy_old[ATP_XSENSORS + ATP_YSENSORS];
 						/* accumulated sensors */
 	int			xy_acc[ATP_XSENSORS + ATP_YSENSORS];
+						/* penalty values for shrinking */
+	int			xy_shrink[ATP_XSENSORS + ATP_YSENSORS];
 	int			overflowwarn;	/* overflow warning printed? */
 	int			datalen;	/* size of an USB urb transfer */
@@ -297,6 +302,23 @@ static void atp_complete(struct urb* urb
 		/* prevent down drifting */
 		if (dev->xy_acc[i] < 0)
 			dev->xy_acc[i] = 0;
+		/* Fix fuzziness. If a value in xy_acc is less than ATP_SHRINK_THRESHOLD
+		 * long enough to let the shrinking penalty grow beyond 
+		 * ATP_SHRINK_PENALTY_THRESHOLD, decrease that value in xy_acc.
+		 */
+		if ((dev->xy_acc[i] > 0) && (dev->xy_acc[i] < ATP_SHRINK_THRESHOLD ))
+		{
+			dev->xy_shrink[i] += ATP_SHRINK_THRESHOLD - dev->xy_acc[i];
+			if (dev->xy_shrink[i] >= ATP_SHRINK_PENALTY_THRESHOLD)
+			{
+				dev->xy_shrink[i] = 0;
+				dev->xy_acc[i]--;
+				printk("appletouch: trying to fix fuzziness. changed xy_acc[%d]: %d\n", i, dev->xy_acc[i]);
+			}
+		} else {
+			dev->xy_shrink[i] = 0;
+		}
 	memcpy(dev->xy_old, dev->xy_cur, sizeof(dev->xy_old));

Reply to: