sun.h revision 685bea66
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
216typedef struct {
217    BYTE	key;
218    CARD8	modifiers;
219} SunModmapRec;
220
221typedef struct {
222    int		    width, height;
223    Bool	    has_cursor;
224    CursorPtr	    pCursor;		/* current cursor */
225} sunCursorRec, *sunCursorPtr;
226
227#define NCMAP	256
228typedef struct {
229    u_char	    origRed[NCMAP];
230    u_char	    origGreen[NCMAP];
231    u_char	    origBlue[NCMAP];
232} sunCmapRec, *sunCmapPtr;
233
234typedef struct {
235    ColormapPtr	    installedMap;
236    CloseScreenProcPtr CloseScreen;
237    void	    (*UpdateColormap)(ScreenPtr, int, int, u_char *, u_char *, u_char *);
238    void	    (*GetColormap)(ScreenPtr, int, int, u_char *, u_char *, u_char *);
239    Bool	    origColormapValid;
240    sunCmapRec	    origColormap;
241    void	    (*RestoreColormap)(ScreenPtr);
242    sunCursorRec    hardwareCursor;
243    Bool	    hasHardwareCursor;
244} sunScreenRec, *sunScreenPtr;
245
246extern DevPrivateKeyRec sunScreenPrivateKeyRec;
247#define sunScreenPrivateKey (&sunScreenPrivateKeyRec)
248#define sunSetScreenPrivate(pScreen, v) \
249    dixSetPrivate(&(pScreen)->devPrivates, sunScreenPrivateKey, (v))
250#define sunGetScreenPrivate(pScreen) ((sunScreenRec *) \
251    dixLookupPrivate(&(pScreen)->devPrivates, sunScreenPrivateKey))
252
253typedef struct {
254    unsigned char*  fb;		/* Frame buffer itself */
255    int		    fd;		/* frame buffer for ioctl()s, */
256    struct fbtype   info;	/* Frame buffer characteristics */
257    void	    (*EnterLeave)(ScreenPtr, int);/* screen switch */
258    unsigned char*  fbPriv;	/* fbattr stuff, for the real type */
259} fbFd;
260
261typedef Bool (*sunFbInitProc)(
262    ScreenPtr /* pScreen */,
263    int /* argc */,
264    char** /* argv */
265);
266
267typedef struct {
268    sunFbInitProc	init;	/* init procedure for this fb */
269    const char		*name;	/* /usr/include/fbio names */
270} sunFbDataRec;
271
272/* sunInit.c */
273extern sunFbDataRec	sunFbData[];
274extern fbFd		sunFbs[];
275extern Bool		sunSwapLkeys;
276extern Bool		sunForceMono;
277extern Bool		sunDebug;
278extern char		*sunDeviceList;
279extern Bool		sunFlipPixels;
280extern Bool		sunFbInfo;
281extern Bool		sunCG4Frob;
282extern Bool		sunNoGX;
283
284/* sunKeyMap.c */
285extern KeySymsRec	sunKeySyms[];
286extern const int	sunMaxLayout;
287extern KeySym		*sunType4KeyMaps[];
288
289/* sunKbd.c */
290extern DeviceIntPtr	sunKeyboardDevice;
291
292/* sunMouse.c */
293extern Bool		sunActiveZaphod;
294extern DeviceIntPtr	sunPointerDevice;
295extern miPointerScreenFuncRec sunPointerScreenFuncs;
296
297/* sunCursor.c */
298extern Bool sunCursorInitialize(ScreenPtr);
299extern void sunDisableCursor(ScreenPtr);
300
301/* sunInit.c */
302extern void sunNonBlockConsoleOff(
303#if defined(SVR4) || defined(CSRG_BASED)
304    void
305#else
306    char* /* arg */
307#endif
308);
309
310/* sunGX.c */
311extern int sunGXInit(ScreenPtr, fbFd *);
312
313/* sunFbs.c */
314extern Bool sunSaveScreen(ScreenPtr, int);
315extern Bool sunScreenInit(ScreenPtr);
316extern void *sunMemoryMap(size_t, off_t, int);
317extern Bool sunScreenAllocate(ScreenPtr);
318extern Bool sunInitCommon(int, ScreenPtr, off_t,
319    Bool (* /* init1 */)(ScreenPtr, void *, int, int, int, int, int, int),
320    void (* /* init2 */)(ScreenPtr),
321    Bool (* /* cr_cm */)(ScreenPtr),
322    Bool (* /* save */)(ScreenPtr, int),
323    int);
324
325/* sunKbd.c */
326extern int sunKbdProc(DeviceIntPtr, int);
327
328/* sunMouse.c */
329extern int sunMouseProc(DeviceIntPtr, int);
330
331/* sunCfb.c */
332Bool sunCG3Init(ScreenPtr, int, char **);
333Bool sunTCXInit(ScreenPtr, int, char **);
334Bool sunCG2Init(ScreenPtr, int, char **);
335Bool sunCG4Init(ScreenPtr, int, char **);
336Bool sunCG6Init(ScreenPtr, int, char **);
337
338/* sunCfb24.c */
339Bool sunCG8Init(ScreenPtr, int, char **);
340
341/* sunMfb.c */
342Bool sunBW2Init(ScreenPtr, int, char **);
343
344/* XXX */
345extern void mfbDoBitblt(DrawablePtr, DrawablePtr, int, RegionPtr, DDXPointPtr);
346
347/*-
348 * TVTOMILLI(tv)
349 *	Given a struct timeval, convert its time into milliseconds...
350 */
351#define TVTOMILLI(tv)	(((tv).tv_usec/1000)+((tv).tv_sec*1000))
352
353extern Bool sunCfbSetupScreen(
354    ScreenPtr /* pScreen */,
355    void * /* pbits */,		/* pointer to screen bitmap */
356    int /* xsize */,		/* in pixels */
357    int /* ysize */,
358    int /* dpix */,		/* dots per inch */
359    int /* dpiy */,		/* dots per inch */
360    int /* width */,		/* pixel width of frame buffer */
361    int	/* bpp */		/* bits per pixel of root */
362);
363
364extern Bool sunCfbFinishScreenInit(
365    ScreenPtr /* pScreen */,
366    void * /* pbits */,		/* pointer to screen bitmap */
367    int /* xsize */,		/* in pixels */
368    int /* ysize */,
369    int /* dpix */,		/* dots per inch */
370    int /* dpiy */,		/* dots per inch */
371    int /* width */,		/* pixel width of frame buffer */
372    int	/* bpp */		/* bits per pixel of root */
373);
374
375extern Bool sunCfbScreenInit(
376    ScreenPtr /* pScreen */,
377    void * /* pbits */,		/* pointer to screen bitmap */
378    int /* xsize */,		/* in pixels */
379    int /* ysize */,
380    int /* dpix */,		/* dots per inch */
381    int /* dpiy */,		/* dots per inch */
382    int /* width */,		/* pixel width of frame buffer */
383    int	/* bpp */		/* bits per pixel of root */
384);
385
386extern void sunInstallColormap(
387    ColormapPtr /* cmap */
388);
389
390extern void sunUninstallColormap(
391    ColormapPtr /* cmap */
392);
393
394extern int sunListInstalledColormaps(
395    ScreenPtr /* pScreen */,
396    Colormap* /* pCmapList */
397);
398
399#endif
400