---
 configure    |38107 -----------------------------------------------------------
 configure.ac            |    2 -
 hw/kdrive/linux/tslib.c |   68 ++++++++++++++++++++++++++----------------------
 2 files changed, 39 insertions(+), 31 deletions(-)


Index: xorg-server-1.1.99.3/hw/kdrive/linux/tslib.c
===================================================================
--- xorg-server-1.1.99.3.orig/hw/kdrive/linux/tslib.c	2007-01-30 00:44:13.000000000 +0000
+++ xorg-server-1.1.99.3/hw/kdrive/linux/tslib.c	2007-01-30 21:55:52.000000000 +0000
@@ -47,6 +47,10 @@
 
 #define TSLIB_QUEUE_SIZE 3
 
+/* For XCalibrate extension */
+void (*tslib_raw_event_hook)(int x, int y, int pressure, void *closure);
+void *tslib_raw_event_closure;
+
 struct TslibPrivate {
     int fd;
     int lastx, lasty;
@@ -76,6 +80,19 @@ TsRead (int fd, void *closure)
     unsigned long       flags = 0;
     int                 discard = 0;
 
+    if (tslib_raw_event_hook)
+      {
+	/* XCalibrate Ext */
+	if (ts_read_raw(private->tsDev, &event, 1) == 1)
+	  {
+	    tslib_raw_event_hook (event.x, 
+				  event.y, 
+				  event.pressure, 
+				  tslib_raw_event_closure);
+	  }
+	return;
+      }
+
     if (!private->tsDev) {
         DebugF("[tslib] EXTREME BADNESS: TsRead called while tsDev is null!\n");
         return;
@@ -322,14 +339,14 @@ TsRead (int fd, void *closure)
     }
 }
 
-/* must always be NULL-terminated. */
-char *valid_ts_names[] = {
-    "ADS784x Touchscreen",
-    "omap-ts",
-    "TSC2301 touchscreen",
-    NULL
+static char *TsNames[] = {
+  NULL, 			/* set via TSLIB_TSDEVICE */
+  "/dev/ts",	
+  "/dev/touchscreen/0",
 };
 
+#define NUM_TS_NAMES (sizeof (TsNames) / sizeof (TsNames[0]))
+
 #define TS_NAME_SIZE 32
 
 static Status
@@ -383,11 +400,10 @@ TslibDisable (KdPointerInfo *pi)
     private->tsDev = NULL;
 }
 
-
 static Status
 TslibInit (KdPointerInfo *pi)
 {
-    int		        fd = 0, i = 0;
+    int		        fd = 0, i = 0, j = 0;
     char                devpath[PATH_MAX], devname[TS_NAME_SIZE];
     DIR                 *inputdir = NULL;
     struct dirent       *inputent = NULL;
@@ -397,33 +413,25 @@ TslibInit (KdPointerInfo *pi)
         return !Success;
     
     if (!pi->path || strcmp(pi->path, "auto") == 0) {
-        if (!(inputdir = opendir("/dev/input"))) {
-            ErrorF("[tslib/TslibInit]: couldn't open /dev/input!\n");
-            return BadMatch;
-        }
 
-        while ((inputent = readdir(inputdir))) {
-            if (strncmp(inputent->d_name, "event", 5) != 0)
-                continue;
+        if ((TsNames[0] = getenv("TSLIB_TSDEVICE")) == NULL)
+	  j++;
+      
+	  for (i = j; i < NUM_TS_NAMES; i++)    
+	    {
+              struct tsdev *tsDev;
 
-            snprintf(devpath, PATH_MAX, "/dev/input/%s", inputent->d_name);
-            fd = open(devpath, O_RDWR);
+              if(!(tsDev = ts_open(TsNames[i], 0)))
+                continue;
 
-            if (!ioctl(fd, EVIOCGNAME(sizeof(devname)), devname)) {
-                close(fd);
+              if (ts_config(tsDev))
                 continue;
-            }
-            close(fd);
 
-            for (i = 0; valid_ts_names[i]; i++) {
-                if (strcmp(devname, valid_ts_names[i]) == 0) {
-                    pi->path = KdSaveString(devpath);
-                    break;
-                }
-            }
-        }
-                
-        closedir(inputdir);
+              ts_close(tsDev);
+
+	      pi->path = KdSaveString(TsNames[i]);
+              break;
+	    }
     }
 
     if (!pi->path || strcmp(pi->path, "auto") == 0) {
