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