Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-7-nhusb]: src/sys/dev/usb revision 1.21
details: https://anonhg.NetBSD.org/src/rev/ebacbcb2c091
branches: netbsd-7-nhusb
changeset: 801050:ebacbcb2c091
user: skrll <skrll%NetBSD.org@localhost>
date: Fri Mar 31 10:30:58 2017 +0000
description:
revision 1.21
uep: allow (hard-coded) calibration.
>From Nicolas Jouanne in PR kern/40105
ok skrll
diffstat:
sys/dev/usb/uep.c | 27 +++++++++++++++++++++++----
1 files changed, 23 insertions(+), 4 deletions(-)
diffs (62 lines):
diff -r 771d67a3f53a -r ebacbcb2c091 sys/dev/usb/uep.c
--- a/sys/dev/usb/uep.c Fri Mar 31 10:28:21 2017 +0000
+++ b/sys/dev/usb/uep.c Fri Mar 31 10:30:58 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: uep.c,v 1.19.10.1 2016/09/06 20:33:09 skrll Exp $ */
+/* $NetBSD: uep.c,v 1.19.10.2 2017/03/31 10:30:58 skrll Exp $ */
/*
* Copyright (c) 2004 The NetBSD Foundation, Inc.
@@ -33,7 +33,7 @@
* eGalax USB touchpanel controller driver.
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uep.c,v 1.19.10.1 2016/09/06 20:33:09 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uep.c,v 1.19.10.2 2017/03/31 10:30:58 skrll Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -54,6 +54,14 @@
#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 @@
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 @@
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);
Home |
Main Index |
Thread Index |
Old Index