NetBSD-Bugs archive

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

kern/40105: no calibration in uep(4)



>Number:         40105
>Category:       kern
>Synopsis:       no calibration in uep(4)
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    kern-bug-people
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Thu Dec 04 21:00:01 +0000 2008
>Originator:     Jouanne
>Release:        5.99.01
>Organization:
individual
>Environment:
NetBSD plop.localdomain 5.99.01 NetBSD 5.99.01 (5424) #69: Thu Dec  4 21:21:08 
CET 2008  root%plop.localdomain@localhost:/usr/src/sys/arch/i386/compile/5424 
i386

>Description:
uep(4) lacks calibration.
>How-To-Repeat:
n/a
>Fix:
Hard-coded calibration (EeePC 7" touchscreen)

--- /usr/src/sys/dev/usb/uep.c.orig     2008-11-09 12:09:41.000000000 +0000
+++ /usr/src/sys/dev/usb/uep.c  2008-12-04 20:20:47.000000000 +0000
@@ -59,6 +59,16 @@
 #include <dev/wscons/tpcalibvar.h>
 
 #define UIDSTR "eGalax USB SN000000"
+/* calibration - integer values */
+#define X_RATIO   293 
+#define X_OFFSET  -28
+#define Y_RATIO   -348
+#define Y_OFFSET  537
+/* a X_RATIO of ``312''  means : reduce by a factor 3.12 x axis amplitude */
+/* a Y_RATIO of ``-157'' means : reduce by a factor 1.57 y axis amplitude,
+   and revert y motion */
+#undef  UEP_DEBUG
+/* #define UEP_DEBUG 0 */
 
 struct uep_softc {
        USBBASEDEVICE sc_dev;
@@ -368,6 +378,9 @@
 
        usbd_get_xfer_status(xfer, NULL, NULL, &len, NULL);
 
+       /* calibration */
+       int num,denom,quot,rem ;
+
        if (status == USBD_CANCELLED)
                return;
 
@@ -416,6 +429,36 @@
 
                x = (p[3] << 7) | p[4];
                y = (p[1] << 7) | p[2];
+                
+               /* calibration */
+               
+               /* x axis */
+               num   = 100 * x ;
+               denom = X_RATIO ;
+               
+               quot  = num / denom ;
+               rem   = num % denom ;
+               
+               if (num >= 0 && rem < 0)
+                       quot++;
+               
+               x = (int) (quot) + X_OFFSET ;
+               
+               /* y axis */
+               num   = 100 * y ;
+               denom = Y_RATIO ;
+               
+               quot  = num / denom ;
+               rem   = num % denom ;
+               
+               if (num >= 0 && rem < 0)
+                       quot++;
+               
+               y = (int) (quot) + Y_OFFSET ;
+
+#ifdef UEP_DEBUG
+               printf("uep.c : (x,y) : [%d,%d].\n",x,y);
+#endif
 
                tpcalib_trans(&sc->sc_tpcalib, x, y, &x, &y);



Home | Main Index | Thread Index | Old Index