sun.h revision c46e3e8e
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 sunFbDataRec	sunFbData[];
297extern fbFd		sunFbs[];
298extern Bool		sunSwapLkeys;
299extern Bool		sunForceMono;
300extern Bool		sunDebug;
301extern Bool		sunFlipPixels;
302extern Bool		sunFbInfo;
303extern Bool		sunCG4Frob;
304extern Bool		sunNoGX;
305
306/* sunKeyMap.c */
307extern KeySymsRec	sunKeySyms[];
308extern const int	sunMaxLayout;
309extern KeySym		*sunType4KeyMaps[];
310
311/* sunKbd.c */
312extern long		sunAutoRepeatInitiate;
313extern long		sunAutoRepeatDelay;
314extern DeviceIntPtr	sunKeyboardDevice;
315
316/* sunMouse.c */
317extern Bool		sunActiveZaphod;
318extern DeviceIntPtr	sunPointerDevice;
319extern miPointerScreenFuncRec sunPointerScreenFuncs;
320
321/* sunFbs.c */
322extern int		sunScreenIndex;
323
324/* sunCursor.c */
325extern Bool sunCursorInitialize(ScreenPtr);
326extern void sunDisableCursor(ScreenPtr);
327
328/* sunInit.c */
329extern void sunNonBlockConsoleOff(
330#if defined(SVR4) || defined(CSRG_BASED)
331    void
332#else
333    char* /* arg */
334#endif
335);
336
337/* sunIo.c */
338extern void sunEnqueueEvents(void);
339
340/* sunGX.c */
341extern int sunGXInit(ScreenPtr, fbFd *);
342
343/* sunFbs.c */
344extern Bool sunSaveScreen(ScreenPtr, int);
345extern Bool sunScreenInit(ScreenPtr);
346extern void *sunMemoryMap(size_t, off_t, int);
347extern Bool sunScreenAllocate(ScreenPtr);
348extern Bool sunInitCommon(int, ScreenPtr, off_t,
349    Bool (* /* init1 */)(ScreenPtr, void *, int, int, int, int, int, int),
350    void (* /* init2 */)(ScreenPtr),
351    Bool (* /* cr_cm */)(ScreenPtr),
352    Bool (* /* save */)(ScreenPtr, int),
353    int);
354
355/* sunKbd.c */
356extern int sunChangeKbdTranslation(int, Bool);
357extern Firm_event* sunKbdGetEvents(int, Bool, int *, Bool *);
358extern void sunKbdEnqueueEvent(DeviceIntPtr, Firm_event *);
359extern int sunKbdProc(DeviceIntPtr, int);
360extern void sunKbdWait(void);
361
362/* sunMouse.c */
363extern Firm_event* sunMouseGetEvents(int, Bool, int *, Bool *);
364extern void sunMouseEnqueueEvent(DeviceIntPtr, Firm_event *);
365extern int sunMouseProc(DeviceIntPtr, int);
366
367/* sunCfb.c */
368Bool sunCG3Init(ScreenPtr, int, char **);
369Bool sunTCXInit(ScreenPtr, int, char **);
370Bool sunCG2Init(ScreenPtr, int, char **);
371Bool sunCG4Init(ScreenPtr, int, char **);
372Bool sunCG6Init(ScreenPtr, int, char **);
373
374/* sunCfb24.c */
375Bool sunCG8Init(ScreenPtr, int, char **);
376
377/* sunMfb.c */
378Bool sunBW2Init(ScreenPtr, int, char **);
379
380/* XXX */
381extern void mfbDoBitblt(DrawablePtr, DrawablePtr, int, RegionPtr, DDXPointPtr);
382
383/*-
384 * TVTOMILLI(tv)
385 *	Given a struct timeval, convert its time into milliseconds...
386 */
387#define TVTOMILLI(tv)	(((tv).tv_usec/1000)+((tv).tv_sec*1000))
388
389extern Bool sunCfbSetupScreen(
390    ScreenPtr /* pScreen */,
391    void * /* pbits */,		/* pointer to screen bitmap */
392    int /* xsize */,		/* in pixels */
393    int /* ysize */,
394    int /* dpix */,		/* dots per inch */
395    int /* dpiy */,		/* dots per inch */
396    int /* width */,		/* pixel width of frame buffer */
397    int	/* bpp */		/* bits per pixel of root */
398);
399
400extern Bool sunCfbFinishScreenInit(
401    ScreenPtr /* pScreen */,
402    void * /* pbits */,		/* pointer to screen bitmap */
403    int /* xsize */,		/* in pixels */
404    int /* ysize */,
405    int /* dpix */,		/* dots per inch */
406    int /* dpiy */,		/* dots per inch */
407    int /* width */,		/* pixel width of frame buffer */
408    int	/* bpp */		/* bits per pixel of root */
409);
410
411extern Bool sunCfbScreenInit(
412    ScreenPtr /* pScreen */,
413    void * /* pbits */,		/* pointer to screen bitmap */
414    int /* xsize */,		/* in pixels */
415    int /* ysize */,
416    int /* dpix */,		/* dots per inch */
417    int /* dpiy */,		/* dots per inch */
418    int /* width */,		/* pixel width of frame buffer */
419    int	/* bpp */		/* bits per pixel of root */
420);
421
422extern void sunInstallColormap(
423    ColormapPtr /* cmap */
424);
425
426extern void sunUninstallColormap(
427    ColormapPtr /* cmap */
428);
429
430extern int sunListInstalledColormaps(
431    ScreenPtr /* pScreen */,
432    Colormap* /* pCmapList */
433);
434
435#endif
436