tech-kern archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: uep(4)
On Thu, 4 Dec 2008, Nicolas Jouanne wrote:
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 ;
Look real close at the original file. My copy says:
/* $NetBSD: div.c,v 1.7 2003/08/07 16:43:39 agc Exp $ */
...
r.quot = num / denom;
r.rem = num % denom;
Note that the operator in the second line is different than in the first
line. It also makes sense that the "quota" would be the result of a
division, while the "remainder" would be the result of the modulus
operator.
If you're going to copy code, use cut-and-paste instead of manually
retyping it! :)
+ 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
!DSPAM:4937cf85132446204111864!
----------------------------------------------------------------------
| Paul Goyette | PGP DSS Key fingerprint: | E-mail addresses: |
| Customer Service | FA29 0E3B 35AF E8AE 6651 | paul%whooppee.com@localhost |
| Network Engineer | 0786 F758 55DE 53BA 7731 | pgoyette%juniper.net@localhost |
----------------------------------------------------------------------
Home |
Main Index |
Thread Index |
Old Index