tech-kern archive

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

Re: uep(4)



On Thu, Dec 04, 2008 at 02:14:35PM +0700, Robert Elz wrote:
|     Date:        Thu, 4 Dec 2008 07:02:49 +0100
|     From:        Nicolas Jouanne <nicolas.jouanne%free.fr@localhost>
|     Message-ID:  <20081204060249.GA677%plop.localdomain@localhost>
| 
|   | _div() is a copy/paste from /usr/src/lib/libc/stdlib/div.c
| 
| No, it isn't - you need to look at that one much more carefully.
 
I changed ``long int`` to ``int'' below in _div(), in order to comply with 
div_t struct as defined in /usr/src/include/stdlib.h

--- /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 12:17:45.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(int num, int denom);
+
+int
+ _div(int num, int denom)
+{
+        /* /usr/src/lib/libc/stdlib/div.c */
+       int quot  = num / denom ;
+        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);
 

| kre

-- 
n



Home | Main Index | Thread Index | Old Index