2001-02-22 21:37:54 +03:00
|
|
|
/* $NetBSD: vrpiu.c,v 1.11 2001/02/22 18:38:05 uch Exp $ */
|
1999-12-28 06:15:16 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (c) 1999 Shin Takemura All rights reserved.
|
2000-12-02 11:35:45 +03:00
|
|
|
* Copyright (c) 2000 SATO Kazumi, All rights reserved.
|
|
|
|
* Copyright (c) 1999,2000 PocketBSD Project. All rights reserved.
|
1999-12-28 06:15:16 +03:00
|
|
|
*
|
|
|
|
* 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 REGENTS 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 REGENTS 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.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2000-12-02 11:35:45 +03:00
|
|
|
/*
|
|
|
|
* A/D polling part written by SATO Kazumi.
|
|
|
|
*/
|
|
|
|
|
1999-12-28 06:15:16 +03:00
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/device.h>
|
|
|
|
#include <sys/kernel.h>
|
2000-12-02 11:35:45 +03:00
|
|
|
#include <sys/callout.h>
|
|
|
|
#include <sys/boot_flag.h>
|
1999-12-28 06:15:16 +03:00
|
|
|
|
|
|
|
#include <dev/wscons/wsconsio.h>
|
|
|
|
#include <dev/wscons/wsmousevar.h>
|
|
|
|
|
|
|
|
#include <machine/bus.h>
|
2000-06-13 09:59:55 +04:00
|
|
|
#include <machine/platid.h>
|
|
|
|
#include <machine/platid_mask.h>
|
2000-12-02 11:35:45 +03:00
|
|
|
#include <machine/config_hook.h>
|
1999-12-28 06:15:16 +03:00
|
|
|
|
2001-02-22 21:37:54 +03:00
|
|
|
#include <dev/hpc/tpcalibvar.h>
|
2000-12-02 11:35:45 +03:00
|
|
|
|
2001-02-22 21:37:54 +03:00
|
|
|
#include <hpcmips/hpcmips/machdep.h>
|
1999-12-28 06:15:16 +03:00
|
|
|
#include <hpcmips/vr/vripvar.h>
|
|
|
|
#include <hpcmips/vr/cmureg.h>
|
|
|
|
#include <hpcmips/vr/vrpiuvar.h>
|
|
|
|
#include <hpcmips/vr/vrpiureg.h>
|
|
|
|
|
|
|
|
/*
|
|
|
|
* contant and macro definitions
|
|
|
|
*/
|
|
|
|
#define VRPIUDEBUG
|
|
|
|
#ifdef VRPIUDEBUG
|
|
|
|
int vrpiu_debug = 0;
|
|
|
|
#define DPRINTF(arg) if (vrpiu_debug) printf arg;
|
2000-12-02 11:35:45 +03:00
|
|
|
#define VPRINTF(arg) if (bootverbose || vrpiu_debug) printf arg;
|
1999-12-28 06:15:16 +03:00
|
|
|
#else
|
|
|
|
#define DPRINTF(arg)
|
2000-12-02 11:35:45 +03:00
|
|
|
#define VPRINTF(arg) if (bootverbose) printf arg;
|
1999-12-28 06:15:16 +03:00
|
|
|
#endif
|
|
|
|
|
2000-12-02 11:35:45 +03:00
|
|
|
#ifndef VRPIU_AD_POLL_INTERVAL
|
|
|
|
#define VRPIU_AD_POLL_INTERVAL 60 /* interval is 60 sec */
|
|
|
|
#endif /* VRPIU_AD_POLL_INTERTVAL */
|
2001-01-08 12:50:08 +03:00
|
|
|
|
|
|
|
#define PIUSIVL_SCANINTVAL_MIN 333 /* 10msec */
|
|
|
|
#define PIUSIVL_SCANINTVAL_MAX PIUSIVL_SCANINTVAL_MASK /* 60msec */
|
2001-01-21 08:00:28 +03:00
|
|
|
#define VRPIU_TP_SCAN_TIMEOUT (hz/10) /* timeout is 100msec */
|
2001-01-08 12:50:08 +03:00
|
|
|
|
|
|
|
#define TP_INTR (PIUINT_ALLINTR & ~PIUINT_PADADPINTR)
|
|
|
|
#define AD_INTR (PIUINT_PADADPINTR)
|
|
|
|
|
1999-12-28 06:15:16 +03:00
|
|
|
/*
|
|
|
|
* data types
|
|
|
|
*/
|
|
|
|
/* struct vrpiu_softc is defined in vrpiuvar.h */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* function prototypes
|
|
|
|
*/
|
|
|
|
static int vrpiumatch __P((struct device *, struct cfdata *, void *));
|
|
|
|
static void vrpiuattach __P((struct device *, struct device *, void *));
|
|
|
|
|
|
|
|
static void vrpiu_write __P((struct vrpiu_softc *, int, unsigned short));
|
|
|
|
static u_short vrpiu_read __P((struct vrpiu_softc *, int));
|
|
|
|
|
|
|
|
static int vrpiu_intr __P((void *));
|
2000-12-02 11:35:45 +03:00
|
|
|
static void vrpiu_tp_intr __P((struct vrpiu_softc *));
|
|
|
|
static void vrpiu_ad_intr __P((struct vrpiu_softc *));
|
1999-12-28 06:15:16 +03:00
|
|
|
#ifdef DEBUG
|
|
|
|
static void vrpiu_dump_cntreg __P((unsigned int cmd));
|
|
|
|
#endif
|
|
|
|
|
2000-12-02 11:35:45 +03:00
|
|
|
static int vrpiu_tp_enable __P((void *));
|
|
|
|
static int vrpiu_tp_ioctl __P((void *, u_long, caddr_t, int, struct proc *));
|
|
|
|
static void vrpiu_tp_disable __P((void *));
|
2001-01-21 08:00:28 +03:00
|
|
|
static void vrpiu_tp_up __P((struct vrpiu_softc *));
|
|
|
|
static void vrpiu_tp_timeout __P((void *));
|
2000-12-02 11:35:45 +03:00
|
|
|
int vrpiu_ad_enable __P((void *));
|
|
|
|
void vrpiu_ad_disable __P((void *));
|
|
|
|
static void vrpiu_start_powerstate __P((void *));
|
|
|
|
static void vrpiu_calc_powerstate __P((struct vrpiu_softc *));
|
|
|
|
static void vrpiu_power __P((int, void *));
|
2001-01-08 12:50:08 +03:00
|
|
|
static u_int scan_interval __P((u_int data));
|
1999-12-28 06:15:16 +03:00
|
|
|
|
|
|
|
/* mra is defined in mra.c */
|
|
|
|
int mra_Y_AX1_BX2_C __P((int *y, int ys, int *x1, int x1s, int *x2, int x2s,
|
|
|
|
int n, int scale, int *a, int *b, int *c));
|
|
|
|
|
|
|
|
/*
|
|
|
|
* static or global variables
|
|
|
|
*/
|
|
|
|
struct cfattach vrpiu_ca = {
|
|
|
|
sizeof(struct vrpiu_softc), vrpiumatch, vrpiuattach
|
|
|
|
};
|
|
|
|
|
|
|
|
const struct wsmouse_accessops vrpiu_accessops = {
|
2000-12-02 11:35:45 +03:00
|
|
|
vrpiu_tp_enable,
|
|
|
|
vrpiu_tp_ioctl,
|
|
|
|
vrpiu_tp_disable,
|
1999-12-28 06:15:16 +03:00
|
|
|
};
|
|
|
|
|
2000-12-02 11:35:45 +03:00
|
|
|
int vrpiu_ad_poll_interval = VRPIU_AD_POLL_INTERVAL;
|
|
|
|
|
1999-12-28 06:15:16 +03:00
|
|
|
/*
|
|
|
|
* function definitions
|
|
|
|
*/
|
|
|
|
static inline void
|
|
|
|
vrpiu_write(sc, port, val)
|
|
|
|
struct vrpiu_softc *sc;
|
|
|
|
int port;
|
|
|
|
unsigned short val;
|
|
|
|
{
|
|
|
|
bus_space_write_2(sc->sc_iot, sc->sc_ioh, port, val);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline u_short
|
|
|
|
vrpiu_read(sc, port)
|
|
|
|
struct vrpiu_softc *sc;
|
|
|
|
int port;
|
|
|
|
{
|
|
|
|
return bus_space_read_2(sc->sc_iot, sc->sc_ioh, port);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
vrpiumatch(parent, cf, aux)
|
|
|
|
struct device *parent;
|
|
|
|
struct cfdata *cf;
|
|
|
|
void *aux;
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
vrpiuattach(parent, self, aux)
|
|
|
|
struct device *parent;
|
|
|
|
struct device *self;
|
|
|
|
void *aux;
|
|
|
|
{
|
|
|
|
struct vrpiu_softc *sc = (struct vrpiu_softc *)self;
|
|
|
|
struct vrip_attach_args *va = aux;
|
|
|
|
struct wsmousedev_attach_args wsmaa;
|
|
|
|
|
|
|
|
bus_space_tag_t iot = va->va_iot;
|
|
|
|
bus_space_handle_t ioh;
|
|
|
|
|
|
|
|
if (bus_space_map(iot, va->va_addr, 1, 0, &ioh)) {
|
2001-01-20 15:24:22 +03:00
|
|
|
printf(": can't map bus space\n");
|
|
|
|
return;
|
1999-12-28 06:15:16 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
sc->sc_iot = iot;
|
|
|
|
sc->sc_ioh = ioh;
|
|
|
|
sc->sc_vrip = va->va_vc;
|
|
|
|
|
2001-01-08 12:50:08 +03:00
|
|
|
sc->sc_interval = scan_interval(WSMOUSE_RES_DEFAULT);
|
|
|
|
|
1999-12-28 06:15:16 +03:00
|
|
|
/*
|
|
|
|
* disable device until vrpiu_enable called
|
|
|
|
*/
|
2000-12-02 11:35:45 +03:00
|
|
|
sc->sc_tpstat = VRPIU_TP_STAT_DISABLE;
|
1999-12-28 06:15:16 +03:00
|
|
|
|
2001-01-21 08:00:28 +03:00
|
|
|
/* initialize touch panel timeout structure */
|
|
|
|
callout_init(&sc->sc_tptimeout);
|
|
|
|
|
|
|
|
/* initialize calibration context */
|
2000-01-10 17:07:58 +03:00
|
|
|
tpcalib_init(&sc->sc_tpcalib);
|
1999-12-28 06:15:16 +03:00
|
|
|
#if 1
|
|
|
|
/*
|
|
|
|
* XXX, calibrate parameters
|
|
|
|
*/
|
|
|
|
{
|
2001-01-20 15:24:22 +03:00
|
|
|
int i;
|
|
|
|
static const struct {
|
|
|
|
platid_mask_t *mask;
|
|
|
|
struct wsmouse_calibcoords coords;
|
|
|
|
} calibrations[] = {
|
|
|
|
{ &platid_mask_MACH_NEC_MCR_700A,
|
|
|
|
{ 0, 0, 799, 599,
|
|
|
|
4,
|
|
|
|
{ { 115, 80, 0, 0 },
|
|
|
|
{ 115, 966, 0, 599 },
|
|
|
|
{ 912, 80, 799, 0 },
|
|
|
|
{ 912, 966, 799, 599 } } } },
|
|
|
|
|
|
|
|
{ NULL, /* samples got on my MC-R500 */
|
|
|
|
{ 0, 0, 639, 239,
|
|
|
|
5,
|
|
|
|
{ { 502, 486, 320, 120 },
|
|
|
|
{ 55, 109, 0, 0 },
|
|
|
|
{ 54, 913, 0, 239 },
|
|
|
|
{ 973, 924, 639, 239 },
|
|
|
|
{ 975, 123, 639, 0 } } } },
|
|
|
|
};
|
|
|
|
for (i = 0; ; i++) {
|
|
|
|
if (calibrations[i].mask == NULL
|
|
|
|
|| platid_match(&platid, calibrations[i].mask))
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
tpcalib_ioctl(&sc->sc_tpcalib, WSMOUSEIO_SCALIBCOORDS,
|
|
|
|
(caddr_t)&calibrations[i].coords, 0, 0);
|
1999-12-28 06:15:16 +03:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* install interrupt handler and enable interrupt */
|
|
|
|
if (!(sc->sc_handler =
|
2001-01-20 15:24:22 +03:00
|
|
|
vrip_intr_establish(va->va_vc, va->va_intr, IPL_TTY,
|
|
|
|
vrpiu_intr, sc))) {
|
|
|
|
printf (": can't map interrupt line.\n");
|
|
|
|
return;
|
1999-12-28 06:15:16 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/* mask level2 interrupt, stop scan sequencer and mask clock to piu */
|
2000-12-02 11:35:45 +03:00
|
|
|
vrpiu_tp_disable(sc);
|
1999-12-28 06:15:16 +03:00
|
|
|
|
|
|
|
printf("\n");
|
|
|
|
|
|
|
|
wsmaa.accessops = &vrpiu_accessops;
|
|
|
|
wsmaa.accesscookie = sc;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* attach the wsmouse
|
|
|
|
*/
|
|
|
|
sc->sc_wsmousedev = config_found(self, &wsmaa, wsmousedevprint);
|
2000-12-02 11:35:45 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* power management events
|
|
|
|
*/
|
|
|
|
sc->sc_power_hook = powerhook_establish(vrpiu_power, sc);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* init A/D port polling.
|
|
|
|
*/
|
|
|
|
sc->sc_battery.n_values = 3;
|
|
|
|
sc->sc_battery.value[0] = -1;
|
|
|
|
sc->sc_battery.value[1] = -1;
|
|
|
|
sc->sc_battery.value[2] = -1;
|
|
|
|
sc->sc_battery.nextpoll = hz*vrpiu_ad_poll_interval;
|
|
|
|
callout_init(&sc->sc_adpoll);
|
2001-01-20 15:24:22 +03:00
|
|
|
callout_reset(&sc->sc_adpoll, hz, vrpiu_start_powerstate, sc);
|
1999-12-28 06:15:16 +03:00
|
|
|
}
|
|
|
|
|
2001-01-08 12:50:08 +03:00
|
|
|
/*
|
|
|
|
* calculate interval value
|
|
|
|
* input: WSMOUSE_RES_MIN - WSMOUSE_RES_MAX
|
|
|
|
* output: value for PIUSIVL_REG
|
|
|
|
*/
|
|
|
|
static u_int
|
|
|
|
scan_interval(u_int data)
|
|
|
|
{
|
|
|
|
int scale;
|
|
|
|
|
|
|
|
if (data < WSMOUSE_RES_MIN)
|
2001-01-20 15:24:22 +03:00
|
|
|
data = WSMOUSE_RES_MIN;
|
2001-01-08 12:50:08 +03:00
|
|
|
|
|
|
|
if (WSMOUSE_RES_MAX < data)
|
2001-01-20 15:24:22 +03:00
|
|
|
data = WSMOUSE_RES_MAX;
|
2001-01-08 12:50:08 +03:00
|
|
|
|
|
|
|
scale = WSMOUSE_RES_MAX - WSMOUSE_RES_MIN;
|
|
|
|
data += WSMOUSE_RES_MIN;
|
|
|
|
|
|
|
|
return PIUSIVL_SCANINTVAL_MIN +
|
|
|
|
(PIUSIVL_SCANINTVAL_MAX - PIUSIVL_SCANINTVAL_MIN) *
|
|
|
|
(scale - data) / scale;
|
|
|
|
}
|
|
|
|
|
1999-12-28 06:15:16 +03:00
|
|
|
int
|
2000-12-02 11:35:45 +03:00
|
|
|
vrpiu_ad_enable(v)
|
1999-12-28 06:15:16 +03:00
|
|
|
void *v;
|
|
|
|
{
|
|
|
|
struct vrpiu_softc *sc = v;
|
|
|
|
int s;
|
|
|
|
unsigned int cnt;
|
|
|
|
|
2001-01-08 12:50:08 +03:00
|
|
|
DPRINTF(("%s(%d): vrpiu_ad_enable(): interval=0x%03x\n",
|
2001-01-20 15:24:22 +03:00
|
|
|
__FILE__, __LINE__, sc->sc_interval));
|
2000-12-02 11:35:45 +03:00
|
|
|
if (sc->sc_adstat != VRPIU_AD_STAT_DISABLE)
|
2001-01-20 15:24:22 +03:00
|
|
|
return EBUSY;
|
1999-12-28 06:15:16 +03:00
|
|
|
|
|
|
|
/* supply clock to PIU */
|
|
|
|
__vrcmu_supply(CMUMSKPIU, 1);
|
|
|
|
|
2001-01-08 12:50:08 +03:00
|
|
|
/* set scan interval */
|
|
|
|
vrpiu_write(sc, PIUSIVL_REG_W, sc->sc_interval);
|
1999-12-28 06:15:16 +03:00
|
|
|
|
|
|
|
s = spltty();
|
|
|
|
|
|
|
|
/* clear interrupt status */
|
2001-01-08 12:50:08 +03:00
|
|
|
vrpiu_write(sc, PIUINT_REG_W, AD_INTR);
|
1999-12-28 06:15:16 +03:00
|
|
|
|
|
|
|
/* Disable -> Standby */
|
|
|
|
cnt = PIUCNT_PIUPWR |
|
|
|
|
PIUCNT_PIUMODE_COORDINATE |
|
|
|
|
PIUCNT_PADATSTART | PIUCNT_PADATSTOP;
|
|
|
|
vrpiu_write(sc, PIUCNT_REG_W, cnt);
|
|
|
|
|
2000-12-02 11:35:45 +03:00
|
|
|
/* Level2 interrupt register setting */
|
2001-01-08 12:50:08 +03:00
|
|
|
vrip_intr_setmask2(sc->sc_vrip, sc->sc_handler, AD_INTR, 1);
|
2000-12-02 11:35:45 +03:00
|
|
|
|
1999-12-28 06:15:16 +03:00
|
|
|
/* save pen status, touch or release */
|
|
|
|
cnt = vrpiu_read(sc, PIUCNT_REG_W);
|
|
|
|
|
2000-12-02 11:35:45 +03:00
|
|
|
/*
|
|
|
|
* Enable scan sequencer operation
|
|
|
|
* Standby -> WaitPenTouch
|
|
|
|
*/
|
|
|
|
cnt |= PIUCNT_PIUSEQEN;
|
|
|
|
vrpiu_write(sc, PIUCNT_REG_W, cnt);
|
|
|
|
|
|
|
|
sc->sc_adstat = VRPIU_AD_STAT_ENABLE;
|
|
|
|
|
|
|
|
splx(s);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
vrpiu_ad_disable(v)
|
|
|
|
void *v;
|
|
|
|
{
|
|
|
|
struct vrpiu_softc *sc = v;
|
|
|
|
|
|
|
|
DPRINTF(("%s(%d): vrpiu_ad_disable()\n", __FILE__, __LINE__));
|
|
|
|
|
|
|
|
/* Set level2 interrupt register to mask interrupts */
|
2001-01-08 12:50:08 +03:00
|
|
|
vrip_intr_setmask2(sc->sc_vrip, sc->sc_handler, AD_INTR, 0);
|
2000-12-02 11:35:45 +03:00
|
|
|
|
|
|
|
sc->sc_adstat = VRPIU_AD_STAT_DISABLE;
|
|
|
|
|
|
|
|
if (sc->sc_tpstat == VRPIU_TP_STAT_DISABLE){
|
2001-01-20 15:24:22 +03:00
|
|
|
/* Disable scan sequencer operation and power off */
|
|
|
|
vrpiu_write(sc, PIUCNT_REG_W, 0);
|
2000-12-02 11:35:45 +03:00
|
|
|
|
2001-01-20 15:24:22 +03:00
|
|
|
/* mask clock to PIU */
|
|
|
|
__vrcmu_supply(CMUMSKPIU, 1);
|
2000-12-02 11:35:45 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
vrpiu_tp_enable(v)
|
|
|
|
void *v;
|
|
|
|
{
|
|
|
|
struct vrpiu_softc *sc = v;
|
|
|
|
int s;
|
|
|
|
unsigned int cnt;
|
|
|
|
|
2001-01-08 12:50:08 +03:00
|
|
|
DPRINTF(("%s(%d): vrpiu_tp_enable(): interval=0x%03x\n",
|
2001-01-20 15:24:22 +03:00
|
|
|
__FILE__, __LINE__, sc->sc_interval));
|
2000-12-02 11:35:45 +03:00
|
|
|
if (sc->sc_tpstat != VRPIU_TP_STAT_DISABLE)
|
2001-01-20 15:24:22 +03:00
|
|
|
return EBUSY;
|
2000-12-02 11:35:45 +03:00
|
|
|
|
|
|
|
/* supply clock to PIU */
|
|
|
|
__vrcmu_supply(CMUMSKPIU, 1);
|
|
|
|
|
2001-01-08 12:50:08 +03:00
|
|
|
/* set scan interval */
|
|
|
|
vrpiu_write(sc, PIUSIVL_REG_W, sc->sc_interval);
|
2000-12-02 11:35:45 +03:00
|
|
|
|
|
|
|
s = spltty();
|
|
|
|
|
|
|
|
/* clear interrupt status */
|
2001-01-08 12:50:08 +03:00
|
|
|
vrpiu_write(sc, PIUINT_REG_W, TP_INTR);
|
2000-12-02 11:35:45 +03:00
|
|
|
|
|
|
|
/* Disable -> Standby */
|
|
|
|
cnt = PIUCNT_PIUPWR |
|
|
|
|
PIUCNT_PIUMODE_COORDINATE |
|
|
|
|
PIUCNT_PADATSTART | PIUCNT_PADATSTOP;
|
|
|
|
vrpiu_write(sc, PIUCNT_REG_W, cnt);
|
|
|
|
|
1999-12-28 06:15:16 +03:00
|
|
|
/* Level2 interrupt register setting */
|
2001-01-08 12:50:08 +03:00
|
|
|
vrip_intr_setmask2(sc->sc_vrip, sc->sc_handler, TP_INTR, 1);
|
2000-12-02 11:35:45 +03:00
|
|
|
|
|
|
|
/* save pen status, touch or release */
|
|
|
|
cnt = vrpiu_read(sc, PIUCNT_REG_W);
|
1999-12-28 06:15:16 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Enable scan sequencer operation
|
|
|
|
* Standby -> WaitPenTouch
|
|
|
|
*/
|
|
|
|
cnt |= PIUCNT_PIUSEQEN;
|
|
|
|
vrpiu_write(sc, PIUCNT_REG_W, cnt);
|
|
|
|
|
|
|
|
/* transit status DISABLE -> TOUCH or RELEASE */
|
2000-12-02 11:35:45 +03:00
|
|
|
sc->sc_tpstat = (cnt & PIUCNT_PENSTC) ?
|
|
|
|
VRPIU_TP_STAT_TOUCH : VRPIU_TP_STAT_RELEASE;
|
1999-12-28 06:15:16 +03:00
|
|
|
|
|
|
|
splx(s);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2000-12-02 11:35:45 +03:00
|
|
|
vrpiu_tp_disable(v)
|
1999-12-28 06:15:16 +03:00
|
|
|
void *v;
|
|
|
|
{
|
|
|
|
struct vrpiu_softc *sc = v;
|
|
|
|
|
2000-12-02 11:35:45 +03:00
|
|
|
DPRINTF(("%s(%d): vrpiu_tp_disable()\n", __FILE__, __LINE__));
|
1999-12-28 06:15:16 +03:00
|
|
|
|
|
|
|
/* Set level2 interrupt register to mask interrupts */
|
2001-01-08 12:50:08 +03:00
|
|
|
vrip_intr_setmask2(sc->sc_vrip, sc->sc_handler, TP_INTR, 0);
|
1999-12-28 06:15:16 +03:00
|
|
|
|
2000-12-02 11:35:45 +03:00
|
|
|
sc->sc_tpstat = VRPIU_TP_STAT_DISABLE;
|
1999-12-28 06:15:16 +03:00
|
|
|
|
2000-12-02 11:35:45 +03:00
|
|
|
if (sc->sc_adstat == VRPIU_AD_STAT_DISABLE){
|
2001-01-20 15:24:22 +03:00
|
|
|
/* Disable scan sequencer operation and power off */
|
|
|
|
vrpiu_write(sc, PIUCNT_REG_W, 0);
|
1999-12-28 06:15:16 +03:00
|
|
|
|
2001-01-20 15:24:22 +03:00
|
|
|
/* mask clock to PIU */
|
|
|
|
__vrcmu_supply(CMUMSKPIU, 1);
|
2000-12-02 11:35:45 +03:00
|
|
|
}
|
1999-12-28 06:15:16 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2000-12-02 11:35:45 +03:00
|
|
|
vrpiu_tp_ioctl(v, cmd, data, flag, p)
|
1999-12-28 06:15:16 +03:00
|
|
|
void *v;
|
|
|
|
u_long cmd;
|
|
|
|
caddr_t data;
|
|
|
|
int flag;
|
|
|
|
struct proc *p;
|
|
|
|
{
|
|
|
|
struct vrpiu_softc *sc = v;
|
|
|
|
|
2000-12-02 11:35:45 +03:00
|
|
|
DPRINTF(("%s(%d): vrpiu_tp_ioctl(%08lx)\n", __FILE__, __LINE__, cmd));
|
1999-12-28 06:15:16 +03:00
|
|
|
|
|
|
|
switch (cmd) {
|
|
|
|
case WSMOUSEIO_GTYPE:
|
2001-01-20 15:24:22 +03:00
|
|
|
*(u_int *)data = WSMOUSE_TYPE_TPANEL;
|
|
|
|
break;
|
1999-12-28 06:15:16 +03:00
|
|
|
|
|
|
|
case WSMOUSEIO_SRES:
|
2001-01-08 12:50:08 +03:00
|
|
|
{
|
|
|
|
int tp_enable;
|
|
|
|
int ad_enable;
|
|
|
|
|
|
|
|
tp_enable = (sc->sc_tpstat != VRPIU_TP_STAT_DISABLE);
|
|
|
|
ad_enable = (sc->sc_adstat != VRPIU_AD_STAT_DISABLE);
|
|
|
|
|
|
|
|
if (tp_enable)
|
2001-01-20 15:24:22 +03:00
|
|
|
vrpiu_tp_disable(sc);
|
2001-01-08 12:50:08 +03:00
|
|
|
if (ad_enable)
|
2001-01-20 15:24:22 +03:00
|
|
|
vrpiu_ad_disable(sc);
|
2001-01-08 12:50:08 +03:00
|
|
|
|
|
|
|
sc->sc_interval = scan_interval(*(u_int *)data);
|
|
|
|
DPRINTF(("%s(%d): WSMOUSEIO_SRES: *data=%d, interval=0x%03x\n",
|
|
|
|
__FILE__, __LINE__, *(u_int *)data, sc->sc_interval));
|
|
|
|
|
|
|
|
if (sc->sc_interval < PIUSIVL_SCANINTVAL_MIN)
|
2001-01-20 15:24:22 +03:00
|
|
|
sc->sc_interval = PIUSIVL_SCANINTVAL_MIN;
|
2001-01-08 12:50:08 +03:00
|
|
|
|
|
|
|
if (PIUSIVL_SCANINTVAL_MAX < sc->sc_interval)
|
2001-01-20 15:24:22 +03:00
|
|
|
sc->sc_interval = PIUSIVL_SCANINTVAL_MAX;
|
2001-01-08 12:50:08 +03:00
|
|
|
|
|
|
|
if (tp_enable)
|
2001-01-20 15:24:22 +03:00
|
|
|
vrpiu_tp_enable(sc);
|
2001-01-08 12:50:08 +03:00
|
|
|
if (ad_enable)
|
2001-01-20 15:24:22 +03:00
|
|
|
vrpiu_ad_enable(sc);
|
2001-01-08 12:50:08 +03:00
|
|
|
}
|
|
|
|
break;
|
2000-01-10 17:07:58 +03:00
|
|
|
|
|
|
|
case WSMOUSEIO_SCALIBCOORDS:
|
|
|
|
case WSMOUSEIO_GCALIBCOORDS:
|
2001-01-20 15:24:22 +03:00
|
|
|
return tpcalib_ioctl(&sc->sc_tpcalib, cmd, data, flag, p);
|
1999-12-28 06:15:16 +03:00
|
|
|
|
|
|
|
default:
|
2001-01-20 15:24:22 +03:00
|
|
|
return (-1);
|
1999-12-28 06:15:16 +03:00
|
|
|
}
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2000-12-02 11:35:45 +03:00
|
|
|
* PIU AD interrupt handler.
|
1999-12-28 06:15:16 +03:00
|
|
|
*/
|
2000-12-02 11:35:45 +03:00
|
|
|
void
|
|
|
|
vrpiu_ad_intr(sc)
|
|
|
|
struct vrpiu_softc *sc;
|
|
|
|
{
|
|
|
|
unsigned int i;
|
|
|
|
unsigned int intrstat;
|
|
|
|
|
|
|
|
intrstat = vrpiu_read(sc, PIUINT_REG_W);
|
|
|
|
|
|
|
|
if (sc->sc_adstat == VRPIU_AD_STAT_DISABLE) {
|
2001-01-20 15:24:22 +03:00
|
|
|
/*
|
|
|
|
* the device isn't enabled. just clear interrupt.
|
|
|
|
*/
|
|
|
|
vrpiu_write(sc, PIUINT_REG_W, AD_INTR);
|
|
|
|
return;
|
2000-12-02 11:35:45 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if (intrstat & PIUINT_PADADPINTR) {
|
2001-01-20 15:24:22 +03:00
|
|
|
sc->sc_battery.value[0] = (unsigned int)vrpiu_read(sc, PIUAB(0));
|
|
|
|
sc->sc_battery.value[1] = (unsigned int)vrpiu_read(sc, PIUAB(1));
|
|
|
|
sc->sc_battery.value[2] = (unsigned int)vrpiu_read(sc, PIUAB(2));
|
2000-12-02 11:35:45 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if (intrstat & PIUINT_PADADPINTR) {
|
2001-01-20 15:24:22 +03:00
|
|
|
for (i = 0; i < 3; i++) {
|
|
|
|
if (sc->sc_battery.value[i] & PIUAB_VALID)
|
|
|
|
sc->sc_battery.value[i] &= PIUAB_PADDATA_MASK;
|
|
|
|
else
|
|
|
|
sc->sc_battery.value[i] = 0;
|
|
|
|
}
|
|
|
|
vrpiu_calc_powerstate(sc);
|
2000-12-02 11:35:45 +03:00
|
|
|
}
|
2001-01-08 12:50:08 +03:00
|
|
|
vrpiu_write(sc, PIUINT_REG_W, AD_INTR);
|
2000-12-02 11:35:45 +03:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* PIU TP interrupt handler.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
vrpiu_tp_intr(sc)
|
|
|
|
struct vrpiu_softc *sc;
|
1999-12-28 06:15:16 +03:00
|
|
|
{
|
|
|
|
unsigned int cnt, i;
|
|
|
|
unsigned int intrstat, page;
|
|
|
|
int tpx0, tpx1, tpy0, tpy1;
|
|
|
|
int x, y, xraw, yraw;
|
|
|
|
|
|
|
|
intrstat = vrpiu_read(sc, PIUINT_REG_W);
|
|
|
|
|
2000-12-02 11:35:45 +03:00
|
|
|
if (sc->sc_tpstat == VRPIU_TP_STAT_DISABLE) {
|
2001-01-20 15:24:22 +03:00
|
|
|
/*
|
|
|
|
* the device isn't enabled. just clear interrupt.
|
|
|
|
*/
|
|
|
|
vrpiu_write(sc, PIUINT_REG_W, intrstat & TP_INTR);
|
|
|
|
return;
|
1999-12-28 06:15:16 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
page = (intrstat & PIUINT_OVP) ? 1 : 0;
|
|
|
|
if (intrstat & (PIUINT_PADPAGE0INTR | PIUINT_PADPAGE1INTR)) {
|
2001-01-20 15:24:22 +03:00
|
|
|
tpx0 = vrpiu_read(sc, PIUPB(page, 0));
|
|
|
|
tpx1 = vrpiu_read(sc, PIUPB(page, 1));
|
|
|
|
tpy0 = vrpiu_read(sc, PIUPB(page, 2));
|
|
|
|
tpy1 = vrpiu_read(sc, PIUPB(page, 3));
|
1999-12-28 06:15:16 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if (intrstat & PIUINT_PADDLOSTINTR) {
|
2001-01-20 15:24:22 +03:00
|
|
|
page = page ? 0 : 1;
|
|
|
|
for (i = 0; i < 4; i++)
|
|
|
|
vrpiu_read(sc, PIUPB(page, i));
|
1999-12-28 06:15:16 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
cnt = vrpiu_read(sc, PIUCNT_REG_W);
|
|
|
|
#ifdef DEBUG
|
|
|
|
if (vrpiu_debug)
|
2001-01-20 15:24:22 +03:00
|
|
|
vrpiu_dump_cntreg(cnt);
|
1999-12-28 06:15:16 +03:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/* clear interrupt status */
|
2001-01-08 12:50:08 +03:00
|
|
|
vrpiu_write(sc, PIUINT_REG_W, intrstat & TP_INTR);
|
1999-12-28 06:15:16 +03:00
|
|
|
|
|
|
|
#if 0
|
|
|
|
DPRINTF(("vrpiu_intr: OVP=%d", page));
|
|
|
|
if (intrstat & PIUINT_PADCMDINTR)
|
2001-01-20 15:24:22 +03:00
|
|
|
DPRINTF((" CMD"));
|
1999-12-28 06:15:16 +03:00
|
|
|
if (intrstat & PIUINT_PADADPINTR)
|
2001-01-20 15:24:22 +03:00
|
|
|
DPRINTF((" A/D"));
|
1999-12-28 06:15:16 +03:00
|
|
|
if (intrstat & PIUINT_PADPAGE1INTR)
|
2001-01-20 15:24:22 +03:00
|
|
|
DPRINTF((" PAGE1"));
|
1999-12-28 06:15:16 +03:00
|
|
|
if (intrstat & PIUINT_PADPAGE0INTR)
|
2001-01-20 15:24:22 +03:00
|
|
|
DPRINTF((" PAGE0"));
|
1999-12-28 06:15:16 +03:00
|
|
|
if (intrstat & PIUINT_PADDLOSTINTR)
|
2001-01-20 15:24:22 +03:00
|
|
|
DPRINTF((" DLOST"));
|
1999-12-28 06:15:16 +03:00
|
|
|
if (intrstat & PIUINT_PENCHGINTR)
|
2001-01-20 15:24:22 +03:00
|
|
|
DPRINTF((" PENCHG"));
|
1999-12-28 06:15:16 +03:00
|
|
|
DPRINTF(("\n"));
|
|
|
|
#endif
|
|
|
|
if (intrstat & (PIUINT_PADPAGE0INTR | PIUINT_PADPAGE1INTR)) {
|
2001-01-21 08:00:28 +03:00
|
|
|
/*
|
|
|
|
* just ignore scan data if status isn't Touch.
|
|
|
|
*/
|
|
|
|
if (sc->sc_tpstat == VRPIU_TP_STAT_TOUCH) {
|
|
|
|
/* reset tp scan timeout */
|
|
|
|
callout_reset(&sc->sc_tptimeout, VRPIU_TP_SCAN_TIMEOUT,
|
|
|
|
vrpiu_tp_timeout, sc);
|
|
|
|
|
|
|
|
if (!((tpx0 & PIUPB_VALID) && (tpx1 & PIUPB_VALID) &&
|
|
|
|
(tpy0 & PIUPB_VALID) && (tpy1 & PIUPB_VALID))) {
|
|
|
|
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;
|
1999-12-28 06:15:16 +03:00
|
|
|
#define ISVALID(n, c, m) ((c) - (m) < (n) && (n) < (c) + (m))
|
2001-01-21 08:00:28 +03:00
|
|
|
if (ISVALID(tpx0 + tpx1, 1024, 200) &&
|
|
|
|
ISVALID(tpy0 + tpy1, 1024, 200)) {
|
1999-12-28 06:15:16 +03:00
|
|
|
#if 0
|
2001-01-21 08:00:28 +03:00
|
|
|
DPRINTF(("%04x %04x %04x %04x\n",
|
|
|
|
tpx0, tpx1, tpy0, tpy1));
|
|
|
|
DPRINTF(("%3d %3d (%4d %4d)->", tpx0, tpy0,
|
|
|
|
tpx0 + tpx1, tpy0 + tpy1));
|
1999-12-28 06:15:16 +03:00
|
|
|
#endif
|
2001-01-21 08:00:28 +03:00
|
|
|
xraw = tpy1 * 1024 / (tpy0 + tpy1);
|
|
|
|
yraw = tpx1 * 1024 / (tpx0 + tpx1);
|
|
|
|
DPRINTF(("%3d %3d", xraw, yraw));
|
|
|
|
|
|
|
|
tpcalib_trans(&sc->sc_tpcalib, xraw, yraw, &x, &y);
|
|
|
|
|
|
|
|
DPRINTF(("->%4d %4d", x, y));
|
|
|
|
wsmouse_input(sc->sc_wsmousedev,
|
|
|
|
1, /* button 0 down */
|
|
|
|
x, /* x */
|
|
|
|
y, /* y */
|
|
|
|
0, /* z */
|
|
|
|
WSMOUSE_INPUT_ABSOLUTE_X |
|
|
|
|
WSMOUSE_INPUT_ABSOLUTE_Y);
|
|
|
|
DPRINTF(("\n"));
|
|
|
|
}
|
1999-12-28 06:15:16 +03:00
|
|
|
}
|
2001-01-20 15:24:22 +03:00
|
|
|
}
|
1999-12-28 06:15:16 +03:00
|
|
|
}
|
|
|
|
|
2000-05-04 10:14:05 +04:00
|
|
|
if (cnt & PIUCNT_PENSTC) {
|
2001-01-20 15:24:22 +03:00
|
|
|
if (sc->sc_tpstat == VRPIU_TP_STAT_RELEASE) {
|
|
|
|
/*
|
|
|
|
* pen touch
|
|
|
|
*/
|
|
|
|
DPRINTF(("PEN TOUCH\n"));
|
|
|
|
sc->sc_tpstat = VRPIU_TP_STAT_TOUCH;
|
|
|
|
/*
|
|
|
|
* We should not report button down event while
|
|
|
|
* we don't know where it occur.
|
|
|
|
*/
|
2001-01-21 08:00:28 +03:00
|
|
|
|
|
|
|
/* set tp scan timeout */
|
|
|
|
callout_reset(&sc->sc_tptimeout, VRPIU_TP_SCAN_TIMEOUT,
|
|
|
|
vrpiu_tp_timeout, sc);
|
2001-01-20 15:24:22 +03:00
|
|
|
}
|
2000-05-04 10:14:05 +04:00
|
|
|
} else {
|
2001-01-21 08:00:28 +03:00
|
|
|
vrpiu_tp_up(sc);
|
2000-05-04 10:14:05 +04:00
|
|
|
}
|
|
|
|
|
1999-12-28 06:15:16 +03:00
|
|
|
if (intrstat & PIUINT_PADDLOSTINTR) {
|
2001-01-20 15:24:22 +03:00
|
|
|
cnt |= PIUCNT_PIUSEQEN;
|
|
|
|
vrpiu_write(sc, PIUCNT_REG_W, cnt);
|
1999-12-28 06:15:16 +03:00
|
|
|
}
|
|
|
|
|
2000-12-02 11:35:45 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2001-01-21 08:00:28 +03:00
|
|
|
void
|
|
|
|
vrpiu_tp_up(sc)
|
|
|
|
struct vrpiu_softc *sc;
|
|
|
|
{
|
|
|
|
if (sc->sc_tpstat == VRPIU_TP_STAT_TOUCH) {
|
|
|
|
/*
|
|
|
|
* pen release
|
|
|
|
*/
|
|
|
|
DPRINTF(("RELEASE\n"));
|
|
|
|
sc->sc_tpstat = VRPIU_TP_STAT_RELEASE;
|
|
|
|
|
|
|
|
/* clear tp scan timeout */
|
|
|
|
callout_stop(&sc->sc_tptimeout);
|
|
|
|
|
|
|
|
/* button 0 UP */
|
|
|
|
wsmouse_input(sc->sc_wsmousedev, 0, 0, 0, 0, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* touch panel timeout handler */
|
|
|
|
void
|
|
|
|
vrpiu_tp_timeout(v)
|
|
|
|
void *v;
|
|
|
|
{
|
|
|
|
struct vrpiu_softc *sc = (struct vrpiu_softc *)v;
|
|
|
|
|
|
|
|
#ifdef VRPIUDEBUG
|
|
|
|
{
|
|
|
|
unsigned int cnt = vrpiu_read(sc, PIUCNT_REG_W);
|
|
|
|
DPRINTF(("TIMEOUT: stat=%s reg=%s\n",
|
|
|
|
(sc->sc_tpstat == VRPIU_TP_STAT_TOUCH)?"touch":"release",
|
|
|
|
(cnt & PIUCNT_PENSTC)?"touch":"release"));
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
vrpiu_tp_up(sc);
|
|
|
|
}
|
|
|
|
|
2000-12-02 11:35:45 +03:00
|
|
|
/*
|
|
|
|
* PIU interrupt handler.
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
vrpiu_intr(arg)
|
|
|
|
void *arg;
|
|
|
|
{
|
|
|
|
struct vrpiu_softc *sc = arg;
|
|
|
|
|
|
|
|
vrpiu_ad_intr(sc);
|
|
|
|
vrpiu_tp_intr(sc);
|
|
|
|
|
1999-12-28 06:15:16 +03:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2000-12-02 11:35:45 +03:00
|
|
|
void
|
|
|
|
vrpiu_start_powerstate(v)
|
|
|
|
void *v;
|
|
|
|
{
|
|
|
|
int mask;
|
|
|
|
struct vrpiu_softc *sc = (struct vrpiu_softc *)v;
|
|
|
|
|
|
|
|
vrpiu_ad_enable(sc);
|
|
|
|
mask = vrpiu_read(sc, PIUAMSK_REG_W);
|
|
|
|
mask &= 0xff8f; /* XXX */
|
|
|
|
vrpiu_write(sc, PIUAMSK_REG_W, mask);
|
|
|
|
vrpiu_write(sc, PIUASCN_REG_W, PIUACN_ADPSSTART);
|
|
|
|
/*
|
|
|
|
* restart next A/D polling
|
|
|
|
*/
|
|
|
|
callout_reset(&sc->sc_adpoll, hz*vrpiu_ad_poll_interval,
|
2001-01-20 15:24:22 +03:00
|
|
|
vrpiu_start_powerstate, sc);
|
2000-12-02 11:35:45 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
vrpiu_calc_powerstate(sc)
|
|
|
|
struct vrpiu_softc *sc;
|
|
|
|
{
|
|
|
|
extern void vrgiu_diff_io __P((void));
|
|
|
|
vrpiu_ad_disable(sc);
|
|
|
|
VPRINTF(("vrpiu:AD: %d, %d, %d\n",
|
|
|
|
sc->sc_battery.value[0],
|
|
|
|
sc->sc_battery.value[1],
|
|
|
|
sc->sc_battery.value[2]));
|
|
|
|
sc->sc_battery.nextpoll = hz*vrpiu_ad_poll_interval;
|
|
|
|
#ifdef notyet
|
2000-12-27 15:22:07 +03:00
|
|
|
config_hook_call(CONFIG_HOOK_SET,
|
|
|
|
CONFIG_HOOK_BATTERYVAL,
|
2000-12-02 11:35:45 +03:00
|
|
|
(void *)&sc->sc_battery);
|
|
|
|
#endif /* notyet */
|
|
|
|
/*
|
|
|
|
* restart next A/D polling if change polling timming.
|
|
|
|
*/
|
|
|
|
if (sc->sc_battery.nextpoll != hz*vrpiu_ad_poll_interval)
|
2001-01-20 15:24:22 +03:00
|
|
|
callout_reset(&sc->sc_adpoll, sc->sc_battery.nextpoll,
|
|
|
|
vrpiu_start_powerstate, sc);
|
2000-12-02 11:35:45 +03:00
|
|
|
if (bootverbose)
|
2001-01-20 15:24:22 +03:00
|
|
|
vrgiu_diff_io();
|
2000-12-02 11:35:45 +03:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
vrpiu_power(why, arg)
|
|
|
|
int why;
|
|
|
|
void *arg;
|
|
|
|
{
|
|
|
|
struct vrpiu_softc *sc = arg;
|
|
|
|
|
|
|
|
switch (why) {
|
|
|
|
case PWR_STANDBY:
|
|
|
|
case PWR_SUSPEND:
|
2001-01-20 15:24:22 +03:00
|
|
|
break;
|
2000-12-02 11:35:45 +03:00
|
|
|
case PWR_RESUME:
|
2001-01-20 15:24:22 +03:00
|
|
|
callout_reset(&sc->sc_adpoll, hz,
|
|
|
|
vrpiu_start_powerstate, sc);
|
|
|
|
break;
|
2000-12-02 11:35:45 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-12-28 06:15:16 +03:00
|
|
|
#ifdef DEBUG
|
|
|
|
void
|
|
|
|
vrpiu_dump_cntreg(cnt)
|
|
|
|
unsigned int cnt;
|
|
|
|
{
|
|
|
|
printf("%s", (cnt & PIUCNT_PENSTC) ? "Touch" : "Release");
|
|
|
|
printf(" state=");
|
|
|
|
if ((cnt & PIUCNT_PADSTATE_MASK) == PIUCNT_PADSTATE_CmdScan)
|
2001-01-20 15:24:22 +03:00
|
|
|
printf("CmdScan");
|
1999-12-28 06:15:16 +03:00
|
|
|
if ((cnt & PIUCNT_PADSTATE_MASK) == PIUCNT_PADSTATE_IntervalNextScan)
|
2001-01-20 15:24:22 +03:00
|
|
|
printf("IntervalNextScan");
|
1999-12-28 06:15:16 +03:00
|
|
|
if ((cnt & PIUCNT_PADSTATE_MASK) == PIUCNT_PADSTATE_PenDataScan)
|
2001-01-20 15:24:22 +03:00
|
|
|
printf("PenDataScan");
|
1999-12-28 06:15:16 +03:00
|
|
|
if ((cnt & PIUCNT_PADSTATE_MASK) == PIUCNT_PADSTATE_WaitPenTouch)
|
2001-01-20 15:24:22 +03:00
|
|
|
printf("WaitPenTouch");
|
1999-12-28 06:15:16 +03:00
|
|
|
if ((cnt & PIUCNT_PADSTATE_MASK) == PIUCNT_PADSTATE_RFU)
|
2001-01-20 15:24:22 +03:00
|
|
|
printf("???");
|
1999-12-28 06:15:16 +03:00
|
|
|
if ((cnt & PIUCNT_PADSTATE_MASK) == PIUCNT_PADSTATE_ADPortScan)
|
2001-01-20 15:24:22 +03:00
|
|
|
printf("ADPortScan");
|
1999-12-28 06:15:16 +03:00
|
|
|
if ((cnt & PIUCNT_PADSTATE_MASK) == PIUCNT_PADSTATE_Standby)
|
2001-01-20 15:24:22 +03:00
|
|
|
printf("Standby");
|
1999-12-28 06:15:16 +03:00
|
|
|
if ((cnt & PIUCNT_PADSTATE_MASK) == PIUCNT_PADSTATE_Disable)
|
2001-01-20 15:24:22 +03:00
|
|
|
printf("Disable");
|
1999-12-28 06:15:16 +03:00
|
|
|
if (cnt & PIUCNT_PADATSTOP)
|
2001-01-20 15:24:22 +03:00
|
|
|
printf(" AutoStop");
|
1999-12-28 06:15:16 +03:00
|
|
|
if (cnt & PIUCNT_PADATSTART)
|
2001-01-20 15:24:22 +03:00
|
|
|
printf(" AutoStart");
|
1999-12-28 06:15:16 +03:00
|
|
|
if (cnt & PIUCNT_PADSCANSTOP)
|
2001-01-20 15:24:22 +03:00
|
|
|
printf(" Stop");
|
1999-12-28 06:15:16 +03:00
|
|
|
if (cnt & PIUCNT_PADSCANSTART)
|
2001-01-20 15:24:22 +03:00
|
|
|
printf(" Start");
|
1999-12-28 06:15:16 +03:00
|
|
|
if (cnt & PIUCNT_PADSCANTYPE)
|
2001-01-20 15:24:22 +03:00
|
|
|
printf(" ScanPressure");
|
1999-12-28 06:15:16 +03:00
|
|
|
if ((cnt & PIUCNT_PIUMODE_MASK) == PIUCNT_PIUMODE_ADCONVERTER)
|
2001-01-20 15:24:22 +03:00
|
|
|
printf(" A/D");
|
1999-12-28 06:15:16 +03:00
|
|
|
if ((cnt & PIUCNT_PIUMODE_MASK) == PIUCNT_PIUMODE_COORDINATE)
|
2001-01-20 15:24:22 +03:00
|
|
|
printf(" Coordinate");
|
1999-12-28 06:15:16 +03:00
|
|
|
if (cnt & PIUCNT_PIUSEQEN)
|
2001-01-20 15:24:22 +03:00
|
|
|
printf(" SeqEn");
|
1999-12-28 06:15:16 +03:00
|
|
|
if ((cnt & PIUCNT_PIUPWR) == 0)
|
2001-01-20 15:24:22 +03:00
|
|
|
printf(" PowerOff");
|
1999-12-28 06:15:16 +03:00
|
|
|
if ((cnt & PIUCNT_PADRST) == 0)
|
2001-01-20 15:24:22 +03:00
|
|
|
printf(" Reset");
|
1999-12-28 06:15:16 +03:00
|
|
|
printf("\n");
|
|
|
|
}
|
|
|
|
#endif
|