tech-kern archive

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

uep(4)



Hello,

After hesitating a lot, I decided to post a patch a patch for uep(4), in
 case it can help someone else.

My goal was to calibrate a 7" eGalax touchscreen mounted in a eeepc.

--- sys/dev/usb/uep.c.orig      2008-11-09 12:09:41.000000000 +0000
+++ sys/dev/usb/uep.c   2008-11-16 14:19:39.000000000 +0000
@@ -59,6 +59,7 @@
 #include <dev/wscons/tpcalibvar.h>
 
 #define UIDSTR "eGalax USB SN000000"
+#undef UEP_DEBUG
 
 struct uep_softc {
        USBBASEDEVICE sc_dev;
@@ -358,6 +359,22 @@
        return EPASSTHROUGH;
 }
 
+int
+ _div(long int num, long int denom);
+
+int
+ _div(long int num, long int denom)
+{
+        /* /usr/src/lib/libc/stdlib/div.c */
+       long int quot  = num / denom ;
+        long int rem   = num / denom ;
+       if (num >= 0 && rem < 0) {
+               quot++;
+               rem -= denom;
+       }
+        return (int) quot;
+}
+
 void
 uep_intr(usbd_xfer_handle xfer, usbd_private_handle addr, usbd_status status)
 {
@@ -416,6 +433,21 @@
 
                x = (p[3] << 7) | p[4];
                y = (p[1] << 7) | p[2];
+                
+               /* calibration */
+
+#ifdef UEP_DEBUG
+               /* pre-calibration coords */
+               int x_before = x ;
+               int y_before = y ;
+#endif
+
+               x = _div(100*x,293) - 28 ;
+               y = _div(100*(1805-y),349) + 20 ;
+
+#ifdef UEP_DEBUG
+               printf("uep.c : (x,y) : 
[%d->%d,%d->%d].\n",x_before,x,y_before,y);
+#endif
 
                tpcalib_trans(&sc->sc_tpcalib, x, y, &x, &y);
 
-- 
n



Home | Main Index | Thread Index | Old Index