ucb1200var.h revision 1.1 1 /* $NetBSD: ucb1200var.h,v 1.1 2000/01/08 21:07:04 uch Exp $ */
2
3 /*
4 * Copyright (c) 2000, by UCHIYAMA Yasushi
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. The name of the developer may NOT be used to endorse or promote products
13 * derived from this software without specific prior written permission.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 * SUCH DAMAGE.
26 *
27 */
28
29 enum ucbts_stat {
30 UCBTS_STAT_DISABLE,
31 UCBTS_STAT_RELEASE,
32 UCBTS_STAT_TOUCH,
33 UCBTS_STAT_DRAG,
34 };
35
36 #define UCBTS_POSX 1
37 #define UCBTS_POSY 2
38 #define UCBTS_PRESS 3
39
40 #define UCBTS_PRESS_THRESHOLD 100
41 #define UCBTS_TAP_THRESHOLD 5
42
43 enum ucbadc_state {
44 /* 0 */ UCBADC_IDLE,
45 /* 1 */ UCBADC_ADC_INIT,
46 /* 2 */ UCBADC_ADC_FINI,
47 /* 3 */ UCBADC_MEASUMENT_INIT,
48 /* 4 */ UCBADC_MEASUMENT_FINI,
49 /* 5 */ UCBADC_ADC_ENABLE,
50 /* 6 */ UCBADC_ADC_START0,
51 /* 7 */ UCBADC_ADC_START1,
52 /* 8 */ UCBADC_ADC_DATAREAD,
53 /* 9 */ UCBADC_ADC_DATAREAD_WAIT,
54 /*10 */ UCBADC_ADC_DISABLE,
55 /*11 */ UCBADC_ADC_INTRMODE,
56 /*12 */ UCBADC_ADC_INPUT,
57 /*13 */ UCBADC_INTR_ACK0,
58 /*14 */ UCBADC_INTR_ACK1,
59 /*15 */ UCBADC_INTR_ACK2,
60 /*16 */ UCBADC_REGREAD,
61 /*17 */ UCBADC_REGWRITE
62 };
63
64 struct ucb1200_softc {
65 struct device sc_dev;
66 struct device *sc_parent; /* parent (TX39 SIB module) */
67 tx_chipset_tag_t sc_tc;
68
69 enum ucbts_stat sc_stat;
70 int sc_polling;
71 int sc_polling_finish;
72 void *sc_pollh;
73
74 /* correction parameters */
75 int sc_prmax, sc_prmbx, sc_prmcx, sc_prmxs;
76 int sc_prmay, sc_prmby, sc_prmcy, sc_prmys;
77 /* limit */
78 int sc_maxx, sc_maxy;
79
80 /* measurement value */
81 int sc_x, sc_y, sc_p;
82
83 /* SIB frame 0 state machine */
84 void *sm_ih; /* TX39 SIB subframe 0 interrupt handler */
85
86 int sm_addr; /* UCB1200 register address */
87 u_int32_t sm_reg; /* UCB1200 register data & TX39 SIB header */
88 int sm_tmpreg;
89 int sm_retry; /* retry counter */
90
91 enum ucbadc_state sm_state;
92 int sm_measurement; /* X, Y, Pressure */
93 #define UCBADC_MEASUREMENT_X 0
94 #define UCBADC_MEASUREMENT_Y 1
95 #define UCBADC_MEASUREMENT_PRESSURE 2
96 int sm_returnstate;
97
98 int sm_read_state, sm_write_state;
99 int sm_writing; /* writing state flag */
100 u_int32_t sm_write_val; /* temporary buffer */
101
102 int sm_rw_retry; /* retry counter for r/w */
103
104 /* wsmouse */
105 struct device *sc_wsmousedev;
106 };
107
108