Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev Add tpcalib, touch panel calibration to ims(4)
details: https://anonhg.NetBSD.org/src/rev/94eda0edff67
branches: trunk
changeset: 461799:94eda0edff67
user: ryoon <ryoon%NetBSD.org@localhost>
date: Tue Jul 09 12:52:51 2019 +0000
description:
Add tpcalib, touch panel calibration to ims(4)
Suggested by ryo@ at Japan NetBSD Users' Group BOF 2019-07-06.
diffstat:
sys/dev/hid/hidms.c | 5 +++--
sys/dev/hid/hidms.h | 6 +++++-
sys/dev/i2c/ims.c | 33 +++++++++++++++++++++++++++++++--
3 files changed, 39 insertions(+), 5 deletions(-)
diffs (121 lines):
diff -r 0b60f6df8d53 -r 94eda0edff67 sys/dev/hid/hidms.c
--- a/sys/dev/hid/hidms.c Tue Jul 09 12:17:13 2019 +0000
+++ b/sys/dev/hid/hidms.c Tue Jul 09 12:52:51 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: hidms.c,v 1.2 2018/05/25 15:52:45 ryoon Exp $ */
+/* $NetBSD: hidms.c,v 1.3 2019/07/09 12:52:51 ryoon Exp $ */
/*
* Copyright (c) 1998, 2017 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: hidms.c,v 1.2 2018/05/25 15:52:45 ryoon Exp $");
+__KERNEL_RCSID(0, "$NetBSD: hidms.c,v 1.3 2019/07/09 12:52:51 ryoon Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -267,6 +267,7 @@
if (ms->flags & HIDMS_ABS) {
flags |= (WSMOUSE_INPUT_ABSOLUTE_X | WSMOUSE_INPUT_ABSOLUTE_Y);
dy = hid_get_data(ibuf, &ms->hidms_loc_y);
+ tpcalib_trans(&ms->sc_tpcalib, dx, dy, &dx, &dy);
} else
dy = -hid_get_data(ibuf, &ms->hidms_loc_y);
dz = hid_get_data(ibuf, &ms->hidms_loc_z);
diff -r 0b60f6df8d53 -r 94eda0edff67 sys/dev/hid/hidms.h
--- a/sys/dev/hid/hidms.h Tue Jul 09 12:17:13 2019 +0000
+++ b/sys/dev/hid/hidms.h Tue Jul 09 12:52:51 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: hidms.h,v 1.1 2017/12/10 17:03:07 bouyer Exp $ */
+/* $NetBSD: hidms.h,v 1.2 2019/07/09 12:52:51 ryoon Exp $ */
/*
* Copyright (c) 1998, 2017 The NetBSD Foundation, Inc.
@@ -32,6 +32,7 @@
#include <dev/wscons/wsconsio.h>
#include <dev/wscons/wsmousevar.h>
+#include <dev/wscons/tpcalibvar.h>
#define MAX_BUTTONS 31 /* must not exceed size of sc_buttons */
@@ -55,6 +56,9 @@
uint32_t hidms_buttons; /* mouse button status */
device_t hidms_wsmousedev;
+
+ struct tpcalib_softc sc_tpcalib; /* calibration */
+ struct wsmouse_calibcoords sc_calibcoords;
};
bool hidms_setup(device_t, struct hidms *, int, void *, int);
diff -r 0b60f6df8d53 -r 94eda0edff67 sys/dev/i2c/ims.c
--- a/sys/dev/i2c/ims.c Tue Jul 09 12:17:13 2019 +0000
+++ b/sys/dev/i2c/ims.c Tue Jul 09 12:52:51 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ims.c,v 1.1 2017/12/10 17:05:54 bouyer Exp $ */
+/* $NetBSD: ims.c,v 1.2 2019/07/09 12:52:51 ryoon Exp $ */
/* $OpenBSD ims.c,v 1.1 2016/01/12 01:11:15 jcs Exp $ */
/*
@@ -20,7 +20,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ims.c,v 1.1 2017/12/10 17:05:54 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ims.c,v 1.2 2019/07/09 12:52:51 ryoon Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -92,6 +92,8 @@
struct ihidev_attach_arg *iha = (struct ihidev_attach_arg *)aux;
int size, repid;
void *desc;
+ struct hid_data * d __debugused;
+ struct hid_item item __debugused;
sc->sc_hdev.sc_idev = self;
sc->sc_hdev.sc_intr = ims_intr;
@@ -110,6 +112,30 @@
if (!hidms_setup(self, ms, iha->reportid, desc, size) != 0)
return;
+#if defined(DEBUG)
+ /* calibrate the touchscreen */
+ memset(&sc->sc_ms.sc_calibcoords, 0, sizeof(sc->sc_ms.sc_calibcoords));
+ d = hid_start_parse(desc, size, hid_input);
+ if (d != NULL) {
+ while (hid_get_item(d, &item)) {
+ if (item.kind != hid_input
+ || HID_GET_USAGE_PAGE(item.usage) != HUP_GENERIC_DESKTOP
+ || item.report_ID != sc->sc_hdev.sc_report_id)
+ continue;
+ if (HID_GET_USAGE(item.usage) == HUG_X) {
+ aprint_normal("X range: %d - %d\n", item.logical_minimum, item.logical_maximum);
+ }
+ if (HID_GET_USAGE(item.usage) == HUG_Y) {
+ aprint_normal("Y range: %d - %d\n", item.logical_minimum, item.logical_maximum);
+ }
+ }
+ hid_end_parse(d);
+ }
+#endif
+ tpcalib_init(&sc->sc_ms.sc_tpcalib);
+ tpcalib_ioctl(&sc->sc_ms.sc_tpcalib, WSMOUSEIO_SCALIBCOORDS,
+ (void *)&sc->sc_ms.sc_calibcoords, 0, 0);
+
hidms_attach(self, ms, &ims_accessops);
}
@@ -199,6 +225,9 @@
*(u_int *)data = WSMOUSE_TYPE_USB;
}
return 0;
+ case WSMOUSEIO_SCALIBCOORDS:
+ case WSMOUSEIO_GCALIBCOORDS:
+ return tpcalib_ioctl(&sc->sc_ms.sc_tpcalib, cmd, data, flag, l);
}
return EPASSTHROUGH;
}
Home |
Main Index |
Thread Index |
Old Index