Module Name: src
Committed By: christos
Date: Tue Jan 17 03:49:20 UTC 2012
Modified Files:
src/lib/libusbhid: usb_hid_usages
src/share/man/man4: Makefile wsmouse.4
src/sys/arch/amd64/conf: GENERIC
src/sys/dev/usb: FILES files.usb usbdevices.config usbhid.h
Added Files:
src/share/man/man4: uts.4
src/sys/dev/usb: uts.c
Log Message:
PR/45850: Pierre Pronchery: USB multi-touch panels are not supported
To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/lib/libusbhid/usb_hid_usages
cvs rdiff -u -r1.577 -r1.578 src/share/man/man4/Makefile
cvs rdiff -u -r0 -r1.1 src/share/man/man4/uts.4
cvs rdiff -u -r1.18 -r1.19 src/share/man/man4/wsmouse.4
cvs rdiff -u -r1.345 -r1.346 src/sys/arch/amd64/conf/GENERIC
cvs rdiff -u -r1.11 -r1.12 src/sys/dev/usb/FILES \
src/sys/dev/usb/usbdevices.config
cvs rdiff -u -r1.118 -r1.119 src/sys/dev/usb/files.usb
cvs rdiff -u -r1.13 -r1.14 src/sys/dev/usb/usbhid.h
cvs rdiff -u -r0 -r1.1 src/sys/dev/usb/uts.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/lib/libusbhid/usb_hid_usages
diff -u src/lib/libusbhid/usb_hid_usages:1.4 src/lib/libusbhid/usb_hid_usages:1.5
--- src/lib/libusbhid/usb_hid_usages:1.4 Fri Jul 10 18:11:58 2009
+++ src/lib/libusbhid/usb_hid_usages Mon Jan 16 22:49:20 2012
@@ -1,4 +1,4 @@
-# $NetBSD: usb_hid_usages,v 1.4 2009/07/10 22:11:58 jakllsch Exp $
+# $NetBSD: usb_hid_usages,v 1.5 2012/01/17 03:49:20 christos Exp $
#
# USB HID usage table
# Syntax:
@@ -858,6 +858,10 @@
0x44 Barrel Switch
0x45 Eraser
0x46 Tablet Pick
+ 0x51 Contact ID
+ 0x53 Device Index
+ 0x54 Contact Count
+ 0x55 Contact Count Maximum
15 Physical Interface Device
Index: src/share/man/man4/Makefile
diff -u src/share/man/man4/Makefile:1.577 src/share/man/man4/Makefile:1.578
--- src/share/man/man4/Makefile:1.577 Mon Jan 9 10:16:31 2012
+++ src/share/man/man4/Makefile Mon Jan 16 22:49:19 2012
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.577 2012/01/09 15:16:31 drochner Exp $
+# $NetBSD: Makefile,v 1.578 2012/01/17 03:49:19 christos Exp $
# @(#)Makefile 8.1 (Berkeley) 6/18/93
MAN= aac.4 ac97.4 acardide.4 aceride.4 acphy.4 \
@@ -70,14 +70,14 @@ MAN= aac.4 ac97.4 acardide.4 aceride.4 a
zero.4 zstty.4 zyd.4
# USB devices
-MAN+= stuirda.4 u3g.4 uaudio.4 uberry.4 ubsa.4 ubt.4 uchcom.4 ucom.4 ucycom.4 \
- udsbr.4 uftdi.4 ugen.4 ugensa.4 uhid.4 \
+MAN+= atu.4 aue.4 axe.4 cdce.4 cue.4 ehci.4 kue.4 ohci.4 slhci.4 \
+ stuirda.4 u3g.4 uaudio.4 uberry.4 ubsa.4 ubt.4 uchcom.4 ucom.4 \
+ ucycom.4 udav.4 udsbr.4 uftdi.4 ugen.4 ugensa.4 uhci.4 uhid.4 \
uhidev.4 uhmodem.4 uhso.4 uipaq.4 uirda.4 ukbd.4 ukyopon.4 ulpt.4 \
- umass.4 umct.4 umidi.4 umodem.4 ums.4 uplcom.4 urio.4 usb.4 \
- uscanner.4 uslsa.4 usscanner.4 ustir.4 uvisor.4 uvscom.4 uyap.4 \
- aue.4 atu.4 axe.4 cdce.4 cue.4 kue.4 upgt.4 upl.4 url.4 udav.4 \
- ehci.4 ohci.4 slhci.4 uhci.4 uthum.4 utoppy.4 uvideo.4 uyurex.4 \
- urndis.4
+ umass.4 umct.4 umidi.4 umodem.4 ums.4 upgt.4 upl.4 uplcom.4 \
+ urio.4 url.4 urndis.4 usb.4 uscanner.4 uslsa.4 usscanner.4 \
+ ustir.4 uthum.4 utoppy.4 uts.4 uvideo.4 uvisor.4 uvscom.4 uyap.4 \
+ uyurex.4
# Ir devices
MAN+= irframe.4 cir.4 irframetty.4 oboe.4
Index: src/share/man/man4/wsmouse.4
diff -u src/share/man/man4/wsmouse.4:1.18 src/share/man/man4/wsmouse.4:1.19
--- src/share/man/man4/wsmouse.4:1.18 Mon Mar 9 15:24:28 2009
+++ src/share/man/man4/wsmouse.4 Mon Jan 16 22:49:19 2012
@@ -1,4 +1,4 @@
-.\" $NetBSD: wsmouse.4,v 1.18 2009/03/09 19:24:28 joerg Exp $
+.\" $NetBSD: wsmouse.4,v 1.19 2012/01/17 03:49:19 christos Exp $
.\"
.\" Copyright (c) 1999
.\" Matthias Drochner. All rights reserved.
@@ -38,6 +38,8 @@
(PS/2 mouse, including ``IntelliMouse''-compatible wheel mice)
.Cd "wsmouse* at ums? mux 0"
(USB mouse)
+.Cd "wsmouse* at uts? mux 0"
+(USB touchscreen)
.Cd "wsmouse* at lms? mux 0"
(Logitech bus mouse, i386 only)
.Cd "wsmouse* at mms? mux 0"
@@ -124,6 +126,7 @@ above for more details.
.Xr pms 4 ,
.Xr uep 4 ,
.Xr ums 4 ,
+.Xr uts 4 ,
.Xr wscons 4 ,
.Xr wsmux 4 ,
.Xr moused 8 ,
Index: src/sys/arch/amd64/conf/GENERIC
diff -u src/sys/arch/amd64/conf/GENERIC:1.345 src/sys/arch/amd64/conf/GENERIC:1.346
--- src/sys/arch/amd64/conf/GENERIC:1.345 Mon Jan 16 09:44:07 2012
+++ src/sys/arch/amd64/conf/GENERIC Mon Jan 16 22:49:19 2012
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC,v 1.345 2012/01/16 14:44:07 jmcneill Exp $
+# $NetBSD: GENERIC,v 1.346 2012/01/17 03:49:19 christos Exp $
#
# GENERIC machine description file
#
@@ -22,10 +22,15 @@ include "arch/amd64/conf/std.amd64"
options INCLUDE_CONFIG_FILE # embed config file in kernel binary
-#ident "GENERIC-$Revision: 1.345 $"
+#ident "GENERIC-$Revision: 1.346 $"
maxusers 64 # estimated number of users
+# Common binary formats are statically compiled in by default.
+options EXEC_ELF32 # exec ELF 32-bits binaries
+#no options EXEC_ELF64 # exec ELF 64-bits binaries
+#no options EXEC_SCRIPT # exec #! scripts
+
# delay between "rebooting ..." message and hardware reset, in milliseconds
#options CPURESET_DELAY=2000
@@ -67,6 +72,8 @@ options SYSVMSG # System V-like messag
options SYSVSEM # System V-like semaphores
options SYSVSHM # System V-like memory sharing
options P1003_1B_SEMAPHORE # p1003.1b semaphore support
+#no options EXEC_ELF64 # exec ELF 64-bits binaries
+#no options EXEC_SCRIPT # exec #! scripts
options MODULAR # new style module(7) framework
options USERCONF # userconf(4) support
@@ -117,11 +124,10 @@ options COMPAT_50 # NetBSD 5.0 compatib
options COMPAT_43 # and 4.3BSD
#options COMPAT_386BSD_MBRPART # recognize old partition ID
-options COMPAT_OSSAUDIO
+#options COMPAT_OSSAUDIO
options COMPAT_NETBSD32
-options COMPAT_LINUX
-options COMPAT_LINUX32 # req. COMPAT_LINUX and COMPAT_NETBSD32
-options EXEC_ELF32
+#options COMPAT_LINUX
+#options COMPAT_LINUX32 # req. COMPAT_LINUX and COMPAT_NETBSD32
options COMPAT_BSDPTY # /dev/[pt]ty?? ptys.
# Wedge support
@@ -135,22 +141,23 @@ file-system FFS # UFS
file-system MFS # memory file system
file-system NFS # Network File System client
file-system TMPFS # Efficient memory file-system
-file-system EXT2FS # second extended file system (linux)
-file-system LFS # log-structured file system
-file-system NTFS # Windows/NT file system (experimental)
-file-system CD9660 # ISO 9660 + Rock Ridge file system
-file-system MSDOSFS # MS-DOS file system
-file-system FDESC # /dev/fd
-file-system KERNFS # /kern
-file-system NULLFS # loopback file system
-file-system OVERLAY # overlay file system
-file-system PROCFS # /proc
-file-system PUFFS # Userspace file systems (e.g. ntfs-3g & sshfs)
-file-system SMBFS # experimental - CIFS; also needs nsmb (below)
-file-system UMAPFS # NULLFS + uid and gid remapping
-file-system UNION # union file system
-file-system CODA # Coda File System; also needs vcoda (below)
-file-system PTYFS # /dev/ptm support
+# File systems, built as module(7)s by default
+#file-system EXT2FS # second extended file system (linux)
+#file-system LFS # log-structured file system
+#file-system NTFS # Windows/NT file system (experimental)
+#file-system CD9660 # ISO 9660 + Rock Ridge file system
+#file-system MSDOSFS # MS-DOS file system
+#file-system FDESC # /dev/fd
+#file-system KERNFS # /kern
+#file-system NULLFS # loopback file system
+#file-system OVERLAY # overlay file system
+#file-system PROCFS # /proc
+#file-system PUFFS # Userspace file systems (e.g. ntfs-3g & sshfs)
+#file-system SMBFS # experimental - CIFS; also needs nsmb (below)
+#file-system UMAPFS # NULLFS + uid and gid remapping
+#file-system UNION # union file system
+#file-system CODA # Coda File System; also needs vcoda (below)
+#file-system PTYFS # /dev/ptm support
#file-system UDF # experimental - OSTA UDF CD/DVD file-system
#file-system HFS # experimental - Apple HFS+ (read-only)
#file-system NILFS # experimental - NTT's NiLFS(2)
@@ -382,15 +389,19 @@ attimer0 at isa?
pcppi0 at isa?
sysbeep0 at pcppi?
-# DRI driver
-i915drm* at drm? # Intel i915, i945 DRM driver
-mach64drm* at drm? # mach64 (3D Rage Pro, Rage) DRM driver
-mgadrm* at drm? # Matrox G[24]00, G[45]50 DRM driver
-r128drm* at drm? # ATI Rage 128 DRM driver
-radeondrm* at drm? # ATI Radeon DRM driver
-savagedrm* at drm? # S3 Savage DRM driver
-sisdrm* at drm? # SiS DRM driver
-tdfxdrm* at drm? # 3dfx (voodoo) DRM driver
+# Legacy DRI driver
+#i915drm* at drm? # Intel i915, i945 DRM driver
+#mach64drm* at drm? # mach64 (3D Rage Pro, Rage) DRM driver
+#mgadrm* at drm? # Matrox G[24]00, G[45]50 DRM driver
+#r128drm* at drm? # ATI Rage 128 DRM driver
+#radeondrm* at drm? # ATI Radeon DRM driver
+#savagedrm* at drm? # S3 Savage DRM driver
+#sisdrm* at drm? # SiS DRM driver
+#tdfxdrm* at drm? # 3dfx (voodoo) DRM driver
+
+# New DRM/GEM driver ported from OpenBSD (Intel only)
+inteldrm* at drm?
+drmdev* at inteldrm?
# Cryptographic Devices
@@ -831,6 +842,10 @@ uhidev* at uhub? port ? configuration ?
ums* at uhidev? reportid ?
wsmouse* at ums? mux 0
+# USB Touchscreens
+uts* at uhidev? reportid ?
+wsmouse* at uts? mux 0
+
# USB eGalax touch-panel
uep* at uhub? port ?
wsmouse* at uep? mux 0
@@ -1188,9 +1203,9 @@ pseudo-device bridge # simple inter-ne
pseudo-device agr # IEEE 802.3ad link aggregation
#
-# accept filters
-pseudo-device accf_data # "dataready" accept filter
-pseudo-device accf_http # "httpready" accept filter
+# accept filters, built as module(7)s by default
+#pseudo-device accf_data # "dataready" accept filter
+#pseudo-device accf_http # "httpready" accept filter
# miscellaneous pseudo-devices
pseudo-device pty # pseudo-terminals
@@ -1206,7 +1221,7 @@ pseudo-device bcsp # BlueCore Serial P
pseudo-device btuart # Bluetooth HCI UART (H4)
# a pseudo device needed for Coda # also needs CODA (above)
-pseudo-device vcoda 4 # coda minicache <-> venus comm.
+#pseudo-device vcoda 4 # coda minicache <-> venus comm.
# a pseudo device needed for SMBFS
pseudo-device nsmb # experimental - SMB requester
Index: src/sys/dev/usb/FILES
diff -u src/sys/dev/usb/FILES:1.11 src/sys/dev/usb/FILES:1.12
--- src/sys/dev/usb/FILES:1.11 Wed Nov 3 23:14:54 2010
+++ src/sys/dev/usb/FILES Mon Jan 16 22:49:20 2012
@@ -80,6 +80,7 @@ usbdivar.h internal defines and structu
uscanner.c minimal USB scanner driver
usscanner.c driver for some SCSI-over-USB scanners
usbhid.h USB HID class definitions
+uts.c USB touchscreen driver
uvisor.c USB Handsping Visor driver
uyap.c Initial firmware downloader for Y@P phones
uyap_firmware.h Firmware for the Y@P phone
Index: src/sys/dev/usb/usbdevices.config
diff -u src/sys/dev/usb/usbdevices.config:1.11 src/sys/dev/usb/usbdevices.config:1.12
--- src/sys/dev/usb/usbdevices.config:1.11 Sat Dec 31 10:01:06 2011
+++ src/sys/dev/usb/usbdevices.config Mon Jan 16 22:49:20 2012
@@ -1,4 +1,4 @@
-# $NetBSD: usbdevices.config,v 1.11 2011/12/31 15:01:06 jakllsch Exp $
+# $NetBSD: usbdevices.config,v 1.12 2012/01/17 03:49:20 christos Exp $
#
# This file contains all USB related configuration.
# It is suitable for inclusion in a kernel config(5) file.
@@ -37,6 +37,10 @@ uhidev* at uhub? port ? configuration ?
ums* at uhidev? reportid ?
wsmouse* at ums? mux 0
+# USB Touchscreens
+uts* at uhidev? reportid ?
+wsmouse* at uts? mux 0
+
# USB Keyboards
ukbd* at uhidev? reportid ?
wskbd* at ukbd? console ? mux 1
Index: src/sys/dev/usb/files.usb
diff -u src/sys/dev/usb/files.usb:1.118 src/sys/dev/usb/files.usb:1.119
--- src/sys/dev/usb/files.usb:1.118 Sat Jan 14 16:06:01 2012
+++ src/sys/dev/usb/files.usb Mon Jan 16 22:49:20 2012
@@ -1,4 +1,4 @@
-# $NetBSD: files.usb,v 1.118 2012/01/14 21:06:01 jakllsch Exp $
+# $NetBSD: files.usb,v 1.119 2012/01/17 03:49:20 christos Exp $
#
# Config file and device description for machine-independent USB code.
# Included by ports that need it. Ports that use it must provide
@@ -91,6 +91,11 @@ device ums: hid, wsmousedev
attach ums at uhidbus
file dev/usb/ums.c ums
+# Touchscreens
+device uts: hid, wsmousedev
+attach uts at uhidbus
+file dev/usb/uts.c uts
+
# eGalax USB Touch Panel
device uep: wsmousedev, tpcalib
attach uep at usbdevif
Index: src/sys/dev/usb/usbhid.h
diff -u src/sys/dev/usb/usbhid.h:1.13 src/sys/dev/usb/usbhid.h:1.14
--- src/sys/dev/usb/usbhid.h:1.13 Mon Apr 28 16:24:01 2008
+++ src/sys/dev/usb/usbhid.h Mon Jan 16 22:49:20 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: usbhid.h,v 1.13 2008/04/28 20:24:01 martin Exp $ */
+/* $NetBSD: usbhid.h,v 1.14 2012/01/17 03:49:20 christos Exp $ */
/* $FreeBSD: src/sys/dev/usb/usbhid.h,v 1.7 1999/11/17 22:33:51 n_hibma Exp $ */
/*
@@ -133,6 +133,8 @@ typedef struct usb_hid_descriptor {
/* Usages Digitizers */
#define HUD_UNDEFINED 0x0000
+#define HUD_TOUCH_SCREEN 0x0004
+#define HUD_FINGER 0x0022
#define HUD_TIP_PRESSURE 0x0030
#define HUD_BARREL_PRESSURE 0x0031
#define HUD_IN_RANGE 0x0032
Added files:
Index: src/share/man/man4/uts.4
diff -u /dev/null src/share/man/man4/uts.4:1.1
--- /dev/null Mon Jan 16 22:49:20 2012
+++ src/share/man/man4/uts.4 Mon Jan 16 22:49:19 2012
@@ -0,0 +1,64 @@
+.\" $NetBSD: uts.4,v 1.1 2012/01/17 03:49:19 christos Exp $
+.\"
+.\" Copyright (c) 2012 The NetBSD Foundation, Inc.
+.\" All rights reserved.
+.\"
+.\" This code is derived from software contributed to The NetBSD Foundation
+.\" by Pierre Pronchery.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+.\" POSSIBILITY OF SUCH DAMAGE.
+.\"
+.Dd January 16, 2012
+.Dt UTS 4
+.Os
+.Sh NAME
+.Nm uts
+.Nd USB generic touchscreens
+.Sh SYNOPSIS
+.Cd "uts* at uhidev? reportid ?"
+.Cd "wsmouse* at uts?"
+.Sh DESCRIPTION
+The
+.Nm
+driver provides support for USB touchscreens, otherwise known as Touch
+Digitizer devices.
+Access to panel events is through the
+.Xr wsmouse 4
+driver.
+.Sh SEE ALSO
+.Xr uhidev 4 ,
+.Xr wsmouse 4
+.Sh HISTORY
+The
+.Nm
+driver was written by Pierre Pronchery for
+.Nx .
+The
+.Nm
+driver appeared in
+.Nx 6.0 .
+.Sh BUGS
+.Nm
+currently does not support calibration.
+Also, not all
+.Nx Ns -supplied
+X servers support the absolute position events it generates.
Index: src/sys/dev/usb/uts.c
diff -u /dev/null src/sys/dev/usb/uts.c:1.1
--- /dev/null Mon Jan 16 22:49:20 2012
+++ src/sys/dev/usb/uts.c Mon Jan 16 22:49:20 2012
@@ -0,0 +1,387 @@
+/* $NetBSD: uts.c,v 1.1 2012/01/17 03:49:20 christos Exp $ */
+
+/*
+ * Copyright (c) 2012 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Pierre Pronchery ([email protected]).
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * USB generic Touch Screen driver.
+ */
+
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: uts.c,v 1.1 2012/01/17 03:49:20 christos Exp $");
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/malloc.h>
+#include <sys/device.h>
+#include <sys/ioctl.h>
+#include <sys/vnode.h>
+
+#include <dev/usb/usb.h>
+#include <dev/usb/usbhid.h>
+
+#include <dev/usb/usbdi.h>
+#include <dev/usb/usbdi_util.h>
+#include <dev/usb/usbdevs.h>
+#include <dev/usb/usb_quirks.h>
+#include <dev/usb/uhidev.h>
+#include <dev/usb/hid.h>
+
+#include <dev/wscons/wsconsio.h>
+#include <dev/wscons/wsmousevar.h>
+#include <dev/wscons/tpcalibvar.h>
+
+#ifdef USB_DEBUG
+#define DPRINTF(x) if (utsdebug) printf x
+#define DPRINTFN(n,x) if (utsdebug>(n)) printf x
+int utsdebug = 0;
+#else
+#define DPRINTF(x)
+#define DPRINTFN(n,x)
+#endif
+
+
+struct uts_softc {
+ struct uhidev sc_hdev;
+
+ struct hid_location sc_loc_x, sc_loc_y, sc_loc_z;
+ struct hid_location sc_loc_btn;
+
+ int sc_enabled;
+
+ int flags; /* device configuration */
+#define UTS_ABS 0x1 /* absolute position */
+
+ u_int32_t sc_buttons; /* touchscreen button status */
+ device_t sc_wsmousedev;
+ struct tpcalib_softc sc_tpcalib; /* calibration */
+ struct wsmouse_calibcoords sc_calibcoords;
+
+ char sc_dying;
+};
+
+#define TSCREEN_FLAGS_MASK (HIO_CONST|HIO_RELATIVE)
+
+Static void uts_intr(struct uhidev *addr, void *ibuf, u_int len);
+
+Static int uts_enable(void *);
+Static void uts_disable(void *);
+Static int uts_ioctl(void *, u_long, void *, int, struct lwp *);
+
+Static const struct wsmouse_accessops uts_accessops = {
+ uts_enable,
+ uts_ioctl,
+ uts_disable,
+};
+
+Static int uts_match(device_t, cfdata_t, void *);
+Static void uts_attach(device_t, device_t, void *);
+Static void uts_childdet(device_t, device_t);
+Static int uts_detach(device_t, int);
+Static int uts_activate(device_t, enum devact);
+
+extern struct cfdriver uts_cd;
+
+CFATTACH_DECL2_NEW(uts, sizeof(struct uts_softc), uts_match, uts_attach,
+ uts_detach, uts_activate, NULL, uts_childdet);
+
+Static int
+uts_match(device_t parent, cfdata_t match, void *aux)
+{
+ struct uhidev_attach_arg *uha = aux;
+ int size;
+ void *desc;
+
+ uhidev_get_report_desc(uha->parent, &desc, &size);
+ if (!hid_is_collection(desc, size, uha->reportid,
+ HID_USAGE2(HUP_DIGITIZERS, HUD_TOUCH_SCREEN)) &&
+ !hid_is_collection(desc, size, uha->reportid,
+ HID_USAGE2(HUP_DIGITIZERS, HUD_FINGER)))
+ return UMATCH_NONE;
+
+ return UMATCH_IFACECLASS;
+}
+
+Static void
+uts_attach(device_t parent, device_t self, void *aux)
+{
+ struct uts_softc *sc = device_private(self);
+ struct uhidev_attach_arg *uha = aux;
+ struct wsmousedev_attach_args a;
+ int size;
+ void *desc;
+ u_int32_t flags;
+ struct hid_data * d;
+ struct hid_item item;
+
+ aprint_naive("\n");
+
+ sc->sc_hdev.sc_dev = self;
+ sc->sc_hdev.sc_intr = uts_intr;
+ sc->sc_hdev.sc_parent = uha->parent;
+ sc->sc_hdev.sc_report_id = uha->reportid;
+
+ uhidev_get_report_desc(uha->parent, &desc, &size);
+
+ if (!pmf_device_register(self, NULL, NULL))
+ aprint_error_dev(self, "couldn't establish power handler\n");
+
+ /* requires HID usage Generic_Desktop:X */
+ if (!hid_locate(desc, size, HID_USAGE2(HUP_GENERIC_DESKTOP, HUG_X),
+ uha->reportid, hid_input, &sc->sc_loc_x, &flags)) {
+ aprint_error_dev(sc->sc_hdev.sc_dev,
+ "touchscreen has no X report\n");
+ return;
+ }
+ switch (flags & TSCREEN_FLAGS_MASK) {
+ case 0:
+ sc->flags |= UTS_ABS;
+ break;
+ case HIO_RELATIVE:
+ break;
+ default:
+ aprint_error_dev(sc->sc_hdev.sc_dev,
+ "X report 0x%04x not supported\n", flags);
+ return;
+ }
+
+ /* requires HID usage Generic_Desktop:Y */
+ if (!hid_locate(desc, size, HID_USAGE2(HUP_GENERIC_DESKTOP, HUG_Y),
+ uha->reportid, hid_input, &sc->sc_loc_y, &flags)) {
+ aprint_error_dev(sc->sc_hdev.sc_dev,
+ "touchscreen has no Y report\n");
+ return;
+ }
+ switch (flags & TSCREEN_FLAGS_MASK) {
+ case 0:
+ sc->flags |= UTS_ABS;
+ break;
+ case HIO_RELATIVE:
+ break;
+ default:
+ aprint_error_dev(sc->sc_hdev.sc_dev,
+ "Y report 0x%04x not supported\n", flags);
+ return;
+ }
+
+ /* requires HID usage Digitizer:Tip_Switch */
+ if (!hid_locate(desc, size, HID_USAGE2(HUP_DIGITIZERS, HUD_TIP_SWITCH),
+ uha->reportid, hid_input, &sc->sc_loc_btn, 0)) {
+ aprint_error_dev(sc->sc_hdev.sc_dev,
+ "touchscreen has no tip switch report\n");
+ return;
+ }
+
+ /* requires HID usage Digitizer:In_Range */
+ if (!hid_locate(desc, size, HID_USAGE2(HUP_DIGITIZERS, HUD_IN_RANGE),
+ uha->reportid, hid_input, &sc->sc_loc_z, &flags)) {
+ aprint_error_dev(sc->sc_hdev.sc_dev,
+ "touchscreen has no range report\n");
+ return;
+ }
+
+ /* multi-touch support would need HUD_CONTACTID and HUD_CONTACTMAX */
+
+#ifdef USB_DEBUG
+ DPRINTF(("uts_attach: sc=%p\n", sc));
+ DPRINTF(("uts_attach: X\t%d/%d\n",
+ sc->sc_loc_x.pos, sc->sc_loc_x.size));
+ DPRINTF(("uts_attach: Y\t%d/%d\n",
+ sc->sc_loc_y.pos, sc->sc_loc_y.size));
+ DPRINTF(("uts_attach: Z\t%d/%d\n",
+ sc->sc_loc_z.pos, sc->sc_loc_z.size));
+#endif
+
+ a.accessops = &uts_accessops;
+ a.accesscookie = sc;
+
+ sc->sc_wsmousedev = config_found(self, &a, wsmousedevprint);
+
+ /* calibrate the touchscreen */
+ memset(&sc->sc_calibcoords, 0, sizeof(sc->sc_calibcoords));
+ sc->sc_calibcoords.maxx = 4095;
+ sc->sc_calibcoords.maxy = 4095;
+ sc->sc_calibcoords.samplelen = WSMOUSE_CALIBCOORDS_RESET;
+ d = hid_start_parse(desc, size, hid_input);
+ 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) {
+ sc->sc_calibcoords.minx = item.logical_minimum;
+ sc->sc_calibcoords.maxx = item.logical_maximum;
+ }
+ if (HID_GET_USAGE(item.usage) == HUG_Y) {
+ sc->sc_calibcoords.miny = item.logical_minimum;
+ sc->sc_calibcoords.maxy = item.logical_maximum;
+ }
+ }
+ hid_end_parse(d);
+
+ tpcalib_init(&sc->sc_tpcalib);
+ tpcalib_ioctl(&sc->sc_tpcalib, WSMOUSEIO_SCALIBCOORDS,
+ (void *)&sc->sc_calibcoords, 0, 0);
+
+ return;
+}
+
+Static int
+uts_detach(device_t self, int flags)
+{
+ struct uts_softc *sc = device_private(self);
+ int rv = 0;
+
+ DPRINTF(("uts_detach: sc=%p flags=%d\n", sc, flags));
+
+ if (sc->sc_wsmousedev != NULL)
+ rv = config_detach(sc->sc_wsmousedev, flags);
+
+ pmf_device_deregister(self);
+
+ return rv;
+}
+
+Static void
+uts_childdet(device_t self, device_t child)
+{
+ struct uts_softc *sc = device_private(self);
+
+ KASSERT(sc->sc_wsmousedev == child);
+ sc->sc_wsmousedev = NULL;
+}
+
+Static int
+uts_activate(device_t self, enum devact act)
+{
+ struct uts_softc *sc = device_private(self);
+
+ switch (act) {
+ case DVACT_DEACTIVATE:
+ sc->sc_dying = 1;
+ return 0;
+ default:
+ return EOPNOTSUPP;
+ }
+}
+
+Static int
+uts_enable(void *v)
+{
+ struct uts_softc *sc = v;
+
+ DPRINTFN(1,("uts_enable: sc=%p\n", sc));
+
+ if (sc->sc_dying)
+ return EIO;
+
+ if (sc->sc_enabled)
+ return EBUSY;
+
+ sc->sc_enabled = 1;
+ sc->sc_buttons = 0;
+
+ return uhidev_open(&sc->sc_hdev);
+}
+
+Static void
+uts_disable(void *v)
+{
+ struct uts_softc *sc = v;
+
+ DPRINTFN(1,("uts_disable: sc=%p\n", sc));
+#ifdef DIAGNOSTIC
+ if (!sc->sc_enabled) {
+ printf("uts_disable: not enabled\n");
+ return;
+ }
+#endif
+
+ sc->sc_enabled = 0;
+ uhidev_close(&sc->sc_hdev);
+}
+
+Static int
+uts_ioctl(void *v, u_long cmd, void *data, int flag, struct lwp *l)
+{
+ struct uts_softc *sc = v;
+
+ switch (cmd) {
+ case WSMOUSEIO_GTYPE:
+ if (sc->flags & UTS_ABS)
+ *(u_int *)data = WSMOUSE_TYPE_TPANEL;
+ else
+ *(u_int *)data = WSMOUSE_TYPE_USB;
+ return 0;
+ case WSMOUSEIO_SCALIBCOORDS:
+ case WSMOUSEIO_GCALIBCOORDS:
+ return tpcalib_ioctl(&sc->sc_tpcalib, cmd, data, flag, l);
+ }
+
+ return EPASSTHROUGH;
+}
+
+Static void
+uts_intr(struct uhidev *addr, void *ibuf, u_int len)
+{
+ struct uts_softc *sc = (struct uts_softc *)addr;
+ int dx, dy, dz;
+ u_int32_t buttons = 0;
+ int flags, s;
+
+ DPRINTFN(5,("uts_intr: len=%d\n", len));
+
+ flags = WSMOUSE_INPUT_DELTA | WSMOUSE_INPUT_ABSOLUTE_Z;
+
+ dx = hid_get_data(ibuf, &sc->sc_loc_x);
+ if (sc->flags & UTS_ABS) {
+ flags |= (WSMOUSE_INPUT_ABSOLUTE_X | WSMOUSE_INPUT_ABSOLUTE_Y);
+ dy = hid_get_data(ibuf, &sc->sc_loc_y);
+ tpcalib_trans(&sc->sc_tpcalib, dx, dy, &dx, &dy);
+ } else
+ dy = -hid_get_data(ibuf, &sc->sc_loc_y);
+
+ dz = hid_get_data(ibuf, &sc->sc_loc_z);
+
+ if (hid_get_data(ibuf, &sc->sc_loc_btn))
+ buttons |= 1;
+
+ if (dx != 0 || dy != 0 || dz != 0 || buttons != sc->sc_buttons) {
+ DPRINTFN(10,("uts_intr: x:%d y:%d z:%d buttons:0x%x\n",
+ dx, dy, dz, buttons));
+ sc->sc_buttons = buttons;
+ if (sc->sc_wsmousedev != NULL) {
+ s = spltty();
+ wsmouse_input(sc->sc_wsmousedev, buttons, dx, dy, dz, 0,
+ flags);
+ splx(s);
+ }
+ }
+}