diff -u calibrate.orig/Makefile calibrate/Makefile
--- calibrate.orig/Makefile	Wed Jun  5 10:40:10 2002
+++ calibrate/Makefile	Wed Jun  5 10:36:41 2002
@@ -129,7 +129,7 @@
         DEPENDSRC = $(CONFIGSRC)/util
 
           INCROOT = /usr/X11R6/include
-        USRLIBDIR = /usr/X11R6/lib
+        USRLIBDIR = /usr/local/arm/X11R6/lib
         VARLIBDIR = /var/lib
          SHLIBDIR = /usr/X11R6/lib
        LINTLIBDIR = $(USRLIBDIR)/lint
diff -u calibrate.orig/xcalibrate.c calibrate/xcalibrate.c
--- calibrate.orig/xcalibrate.c	Wed Jun  5 10:40:20 2002
+++ calibrate/xcalibrate.c	Wed Jun  5 19:39:26 2002
@@ -13,6 +13,10 @@
  * FITNESS FOR ANY PARTICULAR PURPOSE.
  *
  * Author: Charles Flynn.
+ *
+ * Revision: Sri Subramanian 06/03/2002
+ *           rat701@email.sps.mot.com
+ *           Added support for h38xx iPaq
  */
 
 #define SCANCHAR 1
@@ -64,6 +68,10 @@
 TS_CAL raw_cal={256, 0, 256, 0 };
 static int rate = 50;
 
+/* Sri */
+static int ipaqModel = 3600;
+char * ipaqModelEnv = NULL;
+
 /* Note: ITSY geometry screenW=320, screenH=200; H3600 Width=320 Height=240*/
 #define SCREEN_WIDTH		320
 #define SCREEN_HEIGHT		240
@@ -268,6 +276,7 @@
   int xa[5], ya[5];
   char dummychar;
 
+  FILE* ipaqFd;
 
 #if 0
   /* TODO set what we think is a good calibration*/
@@ -341,6 +350,7 @@
 	    drawPlus(screenCalPos[k].x, screenCalPos[k].y,0);
 	    continue;
 	  }
+
 	  
 	  XUndefineCursor( dpy, w);
 	  XDefineCursor( dpy, w, 
@@ -362,9 +372,13 @@
 	       * ballpark) don't log it.
 	       */
 	      
+/* Sri: Comment out for now */
+
+/*
 	      if(!nearPlus(screenCalPos[k].x, screenCalPos[k].y, ts_ev)) {
 		continue;
 	      }
+*/
 	      
 	      /* accumulate the x coords */
 	      xsum += ts_ev.x;
@@ -537,6 +551,29 @@
 );
 ;
   
+/* Sri */
+
+ipaqModelEnv = getenv("IPAQMODEL");
+
+if (strcmp(ipaqModelEnv, "") == 0) {
+	ipaqFd = fopen("/proc/hal/model", "r");
+        fgets(ipaqModelEnv, 5, ipaqFd);
+}
+
+if ((ipaqModel == 3800) || (ipaqModel == 3850) || 
+		(ipaqModel == 3870)) {
+    new_cal.xscale = -(new_cal.xscale);
+    new_cal.xtrans = -(new_cal.xtrans - SCREEN_WIDTH);
+    new_cal.yscale = -(new_cal.yscale);
+    new_cal.ytrans = -(new_cal.ytrans - SCREEN_HEIGHT);
+} else if (strcmp(ipaqModelEnv, "3800") == 0) {
+    printf("Defaulting to iPaq Model h38xx\n");
+    new_cal.xscale = -(new_cal.xscale);
+    new_cal.xtrans = -(new_cal.xtrans - SCREEN_WIDTH);
+    new_cal.yscale = -(new_cal.yscale);
+    new_cal.ytrans = -(new_cal.ytrans - SCREEN_HEIGHT);
+}
+
   /* store this calibration in the device */
 #if 1
   if (ioctl(fd, TS_SET_CAL, (void *)&new_cal) != 0)
@@ -639,10 +676,13 @@
       sscanf(argv[++k], "%d", &new_cal.ytrans);
       sscanf(argv[++k], "%d", &new_cal.xyswap);
       setCalFlag = 1, calFlag = 0;
+    } else if (!strcmp(argv[k], "-ipaq")) {
+      sscanf(argv[++k], "%d", &ipaqModel);
     }
-    else if (!strncmp(argv[k], "-h", 2)) {
+    else if ( (!strncmp(argv[k], "-h", 2)) || (!strcmp(argv[k], "--help")) ){
       printf("USAGE: tstest <optional arguments>\n");
       printf("  optional args:\n");
+      printf("    -ipaq <model>    iPaq model number Eg., 3800\n");
       printf("    -view            view ts calibrated data\n");
       printf("    -raw             view ts raw (non-calibrated) data\n");
       printf("    -test            show + where screen is pressed\n");
@@ -655,6 +695,7 @@
       printf("       your calibration is already wildly wrong\n");
       exit(0);
     }
+
   }
 
   if( initX() < 0 )
@@ -702,9 +743,56 @@
     while (0<read(0, &dummychar, 1)) {};
 
 #endif
-    make_cursors();
 
-  do_calibration (fd);
+/* Sri */
+   if (setCalFlag == 1) {
+	  if (ioctl(fd, TS_SET_CAL, (void *)&new_cal) != 0)
+	  {
+	   perror("TS_SET_CALIBRATION ioctl fail\n");
+	   return -1;
+	  }
+   /* close session devices */
+   (void) close(fd);
+
+   /* everything OK */
+   return 1;
+	  
+   }
+
+   if (viewFlag == 1) {
+    
+    if (ioctl(fd, TS_GET_CAL, &raw_cal) != 0) {
+        printf("ERROR: TS_GET_CALIBRATION `raw_cal' ioctl fails!\n");
+        return -1;
+    }
+
+    printf("%d %d %d %d %d\n", raw_cal.xscale, raw_cal.xtrans, 
+			raw_cal.yscale, raw_cal.ytrans, raw_cal.xyswap);
+    
+    /* close session devices */
+    (void) close(fd);
+
+    /* everything OK */
+    return 1;
+
+   }
+
+/* end Sri */
+
+/* Sri */
+
+  if (ipaqModel == 3600) {
+	  printf("Assuming iPaq Model is h36xx\n");
+  } else if ((ipaqModel == 3700) || (ipaqModel == 3750)) {
+	  printf("iPaq Model is h37xx\n");
+  } else {
+	  printf("iPaq Model is 38xx\n");
+	  printf("Using alternate calibration technique\n");
+  }
+
+   make_cursors();
+
+   do_calibration (fd);
 
   /* close session devices */
   (void) close(fd);

