vrpiu.c revision 1.5 1 1.5 matt /* $NetBSD: vrpiu.c,v 1.5 2000/06/13 05:59:55 matt Exp $ */
2 1.1 takemura
3 1.1 takemura /*
4 1.1 takemura * Copyright (c) 1999 Shin Takemura All rights reserved.
5 1.1 takemura * Copyright (c) 1999 PocketBSD Project. All rights reserved.
6 1.1 takemura *
7 1.1 takemura * Redistribution and use in source and binary forms, with or without
8 1.1 takemura * modification, are permitted provided that the following conditions
9 1.1 takemura * are met:
10 1.1 takemura * 1. Redistributions of source code must retain the above copyright
11 1.1 takemura * notice, this list of conditions and the following disclaimer.
12 1.1 takemura * 2. Redistributions in binary form must reproduce the above copyright
13 1.1 takemura * notice, this list of conditions and the following disclaimer in the
14 1.1 takemura * documentation and/or other materials provided with the distribution.
15 1.1 takemura *
16 1.1 takemura * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
17 1.1 takemura * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 1.1 takemura * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 1.1 takemura * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
20 1.1 takemura * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 1.1 takemura * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 1.1 takemura * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 1.1 takemura * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 1.1 takemura * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 1.1 takemura * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 1.1 takemura * SUCH DAMAGE.
27 1.1 takemura *
28 1.1 takemura */
29 1.1 takemura
30 1.1 takemura #include <sys/param.h>
31 1.1 takemura #include <sys/systm.h>
32 1.1 takemura #include <sys/device.h>
33 1.1 takemura #include <sys/kernel.h>
34 1.1 takemura
35 1.1 takemura #include <dev/wscons/wsconsio.h>
36 1.1 takemura #include <dev/wscons/wsmousevar.h>
37 1.1 takemura
38 1.1 takemura #include <machine/bus.h>
39 1.5 matt #include <machine/platid.h>
40 1.5 matt #include <machine/platid_mask.h>
41 1.1 takemura
42 1.3 takemura #include <hpcmips/dev/tpcalibvar.h>
43 1.1 takemura #include <hpcmips/vr/vripvar.h>
44 1.1 takemura #include <hpcmips/vr/cmureg.h>
45 1.1 takemura #include <hpcmips/vr/vrpiuvar.h>
46 1.1 takemura #include <hpcmips/vr/vrpiureg.h>
47 1.1 takemura
48 1.1 takemura /*
49 1.1 takemura * contant and macro definitions
50 1.1 takemura */
51 1.1 takemura #define VRPIUDEBUG
52 1.1 takemura #ifdef VRPIUDEBUG
53 1.1 takemura int vrpiu_debug = 0;
54 1.1 takemura #define DPRINTF(arg) if (vrpiu_debug) printf arg;
55 1.1 takemura #else
56 1.1 takemura #define DPRINTF(arg)
57 1.1 takemura #endif
58 1.1 takemura
59 1.1 takemura /*
60 1.1 takemura * data types
61 1.1 takemura */
62 1.1 takemura /* struct vrpiu_softc is defined in vrpiuvar.h */
63 1.1 takemura
64 1.1 takemura /*
65 1.1 takemura * function prototypes
66 1.1 takemura */
67 1.1 takemura static int vrpiumatch __P((struct device *, struct cfdata *, void *));
68 1.1 takemura static void vrpiuattach __P((struct device *, struct device *, void *));
69 1.1 takemura
70 1.1 takemura static void vrpiu_write __P((struct vrpiu_softc *, int, unsigned short));
71 1.1 takemura static u_short vrpiu_read __P((struct vrpiu_softc *, int));
72 1.1 takemura
73 1.1 takemura static int vrpiu_intr __P((void *));
74 1.1 takemura #ifdef DEBUG
75 1.1 takemura static void vrpiu_dump_cntreg __P((unsigned int cmd));
76 1.1 takemura #endif
77 1.1 takemura
78 1.1 takemura static int vrpiu_enable __P((void *));
79 1.1 takemura static int vrpiu_ioctl __P((void *, u_long, caddr_t, int, struct proc *));
80 1.1 takemura static void vrpiu_disable __P((void *));
81 1.1 takemura
82 1.1 takemura /* mra is defined in mra.c */
83 1.1 takemura int mra_Y_AX1_BX2_C __P((int *y, int ys, int *x1, int x1s, int *x2, int x2s,
84 1.1 takemura int n, int scale, int *a, int *b, int *c));
85 1.1 takemura
86 1.1 takemura /*
87 1.1 takemura * static or global variables
88 1.1 takemura */
89 1.1 takemura struct cfattach vrpiu_ca = {
90 1.1 takemura sizeof(struct vrpiu_softc), vrpiumatch, vrpiuattach
91 1.1 takemura };
92 1.1 takemura
93 1.1 takemura const struct wsmouse_accessops vrpiu_accessops = {
94 1.1 takemura vrpiu_enable,
95 1.1 takemura vrpiu_ioctl,
96 1.1 takemura vrpiu_disable,
97 1.1 takemura };
98 1.1 takemura
99 1.1 takemura /*
100 1.1 takemura * function definitions
101 1.1 takemura */
102 1.1 takemura static inline void
103 1.1 takemura vrpiu_write(sc, port, val)
104 1.1 takemura struct vrpiu_softc *sc;
105 1.1 takemura int port;
106 1.1 takemura unsigned short val;
107 1.1 takemura {
108 1.1 takemura bus_space_write_2(sc->sc_iot, sc->sc_ioh, port, val);
109 1.1 takemura }
110 1.1 takemura
111 1.1 takemura static inline u_short
112 1.1 takemura vrpiu_read(sc, port)
113 1.1 takemura struct vrpiu_softc *sc;
114 1.1 takemura int port;
115 1.1 takemura {
116 1.1 takemura return bus_space_read_2(sc->sc_iot, sc->sc_ioh, port);
117 1.1 takemura }
118 1.1 takemura
119 1.1 takemura static int
120 1.1 takemura vrpiumatch(parent, cf, aux)
121 1.1 takemura struct device *parent;
122 1.1 takemura struct cfdata *cf;
123 1.1 takemura void *aux;
124 1.1 takemura {
125 1.1 takemura return 1;
126 1.1 takemura }
127 1.1 takemura
128 1.1 takemura static void
129 1.1 takemura vrpiuattach(parent, self, aux)
130 1.1 takemura struct device *parent;
131 1.1 takemura struct device *self;
132 1.1 takemura void *aux;
133 1.1 takemura {
134 1.1 takemura struct vrpiu_softc *sc = (struct vrpiu_softc *)self;
135 1.1 takemura struct vrip_attach_args *va = aux;
136 1.1 takemura struct wsmousedev_attach_args wsmaa;
137 1.1 takemura
138 1.1 takemura bus_space_tag_t iot = va->va_iot;
139 1.1 takemura bus_space_handle_t ioh;
140 1.1 takemura
141 1.1 takemura if (bus_space_map(iot, va->va_addr, 1, 0, &ioh)) {
142 1.1 takemura printf(": can't map bus space\n");
143 1.1 takemura return;
144 1.1 takemura }
145 1.1 takemura
146 1.1 takemura sc->sc_iot = iot;
147 1.1 takemura sc->sc_ioh = ioh;
148 1.1 takemura sc->sc_vrip = va->va_vc;
149 1.1 takemura
150 1.1 takemura /*
151 1.1 takemura * disable device until vrpiu_enable called
152 1.1 takemura */
153 1.1 takemura sc->sc_stat = VRPIU_STAT_DISABLE;
154 1.1 takemura
155 1.3 takemura tpcalib_init(&sc->sc_tpcalib);
156 1.1 takemura #if 1
157 1.1 takemura /*
158 1.1 takemura * XXX, calibrate parameters
159 1.1 takemura */
160 1.1 takemura {
161 1.5 matt int i;
162 1.5 matt static const struct {
163 1.5 matt platid_mask_t *mask;
164 1.5 matt struct wsmouse_calibcoords coords;
165 1.5 matt } calibrations[] = {
166 1.5 matt { &platid_mask_MACH_NEC_MCR_700A,
167 1.5 matt { 0, 0, 799, 599,
168 1.5 matt 4,
169 1.5 matt { { 115, 80, 0, 0 },
170 1.5 matt { 115, 966, 0, 599 },
171 1.5 matt { 912, 80, 799, 0 },
172 1.5 matt { 912, 966, 799, 599 } } } },
173 1.5 matt
174 1.5 matt { NULL, /* samples got on my MC-R500 */
175 1.5 matt { 0, 0, 639, 239,
176 1.5 matt 5,
177 1.5 matt { { 502, 486, 320, 120 },
178 1.5 matt { 55, 109, 0, 0 },
179 1.5 matt { 54, 913, 0, 239 },
180 1.5 matt { 973, 924, 639, 239 },
181 1.5 matt { 975, 123, 639, 0 } } } },
182 1.1 takemura };
183 1.5 matt for (i = 0; ; i++) {
184 1.5 matt if (calibrations[i].mask == NULL
185 1.5 matt || platid_match(&platid, calibrations[i].mask))
186 1.5 matt break;
187 1.5 matt }
188 1.3 takemura tpcalib_ioctl(&sc->sc_tpcalib, WSMOUSEIO_SCALIBCOORDS,
189 1.5 matt (caddr_t)&calibrations[i].coords, 0, 0);
190 1.1 takemura }
191 1.1 takemura #endif
192 1.1 takemura
193 1.1 takemura /* install interrupt handler and enable interrupt */
194 1.1 takemura if (!(sc->sc_handler =
195 1.1 takemura vrip_intr_establish(va->va_vc, va->va_intr, IPL_TTY,
196 1.1 takemura vrpiu_intr, sc))) {
197 1.1 takemura printf (": can't map interrupt line.\n");
198 1.1 takemura return;
199 1.1 takemura }
200 1.1 takemura
201 1.1 takemura /* mask level2 interrupt, stop scan sequencer and mask clock to piu */
202 1.1 takemura vrpiu_disable(sc);
203 1.1 takemura
204 1.1 takemura printf("\n");
205 1.1 takemura
206 1.1 takemura wsmaa.accessops = &vrpiu_accessops;
207 1.1 takemura wsmaa.accesscookie = sc;
208 1.1 takemura
209 1.1 takemura /*
210 1.1 takemura * attach the wsmouse
211 1.1 takemura */
212 1.1 takemura sc->sc_wsmousedev = config_found(self, &wsmaa, wsmousedevprint);
213 1.1 takemura }
214 1.1 takemura
215 1.1 takemura int
216 1.1 takemura vrpiu_enable(v)
217 1.1 takemura void *v;
218 1.1 takemura {
219 1.1 takemura struct vrpiu_softc *sc = v;
220 1.1 takemura int s;
221 1.1 takemura unsigned int cnt;
222 1.1 takemura
223 1.1 takemura DPRINTF(("%s(%d): vrpiu_enable()\n", __FILE__, __LINE__));
224 1.1 takemura if (sc->sc_stat != VRPIU_STAT_DISABLE)
225 1.1 takemura return EBUSY;
226 1.1 takemura
227 1.1 takemura /* supply clock to PIU */
228 1.1 takemura __vrcmu_supply(CMUMSKPIU, 1);
229 1.1 takemura
230 1.1 takemura /* Scan interval 0x7FF is maximum value */
231 1.1 takemura vrpiu_write(sc, PIUSIVL_REG_W, 0x7FF);
232 1.1 takemura
233 1.1 takemura s = spltty();
234 1.1 takemura
235 1.1 takemura /* clear interrupt status */
236 1.1 takemura vrpiu_write(sc, PIUINT_REG_W, PIUINT_ALLINTR);
237 1.1 takemura
238 1.1 takemura /* Disable -> Standby */
239 1.1 takemura cnt = PIUCNT_PIUPWR |
240 1.1 takemura PIUCNT_PIUMODE_COORDINATE |
241 1.1 takemura PIUCNT_PADATSTART | PIUCNT_PADATSTOP;
242 1.1 takemura vrpiu_write(sc, PIUCNT_REG_W, cnt);
243 1.1 takemura
244 1.1 takemura /* save pen status, touch or release */
245 1.1 takemura cnt = vrpiu_read(sc, PIUCNT_REG_W);
246 1.1 takemura
247 1.1 takemura /* Level2 interrupt register setting */
248 1.1 takemura vrip_intr_setmask2(sc->sc_vrip, sc->sc_handler, PIUINT_ALLINTR, 1);
249 1.1 takemura
250 1.1 takemura /*
251 1.1 takemura * Enable scan sequencer operation
252 1.1 takemura * Standby -> WaitPenTouch
253 1.1 takemura */
254 1.1 takemura cnt |= PIUCNT_PIUSEQEN;
255 1.1 takemura vrpiu_write(sc, PIUCNT_REG_W, cnt);
256 1.1 takemura
257 1.1 takemura /* transit status DISABLE -> TOUCH or RELEASE */
258 1.1 takemura sc->sc_stat = (cnt & PIUCNT_PENSTC) ?
259 1.1 takemura VRPIU_STAT_TOUCH : VRPIU_STAT_RELEASE;
260 1.1 takemura
261 1.1 takemura splx(s);
262 1.1 takemura
263 1.1 takemura return 0;
264 1.1 takemura }
265 1.1 takemura
266 1.1 takemura void
267 1.1 takemura vrpiu_disable(v)
268 1.1 takemura void *v;
269 1.1 takemura {
270 1.1 takemura struct vrpiu_softc *sc = v;
271 1.1 takemura
272 1.1 takemura DPRINTF(("%s(%d): vrpiu_disable()\n", __FILE__, __LINE__));
273 1.1 takemura
274 1.1 takemura /* Set level2 interrupt register to mask interrupts */
275 1.1 takemura vrip_intr_setmask2(sc->sc_vrip, sc->sc_handler, PIUINT_ALLINTR, 0);
276 1.1 takemura
277 1.1 takemura sc->sc_stat = VRPIU_STAT_DISABLE;
278 1.1 takemura
279 1.1 takemura /* Disable scan sequencer operation and power off */
280 1.1 takemura vrpiu_write(sc, PIUCNT_REG_W, 0);
281 1.1 takemura
282 1.1 takemura /* mask clock to PIU */
283 1.1 takemura __vrcmu_supply(CMUMSKPIU, 1);
284 1.1 takemura }
285 1.1 takemura
286 1.1 takemura int
287 1.1 takemura vrpiu_ioctl(v, cmd, data, flag, p)
288 1.1 takemura void *v;
289 1.1 takemura u_long cmd;
290 1.1 takemura caddr_t data;
291 1.1 takemura int flag;
292 1.1 takemura struct proc *p;
293 1.1 takemura {
294 1.1 takemura struct vrpiu_softc *sc = v;
295 1.1 takemura
296 1.1 takemura DPRINTF(("%s(%d): vrpiu_ioctl(%08lx)\n", __FILE__, __LINE__, cmd));
297 1.1 takemura
298 1.1 takemura switch (cmd) {
299 1.1 takemura case WSMOUSEIO_GTYPE:
300 1.2 takemura *(u_int *)data = WSMOUSE_TYPE_TPANEL;
301 1.1 takemura break;
302 1.1 takemura
303 1.1 takemura case WSMOUSEIO_SRES:
304 1.1 takemura printf("%s(%d): WSMOUSRIO_SRES is not supported",
305 1.1 takemura __FILE__, __LINE__);
306 1.1 takemura break;
307 1.3 takemura
308 1.3 takemura case WSMOUSEIO_SCALIBCOORDS:
309 1.3 takemura case WSMOUSEIO_GCALIBCOORDS:
310 1.3 takemura return tpcalib_ioctl(&sc->sc_tpcalib, cmd, data, flag, p);
311 1.1 takemura
312 1.1 takemura default:
313 1.1 takemura return (-1);
314 1.1 takemura }
315 1.1 takemura return (0);
316 1.1 takemura }
317 1.1 takemura
318 1.1 takemura /*
319 1.1 takemura * PIU interrupt handler.
320 1.1 takemura */
321 1.1 takemura int
322 1.1 takemura vrpiu_intr(arg)
323 1.1 takemura void *arg;
324 1.1 takemura {
325 1.1 takemura struct vrpiu_softc *sc = arg;
326 1.1 takemura unsigned int cnt, i;
327 1.1 takemura unsigned int intrstat, page;
328 1.1 takemura int tpx0, tpx1, tpy0, tpy1;
329 1.1 takemura int x, y, xraw, yraw;
330 1.1 takemura
331 1.1 takemura intrstat = vrpiu_read(sc, PIUINT_REG_W);
332 1.1 takemura
333 1.1 takemura if (sc->sc_stat == VRPIU_STAT_DISABLE) {
334 1.1 takemura /*
335 1.1 takemura * the device isn't enabled. just clear interrupt.
336 1.1 takemura */
337 1.1 takemura vrpiu_write(sc, PIUINT_REG_W, intrstat);
338 1.1 takemura return (0);
339 1.1 takemura }
340 1.1 takemura
341 1.1 takemura page = (intrstat & PIUINT_OVP) ? 1 : 0;
342 1.1 takemura if (intrstat & (PIUINT_PADPAGE0INTR | PIUINT_PADPAGE1INTR)) {
343 1.1 takemura tpx0 = vrpiu_read(sc, PIUPB(page, 0));
344 1.1 takemura tpx1 = vrpiu_read(sc, PIUPB(page, 1));
345 1.1 takemura tpy0 = vrpiu_read(sc, PIUPB(page, 2));
346 1.1 takemura tpy1 = vrpiu_read(sc, PIUPB(page, 3));
347 1.1 takemura }
348 1.1 takemura
349 1.1 takemura if (intrstat & PIUINT_PADDLOSTINTR) {
350 1.1 takemura page = page ? 0 : 1;
351 1.1 takemura for (i = 0; i < 4; i++)
352 1.1 takemura vrpiu_read(sc, PIUPB(page, i));
353 1.1 takemura }
354 1.1 takemura
355 1.1 takemura cnt = vrpiu_read(sc, PIUCNT_REG_W);
356 1.1 takemura #ifdef DEBUG
357 1.1 takemura if (vrpiu_debug)
358 1.1 takemura vrpiu_dump_cntreg(cnt);
359 1.1 takemura #endif
360 1.1 takemura
361 1.1 takemura /* clear interrupt status */
362 1.1 takemura vrpiu_write(sc, PIUINT_REG_W, intrstat);
363 1.1 takemura
364 1.1 takemura #if 0
365 1.1 takemura DPRINTF(("vrpiu_intr: OVP=%d", page));
366 1.1 takemura if (intrstat & PIUINT_PADCMDINTR)
367 1.1 takemura DPRINTF((" CMD"));
368 1.1 takemura if (intrstat & PIUINT_PADADPINTR)
369 1.1 takemura DPRINTF((" A/D"));
370 1.1 takemura if (intrstat & PIUINT_PADPAGE1INTR)
371 1.1 takemura DPRINTF((" PAGE1"));
372 1.1 takemura if (intrstat & PIUINT_PADPAGE0INTR)
373 1.1 takemura DPRINTF((" PAGE0"));
374 1.1 takemura if (intrstat & PIUINT_PADDLOSTINTR)
375 1.1 takemura DPRINTF((" DLOST"));
376 1.1 takemura if (intrstat & PIUINT_PENCHGINTR)
377 1.1 takemura DPRINTF((" PENCHG"));
378 1.1 takemura DPRINTF(("\n"));
379 1.1 takemura #endif
380 1.1 takemura if (intrstat & (PIUINT_PADPAGE0INTR | PIUINT_PADPAGE1INTR)) {
381 1.1 takemura if (!((tpx0 & PIUPB_VALID) && (tpx1 & PIUPB_VALID) &&
382 1.1 takemura (tpy0 & PIUPB_VALID) && (tpy1 & PIUPB_VALID))) {
383 1.1 takemura printf("vrpiu: internal error, data is not valid!\n");
384 1.1 takemura } else {
385 1.1 takemura tpx0 &= PIUPB_PADDATA_MASK;
386 1.1 takemura tpx1 &= PIUPB_PADDATA_MASK;
387 1.1 takemura tpy0 &= PIUPB_PADDATA_MASK;
388 1.1 takemura tpy1 &= PIUPB_PADDATA_MASK;
389 1.1 takemura #define ISVALID(n, c, m) ((c) - (m) < (n) && (n) < (c) + (m))
390 1.1 takemura if (ISVALID(tpx0 + tpx1, 1024, 200) &&
391 1.1 takemura ISVALID(tpx0 + tpx1, 1024, 200)) {
392 1.1 takemura #if 0
393 1.1 takemura DPRINTF(("%04x %04x %04x %04x\n",
394 1.1 takemura tpx0, tpx1, tpy0, tpy1));
395 1.1 takemura DPRINTF(("%3d %3d (%4d %4d)->", tpx0, tpy0,
396 1.4 takemura tpx0 + tpx1, tpy0 + tpy1));
397 1.1 takemura #endif
398 1.1 takemura xraw = tpy1 * 1024 / (tpy0 + tpy1);
399 1.1 takemura yraw = tpx1 * 1024 / (tpx0 + tpx1);
400 1.1 takemura DPRINTF(("%3d %3d", xraw, yraw));
401 1.1 takemura
402 1.3 takemura tpcalib_trans(&sc->sc_tpcalib,
403 1.3 takemura xraw, yraw, &x, &y);
404 1.3 takemura
405 1.1 takemura DPRINTF(("->%4d %4d", x, y));
406 1.2 takemura wsmouse_input(sc->sc_wsmousedev,
407 1.2 takemura (cnt & PIUCNT_PENSTC) ? 1 : 0,
408 1.2 takemura x, /* x */
409 1.2 takemura y, /* y */
410 1.2 takemura 0, /* z */
411 1.2 takemura WSMOUSE_INPUT_ABSOLUTE_X |
412 1.2 takemura WSMOUSE_INPUT_ABSOLUTE_Y);
413 1.1 takemura DPRINTF(("\n"));
414 1.1 takemura }
415 1.4 takemura }
416 1.4 takemura }
417 1.4 takemura
418 1.4 takemura if (cnt & PIUCNT_PENSTC) {
419 1.4 takemura if (sc->sc_stat == VRPIU_STAT_RELEASE) {
420 1.4 takemura /*
421 1.4 takemura * pen touch
422 1.4 takemura */
423 1.4 takemura DPRINTF(("PEN TOUCH\n"));
424 1.4 takemura sc->sc_stat = VRPIU_STAT_TOUCH;
425 1.4 takemura /*
426 1.4 takemura * We should not report button down event while
427 1.4 takemura * we don't know where it occur.
428 1.4 takemura */
429 1.4 takemura }
430 1.4 takemura } else {
431 1.4 takemura if (sc->sc_stat == VRPIU_STAT_TOUCH) {
432 1.4 takemura /*
433 1.4 takemura * pen release
434 1.4 takemura */
435 1.4 takemura DPRINTF(("RELEASE\n"));
436 1.4 takemura sc->sc_stat = VRPIU_STAT_RELEASE;
437 1.4 takemura /* button 0 UP */
438 1.4 takemura wsmouse_input(sc->sc_wsmousedev,
439 1.4 takemura 0,
440 1.4 takemura 0, 0, 0, 0);
441 1.1 takemura }
442 1.1 takemura }
443 1.1 takemura
444 1.1 takemura if (intrstat & PIUINT_PADDLOSTINTR) {
445 1.1 takemura cnt |= PIUCNT_PIUSEQEN;
446 1.1 takemura vrpiu_write(sc, PIUCNT_REG_W, cnt);
447 1.1 takemura }
448 1.1 takemura
449 1.1 takemura return 0;
450 1.1 takemura }
451 1.1 takemura
452 1.1 takemura #ifdef DEBUG
453 1.1 takemura void
454 1.1 takemura vrpiu_dump_cntreg(cnt)
455 1.1 takemura unsigned int cnt;
456 1.1 takemura {
457 1.1 takemura printf("%s", (cnt & PIUCNT_PENSTC) ? "Touch" : "Release");
458 1.1 takemura printf(" state=");
459 1.1 takemura if ((cnt & PIUCNT_PADSTATE_MASK) == PIUCNT_PADSTATE_CmdScan)
460 1.1 takemura printf("CmdScan");
461 1.1 takemura if ((cnt & PIUCNT_PADSTATE_MASK) == PIUCNT_PADSTATE_IntervalNextScan)
462 1.1 takemura printf("IntervalNextScan");
463 1.1 takemura if ((cnt & PIUCNT_PADSTATE_MASK) == PIUCNT_PADSTATE_PenDataScan)
464 1.1 takemura printf("PenDataScan");
465 1.1 takemura if ((cnt & PIUCNT_PADSTATE_MASK) == PIUCNT_PADSTATE_WaitPenTouch)
466 1.1 takemura printf("WaitPenTouch");
467 1.1 takemura if ((cnt & PIUCNT_PADSTATE_MASK) == PIUCNT_PADSTATE_RFU)
468 1.1 takemura printf("???");
469 1.1 takemura if ((cnt & PIUCNT_PADSTATE_MASK) == PIUCNT_PADSTATE_ADPortScan)
470 1.1 takemura printf("ADPortScan");
471 1.1 takemura if ((cnt & PIUCNT_PADSTATE_MASK) == PIUCNT_PADSTATE_Standby)
472 1.1 takemura printf("Standby");
473 1.1 takemura if ((cnt & PIUCNT_PADSTATE_MASK) == PIUCNT_PADSTATE_Disable)
474 1.1 takemura printf("Disable");
475 1.1 takemura if (cnt & PIUCNT_PADATSTOP)
476 1.1 takemura printf(" AutoStop");
477 1.1 takemura if (cnt & PIUCNT_PADATSTART)
478 1.1 takemura printf(" AutoStart");
479 1.1 takemura if (cnt & PIUCNT_PADSCANSTOP)
480 1.1 takemura printf(" Stop");
481 1.1 takemura if (cnt & PIUCNT_PADSCANSTART)
482 1.1 takemura printf(" Start");
483 1.1 takemura if (cnt & PIUCNT_PADSCANTYPE)
484 1.1 takemura printf(" ScanPressure");
485 1.1 takemura if ((cnt & PIUCNT_PIUMODE_MASK) == PIUCNT_PIUMODE_ADCONVERTER)
486 1.1 takemura printf(" A/D");
487 1.1 takemura if ((cnt & PIUCNT_PIUMODE_MASK) == PIUCNT_PIUMODE_COORDINATE)
488 1.1 takemura printf(" Coordinate");
489 1.1 takemura if (cnt & PIUCNT_PIUSEQEN)
490 1.1 takemura printf(" SeqEn");
491 1.1 takemura if ((cnt & PIUCNT_PIUPWR) == 0)
492 1.1 takemura printf(" PowerOff");
493 1.1 takemura if ((cnt & PIUCNT_PADRST) == 0)
494 1.1 takemura printf(" Reset");
495 1.1 takemura printf("\n");
496 1.1 takemura }
497 1.1 takemura #endif
498