Added Vrc4173PIU. (touch panel interface unit on Vrc4173)

This commit is contained in:
takemura 2002-12-15 09:24:24 +00:00
parent 564a7fd556
commit e9628b7102
5 changed files with 55 additions and 19 deletions

View File

@ -1,4 +1,4 @@
# $NetBSD: GENERIC,v 1.133 2002/11/27 07:33:01 shin Exp $
# $NetBSD: GENERIC,v 1.134 2002/12/15 09:24:24 takemura Exp $
#
# GENERIC machine description file
#
@ -24,7 +24,7 @@ include "arch/hpcmips/conf/std.hpcmips.tx39"
options INCLUDE_CONFIG_FILE # embed config file in kernel binary
#ident "GENERIC-$Revision: 1.133 $"
#ident "GENERIC-$Revision: 1.134 $"
maxusers 16
@ -435,6 +435,7 @@ hpcfb* at bivideo0
wsdisplay* at hpcfb?
wskbd* at hpckbd? mux 1
wsmouse* at vrpiu? mux 0
wsmouse* at vrc4173piu? mux 0
wsmouse* at vrdsiu_mouse? mux 0
btnmgr0 at mainbus0
wskbd* at btnmgr0 mux 1
@ -446,7 +447,7 @@ pci* at vrpciu?
# VRC4173
vrc4173bcu* at pci? dev ? function ? # VRC4173 BCU
vrkiu* at vrc4173bcu? addr 0x100 size 0x20 unit VRKIU # VRC4173 KIU
vrpiu* at vrc4173bcu? addr 0x0a0 size 0x20 addr2 0x0c0 size2 0x20 unit VRPIU # VRC4173 PIU
vrc4173piu* at vrc4173bcu? addr 0x0a0 size 0x20 addr2 0x0c0 size2 0x20 unit VRPIU # VRC4173 PIU
#vrc4173cardu* at pci? dev ? function ? # VRC4173 CARDU
#pcmcia* at vrc4173cardu?

View File

@ -1,4 +1,4 @@
# $NetBSD: files.hpcmips,v 1.88 2002/10/26 13:50:28 jdolecek Exp $
# $NetBSD: files.hpcmips,v 1.89 2002/12/15 09:24:25 takemura Exp $
# maxpartitions must be first item in files.${ARCH}.
maxpartitions 8
@ -152,9 +152,12 @@ device vrled
attach vrled at vripif
file arch/hpcmips/vr/vrled.c vrled needs-flag
define vrpiu_common
file arch/hpcmips/vr/vrpiu.c vrpiu_common
device vrpiu: wsmousedev
attach vrpiu at vripif: tpcalib
file arch/hpcmips/vr/vrpiu.c vrpiu
attach vrpiu at vripif: tpcalib, vrpiu_common
device vrc4173piu: wsmousedev
attach vrc4173piu at vripif: tpcalib, vrpiu_common
device vrdsiu_mouse: wsmousedev
attach vrdsiu_mouse at vripif

View File

@ -1,4 +1,4 @@
/* $NetBSD: vrpiu.c,v 1.25 2002/10/02 05:26:56 thorpej Exp $ */
/* $NetBSD: vrpiu.c,v 1.26 2002/12/15 09:24:26 takemura Exp $ */
/*
* Copyright (c) 1999-2002 TAKEMURA Shin All rights reserved.
@ -97,6 +97,8 @@ int vrpiu_debug = 0;
*/
static int vrpiumatch(struct device *, struct cfdata *, void *);
static void vrpiuattach(struct device *, struct device *, void *);
static void vrc4173piuattach(struct device *, struct device *, void *);
static void vrpiu_init(struct vrpiu_softc *, void *);
static void vrpiu_write(struct vrpiu_softc *, int, unsigned short);
static u_short vrpiu_read(struct vrpiu_softc *, int);
@ -130,6 +132,8 @@ int mra_Y_AX1_BX2_C(int *y, int ys, int *x1, int x1s, int *x2, int x2s,
*/
CFATTACH_DECL(vrpiu, sizeof(struct vrpiu_softc),
vrpiumatch, vrpiuattach, NULL, NULL);
CFATTACH_DECL(vrc4173piu, sizeof(struct vrpiu_softc),
vrpiumatch, vrc4173piuattach, NULL, NULL);
const struct wsmouse_accessops vrpiu_accessops = {
vrpiu_tp_enable,
@ -174,6 +178,27 @@ static void
vrpiuattach(struct device *parent, struct device *self, void *aux)
{
struct vrpiu_softc *sc = (struct vrpiu_softc *)self;
sc->sc_ab_paddata_mask = PIUAB_PADDATA_MASK;
sc->sc_pb_paddata_mask = PIUPB_PADDATA_MASK;
sc->sc_pb_paddata_max = PIUPB_PADDATA_MAX;
vrpiu_init(sc, aux);
}
static void
vrc4173piuattach(struct device *parent, struct device *self, void *aux)
{
struct vrpiu_softc *sc = (struct vrpiu_softc *)self;
sc->sc_ab_paddata_mask = VRC4173PIUAB_PADDATA_MASK;
sc->sc_pb_paddata_mask = VRC4173PIUPB_PADDATA_MASK;
sc->sc_pb_paddata_max = VRC4173PIUPB_PADDATA_MAX;
vrpiu_init(sc, aux);
}
static void
vrpiu_init(struct vrpiu_softc *sc, void *aux)
{
struct vrip_attach_args *va = aux;
struct wsmousedev_attach_args wsmaa;
int res;
@ -290,7 +315,7 @@ vrpiuattach(struct device *parent, struct device *self, void *aux)
/*
* attach the wsmouse
*/
sc->sc_wsmousedev = config_found(self, &wsmaa, wsmousedevprint);
sc->sc_wsmousedev = config_found(&sc->sc_dev, &wsmaa, wsmousedevprint);
/*
* power management events
@ -558,7 +583,8 @@ vrpiu_ad_intr(struct vrpiu_softc *sc)
if (intrstat & PIUINT_PADADPINTR) {
for (i = 0; i < 3; i++) {
if (sc->sc_battery.value[i] & PIUAB_VALID)
sc->sc_battery.value[i] &= PIUAB_PADDATA_MASK;
sc->sc_battery.value[i] &=
sc->sc_ab_paddata_mask;
else
sc->sc_battery.value[i] = 0;
}
@ -642,21 +668,21 @@ vrpiu_tp_intr(struct vrpiu_softc *sc)
printf("vrpiu: internal error,"
" data is not valid!\n");
} else {
tpx0 &= PIUPB_PADDATA_MASK;
tpx1 &= PIUPB_PADDATA_MASK;
tpy0 &= PIUPB_PADDATA_MASK;
tpy1 &= PIUPB_PADDATA_MASK;
tpx0 &= sc->sc_pb_paddata_mask;
tpx1 &= sc->sc_pb_paddata_mask;
tpy0 &= sc->sc_pb_paddata_mask;
tpy1 &= sc->sc_pb_paddata_mask;
#define ISVALID(n, c, m) ((c) - (m) < (n) && (n) < (c) + (m))
if (ISVALID(tpx0 + tpx1, 1024, 200) &&
ISVALID(tpy0 + tpy1, 1024, 200)) {
if (ISVALID(tpx0 + tpx1, sc->sc_pb_paddata_max, 200) &&
ISVALID(tpy0 + tpy1, sc->sc_pb_paddata_max, 200)) {
#if 0
DPRINTF(("%04x %04x %04x %04x\n",
tpx0, tpx1, tpy0, tpy1));
DPRINTF(("%3d %3d (%4d %4d)->", tpx0,
tpy0, tpx0 + tpx1, tpy0 + tpy1));
#endif
xraw = tpy1 * 1024 / (tpy0 + tpy1);
yraw = tpx1 * 1024 / (tpx0 + tpx1);
xraw = tpy1 * sc->sc_pb_paddata_max / (tpy0 + tpy1);
yraw = tpx1 * sc->sc_pb_paddata_max / (tpx0 + tpx1);
DPRINTF(("%3d %3d", xraw, yraw));
tpcalib_trans(&sc->sc_tpcalib, xraw,

View File

@ -1,4 +1,4 @@
/* $NetBSD: vrpiureg.h,v 1.3 2002/03/10 10:13:32 takemura Exp $ */
/* $NetBSD: vrpiureg.h,v 1.4 2002/12/15 09:24:26 takemura Exp $ */
/*
* Copyright (c) 1999 Shin Takemura All rights reserved.
@ -150,6 +150,8 @@
#define PIUPB_VALID (1<<15)
#define PIUPB_PADDATA_MASK 0x3FF
#define PIUPB_PADDATA_MAX 0x3FF
#define VRC4173PIUPB_PADDATA_MASK 0xFFF
#define VRC4173PIUPB_PADDATA_MAX 0xFFF
#define PIUAB0_REG_W (PIUB_REG_OFFSSET+0x10) /* PIU A/D scan Buffer 0 reg */
#define PIUAB1_REG_W (PIUB_REG_OFFSSET+0x12) /* PIU A/D scan Buffer 1 reg */
@ -158,3 +160,4 @@
#define PIUAB(n) (PIUAB0_REG_W+(n)*2)
#define PIUAB_VALID (1<<15)
#define PIUAB_PADDATA_MASK 0x3FF
#define VRC4173PIUAB_PADDATA_MASK 0xFFF

View File

@ -1,4 +1,4 @@
/* $NetBSD: vrpiuvar.h,v 1.10 2002/03/10 10:13:32 takemura Exp $ */
/* $NetBSD: vrpiuvar.h,v 1.11 2002/12/15 09:24:26 takemura Exp $ */
/*
* Copyright (c) 1999, 2002 TAKEMURA Shin All rights reserved.
@ -61,4 +61,7 @@ struct vrpiu_softc {
void *sc_power_hook;
struct hpcbattery_values sc_battery;
struct hpcbattery_spec *sc_battery_spec;
int sc_ab_paddata_mask;
int sc_pb_paddata_mask;
int sc_pb_paddata_max;
};