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