sun.h revision a740dc46
1 2/* $Xorg: sun.h,v 1.3 2000/08/17 19:48:29 cpqbld Exp $ */ 3 4/*- 5 * Copyright (c) 1987 by the Regents of the University of California 6 * 7 * Permission to use, copy, modify, and distribute this 8 * software and its documentation for any purpose and without 9 * fee is hereby granted, provided that the above copyright 10 * notice appear in all copies. The University of California 11 * makes no representations about the suitability of this 12 * software for any purpose. It is provided "as is" without 13 * express or implied warranty. 14 */ 15 16/* $XFree86: xc/programs/Xserver/hw/sun/sun.h,v 3.13 2003/11/17 22:20:36 dawes Exp $ */ 17 18#ifndef _SUN_H_ 19#define _SUN_H_ 20 21/* X headers */ 22#include <X11/Xos.h> 23#undef index /* don't mangle silly Sun structure member names */ 24#include <X11/X.h> 25#include <X11/Xproto.h> 26 27/* general system headers */ 28#ifndef NOSTDHDRS 29# include <stdlib.h> 30#else 31# include <malloc.h> 32extern char *getenv(); 33#endif 34 35/* system headers common to both SunOS and Solaris */ 36#include <sys/param.h> 37#include <sys/file.h> 38#include <sys/filio.h> 39#include <sys/ioctl.h> 40#include <sys/resource.h> 41 42#ifdef SVR4 43# ifdef X_POSIX_C_SOURCE 44# define _POSIX_C_SOURCE X_POSIX_C_SOURCE 45# include <signal.h> 46# undef _POSIX_C_SOURCE 47# else 48# define _POSIX_SOURCE 49# include <signal.h> 50# undef _POSIX_SOURCE 51# endif 52#endif 53 54#include <fcntl.h> 55 56#ifndef __bsdi__ 57# ifndef CSRG_BASED 58# ifndef i386 59# include <poll.h> 60# else 61# include <sys/poll.h> 62# endif 63# endif 64#else 65# include <unistd.h> 66#endif 67 68#include <errno.h> 69#include <memory.h> 70#include <signal.h> 71 72 73/* 74 * Sun specific headers Sun moved in Solaris, and are different for NetBSD. 75 * 76 * Even if only needed by one source file, I have put them here 77 * to simplify finding them... 78 */ 79#ifdef SVR4 80# include <sys/fbio.h> 81# include <sys/kbd.h> 82# include <sys/kbio.h> 83# include <sys/msio.h> 84# include <sys/vuid_event.h> 85# include <sys/memreg.h> 86# include <stropts.h> 87# define usleep(usec) poll((struct pollfd *) 0, (size_t) 0, usec / 1000) 88#else 89# ifndef CSRG_BASED 90# include <sun/fbio.h> 91# include <sundev/kbd.h> 92# include <sundev/kbio.h> 93# include <sundev/msio.h> 94# include <sundev/vuid_event.h> 95# include <pixrect/pixrect.h> 96# include <pixrect/memreg.h> 97extern int ioctl(); 98extern int getrlimit(); 99extern int setrlimit(); 100extern int getpagesize(); 101# else 102# if defined(CSRG_BASED) && !defined(__bsdi__) && !defined(__NetBSD__) 103# include <machine/fbio.h> 104# include <machine/kbd.h> 105# include <machine/kbio.h> 106# include <machine/vuid_event.h> 107# endif 108# ifdef __bsdi__ 109# include <sys/fbio.h> 110# include </sys/sparc/dev/kbd.h> 111# include </sys/sparc/dev/kbio.h> 112# include </sys/sparc/dev/vuid_event.h> 113# endif 114# ifdef __NetBSD__ 115# include <dev/sun/fbio.h> 116# include <machine/kbd.h> 117# include <dev/sun/kbio.h> /* also <sparc/kbio.h> -wsr */ 118# include <dev/sun/vuid_event.h> /* also <sparc/vud_event.h> -wsr */ 119# endif 120# endif 121#endif 122 123/* 124 * Sun doesn't see fit to add the TCX to <sys/fbio.h> 125 */ 126#ifndef SVR4 127/* On SunOS 4.1.x the TCX pretends to be a CG3 */ 128#define XFBTYPE_LASTPLUSONE FBTYPE_LASTPLUSONE 129#else 130#define XFBTYPE_TCX 21 131#define XFBTYPE_LASTPLUSONE 22 132#endif 133 134#include <sys/time.h> 135 136/* 137 * Server specific headers 138 */ 139#include "misc.h" 140#undef abs /* don't munge function prototypes in headers, sigh */ 141#include "scrnintstr.h" 142#ifdef NEED_EVENTS 143# include "inputstr.h" 144#endif 145#include "input.h" 146#include "colormapst.h" 147#include "colormap.h" 148#include "cursorstr.h" 149#include "cursor.h" 150#include "dixstruct.h" 151#include "dix.h" 152#include "opaque.h" 153#include "resource.h" 154#include "servermd.h" 155#include "windowstr.h" 156#include "mipointer.h" 157 158/* 159 * ddx specific headers 160 */ 161#ifndef PSZ 162#define PSZ 8 163#endif 164 165extern int monitorResolution; 166 167 168/* Frame buffer devices */ 169#ifdef SVR4 170# define CGTWO0DEV "/dev/fbs/cgtwo0" 171# define CGTWO1DEV "/dev/fbs/cgtwo1" 172# define CGTWO2DEV "/dev/fbs/cgtwo2" 173# define CGTWO3DEV "/dev/fbs/cgtwo3" 174# define CGTHREE0DEV "/dev/fbs/cgthree0" 175# define CGTHREE1DEV "/dev/fbs/cgthree1" 176# define CGTHREE2DEV "/dev/fbs/cgthree2" 177# define CGTHREE3DEV "/dev/fbs/cgthree3" 178# define CGFOUR0DEV "/dev/fbs/cgfour0" 179# define CGSIX0DEV "/dev/fbs/cgsix0" 180# define CGSIX1DEV "/dev/fbs/cgsix1" 181# define CGSIX2DEV "/dev/fbs/cgsix2" 182# define CGSIX3DEV "/dev/fbs/cgsix3" 183# define BWTWO0DEV "/dev/fbs/bwtwo0" 184# define BWTWO1DEV "/dev/fbs/bwtwo1" 185# define BWTWO2DEV "/dev/fbs/bwtwo2" 186# define BWTWO3DEV "/dev/fbs/bwtwo3" 187# define CGEIGHT0DEV "/dev/fbs/cgeight0" 188# define TCX0DEV "/dev/fbs/tcx0" 189#else 190# define CGTWO0DEV "/dev/cgtwo0" 191# define CGTWO1DEV "/dev/cgtwo1" 192# define CGTWO2DEV "/dev/cgtwo2" 193# define CGTWO3DEV "/dev/cgtwo3" 194# define CGTHREE0DEV "/dev/cgthree0" 195# define CGTHREE1DEV "/dev/cgthree1" 196# define CGTHREE2DEV "/dev/cgthree2" 197# define CGTHREE3DEV "/dev/cgthree3" 198# define CGFOUR0DEV "/dev/cgfour0" 199# define CGSIX0DEV "/dev/cgsix0" 200# define CGSIX1DEV "/dev/cgsix1" 201# define CGSIX2DEV "/dev/cgsix2" 202# define CGSIX3DEV "/dev/cgsix3" 203# define BWTWO0DEV "/dev/bwtwo0" 204# define BWTWO1DEV "/dev/bwtwo1" 205# define BWTWO2DEV "/dev/bwtwo2" 206# define BWTWO3DEV "/dev/bwtwo3" 207# define CGEIGHT0DEV "/dev/cgeight0" 208#endif 209 210/* 211 * SUN_MAXEVENTS is the maximum number of events the mouse and keyboard 212 * functions will read on a given call to their GetEvents vectors. 213 */ 214#define SUN_MAXEVENTS 32 215 216/* 217 * Data private to any sun keyboard. 218 */ 219typedef struct { 220 int fd; 221 int type; /* Type of keyboard */ 222 int layout; /* The layout of the keyboard */ 223 int click; /* kbd click save state */ 224 Leds leds; /* last known LED state */ 225} sunKbdPrivRec, *sunKbdPrivPtr; 226 227extern sunKbdPrivRec sunKbdPriv; 228 229/* 230 * Data private to any sun pointer device. 231 */ 232typedef struct { 233 int fd; 234 int bmask; /* last known button state */ 235} sunPtrPrivRec, *sunPtrPrivPtr; 236 237extern sunPtrPrivRec sunPtrPriv; 238 239typedef struct { 240 BYTE key; 241 CARD8 modifiers; 242} SunModmapRec; 243 244typedef struct { 245 int width, height; 246 Bool has_cursor; 247 CursorPtr pCursor; /* current cursor */ 248} sunCursorRec, *sunCursorPtr; 249 250#define NCMAP 256 251typedef struct { 252 u_char origRed[NCMAP]; 253 u_char origGreen[NCMAP]; 254 u_char origBlue[NCMAP]; 255} sunCmapRec, *sunCmapPtr; 256 257typedef struct { 258 ColormapPtr installedMap; 259 CloseScreenProcPtr CloseScreen; 260 void (*UpdateColormap)(ScreenPtr, int, int, u_char *, u_char *, u_char *); 261 void (*GetColormap)(ScreenPtr, int, int, u_char *, u_char *, u_char *); 262 Bool origColormapValid; 263 sunCmapRec origColormap; 264 void (*RestoreColormap)(ScreenPtr); 265 sunCursorRec hardwareCursor; 266 Bool hasHardwareCursor; 267} sunScreenRec, *sunScreenPtr; 268 269extern DevPrivateKeyRec sunScreenPrivateKeyRec; 270#define sunScreenPrivateKey (&sunScreenPrivateKeyRec) 271#define sunSetScreenPrivate(pScreen, v) \ 272 dixSetPrivate(&(pScreen)->devPrivates, sunScreenPrivateKey, (v)) 273#define sunGetScreenPrivate(pScreen) ((sunScreenRec *) \ 274 dixLookupPrivate(&(pScreen)->devPrivates, sunScreenPrivateKey)) 275 276typedef struct { 277 unsigned char* fb; /* Frame buffer itself */ 278 int fd; /* frame buffer for ioctl()s, */ 279 struct fbtype info; /* Frame buffer characteristics */ 280 void (*EnterLeave)(ScreenPtr, int);/* screen switch */ 281 unsigned char* fbPriv; /* fbattr stuff, for the real type */ 282} fbFd; 283 284typedef Bool (*sunFbInitProc)( 285 ScreenPtr /* pScreen */, 286 int /* argc */, 287 char** /* argv */ 288); 289 290typedef struct { 291 sunFbInitProc init; /* init procedure for this fb */ 292 const char *name; /* /usr/include/fbio names */ 293} sunFbDataRec; 294 295/* sunInit.c */ 296extern Bool sunAutoRepeatHandlersInstalled; 297extern sunFbDataRec sunFbData[]; 298extern fbFd sunFbs[]; 299extern Bool sunSwapLkeys; 300extern Bool sunFlipPixels; 301extern Bool sunFbInfo; 302extern Bool sunCG4Frob; 303extern Bool sunNoGX; 304 305/* sunKeyMap.c */ 306extern KeySymsRec sunKeySyms[]; 307extern const SunModmapRec *sunModMaps[]; 308extern const int sunMaxLayout; 309extern KeySym *sunType4KeyMaps[]; 310extern const SunModmapRec *sunType4ModMaps[]; 311 312/* sunKbd.c */ 313extern long sunAutoRepeatInitiate; 314extern long sunAutoRepeatDelay; 315extern DeviceIntPtr sunKeyboardDevice; 316 317/* sunMouse.c */ 318extern Bool sunActiveZaphod; 319extern DeviceIntPtr sunPointerDevice; 320extern miPointerScreenFuncRec sunPointerScreenFuncs; 321 322/* sunFbs.c */ 323extern int sunScreenIndex; 324 325/* sunCursor.c */ 326extern Bool sunCursorInitialize(ScreenPtr); 327extern void sunDisableCursor(ScreenPtr); 328 329/* sunInit.c */ 330extern void sunNonBlockConsoleOff( 331#if defined(SVR4) || defined(CSRG_BASED) 332 void 333#else 334 char* /* arg */ 335#endif 336); 337 338/* sunIo.c */ 339extern void sunEnqueueEvents(void); 340 341/* sunGX.c */ 342extern int sunGXInit(ScreenPtr, fbFd *); 343 344/* sunFbs.c */ 345extern Bool sunSaveScreen(ScreenPtr, int); 346extern Bool sunScreenInit(ScreenPtr); 347extern void *sunMemoryMap(size_t, off_t, int); 348extern Bool sunScreenAllocate(ScreenPtr); 349extern Bool sunInitCommon(int, ScreenPtr, off_t, 350 Bool (* /* init1 */)(ScreenPtr, void *, int, int, int, int, int, int), 351 void (* /* init2 */)(ScreenPtr), 352 Bool (* /* cr_cm */)(ScreenPtr), 353 Bool (* /* save */)(ScreenPtr, int), 354 int); 355 356/* sunKbd.c */ 357extern int sunChangeKbdTranslation(int, Bool); 358extern Firm_event* sunKbdGetEvents(int, Bool, int *, Bool *); 359extern void sunKbdEnqueueEvent(DeviceIntPtr, Firm_event *); 360extern int sunKbdProc(DeviceIntPtr, int); 361extern void sunKbdWait(void); 362 363/* sunMouse.c */ 364extern Firm_event* sunMouseGetEvents(int, Bool, int *, Bool *); 365extern void sunMouseEnqueueEvent(DeviceIntPtr, Firm_event *); 366extern int sunMouseProc(DeviceIntPtr, int); 367 368/* sunCfb.c */ 369Bool sunCG3Init(ScreenPtr, int, char **); 370Bool sunTCXInit(ScreenPtr, int, char **); 371Bool sunCG2Init(ScreenPtr, int, char **); 372Bool sunCG4Init(ScreenPtr, int, char **); 373Bool sunCG6Init(ScreenPtr, int, char **); 374 375/* sunCfb24.c */ 376Bool sunCG8Init(ScreenPtr, int, char **); 377 378/* sunMfb.c */ 379Bool sunBW2Init(ScreenPtr, int, char **); 380 381/* XXX */ 382extern void mfbDoBitblt(DrawablePtr, DrawablePtr, int, RegionPtr, DDXPointPtr); 383 384/*- 385 * TVTOMILLI(tv) 386 * Given a struct timeval, convert its time into milliseconds... 387 */ 388#define TVTOMILLI(tv) (((tv).tv_usec/1000)+((tv).tv_sec*1000)) 389 390extern Bool sunCfbSetupScreen( 391 ScreenPtr /* pScreen */, 392 void * /* pbits */, /* pointer to screen bitmap */ 393 int /* xsize */, /* in pixels */ 394 int /* ysize */, 395 int /* dpix */, /* dots per inch */ 396 int /* dpiy */, /* dots per inch */ 397 int /* width */, /* pixel width of frame buffer */ 398 int /* bpp */ /* bits per pixel of root */ 399); 400 401extern Bool sunCfbFinishScreenInit( 402 ScreenPtr /* pScreen */, 403 void * /* pbits */, /* pointer to screen bitmap */ 404 int /* xsize */, /* in pixels */ 405 int /* ysize */, 406 int /* dpix */, /* dots per inch */ 407 int /* dpiy */, /* dots per inch */ 408 int /* width */, /* pixel width of frame buffer */ 409 int /* bpp */ /* bits per pixel of root */ 410); 411 412extern Bool sunCfbScreenInit( 413 ScreenPtr /* pScreen */, 414 void * /* pbits */, /* pointer to screen bitmap */ 415 int /* xsize */, /* in pixels */ 416 int /* ysize */, 417 int /* dpix */, /* dots per inch */ 418 int /* dpiy */, /* dots per inch */ 419 int /* width */, /* pixel width of frame buffer */ 420 int /* bpp */ /* bits per pixel of root */ 421); 422 423extern void sunInstallColormap( 424 ColormapPtr /* cmap */ 425); 426 427extern void sunUninstallColormap( 428 ColormapPtr /* cmap */ 429); 430 431extern int sunListInstalledColormaps( 432 ScreenPtr /* pScreen */, 433 Colormap* /* pCmapList */ 434); 435 436#endif 437