xref: /original-bsd/sys/vax/uba/qduser.h (revision 703f6d5d)
1 /*-
2  * Copyright (c) 1982, 1986 The Regents of the University of California.
3  * All rights reserved.
4  *
5  * %sccs.include.redist.c%
6  *
7  *	@(#)qduser.h	7.1 (Berkeley) 05/09/91
8  */
9 
10 /* derived from: @(#)qduser.h	6.1	(ULTRIX)	11/24/87       */
11 /************************************************************************
12  *									*
13  *			Copyright (c) 1986 by				*
14  *		Digital Equipment Corporation, Maynard, MA		*
15  *			All rights reserved.				*
16  *									*
17  *   This software is furnished under a license and may be used and	*
18  *   copied  only  in accordance with the terms of such license and	*
19  *   with the  inclusion  of  the  above  copyright  notice.   This	*
20  *   software  or  any  other copies thereof may not be provided or	*
21  *   otherwise made available to any other person.  No title to and	*
22  *   ownership of the software is hereby transferred.			*
23  *									*
24  *   The information in this software is subject to change  without	*
25  *   notice  and should not be construed as a commitment by Digital	*
26  *   Equipment Corporation.						*
27  *									*
28  *   Digital assumes no responsibility for the use  or  reliability	*
29  *   of its software on equipment which is not supplied by Digital.	*
30  *									*
31  ************************************************************************/
32 
33 /***************************************************************************
34 *
35 *	QDUSER...
36 *	This file defines values shared between the driver and a client
37 *
38 ***************************************************************************/
39 
40 /***************************************************************************
41 *	revision history:
42 ****************************************************************************
43 *
44 * 21 jul 86  ram    fixed define of CURSOR_MIN_Y
45 * 25 nov 85  longo  added macro and bit defines for DMA error flags
46 * 11 nov 85  longo  renamed _vs_eventqueue to "qdinput" struct
47 * 23 oct 85  longo  added more defines to the DMA stuff
48 * 17 oct 85  longo  changed "struct rgb" chars to be unsigned
49 * 16 oct 85  longo  added new TABLET support definitions
50 * 15 oct 85  longo  re-wrote DMA queue access macros
51 * 08 oct 85  longo  added status flag manipulation macros to DMA stuff
52 * 02 oct 85  longo  added support for color map write buffer loading
53 * 26 sep 85  longo  removed adder sertup params from DMA request struct
54 * 23 sep 85  longo  added DMA queue access macros
55 * 30 aug 85  longo  fixed crock in "qdiobuf" struct compile-time sizing. Also
56 *		    removed DMAcontrol struct from DMA buffer for field test
57 * 26 aug 85  longo  put in conditional include of "qevent.h" for user prg's
58 * 18 jul 85  longo  changed semantics so that head is tail and tail is head
59 * 12 jul 85  longo  moved "mouse_report" struct and defs over to qd_data.c
60 * 11 jul 85  longo  added device coordinate to gate array cursor coordinate
61 *		    transformation macros
62 * 03 jul 85  longo  changed kernel typdef's for data types to long-hand
63 * 10 may 85  longo  created
64 *
65 ***************************************************************************/
66 
67 #ifdef KERNEL
68 #include "../uba/qevent.h"		/* include event struct defs */
69 #else
70 #include <vax/uba/qevent.h>
71 #endif
72 
73 /*---------------------
74 * QDSS device map */
75 
76 	struct qdmap {			/* map of register blocks in QDSS */
77 
78 	    char *template;
79 	    char *adder;
80 	    char *dga;
81 	    char *duart;
82 	    char *memcsr;
83 	    char *red;
84 	    char *blue;
85 	    char *green;
86 	};
87 
88 /*--------------------------------------------
89 * DGA CSR bit definitions and register map */
90 
91 #define DMADONE		0x8000		/* DMA done status */
92 #define SET_DONE_FIFO	0x4000		/* set DMADONE when FIFO empty.. */
93 					/* ..AND count = 0 */
94 
95 #define PTOB_ENB	0x0600		/* host-to-bitmap DMA xfer */
96 #define BTOP_ENB	0x0400		/* bitmap-to-host DMA xfer */
97 #define DL_ENB		0x0200		/* display list DMA xfer */
98 #define HALT		0x0000		/* halt DGA */
99 
100 #define BYTE_DMA	0x0100		/* byte/word DMA xfer */
101 
102 #define DMA_ERR		0x0080		/* DMA error bits */
103 #define PARITY_ERR	0x0040		/* memory parity error in DMA */
104 #define BUS_ERR		0x0020		/* bus timeout error in DMA */
105 
106 #define GLOBAL_IE	0x0004		/* global interrupt enable */
107 #define DMA_IE		0x0002		/* DMA interrupt enable */
108 #define CURS_ENB	0x0001		/* cursor enable */
109 
110 /* QDSS memcsr bit definitions */
111 
112 #define	UNBLANK			0x0020
113 #define SYNC_ON			0x0008
114 
115 	struct dga {
116 
117 	    unsigned short csr;
118 	    unsigned short adrs_lo;	/* destination address of bitmap to */
119 	    unsigned short adrs_hi;	/*   host DMA */
120 	    unsigned short bytcnt_lo;	/* byte length of requested DMA */
121 	    unsigned short bytcnt_hi;	/* (WO = bytcnt) (RO = fifo count) */
122 	    unsigned short fifo;	/* FIFO register */
123 	    unsigned short x_cursor;	/* cursor position registers */
124 	    unsigned short y_cursor;
125 	    unsigned short ivr;		/* interrupt vector register */
126 	    unsigned short memadr;	/* memory base address register */
127 	};
128 
129 /*-------------------------------------------------------------------------
130 * macros to transform device coordinates to hardware cursor coordinates */
131 
132 #define CURS_MIN_X 	232	/* device coordinate x = 0 */
133 #define CURS_MIN_Y 	16	/* device coordinate y = 0 */
134 
135 #define TRANX(x) ( -(((int)(x)+CURS_MIN_X) & ~0x0003) | \
136 		   (((int)(x)+CURS_MIN_X) & 0x0003) )
137 
138 #define TRANY(y) ( -((y)+CURS_MIN_Y) )
139 
140 /*********************************************************************
141 *
142 *	EVENT QUEUE DEFINITIONS
143 *
144 **********************************************************************
145 * most of the event queue definitions are found in "qevent.h".  But a
146 * few things not found there are here.  */
147 
148 /* The event queue header */
149 
150 typedef struct qdinput {
151 
152 	    struct _vs_eventqueue header;  /* event queue ring handling */
153 
154 	    /* for VS100 and QVSS compatability reasons, additions to this
155 	    *  structure must be made below this point.  */
156 
157 	    struct _vs_cursor curs_pos;	/* current mouse position */
158 	    struct _vs_box curs_box;	/* cursor reporting box */
159 
160 	};
161 
162 /* vse_key field.  definitions for mouse buttons */
163 
164 #define VSE_LEFT_BUTTON		0
165 #define VSE_MIDDLE_BUTTON	1
166 #define VSE_RIGHT_BUTTON	2
167 
168 /* vse_key field.  definitions for mouse buttons */
169 
170 #define VSE_T_LEFT_BUTTON	0
171 #define VSE_T_FRONT_BUTTON	1
172 #define VSE_T_RIGHT_BUTTON	2
173 #define VSE_T_BACK_BUTTON	4
174 
175 #define VSE_T_BARREL_BUTTON	VSE_T_LEFT_BUTTON
176 #define VSE_T_TIP_BUTTON	VSE_T_FRONT_BUTTON
177 
178 /*--------------------------------------------------------------------------
179 *   These are the macros to be used for loading and extracting from the event
180 * queue.  It is presumed that the macro user will only use the access macros
181 * if the event queue is non-empty ( ISEMPTY(eq) == FALSE ), and that the
182 * driver will only load the event queue after checking that it is not full
183 * ( ISFULL(eq) == FALSE ).  ("eq" is a pointer to the event queue header.)
184 *
185 *   Before an event access session for a particular event, the macro users
186 * must use the xxxBEGIN macro, and the xxxEND macro after an event is through
187 * with.  As seen below, the xxxBEGIN and xxxEND macros maintain the event
188 * queue access mechanism.
189 *
190 * First, the macros to be used by the event queue reader
191 */
192 
193 #define ISEMPTY(eq)	  ((eq)->header.head == (eq)->header.tail)
194 #define GETBEGIN(eq)	  (&(eq)->header.events[(eq)->header.head])
195 
196 #define GET_X(event)	  ((event)->vse_x)  	     /* get x position */
197 #define GET_Y(event)	  ((event)->vse_y)  	     /* get y position */
198 #define GET_TIME(event)	  ((event)->vse_time) 	     /* get time */
199 #define GET_TYPE(event)	  ((event)->vse_type)	     /* get entry type */
200 #define GET_KEY(event)	  ((event)->vse_key)  	     /* get keycode */
201 #define GET_DIR(event)	  ((event)->vse_direction)     /* get direction */
202 #define GET_DEVICE(event) ((event)->vse_device)        /* get device */
203 
204 #define GETEND(eq)        (++(eq)->header.head >= (eq)->header.size ? \
205 			   (eq)->header.head = 0 : 0 )
206 
207 /*------------------------------------------------
208 * macros to be used by the event queue loader  */
209 
210 	/* ISFULL yields TRUE if queue is full */
211 
212 #define ISFULL(eq)	((eq)->header.tail+1 == (eq)->header.head ||   \
213 			 ((eq)->header.tail+1 == (eq)->header.size &&  \
214 			  (eq)->header.head == 0))
215 
216 	/* get address of the billet for NEXT event */
217 
218 #define PUTBEGIN(eq)	(&(eq)->header.events[(eq)->header.tail])
219 
220 #define PUT_X(event, value)  	((event)->vse_x = value)    /* put X pos */
221 #define PUT_Y(event, value)   	((event)->vse_y = value)    /* put Y pos */
222 #define PUT_TIME(event, value)	((event)->vse_time = value)   /* put time */
223 #define PUT_TYPE(event, value)	((event)->vse_type = value) /* put type */
224 #define PUT_KEY(event, value)	((event)->vse_key = value) /* put input key */
225 #define PUT_DIR(event, value)	((event)->vse_direction = value) /* put dir */
226 #define PUT_DEVICE(event, value) ((event)->vse_device = value)   /* put dev */
227 
228 #define PUTEND(eq)     (++(eq)->header.tail >= (eq)->header.size ?  \
229 			(eq)->header.tail = 0 : 0)
230 
231 /******************************************************************
232 *
233 *	DMA I/O DEFINITIONS
234 *
235 ******************************************************************/
236 
237 /*---------------------------------------------------------------------
238 * The DMA request queue is implemented as a ring buffer of "DMAreq"
239   structures.  The queue is accessed using ring indices located in the
240   "DMAreq_header" structure.  Access is implemented using access macros
241   similar to the event queue access macros above.  */
242 
243 	struct DMAreq {
244 
245 	    short DMAtype;		/* DMA type code (for QDSS) */
246 	    short DMAdone;		/* DMA done parameter */
247 	    char  *bufp;		/* virtual adrs of buffer */
248 	    int   length;	        /* transfer buffer length */
249 	};
250 
251 /* DMA type command codes */
252 
253 #define DISPLIST	1	/* display list DMA */
254 #define PTOB		2	/* 1 plane Qbus to bitmap DMA */
255 #define BTOP		3	/* 1 plane bitmap to Qbus DMA */
256 
257 /* DMA done notification code */
258 
259 #define FIFO_EMPTY	0x01	/* DONE when FIFO becomes empty */
260 #define COUNT_ZERO	0x02	/* DONE when count becomes zero */
261 #define WORD_PACK	0x04    /* program the gate array for word packing */
262 #define BYTE_PACK	0x08	/* program gate array for byte packing */
263 #define REQUEST_DONE	0x100	/* clear when driver has processed request */
264 #define HARD_ERROR	0x200   /* DMA hardware error occurred */
265 
266 /* DMA request queue is a ring buffer of request structures */
267 
268 	struct DMAreq_header {
269 
270 	    int QBAreg;		    /* cookie Qbus map reg for this buffer */
271 	    short status;	    /* master DMA status word */
272 	    int shared_size;	    /* size of shared memory in bytes */
273 	    struct DMAreq *DMAreq;  /* start address of request queue */
274 	    int used;		    /* # of queue entries currently used */
275 	    int size;		    /* # of "DMAreq"'s in the request queue */
276 	    int oldest;		    /* index to oldest queue'd request */
277 	    int newest;		    /* index to newest queue'd request */
278 	};
279 
280 /* bit definitions for DMAstatus word in DMAreq_header */
281 
282 #define	DMA_ACTIVE	0x0004		/* DMA in progress */
283 #define DMA_ERROR	0x0080		/* DMA hardware error */
284 #define DMA_IGNORE	0x0002		/* flag to ignore this interrupt */
285 
286 /*------------------------------------------
287 * macros for DMA request queue fiddling  */
288 
289 	/* DMA status set/check macros */
290 
291 #define DMA_SETACTIVE(header)   ((header)->status |= DMA_ACTIVE)
292 #define DMA_CLRACTIVE(header)	((header)->status &= ~DMA_ACTIVE)
293 #define DMA_ISACTIVE(header)    ((header)->status & DMA_ACTIVE)
294 
295 #define DMA_SETERROR(header)    ((header)->status |= DMA_ERROR)
296 #define DMA_CLRERROR(header)    ((header)->status &= ~DMA_ERROR)
297 #define DMA_ISERROR(header)     ((header)->status & DMA_ERROR)
298 
299 #define DMA_SETIGNORE(header)	((header)->status |= DMA_IGNORE)
300 #define DMA_CLRIGNORE(header)   ((header)->status &= ~DMA_IGNORE)
301 #define DMA_ISIGNORE(header)    ((header)->status & DMA_IGNORE)
302 
303 	/* yields TRUE if queue is empty (ISEMPTY) or full (ISFULL) */
304 
305 #define DMA_ISEMPTY(header)	((header)->used == 0)
306 #define DMA_ISFULL(header)	((header)->used >= (header)->size)
307 
308 	/* returns address of the billet for next (PUT)
309 	 * or oldest (GET) request */
310 
311 #define DMA_PUTBEGIN(header)	(&(header)->DMAreq[(header)->newest])
312 #define DMA_GETBEGIN(header)  	(&(header)->DMAreq[(header)->oldest])
313 
314 	/* does queue access pointer maintenance */
315 
316 #define DMA_GETEND(header)      (++(header)->oldest >= (header)->size    \
317 				  ? (header)->oldest = 0 : 0);		 \
318 				--(header)->used;
319 
320 #define DMA_PUTEND(header)     	(++(header)->newest >= (header)->size    \
321 				  ? (header)->newest = 0 : 0);		 \
322 				++(header)->used;
323 
324 /******************************************************************
325 *
326 *	COLOR MAP WRITE BUFFER DEFINITIONS
327 *
328 ******************************************************************/
329 
330 	struct rgb {
331 
332 	    unsigned char offset;	/* color map address for load */
333 	    unsigned char red;		/* data for red map */
334 	    unsigned char green;	/* data for green map */
335 	    unsigned char blue;		/* data for blue map */
336 	};
337 
338 	struct color_buf {
339 
340 	    char status;		/* load request/service status */
341 	    short count;		/* number of entries to br loaded */
342 	    struct rgb rgb[256];
343 	};
344 
345 #define LOAD_COLOR_MAP	0x0001
346 
347 /******************************************************************
348 *
349 *	SCROLL ASSIST DEFINITIONS
350 *
351 ******************************************************************/
352 
353 	struct scroll {
354 
355 	    short status;
356 	    short viper_constant;
357 	    short y_scroll_constant;
358 	    short y_offset;
359 	    short x_index_pending;
360 	    short y_index_pending;
361 	};
362 
363 #define LOAD_REGS	0x0001
364 #define LOAD_INDEX	0x0002
365 
366 /******************************************************************
367 *
368 *	MOUSE/TABLET/KBD PROGRAMMING DEFINITIONS
369 *
370 ******************************************************************/
371 
372 /*-----------------------------------
373 * LK201 programmming definitions  */
374 
375 #define LK_UPDOWN 	0x86		/* bits for setting lk201 modes */
376 #define LK_AUTODOWN 	0x82
377 #define LK_DOWN 	0x80
378 #define LK_DEFAULTS 	0xD3		/* reset (some) default settings */
379 #define LK_AR_ENABLE 	0xE3		/* global auto repeat enable */
380 #define LK_CL_ENABLE 	0x1B		/* keyclick enable */
381 #define LK_KBD_ENABLE 	0x8B		/* keyboard enable */
382 #define LK_BELL_ENABLE 	0x23		/* the bell */
383 #define LK_RING_BELL 	0xA7		/* ring keyboard bell */
384 
385 #define LK_LED_ENABLE 	0x13		/* light led */
386 #define LK_LED_DISABLE 	0x11		/* turn off led */
387 #define LED_1 		0x81		/* led bits */
388 #define LED_2 		0x82
389 #define LED_3 		0x84
390 #define LED_4 		0x88
391 #define LED_ALL 	0x8F
392 #define LK_LED_HOLD	LED_4
393 #define LK_LED_LOCK	LED_3
394 #define LK_LED_COMPOSE	LED_2
395 #define LK_LED_WAIT 	LED_1
396 
397 #define LK_KDOWN_ERROR	0x3D		/* key down on powerup error */
398 #define LK_POWER_ERROR 	0x3E		/* keyboard failure on powerup test */
399 #define LK_OUTPUT_ERROR	0xB5		/* keystrokes lost during inhibit */
400 #define LK_INPUT_ERROR 	0xB6		/* garbage command to keyboard */
401 #define LK_LOWEST	0x56		/* lowest significant keycode */
402 #define LK_DIV6_START	0xAD		/* start of div 6 */
403 #define LK_DIV5_END	0xB2		/* end of div 5 */
404 
405 #define LAST_PARAM	0x80		/* "no more params" bit */
406 
407 	struct prgkbd {
408 
409 	    short cmd;			/* LK201 command opcode */
410 	    short param1;		/* 1st cmd parameter (can be null) */
411 	    short param2;		/* 2nd cmd parameter (can be null) */
412 	};
413 
414 /*-------------------------
415 * "special" LK-201 keys */
416 
417 #define SHIFT		174
418 #define LOCK		176
419 #define REPEAT		180
420 #define CNTRL		175
421 #define ALLUP		179
422 
423 /*--------------------------------
424 * cursor programming structure */
425 
426 	struct prg_cursor {
427 
428 	    unsigned short acc_factor;	/* cursor aceleration factor */
429 	    unsigned short threshold;	/* threshold to trigger acc at */
430 	};
431 
432 /*---------------------
433 * mouse definitions */
434 
435 #define INC_STREAM_MODE	'R'		/* stream mode reports (55 hz) */
436 #define PROMPT_MODE	'D'		/* report when prompted */
437 #define REQUEST_POS	'P'		/* request position report */
438 #define SELF_TEST	'T'		/* request self test */
439 
440 #define MOUSE_ID	0x2		/* mouse ID in lo 4 bits */
441 
442 #define START_FRAME	0x80		/* start of report frame bit */
443 #define X_SIGN		0x10		/* position sign bits */
444 #define Y_SIGN		0x08
445 
446 #define RIGHT_BUTTON	0x01		/* mouse buttons */
447 #define MIDDLE_BUTTON	0x02
448 #define LEFT_BUTTON	0x04
449 
450 	/* mouse report structure definition */
451 
452 	struct mouse_report {
453 
454 	    char state;		/* buttons and sign bits */
455 	    short dx;		/* delta X since last change */
456 	    short dy;		/* delta Y since last change */
457 	    char bytcnt;	/* mouse report byte count */
458 	};
459 
460 /*-----------------------------------------
461 * tablet command/interface definitions  */
462 
463 #define T_STREAM	'R'		/* continuous stream report mode */
464 #define T_POINT	 	'D'		/* enter report-on-request mode */
465 #define T_REQUEST	'P'		/* request position report */
466 
467 #define T_BAUD		'B'		/* increase baud to 9600 from 4800 */
468 #define T_RATE_55	'K'		/* report rate: 55/sec */
469 #define T_RATE_72	'L'		/* report rate: 72/sec */
470 #define T_RATE_120	'M'		/* report rate: 120/sec (9600 only) */
471 
472 #define T_TEST		SELF_TEST	/* do self test */
473 
474 #define TABLET_ID	0x4		/* tablet ID in lo 4 bits */
475 
476 #define T_START_FRAME	0x80		/* start of report frame bit */
477 #define T_PROXIMITY	0x01		/* state pointer in proximity */
478 
479 #define T_LEFT_BUTTON	0x02		/* puck buttons */
480 #define T_FRONT_BUTTON	0x04
481 #define T_RIGHT_BUTTON	0x08
482 #define T_BACK_BUTTON	0x10
483 
484 #define T_BARREL_BUTTON T_LEFT_BUTTON		/* stylus buttons */
485 #define T_TIP_BUTTON	T_FRONT_BUTTON
486 
487