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