1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
|
/* $TOG: sunLyFbs.c /main/2 1998/02/10 13:22:39 kaleb $ */
/* $XFree86: xc/programs/Xserver/hw/sunLynx/sunLyFbs.c,v 3.3 1998/06/27 12:53:57 hohndel Exp $ */
/*
* This is sunFbs.c modified for LynxOS
* Copyright 1996 by Thomas Mueller
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
* the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the name of Thomas Mueller not be used in
* advertising or publicity pertaining to distribution of the software without
* specific, written prior permission. Thomas Mueller makes no representations
* about the suitability of this software for any purpose. It is provided
* "as is" without express or implied warranty.
*
* THOMAS MUELLER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL THOMAS MUELLER BE LIABLE FOR ANY SPECIAL, INDIRECT OR
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
* PERFORMANCE OF THIS SOFTWARE.
*
*/
/*
Copyright 1990, 1993, 1998 The Open Group
All Rights Reserved.
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name of The Open Group shall not be
used in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization from The Open Group.
*/
/************************************************************
Copyright 1987 by Sun Microsystems, Inc. Mountain View, CA.
All Rights Reserved
Permission to use, copy, modify, and distribute this
software and its documentation for any purpose and without
fee is hereby granted, provided that the above copyright no-
tice appear in all copies and that both that copyright no-
tice and this permission notice appear in supporting docu-
mentation, and that the names of Sun or The Open Group
not be used in advertising or publicity pertaining to
distribution of the software without specific prior
written permission. Sun and The Open Group make no
representations about the suitability of this software for
any purpose. It is provided "as is" without any express or
implied warranty.
SUN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT-
NESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SUN BE LI-
ABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
THE USE OR PERFORMANCE OF THIS SOFTWARE.
********************************************************/
/*
* Copyright 1987 by the Regents of the University of California
* Copyright 1987 by Adam de Boor, UC Berkeley
*
* Permission to use, copy, modify, and distribute this
* software and its documentation for any purpose and without
* fee is hereby granted, provided that the above copyright
* notice appear in all copies. The University of California
* makes no representations about the suitability of this
* software for any purpose. It is provided "as is" without
* express or implied warranty.
*/
/****************************************************************/
/* Modified from sunCG4C.c for X11R3 by Tom Jarmolowski */
/****************************************************************/
#include "sun.h"
#include <smem.h>
int sunScreenIndex;
static unsigned long generation = 0;
#if NeedFunctionPrototypes
pointer sunMemoryMap (
size_t len,
off_t off,
int fd,
char *name
)
#else
pointer sunMemoryMap (len, off, fd, name)
size_t len;
off_t off;
int fd;
char *name;
#endif
{
int pagemask, mapsize;
caddr_t addr;
pointer mapaddr;
pagemask = getpagesize() - 1;
mapsize = ((int) len + pagemask) & ~pagemask;
addr = 0;
mapaddr = smem_create(name, (char *)off, mapsize, SM_READ|SM_WRITE);
if (mapaddr == (pointer) -1) {
Error ("mapping frame buffer memory");
(void) close (fd);
mapaddr = (pointer) NULL;
}
return mapaddr;
}
#if NeedFunctionPrototypes
Bool sunScreenAllocate (
ScreenPtr pScreen)
#else
Bool sunScreenAllocate (pScreen)
ScreenPtr pScreen;
#endif
{
sunScreenPtr pPrivate;
extern int AllocateScreenPrivateIndex();
if (generation != serverGeneration)
{
sunScreenIndex = AllocateScreenPrivateIndex();
if (sunScreenIndex < 0)
return FALSE;
generation = serverGeneration;
}
pPrivate = (sunScreenPtr) xalloc (sizeof (sunScreenRec));
if (!pPrivate)
return FALSE;
pScreen->devPrivates[sunScreenIndex].ptr = (pointer) pPrivate;
return TRUE;
}
#if NeedFunctionPrototypes
Bool sunSaveScreen (
ScreenPtr pScreen,
int on)
#else
Bool sunSaveScreen (pScreen, on)
ScreenPtr pScreen;
int on;
#endif
{
int state;
if (on != SCREEN_SAVER_FORCER)
{
if (on == SCREEN_SAVER_ON)
state = 0;
else
state = 1;
(void) sunIoctl(&sunFbs[pScreen->myNum], FBIOSVIDEO, &state);
}
return( TRUE );
}
static Bool closeScreen (i, pScreen)
int i;
ScreenPtr pScreen;
{
SetupScreen(pScreen);
Bool ret;
struct fbcmap sunCmap;
unsigned char color;
(void) OsSignal (SIGIO, SIG_IGN);
sunDisableCursor (pScreen);
pScreen->CloseScreen = pPrivate->CloseScreen;
ret = (*pScreen->CloseScreen) (i, pScreen);
(void) (*pScreen->SaveScreen) (pScreen, SCREEN_SAVER_OFF);
/* probably this doesn't belong here: restore black&white cmap */
sunCmap.count = 1;
sunCmap.index = 0;
sunCmap.red = sunCmap.green = sunCmap.blue = &color;
color = 0xff;
(void) sunIoctl(&sunFbs[pScreen->myNum], FBIOPUTCMAP, &sunCmap);
sunCmap.index = 0xff;
color = 0;
(void) sunIoctl(&sunFbs[pScreen->myNum], FBIOPUTCMAP, &sunCmap);
xfree ((pointer) pPrivate);
return ret;
}
#if NeedFunctionPrototypes
Bool sunScreenInit (
ScreenPtr pScreen)
#else
Bool sunScreenInit (pScreen)
ScreenPtr pScreen;
#endif
{
SetupScreen(pScreen);
extern void sunBlockHandler();
extern void sunWakeupHandler();
static ScreenPtr autoRepeatScreen;
extern miPointerScreenFuncRec sunPointerScreenFuncs;
pPrivate->installedMap = 0;
pPrivate->CloseScreen = pScreen->CloseScreen;
pScreen->CloseScreen = closeScreen;
pScreen->SaveScreen = sunSaveScreen;
#ifdef XKB
if (noXkbExtension) {
#endif
/*
* Block/Unblock handlers
*/
if (sunAutoRepeatHandlersInstalled == FALSE) {
autoRepeatScreen = pScreen;
sunAutoRepeatHandlersInstalled = TRUE;
}
if (pScreen == autoRepeatScreen) {
pScreen->BlockHandler = sunBlockHandler;
pScreen->WakeupHandler = sunWakeupHandler;
}
#ifdef XKB
} else {
/* this works around a weird behaviour on LynxOS 2.4.0:
* usually we have no problems using true SIGIO driven mouse input
* as it is used on the other UN*X Suns. On LynxOS we have a
* strange behaviour upon the very first server startup after a
* reboot. We won't get SIGIOs from the mouse device. The mouse
* will only move if we get SIGIOs from the keyboard.
* The solution (for now) is to use a WakeupHandler and
* poll the mouse file descriptor.
*/
pScreen->WakeupHandler = sunWakeupHandler;
}
#endif
if (!sunCursorInitialize (pScreen))
miDCInitialize (pScreen, &sunPointerScreenFuncs);
return TRUE;
}
#if NeedFunctionPrototypes
Bool sunInitCommon (
int scrn,
ScreenPtr pScrn,
off_t offset,
Bool (*init1)(),
void (*init2)(),
Bool (*cr_cm)(),
Bool (*save)(),
int fb_off)
#else
Bool sunInitCommon (scrn, pScrn, offset, init1, init2, cr_cm, save, fb_off)
int scrn;
ScreenPtr pScrn;
off_t offset;
Bool (*init1)();
void (*init2)();
Bool (*cr_cm)();
Bool (*save)();
int fb_off;
#endif
{
unsigned char* fb = sunFbs[scrn].fbuf;
unsigned char* dac = sunFbs[scrn].ramdac;
if (!sunScreenAllocate (pScrn))
return FALSE;
if (!fb) {
if ((fb = sunMemoryMap ((size_t) sunFbs[scrn].info.fb_size,
(unsigned long)offset + 0x00800000UL,
sunFbs[scrn].fd, "FB")) == NULL)
return FALSE;
sunFbs[scrn].fbuf = fb;
if (!dac)
{
unsigned long dacoffset;
if (ioctl(sunFbs[scrn].fd, TIO_QUERYRAMDAC, &dacoffset) < 0)
FatalError("can't query DAC addr\n");
if ((dac = sunMemoryMap((size_t) sunFbs[scrn].info.fb_cmsize * 3,
(unsigned long)offset + dacoffset,
sunFbs[scrn].fd, "DAC")) == NULL)
return FALSE;
sunFbs[scrn].ramdac = dac;
}
}
/* mfbScreenInit() or cfbScreenInit() */
if (!(*init1)(pScrn, fb + fb_off,
sunFbs[scrn].info.fb_width,
sunFbs[scrn].info.fb_height,
monitorResolution, monitorResolution,
sunFbs[scrn].info.fb_width,
sunFbs[scrn].info.fb_depth))
return FALSE;
miInitializeBackingStore(pScrn);
/* sunCGScreenInit() if cfb... */
if (init2)
(*init2)(pScrn);
if (!sunScreenInit(pScrn))
return FALSE;
(void) (*save) (pScrn, SCREEN_SAVER_OFF);
return (*cr_cm)(pScrn);
}
|