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