tech-kern archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
uep(4) : PR opened
Hello,
The patch below has been submitted via PR `kern/40105'.
On Thu, Dec 04, 2008 at 09:47:47PM +0100, Nicolas Jouanne wrote:
> - ``/'' typo corrected,
> - no more _div(),
> - use of #define directives to handle calibration values,
> - debug mode only prints current (x,y) values.
>
> --- /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);
>
> --
> n
>
> On Wed, Dec 03, 2008 at 09:37:12PM +0100, Nicolas Jouanne wrote:
> > 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
>
> --
> n
--
n
Home |
Main Index |
Thread Index |
Old Index