FreeBSD/Linux Kernel Cross Reference
sys/chips/dtop.h
1 /*
2 * Mach Operating System
3 * Copyright (c) 1992 Carnegie Mellon University
4 * All Rights Reserved.
5 *
6 * Permission to use, copy, modify and distribute this software and its
7 * documentation is hereby granted, provided that both the copyright
8 * notice and this permission notice appear in all copies of the
9 * software, derivative works or modified versions, and any portions
10 * thereof, and that both notices appear in supporting documentation.
11 *
12 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
13 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
14 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
15 *
16 * Carnegie Mellon requests users of this software to return to
17 *
18 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
19 * School of Computer Science
20 * Carnegie Mellon University
21 * Pittsburgh PA 15213-3890
22 *
23 * any improvements or extensions that they make and grant Carnegie Mellon
24 * the rights to redistribute these changes.
25 */
26 /*
27 * HISTORY
28 * $Log: dtop.h,v $
29 * Revision 2.4 93/01/14 17:15:37 danner
30 * Now we know how to talk to the bus.
31 * Added more keyboard state for beeps.
32 * [from jtp@hut.fi]
33 *
34 * Revision 2.3 92/03/05 17:08:17 rpd
35 * Define how many buttons and coordinates we can take.
36 * [92/03/05 af]
37 *
38 * Revision 2.2 92/03/02 18:32:17 rpd
39 * Created from DEC specs:
40 * "DESKTOPinterconnect Description and Protocol Specification"
41 * Version 0.9, Jun 17 1991
42 * "Open Desktop Bus, Locator Device Protocol Specification"
43 * Version 0.4, Dec 13 1990
44 * "Open Desktop Bus, Keyboard Device Protocol Specification"
45 * Version 0.7, Jan 9 1991
46 * [92/01/19 af]
47 *
48 */
49 /*
50 * File: dtop.h
51 * Author: Alessandro Forin, Carnegie Mellon University
52 * Date: 1/92
53 *
54 * Definitions for the Desktop serial bus (i2c aka ACCESS).
55 */
56
57 #ifndef _DTOP_H_
58 #define _DTOP_H_
59
60 #define DTOP_MAX_DEVICES 14
61 #define DTOP_MAX_MSG_SIZE 36 /* 3 hdr + 32 data + 1 checksum */
62
63 typedef struct {
64
65 unsigned char dest_address; /* low bit is zero */
66 unsigned char src_address; /* ditto */
67 union {
68 struct {
69 unsigned char len : 5, /* message byte len */
70 sub : 2, /* sub-address */
71 P : 1; /* Control(1)/Data(0) marker */
72 } val;
73 unsigned char bits; /* quick check */
74 } code;
75
76 /* varzise, checksum byte at end */
77 unsigned char body[DTOP_MAX_MSG_SIZE-3];
78
79 } dtop_message, *dtop_message_t;
80
81 /*
82 * Standard addresses
83 */
84
85 #define DTOP_ADDR_HOST 0x50 /* address for the (only) host */
86 #define DTOP_ADDR_DEFAULT 0x6e /* power-up default address */
87 #define DTOP_ADDR_FIRST 0x52 /* first assignable address */
88 #define DTOP_ADDR_LAST 0x6c /* last, inclusive */
89
90 #define DTOP_ADDR_KBD 0x6c /* as used by DEC */
91 #define DTOP_ADDR_MOUSE 0x6a
92
93 /*
94 * Standard messages
95 */
96
97 /* from host to devices */
98
99 #define DTOP_MSG_RESET 0xf0 /* preceeded by 0x81: P,len 1 */
100
101 #define DTOP_MSG_ID_REQUEST 0xf1 /* preceeded by 0x81: P,len 1 */
102
103 #define DTOP_MSG_ASSIGN_ADDRESS 0xf2 /* preceeded by 0x9e: P,len 30 */
104 /* followed by a dtop_id_reply_t */
105 /* and by the new_IC_address */
106
107 #define DTOP_MSG_CAP_REQUEST 0xf3 /* preceeded by 0x83: P,len 3 */
108 /* followed by a 16 bit u_offset */
109
110 #define DTOP_MSG_APPL_TEST 0xb1 /* preceed by P, sub, len 1 */
111
112 /* from devices to host */
113
114 #define DTOP_MSG_ATTENTION 0xe0 /* preceeded by P, len */
115 # define DTOP_ATN_OK_STATUS 0x00 /* anything else bad */
116 /* followed by 0-30 bytes */
117
118 #define DTOP_MSG_ID_REPLY 0xe1 /* preceeded by P,len (29..32) */
119
120 typedef struct {
121 unsigned char module_revision[8]; /* ascii, blank padded */
122 unsigned char vendor_name[8];
123 unsigned char module_name[8];
124 int device_number; /* 32 bits cpl-2 */
125 /* 0-3 optional bytes follow, ignore */
126 } dtop_id_reply_t;
127
128 #define DTOP_MSG_CAP_REPLY 0xe3 /* preceeded by P,len (3..32) */
129 /* followed by 16 bit u_offset */
130 /* followed by data */
131
132 #define DTOP_MSG_APPL_SIGNAL 0xa0 /* application level signal */
133 # define DTOP_SIG_ATTENTION 0x00
134 # define DTOP_SIG_RESET 0x01
135 # define DTOP_SIG_HALT 0x02
136
137 #define DTOP_MSG_APPL_TREPLY 0xa1 /* followed by status (0-->ok) */
138 /* and 0..30 bytes of result data */
139
140 /* reserved message codes (testing, manifacturing) */
141
142 #define DTOP_MSG_RES0 0xc0
143 #define DTOP_MSG_RES1 0xc1
144 #define DTOP_MSG_RES2 0xc2
145 #define DTOP_MSG_RES3 0xc3
146
147
148 /*
149 * Device specific definitions: Keyboard
150 */
151
152 /* from host to keyboard */
153
154 #define DTOP_KMSG_CLICK 0x01 /* preceeded by P, sub len 2 */
155 # define DTOP_CLICK_VOLUME_MAX 0x7 /* followed by one byte */
156
157 #define DTOP_KMSG_BELL 0x02 /* preceeded by P, sub len 2 */
158 /* same as above */
159
160 #define DTOP_KMSG_LED 0x03 /* preceeded by P, sub len 2 */
161 /* four lower bits turn leds on */
162
163 #define DTOP_KMSG_POLL 0x04 /* preceeded by P, sub len 1 */
164
165 /* keyboard sends up to 11 codes in a data message, distinguished values: */
166 #define DTOP_KBD_EMPTY 0x00
167 #define DTOP_KBD_OUT_ERR 0x01
168 #define DTOP_KBD_IN_ERR 0x02
169
170 #define DTOP_KBD_KEY_MIN 0x08
171 #define DTOP_KBD_KEY_MAX 0xff
172
173 /* powerup status values: 0 ok, else.. */
174 #define DTOP_KBD_ROM_FAIL 0x01
175 #define DTOP_KBD_RAM_FAIL 0x02
176 #define DTOP_KBD_KEY_DOWN 0x03
177
178
179 /*
180 * Device specific definitions: Locators (mouse)
181 */
182
183 /* locator sends this type of report data */
184
185 typedef struct {
186 unsigned short buttons; /* 1->pressed */
187 short x;
188 short y;
189 short z;
190 /* possibly 3 more dimensions for gloves */
191 } dtop_locator_msg_t;
192
193 #define DTOP_LMSG_SET_RATE 0x01 /* preceeded by P,sub, len 2 */
194 /* followed by sampling interval,
195 from 8 to 25 msecs (0->polled */
196
197 #define DTOP_LMSG_POLL 0x02 /* preceeded by P,sub, len 1 */
198
199 /* Powerup codes same as keyboard */
200
201
202 /*
203 * Implementation specific definitions
204 */
205
206 typedef union {
207
208 dtop_message unknown_report;
209
210 struct {
211 char last_codes_count;
212 unsigned char last_codes[11]; /* max as per specs */
213 unsigned int last_msec; /* autorepeat state */
214 unsigned short poll_frequency;
215 unsigned char k_ar_state;
216 # define K_AR_IDLE 0 /* quiescent, no polling */
217 # define K_AR_OFF 4 /* turn off polling pls */
218 # define K_AR_ACTIVE 2 /* polling, no autos yet */
219 # define K_AR_TRIGGER 1 /* sent one autorepeat */
220 unsigned char bell_volume;
221 unsigned char led_status;
222 } keyboard;
223
224 struct {
225 unsigned char type : 7, /* DEV_MOUSE, DEV_TABLET, .. */
226 relative : 1;
227 unsigned char n_coords;
228 unsigned short prev_buttons;
229 # define L_BUTTON_MAX 16
230 unsigned char button_code[L_BUTTON_MAX];
231 # define L_COORD_MAX 6
232 unsigned int coordinate[L_COORD_MAX]; /* max 6D */
233 } locator;
234
235 /* add more as they come along */
236
237 } dtop_device, *dtop_device_t;
238
239 /* All handler functions should have this interface */
240 extern int
241 dtop_null_device_handler(
242 dtop_device_t dev,
243 dtop_message_t msg,
244 int event,
245 unsigned char outc),
246 dtop_locator_handler(
247 dtop_device_t dev,
248 dtop_message_t msg,
249 int event,
250 unsigned char outc),
251 dtop_keyboard_handler(
252 dtop_device_t dev,
253 dtop_message_t msg,
254 int event,
255 unsigned char outc);
256
257
258 #define DTOP_EVENT_RECEIVE_PACKET 1
259 #define DTOP_EVENT_BAD_PACKET 2
260 #define DTOP_EVENT_PUTC 4
261 #define DTOP_EVENT_POLL 8
262
263
264 #endif /* _DTOP_H_ */
Cache object: 3a51382161c0a246074adb1e6be6caf3
|