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