2
/* $Xorg: sunFbs.c,v 1.4 2001/02/09 02:04:43 xorgcvs Exp $ */
5
Copyright 1990, 1993, 1998 The Open Group
7
Permission to use, copy, modify, distribute, and sell this software and its
8
documentation for any purpose is hereby granted without fee, provided that
9
the above copyright notice appear in all copies and that both that
10
copyright notice and this permission notice appear in supporting
13
The above copyright notice and this permission notice shall be included in
14
all copies or substantial portions of the Software.
16
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
20
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23
Except as contained in this notice, the name of The Open Group shall not be
24
used in advertising or otherwise to promote the sale, use or other dealings
25
in this Software without prior written authorization from The Open Group.
28
/************************************************************
29
Copyright 1987 by Sun Microsystems, Inc. Mountain View, CA.
33
Permission to use, copy, modify, and distribute this
34
software and its documentation for any purpose and without
35
fee is hereby granted, provided that the above copyright no-
36
tice appear in all copies and that both that copyright no-
37
tice and this permission notice appear in supporting docu-
38
mentation, and that the names of Sun or The Open Group
39
not be used in advertising or publicity pertaining to
40
distribution of the software without specific prior
41
written permission. Sun and The Open Group make no
42
representations about the suitability of this software for
43
any purpose. It is provided "as is" without any express or
46
SUN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
47
INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT-
48
NESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SUN BE LI-
49
ABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
50
ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
51
PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
52
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
53
THE USE OR PERFORMANCE OF THIS SOFTWARE.
55
********************************************************/
58
* Copyright 1987 by the Regents of the University of California
59
* Copyright 1987 by Adam de Boor, UC Berkeley
61
* Permission to use, copy, modify, and distribute this
62
* software and its documentation for any purpose and without
63
* fee is hereby granted, provided that the above copyright
64
* notice appear in all copies. The University of California
65
* makes no representations about the suitability of this
66
* software for any purpose. It is provided "as is" without
67
* express or implied warranty.
70
/* $XFree86: xc/programs/Xserver/hw/sun/sunFbs.c,v 1.7 2002/12/06 00:28:50 tsi Exp $ */
72
/****************************************************************/
73
/* Modified from sunCG4C.c for X11R3 by Tom Jarmolowski */
74
/****************************************************************/
81
static unsigned long generation = 0;
83
#if NeedFunctionPrototypes
84
pointer sunMemoryMap (
89
pointer sunMemoryMap (len, off, fd)
95
int pagemask, mapsize;
100
pagemask = sysconf(_SC_PAGESIZE) - 1;
102
pagemask = getpagesize() - 1;
104
mapsize = ((int) len + pagemask) & ~pagemask;
107
#if !defined(__bsdi__) && !defined(_MAP_NEW) && !defined(__NetBSD__) && !defined(__OpenBSD__)
108
if ((addr = (caddr_t) valloc (mapsize)) == NULL) {
109
Error ("Couldn't allocate frame buffer memory");
115
#if !defined(__NetBSD__) && !defined(__OpenBSD__)
117
* try and make it private first, that way once we get it, an
118
* interloper, e.g. another server, can't get this frame buffer,
119
* and if another server already has it, this one won't.
121
if ((int)(mapaddr = (pointer) mmap (addr,
123
PROT_READ | PROT_WRITE, MAP_PRIVATE,
126
mapaddr = (pointer) mmap (addr,
128
PROT_READ | PROT_WRITE, MAP_SHARED,
130
if (mapaddr == (pointer) -1) {
131
Error ("mapping frame buffer memory");
133
mapaddr = (pointer) NULL;
138
#if NeedFunctionPrototypes
139
Bool sunScreenAllocate (
142
Bool sunScreenAllocate (pScreen)
146
sunScreenPtr pPrivate;
147
extern int AllocateScreenPrivateIndex();
149
if (generation != serverGeneration)
151
sunScreenIndex = AllocateScreenPrivateIndex();
152
if (sunScreenIndex < 0)
154
generation = serverGeneration;
156
pPrivate = (sunScreenPtr) xalloc (sizeof (sunScreenRec));
160
pScreen->devPrivates[sunScreenIndex].ptr = (pointer) pPrivate;
164
#if NeedFunctionPrototypes
169
Bool sunSaveScreen (pScreen, on)
176
if (on != SCREEN_SAVER_FORCER)
178
if (on == SCREEN_SAVER_ON)
182
(void) ioctl(sunFbs[pScreen->myNum].fd, FBIOSVIDEO, &state);
187
static Bool closeScreen (i, pScreen)
191
SetupScreen(pScreen);
194
(void) OsSignal (SIGIO, SIG_IGN);
195
sunDisableCursor (pScreen);
196
pScreen->CloseScreen = pPrivate->CloseScreen;
197
ret = (*pScreen->CloseScreen) (i, pScreen);
198
(void) (*pScreen->SaveScreen) (pScreen, SCREEN_SAVER_OFF);
199
xfree ((pointer) pPrivate);
203
#if NeedFunctionPrototypes
207
Bool sunScreenInit (pScreen)
211
SetupScreen(pScreen);
212
extern void sunBlockHandler();
213
extern void sunWakeupHandler();
214
static ScreenPtr autoRepeatScreen;
215
extern miPointerScreenFuncRec sunPointerScreenFuncs;
217
pPrivate->installedMap = 0;
218
pPrivate->CloseScreen = pScreen->CloseScreen;
219
pScreen->CloseScreen = closeScreen;
220
pScreen->SaveScreen = sunSaveScreen;
222
if (noXkbExtension) {
225
* Block/Unblock handlers
227
if (sunAutoRepeatHandlersInstalled == FALSE) {
228
autoRepeatScreen = pScreen;
229
sunAutoRepeatHandlersInstalled = TRUE;
232
if (pScreen == autoRepeatScreen) {
233
pScreen->BlockHandler = sunBlockHandler;
234
pScreen->WakeupHandler = sunWakeupHandler;
239
if (!sunCursorInitialize (pScreen))
240
miDCInitialize (pScreen, &sunPointerScreenFuncs);
244
#if NeedFunctionPrototypes
255
Bool sunInitCommon (scrn, pScrn, offset, init1, init2, cr_cm, save, fb_off)
266
unsigned char* fb = sunFbs[scrn].fb;
268
if (!sunScreenAllocate (pScrn))
271
if ((fb = sunMemoryMap ((size_t) sunFbs[scrn].info.fb_size,
273
sunFbs[scrn].fd)) == NULL)
275
sunFbs[scrn].fb = fb;
277
/* mfbScreenInit() or cfbScreenInit() */
278
if (!(*init1)(pScrn, fb + fb_off,
279
sunFbs[scrn].info.fb_width,
280
sunFbs[scrn].info.fb_height,
281
monitorResolution, monitorResolution,
282
sunFbs[scrn].info.fb_width,
283
sunFbs[scrn].info.fb_depth))
285
miInitializeBackingStore(pScrn);
286
/* sunCGScreenInit() if cfb... */
289
if (!sunScreenInit(pScrn))
291
(void) (*save) (pScrn, SCREEN_SAVER_OFF);
292
return (*cr_cm)(pScrn);