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