NetBSD-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: kern/40105: no calibration in uep(4)
The following reply was made to PR kern/40105; it has been noted by GNATS.
From: coypu%SDF.ORG@localhost
To: gnats-bugs%netbsd.org@localhost
Cc:
Subject: Re: kern/40105: no calibration in uep(4)
Date: Sun, 4 Dec 2016 16:40:45 +0000
--ReaqsoxgOBHFXBhH
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Hi!
This bug's patch was tested, but unfortunately. not applied.
I've tried to apply the same to HEAD, but encoutnered one change
since: revision 1.16 by mbalmer
Add support for newer eGalax controllers that send 5 ot 6 byte long packets.
The protocol is backwards compatible. While here, unfold a few lines and
remove the link to the documentation, which was invalid.
This enables the touchscreen on the PROTECH PS-3100 MINI POS system.
Attached is a version taking into account the new & msk introduced
by mbalmer in that revision.
What do you think?
--ReaqsoxgOBHFXBhH
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="uep-new.diff"
Index: uep.c
===================================================================
RCS file: /cvsroot/src/sys/dev/usb/uep.c,v
retrieving revision 1.20
diff -u -p -u -r1.20 uep.c
--- uep.c 23 Apr 2016 10:15:32 -0000 1.20
+++ uep.c 4 Dec 2016 15:15:53 -0000
@@ -54,6 +54,14 @@ __KERNEL_RCSID(0, "$NetBSD: uep.c,v 1.20
#include <dev/wscons/tpcalibvar.h>
#define UIDSTR "eGalax USB SN000000"
+/* calibration - integer values, perhaps sysctls? */
+#define X_RATIO 293
+#define X_OFFSET -28
+#define Y_RATIO -348
+#define Y_OFFSET 537
+/* an X_RATIO of ``312'' means : reduce by a factor 3.12 x axis amplitude */
+/* an Y_RATIO of ``-157'' means : reduce by a factor 1.57 y axis amplitude,
+ * and reverse y motion */
struct uep_softc {
device_t sc_dev;
@@ -358,6 +366,17 @@ uep_ioctl(void *v, u_long cmd, void *dat
return EPASSTHROUGH;
}
+static int
+uep_adjust(int v, int off, int rat)
+{
+ int num = 100 * v;
+ int quot = num / rat;
+ int rem = num % rat;
+ if (num >= 0 && rem < 0)
+ quot++;
+ return quot + off;
+}
+
void
uep_intr(struct usbd_xfer *xfer, void *addr, usbd_status status)
{
@@ -429,8 +448,8 @@ uep_intr(struct usbd_xfer *xfer, void *a
default:
msk = 0x0f; /* H=0, L=0 */
}
- x = ((p[3] & msk) << 7) | p[4];
- y = ((p[1] & msk) << 7) | p[2];
+ x = uep_adjust(((p[3] & msk) << 7) | p[4], X_OFFSET, X_RATIO);
+ y = uep_adjust(((p[1] & msk) << 7) | p[2], Y_OFFSET, Y_RATIO);
tpcalib_trans(&sc->sc_tpcalib, x, y, &x, &y);
--ReaqsoxgOBHFXBhH--
Home |
Main Index |
Thread Index |
Old Index