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