ucbtp.c revision 1.21 1 /* $NetBSD: ucbtp.c,v 1.21 2012/10/27 17:17:53 chs Exp $ */
2
3 /*-
4 * Copyright (c) 2000, 2001 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by UCHIYAMA Yasushi.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
30 */
31
32 /*
33 * Device driver for PHILIPS UCB1200 Advanced modem/audio analog front-end
34 * Touch panel part.
35 */
36
37 #include <sys/cdefs.h>
38 __KERNEL_RCSID(0, "$NetBSD: ucbtp.c,v 1.21 2012/10/27 17:17:53 chs Exp $");
39
40 #include "opt_use_poll.h"
41
42 #include <sys/param.h>
43 #include <sys/systm.h>
44 #include <sys/device.h>
45
46 #include <machine/bus.h>
47 #include <machine/intr.h>
48 #include <machine/bootinfo.h> /* bootinfo */
49
50 #include <dev/wscons/wsconsio.h>
51 #include <dev/wscons/wsmousevar.h>
52
53 #include <dev/hpc/hpctpanelvar.h>
54
55 #include <hpcmips/tx/tx39var.h>
56 #include <hpcmips/tx/tx39sibvar.h>
57 #include <hpcmips/tx/tx39sibreg.h>
58 #include <hpcmips/tx/tx39icureg.h>
59
60 #include <hpcmips/dev/ucb1200var.h>
61 #include <hpcmips/dev/ucb1200reg.h>
62
63 #include <hpcmips/tx/txsnd.h>
64 #include <dev/hpc/video_subr.h> /* debug */
65
66 #ifdef UCBTPDEBUG
67 int ucbtp_debug = 0;
68 #define DPRINTF(arg) if (ucbtp_debug) printf arg;
69 #define DPRINTFN(n, arg) if (ucbtp_debug > (n)) printf arg;
70 #else
71 #define DPRINTF(arg)
72 #define DPRINTFN(n, arg)
73 #endif
74
75 enum ucbts_stat {
76 UCBTS_STAT_DISABLE,
77 UCBTS_STAT_RELEASE,
78 UCBTS_STAT_TOUCH,
79 UCBTS_STAT_DRAG,
80 };
81
82 #define UCBTS_POSX 1
83 #define UCBTS_POSY 2
84 #define UCBTS_PRESS 3
85
86 #define UCBTS_PRESS_THRESHOLD 80
87 #define UCBTS_TAP_THRESHOLD 5
88
89 enum ucbadc_state {
90 /* 0 */ UCBADC_IDLE,
91 /* 1 */ UCBADC_ADC_INIT,
92 /* 2 */ UCBADC_ADC_FINI,
93 /* 3 */ UCBADC_MEASUMENT_INIT,
94 /* 4 */ UCBADC_MEASUMENT_FINI,
95 /* 5 */ UCBADC_ADC_ENABLE,
96 /* 6 */ UCBADC_ADC_START0,
97 /* 7 */ UCBADC_ADC_START1,
98 /* 8 */ UCBADC_ADC_DATAREAD,
99 /* 9 */ UCBADC_ADC_DATAREAD_WAIT,
100 /*10 */ UCBADC_ADC_DISABLE,
101 /*11 */ UCBADC_ADC_INTRMODE,
102 /*12 */ UCBADC_ADC_INPUT,
103 /*13 */ UCBADC_INTR_ACK0,
104 /*14 */ UCBADC_INTR_ACK1,
105 /*15 */ UCBADC_INTR_ACK2,
106 /*16 */ UCBADC_REGREAD,
107 /*17 */ UCBADC_REGWRITE
108 };
109
110 struct ucbtp_softc {
111 device_t sc_dev;
112 device_t sc_sib; /* parent (TX39 SIB module) */
113 device_t sc_ucb; /* parent (UCB1200 module) */
114 tx_chipset_tag_t sc_tc;
115
116 enum ucbts_stat sc_stat;
117 int sc_polling;
118 int sc_polling_finish;
119 void *sc_pollh;
120
121 struct tpcalib_softc sc_tpcalib;
122 int sc_calibrated;
123
124 /* measurement value */
125 int sc_x, sc_y, sc_p;
126 int sc_ox, sc_oy;
127 int sc_xy_reverse; /* some platform pin connect interchanged */
128
129 /*
130 * touch panel state machine
131 */
132 void *sm_ih; /* TX39 SIB subframe 0 interrupt handler */
133
134 int sm_addr; /* UCB1200 register address */
135 u_int32_t sm_reg; /* UCB1200 register data & TX39 SIB header */
136 int sm_tmpreg;
137 #define UCBADC_RETRY_DEFAULT 200
138 int sm_retry; /* retry counter */
139
140 enum ucbadc_state sm_state;
141 int sm_measurement; /* X, Y, Pressure */
142 #define UCBADC_MEASUREMENT_X 0
143 #define UCBADC_MEASUREMENT_Y 1
144 #define UCBADC_MEASUREMENT_PRESSURE 2
145 int sm_returnstate;
146
147 int sm_read_state, sm_write_state;
148 int sm_writing; /* writing state flag */
149 u_int32_t sm_write_val; /* temporary buffer */
150
151 int sm_rw_retry; /* retry counter for r/w */
152
153 /* wsmouse */
154 device_t sc_wsmousedev;
155 };
156
157 int ucbtp_match(device_t, cfdata_t, void *);
158 void ucbtp_attach(device_t, device_t, void *);
159
160 int ucbtp_sibintr(void *);
161 int ucbtp_poll(void *);
162 int ucbtp_adc_async(void *);
163 int ucbtp_input(struct ucbtp_softc *);
164 int ucbtp_busy(void *);
165
166 int ucbtp_enable(void *);
167 int ucbtp_ioctl(void *, u_long, void *, int, struct lwp *);
168 void ucbtp_disable(void *);
169
170 CFATTACH_DECL_NEW(ucbtp, sizeof(struct ucbtp_softc),
171 ucbtp_match, ucbtp_attach, NULL, NULL);
172
173 const struct wsmouse_accessops ucbtp_accessops = {
174 ucbtp_enable,
175 ucbtp_ioctl,
176 ucbtp_disable,
177 };
178
179 /*
180 * XXX currently no calibration method. this is temporary hack.
181 */
182 #include <machine/platid.h>
183
184 struct wsmouse_calibcoords *calibration_sample_lookup(void);
185 int ucbtp_calibration(struct ucbtp_softc *);
186
187 struct calibration_sample_table {
188 platid_t cst_platform;
189 struct wsmouse_calibcoords cst_sample;
190 } calibration_sample_table[] = {
191 {{{PLATID_WILD, PLATID_MACH_COMPAQ_C_8XX}}, /* uch machine */
192 { 0, 0, 639, 239, 5,
193 {{ 507, 510, 320, 120 },
194 { 898, 757, 40, 40 },
195 { 900, 255, 40, 200 },
196 { 109, 249, 600, 200 },
197 { 110, 753, 600, 40 }}}},
198
199 {{{PLATID_WILD, PLATID_MACH_COMPAQ_C_2010}}, /* uch machine */
200 { 0, 0, 639, 239, 5,
201 {{ 506, 487, 320, 120 },
202 { 880, 250, 40, 40 },
203 { 880, 718, 40, 200 },
204 { 140, 726, 600, 200 },
205 { 137, 250, 600, 40 }}}},
206
207 {{{PLATID_WILD, PLATID_MACH_SHARP_MOBILON_HC4100}}, /* uch machine */
208 { 0, 0, 639, 239, 5,
209 {{ 497, 501, 320, 120 },
210 { 752, 893, 40, 40 },
211 { 242, 891, 40, 200 },
212 { 241, 115, 600, 200 },
213 { 747, 101, 600, 40 }}}},
214
215 {{{PLATID_WILD, PLATID_MACH_SHARP_TELIOS_HCVJ}}, /* uch machine */
216 { 0, 0, 799, 479, 5,
217 {{ 850, 150, 1, 1 },
218 { 850, 880, 1, 479 },
219 { 850, 880, 1, 479 },
220 { 85, 880, 799, 479 },
221 { 85, 150, 799, 1 }}}},
222
223 {{{PLATID_UNKNOWN, PLATID_UNKNOWN}},
224 { 0, 0, 639, 239, 5,
225 {{0, 0, 0, 0},
226 {0, 0, 0, 0},
227 {0, 0, 0, 0},
228 {0, 0, 0, 0},
229 {0, 0, 0, 0}}}},
230 };
231
232 struct wsmouse_calibcoords *
233 calibration_sample_lookup(void)
234 {
235 struct calibration_sample_table *tab;
236 platid_mask_t mask;
237
238 for (tab = calibration_sample_table;
239 tab->cst_platform.dw.dw1 != PLATID_UNKNOWN; tab++) {
240
241 mask = PLATID_DEREF(&tab->cst_platform);
242
243 if (platid_match(&platid, &mask)) {
244 return (&tab->cst_sample);
245 }
246 }
247
248 return (0);
249 }
250
251 int
252 ucbtp_calibration(struct ucbtp_softc *sc)
253 {
254 struct wsmouse_calibcoords *cs;
255
256 if (sc->sc_tc->tc_videot)
257 video_calibration_pattern(sc->sc_tc->tc_videot); /* debug */
258
259 tpcalib_init(&sc->sc_tpcalib);
260
261 if (!(cs = calibration_sample_lookup())) {
262 DPRINTF(("no calibration data"));
263 return (1);
264 }
265
266 sc->sc_calibrated =
267 tpcalib_ioctl(&sc->sc_tpcalib, WSMOUSEIO_SCALIBCOORDS,
268 (void *)cs, 0, 0) == 0 ? 1 : 0;
269
270 if (!sc->sc_calibrated)
271 printf("not ");
272 printf("calibrated");
273
274 return (0);
275 }
276
277 int
278 ucbtp_match(device_t parent, cfdata_t cf, void *aux)
279 {
280
281 return (1);
282 }
283
284 void
285 ucbtp_attach(device_t parent, device_t self, void *aux)
286 {
287 struct ucb1200_attach_args *ucba = aux;
288 struct ucbtp_softc *sc = device_private(self);
289 struct wsmousedev_attach_args wsmaa;
290 tx_chipset_tag_t tc;
291
292 sc->sc_dev = self;
293 tc = sc->sc_tc = ucba->ucba_tc;
294 sc->sc_sib = ucba->ucba_sib;
295 sc->sc_ucb = ucba->ucba_ucb;
296
297 printf(": ");
298 /* touch panel interrupt */
299 tx_intr_establish(tc, MAKEINTR(1, TX39_INTRSTATUS1_SIBIRQPOSINT),
300 IST_EDGE, IPL_TTY, ucbtp_sibintr, sc);
301
302 /* attempt to calibrate touch panel */
303 ucbtp_calibration(sc);
304 #ifdef TX392X /* hack for Telios HC-VJ1C */
305 sc->sc_xy_reverse = 1;
306 #endif
307
308 printf("\n");
309
310 wsmaa.accessops = &ucbtp_accessops;
311 wsmaa.accesscookie = sc;
312
313 ucb1200_state_install(parent, ucbtp_busy, self, UCB1200_TP_MODULE);
314
315 /*
316 * attach the wsmouse
317 */
318 sc->sc_wsmousedev = config_found(self, &wsmaa, wsmousedevprint);
319 }
320
321 int
322 ucbtp_busy(void *arg)
323 {
324 struct ucbtp_softc *sc = arg;
325
326 return (sc->sm_state != UCBADC_IDLE);
327 }
328
329 int
330 ucbtp_poll(void *arg)
331 {
332 struct ucbtp_softc *sc = arg;
333
334 if (!ucb1200_state_idle(sc->sc_ucb)) /* subframe0 busy */
335 return (POLL_CONT);
336
337 if (sc->sc_polling_finish) {
338 sc->sc_polling_finish = 0;
339 return (POLL_END);
340 }
341
342 /* execute A-D converter */
343 sc->sm_state = UCBADC_ADC_INIT;
344 ucbtp_adc_async(sc);
345
346 return (POLL_CONT);
347 }
348
349 int
350 ucbtp_sibintr(void *arg)
351 {
352 struct ucbtp_softc *sc = arg;
353
354 sc->sc_stat = UCBTS_STAT_TOUCH;
355
356 /* click! */
357 tx_sound_click(sc->sc_tc);
358
359 /* invoke touch panel polling */
360 if (!sc->sc_polling) {
361 sc->sc_pollh = tx39_poll_establish(sc->sc_tc, 1, IST_EDGE,
362 ucbtp_poll, sc);
363 if (!sc->sc_pollh) {
364 printf("%s: can't poll\n", device_xname(sc->sc_dev));
365 }
366 }
367
368 /* don't acknoledge interrupt until polling finish */
369
370 return (0);
371 }
372
373 #define REGWRITE(addr, reg, ret) ( \
374 sc->sm_addr = (addr), \
375 sc->sm_reg = (reg), \
376 sc->sm_returnstate = (ret), \
377 sc->sm_state = UCBADC_REGWRITE)
378 #define REGREAD(addr, ret) ( \
379 sc->sm_addr = (addr), \
380 sc->sm_returnstate = (ret), \
381 sc->sm_state = UCBADC_REGREAD)
382
383 int
384 ucbtp_adc_async(void *arg)
385 {
386 struct ucbtp_softc *sc = arg;
387 tx_chipset_tag_t tc = sc->sc_tc;
388 txreg_t reg;
389 u_int16_t reg16;
390
391 DPRINTFN(9, ("state: %d\n", sc->sm_state));
392
393 switch (sc->sm_state) {
394 default:
395 panic("ucbtp_adc: invalid state %d", sc->sm_state);
396 /* NOTREACHED */
397 break;
398
399 case UCBADC_IDLE:
400 /* nothing to do */
401 break;
402
403 case UCBADC_ADC_INIT:
404 sc->sc_polling++;
405 sc->sc_stat = UCBTS_STAT_DRAG;
406 /* enable heart beat of this state machine */
407 sc->sm_ih = tx_intr_establish(
408 tc,
409 MAKEINTR(1, TX39_INTRSTATUS1_SIBSF0INT),
410 IST_EDGE, IPL_TTY, ucbtp_adc_async, sc);
411
412 sc->sm_state = UCBADC_MEASUMENT_INIT;
413 break;
414
415 case UCBADC_ADC_FINI:
416 /* disable heart beat of this state machine */
417 tx_intr_disestablish(tc, sc->sm_ih);
418 sc->sm_state = UCBADC_IDLE;
419 break;
420
421 case UCBADC_MEASUMENT_INIT:
422 switch (sc->sm_measurement) {
423 default:
424 panic("unknown measurement spec.");
425 /* NOTREACHED */
426 break;
427 case UCBADC_MEASUREMENT_X:
428 REGWRITE(UCB1200_TSCTRL_REG,
429 UCB1200_TSCTRL_XPOSITION,
430 UCBADC_ADC_ENABLE);
431 break;
432 case UCBADC_MEASUREMENT_Y:
433 REGWRITE(UCB1200_TSCTRL_REG,
434 UCB1200_TSCTRL_YPOSITION,
435 UCBADC_ADC_ENABLE);
436 break;
437 case UCBADC_MEASUREMENT_PRESSURE:
438 REGWRITE(UCB1200_TSCTRL_REG,
439 UCB1200_TSCTRL_PRESSURE,
440 UCBADC_ADC_ENABLE);
441 break;
442 }
443 break;
444
445 case UCBADC_MEASUMENT_FINI:
446 switch (sc->sm_measurement) {
447 case UCBADC_MEASUREMENT_X:
448 sc->sm_measurement = UCBADC_MEASUREMENT_Y;
449 sc->sm_state = UCBADC_MEASUMENT_INIT;
450 break;
451 case UCBADC_MEASUREMENT_Y:
452 sc->sm_measurement = UCBADC_MEASUREMENT_PRESSURE;
453 sc->sm_state = UCBADC_MEASUMENT_INIT;
454 break;
455 case UCBADC_MEASUREMENT_PRESSURE:
456 sc->sm_measurement = UCBADC_MEASUREMENT_X;
457 /* measurement complete. pass down to wsmouse_input */
458 sc->sm_state = UCBADC_ADC_INPUT;
459 break;
460 }
461 break;
462
463 case UCBADC_ADC_ENABLE:
464 switch (sc->sm_measurement) {
465 case UCBADC_MEASUREMENT_PRESSURE:
466 /* FALLTHROUGH */
467 case UCBADC_MEASUREMENT_X:
468 sc->sm_tmpreg = UCB1200_ADCCTRL_INPUT_SET(
469 UCB1200_ADCCTRL_ENABLE,
470 UCB1200_ADCCTRL_INPUT_TSPX);
471 REGWRITE(UCB1200_ADCCTRL_REG, sc->sm_tmpreg,
472 UCBADC_ADC_START0);
473 break;
474 case UCBADC_MEASUREMENT_Y:
475 sc->sm_tmpreg = UCB1200_ADCCTRL_INPUT_SET(
476 UCB1200_ADCCTRL_ENABLE,
477 UCB1200_ADCCTRL_INPUT_TSPY);
478 REGWRITE(UCB1200_ADCCTRL_REG, sc->sm_tmpreg,
479 UCBADC_ADC_START0);
480 break;
481 }
482 break;
483
484 case UCBADC_ADC_START0:
485 REGWRITE(UCB1200_ADCCTRL_REG,
486 sc->sm_tmpreg | UCB1200_ADCCTRL_START,
487 UCBADC_ADC_START1);
488 break;
489
490 case UCBADC_ADC_START1:
491 REGWRITE(UCB1200_ADCCTRL_REG,
492 sc->sm_tmpreg,
493 UCBADC_ADC_DATAREAD);
494 sc->sm_retry = UCBADC_RETRY_DEFAULT;
495 break;
496
497 case UCBADC_ADC_DATAREAD:
498 REGREAD(UCB1200_ADCDATA_REG, UCBADC_ADC_DATAREAD_WAIT);
499 break;
500
501 case UCBADC_ADC_DATAREAD_WAIT:
502 reg16 = TX39_SIBSF0_REGDATA(sc->sm_reg);
503 if (!(reg16 & UCB1200_ADCDATA_INPROGRESS) &&
504 --sc->sm_retry > 0) {
505 sc->sm_state = UCBADC_ADC_DATAREAD;
506 } else {
507 if (sc->sm_retry <= 0) {
508 printf("dataread failed\n");
509 sc->sm_state = UCBADC_ADC_FINI;
510 break;
511 }
512
513 switch (sc->sm_measurement) {
514 case UCBADC_MEASUREMENT_X:
515 sc->sc_x = UCB1200_ADCDATA(reg16);
516 DPRINTFN(9, ("x=%d\n", sc->sc_x));
517 break;
518 case UCBADC_MEASUREMENT_Y:
519 sc->sc_y = UCB1200_ADCDATA(reg16);
520 DPRINTFN(9, ("y=%d\n", sc->sc_y));
521 break;
522 case UCBADC_MEASUREMENT_PRESSURE:
523 sc->sc_p = UCB1200_ADCDATA(reg16);
524 DPRINTFN(9, ("p=%d\n", sc->sc_p));
525 break;
526 }
527
528 sc->sm_state = UCBADC_ADC_DISABLE;
529 }
530
531 break;
532
533 case UCBADC_ADC_DISABLE:
534 REGWRITE(UCB1200_ADCCTRL_REG, 0, UCBADC_ADC_INTRMODE);
535
536 break;
537 case UCBADC_ADC_INTRMODE:
538 REGWRITE(UCB1200_TSCTRL_REG, UCB1200_TSCTRL_INTERRUPT,
539 UCBADC_MEASUMENT_FINI);
540 break;
541
542 case UCBADC_ADC_INPUT:
543 if (ucbtp_input(sc) == 0)
544 sc->sm_state = UCBADC_ADC_FINI;
545 else
546 sc->sm_state = UCBADC_INTR_ACK0;
547 break;
548
549 case UCBADC_INTR_ACK0:
550 REGREAD(UCB1200_INTSTAT_REG, UCBADC_INTR_ACK1);
551 break;
552
553 case UCBADC_INTR_ACK1:
554 REGWRITE(UCB1200_INTSTAT_REG, sc->sm_reg, UCBADC_INTR_ACK2);
555 break;
556
557 case UCBADC_INTR_ACK2:
558 sc->sc_polling_finish = 1;
559 REGWRITE(UCB1200_INTSTAT_REG, 0, UCBADC_ADC_FINI);
560 break;
561
562 /*
563 * UCB1200 register access state
564 */
565 case UCBADC_REGREAD:
566 /*
567 * In : sc->sm_addr
568 * Out : sc->sm_reg (with SIBtag)
569 */
570 #define TXSIB_REGREAD_INIT 0
571 #define TXSIB_REGREAD_READ 1
572 switch (sc->sm_read_state) {
573 case TXSIB_REGREAD_INIT:
574 reg = TX39_SIBSF0_REGADDR_SET(0, sc->sm_addr);
575 tx_conf_write(tc, TX39_SIBSF0CTRL_REG, reg);
576 sc->sm_rw_retry = UCBADC_RETRY_DEFAULT;
577 sc->sm_read_state = TXSIB_REGREAD_READ;
578 break;
579 case TXSIB_REGREAD_READ:
580 reg = tx_conf_read(tc, TX39_SIBSF0STAT_REG);
581 if ((TX39_SIBSF0_REGADDR(reg) != sc->sm_addr) &&
582 --sc->sm_rw_retry > 0) {
583 break;
584 }
585
586 if (sc->sm_rw_retry <= 0) {
587 printf("sf0read: command failed\n");
588 sc->sm_state = UCBADC_ADC_FINI;
589 } else {
590 sc->sm_reg = reg;
591 sc->sm_read_state = TXSIB_REGREAD_INIT;
592 DPRINTFN(9, ("%08x\n", reg));
593 if (sc->sm_writing)
594 sc->sm_state = UCBADC_REGWRITE;
595 else
596 sc->sm_state = sc->sm_returnstate;
597 }
598 break;
599 }
600 break;
601
602 case UCBADC_REGWRITE:
603 /*
604 * In : sc->sm_addr, sc->sm_reg (lower 16bit only)
605 */
606 #define TXSIB_REGWRITE_INIT 0
607 #define TXSIB_REGWRITE_WRITE 1
608 switch (sc->sm_write_state) {
609 case TXSIB_REGWRITE_INIT:
610 sc->sm_writing = 1;
611 sc->sm_write_state = TXSIB_REGWRITE_WRITE;
612 sc->sm_state = UCBADC_REGREAD;
613
614 sc->sm_write_val = sc->sm_reg;
615 break;
616 case TXSIB_REGWRITE_WRITE:
617 sc->sm_writing = 0;
618 sc->sm_write_state = TXSIB_REGWRITE_INIT;
619 sc->sm_state = sc->sm_returnstate;
620
621 reg = sc->sm_reg;
622 reg |= TX39_SIBSF0_WRITE;
623 TX39_SIBSF0_REGDATA_CLR(reg);
624 reg = TX39_SIBSF0_REGDATA_SET(reg, sc->sm_write_val);
625 tx_conf_write(tc, TX39_SIBSF0CTRL_REG, reg);
626 break;
627 }
628 break;
629 }
630
631 return (0);
632 }
633
634 int
635 ucbtp_input(struct ucbtp_softc *sc)
636 {
637 int rx, ry, x, y, p;
638
639 rx = sc->sc_x;
640 ry = sc->sc_y;
641 p = sc->sc_p;
642
643 if (!sc->sc_calibrated) {
644 DPRINTFN(2, ("x=%4d y=%4d p=%4d\n", rx, ry, p));
645 DPRINTF(("ucbtp_input: no calibration data\n"));
646 }
647
648 if (p < UCBTS_PRESS_THRESHOLD || rx == 0x3ff || ry == 0x3ff ||
649 rx == 0 || ry == 0) {
650 sc->sc_stat = UCBTS_STAT_RELEASE;
651 if (sc->sc_polling < UCBTS_TAP_THRESHOLD) {
652 DPRINTFN(2, ("TAP!\n"));
653 /* button 0 DOWN */
654 wsmouse_input(sc->sc_wsmousedev, 1, 0, 0, 0, 0, 0);
655 /* button 0 UP */
656 wsmouse_input(sc->sc_wsmousedev, 0, 0, 0, 0, 0, 0);
657 } else {
658 wsmouse_input(sc->sc_wsmousedev, 0,
659 sc->sc_ox, sc->sc_oy, 0, 0,
660 WSMOUSE_INPUT_ABSOLUTE_X |
661 WSMOUSE_INPUT_ABSOLUTE_Y);
662
663 DPRINTFN(2, ("RELEASE\n"));
664 }
665 sc->sc_polling = 0;
666
667 return (1);
668 }
669
670 if (sc->sc_xy_reverse)
671 tpcalib_trans(&sc->sc_tpcalib, ry, rx, &x, &y);
672 else
673 tpcalib_trans(&sc->sc_tpcalib, rx, ry, &x, &y);
674
675 DPRINTFN(2, ("x: %4d->%4d y: %4d->%4d pressure=%4d\n",
676 rx, x, ry, y, p));
677
678 /* debug draw */
679 if (sc->sc_tc->tc_videot) {
680 if (sc->sc_polling == 1)
681 video_dot(sc->sc_tc->tc_videot, x, y);
682 else
683 video_line(sc->sc_tc->tc_videot, sc->sc_ox,
684 sc->sc_oy, x, y);
685 }
686
687 sc->sc_ox = x, sc->sc_oy = y;
688
689 wsmouse_input(sc->sc_wsmousedev, 1, x, y, 0, 0,
690 WSMOUSE_INPUT_ABSOLUTE_X | WSMOUSE_INPUT_ABSOLUTE_Y);
691
692 return (0);
693 }
694
695 /*
696 * access ops.
697 */
698
699 int
700 ucbtp_enable(void *v)
701 {
702 /* not yet */
703 return (0);
704 }
705
706 void
707 ucbtp_disable(void *v)
708 {
709 /* not yet */
710 }
711
712 int
713 ucbtp_ioctl(void *v, u_long cmd, void *data, int flag, struct lwp *l)
714 {
715 struct ucbtp_softc *sc = v;
716
717 DPRINTF(("%s(%d): ucbtp_ioctl(%08lx)\n", __FILE__, __LINE__, cmd));
718
719 switch (cmd) {
720 case WSMOUSEIO_SRES:
721 printf("%s(%d): WSMOUSRIO_SRES is not supported",
722 __FILE__, __LINE__);
723 break;
724
725 default:
726 return hpc_tpanel_ioctl(&sc->sc_tpcalib, cmd, data, flag, l);
727 }
728
729 return 0;
730 }
731