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