Initial commit
[xorg_rtime.git] / xorg-server-1.4 / hw / xfree86 / xf4bpp / ppcIO.c
blob72793cc6ec1f70c43f672cfd192cb11d73b8efa8
1 /*
3 Copyright (c) 1990 X Consortium
5 Permission is hereby granted, free of charge, to any person obtaining
6 a copy of this software and associated documentation files (the
7 "Software"), to deal in the Software without restriction, including
8 without limitation the rights to use, copy, modify, merge, publish,
9 distribute, sublicense, and/or sell copies of the Software, and to
10 permit persons to whom the Software is furnished to do so, subject to
11 the following conditions:
13 The above copyright notice and this permission notice shall be included
14 in all copies or substantial portions of the Software.
16 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19 IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
20 OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22 OTHER DEALINGS IN THE SOFTWARE.
24 Except as contained in this notice, the name of the X Consortium shall
25 not be used in advertising or otherwise to promote the sale, use or
26 other dealings in this Software without prior written authorization
27 from the X Consortium.
30 Copyright IBM Corporation 1987,1988,1989
31 All Rights Reserved
33 Permission to use, copy, modify, and distribute this software and its
34 documentation for any purpose and without fee is hereby granted,
35 provided that the above copyright notice appear in all copies and that
36 both that copyright notice and this permission notice appear in
37 supporting documentation, and that the name of IBM not be
38 used in advertising or publicity pertaining to distribution of the
39 software without specific, written prior permission.
41 IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
42 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
43 IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
44 ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
45 WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
46 ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
47 SOFTWARE.
51 #ifdef HAVE_XORG_CONFIG_H
52 #include <xorg-config.h>
53 #endif
55 #include <stdlib.h>
57 #include "xf4bpp.h"
58 #include "mfbmap.h"
59 #include "mfb.h"
60 #include "mi.h"
61 #include "micmap.h"
62 #include "scrnintstr.h"
63 #include "vgaVideo.h"
65 #if 0
66 /* XXX This remains to remind of the PC98 difference */
67 static VisualRec vgaVisuals[] = {
68 /* StaticColor needs to be first so is can be used as the default */
69 /* vid class bpRGB cmpE nplan rMask gMask bMask oRed oGreen oBlue */
70 #ifdef PC98
71 { 0, StaticColor, 4, 1 << VGA_MAXPLANES, VGA_MAXPLANES, 0, 0, 0, 0, 0, 0 },
72 { 0, StaticGray, 4, 1 << VGA_MAXPLANES, VGA_MAXPLANES, 0, 0, 0, 0, 0, 0 },
73 { 0, GrayScale, 4, 1 << VGA_MAXPLANES, VGA_MAXPLANES, 0, 0, 0, 0, 0, 0 },
74 { 0, PseudoColor, 4, 1 << VGA_MAXPLANES, VGA_MAXPLANES, 0, 0, 0, 0, 0, 0 },
75 #else
76 { 0, StaticColor, 6, 1 << VGA_MAXPLANES, VGA_MAXPLANES, 0, 0, 0, 0, 0, 0 },
77 { 0, StaticGray, 6, 1 << VGA_MAXPLANES, VGA_MAXPLANES, 0, 0, 0, 0, 0, 0 },
78 { 0, GrayScale, 6, 1 << VGA_MAXPLANES, VGA_MAXPLANES, 0, 0, 0, 0, 0, 0 },
79 { 0, PseudoColor, 6, 1 << VGA_MAXPLANES, VGA_MAXPLANES, 0, 0, 0, 0, 0, 0 },
80 #endif
81 } ;
82 #endif
84 void
85 xf4bppNeverCalled()
87 FatalError("xf4bppNeverCalled was nevertheless called\n");
90 static BSFuncRec ppcBSFuncRec = {
91 xf4bppSaveAreas,
92 xf4bppRestoreAreas,
93 (BackingStoreSetClipmaskRgnProcPtr) 0,
94 (BackingStoreGetImagePixmapProcPtr) 0,
95 (BackingStoreGetSpansPixmapProcPtr) 0,
98 /*ARGSUSED*/
99 static Bool
100 vgaScreenClose
102 int idx,
103 ScreenPtr pScreen
106 pScreen->defColormap = 0 ;
107 return TRUE;
111 static GCPtr sampleGCperDepth[MAXFORMATS+1] = { 0 };
112 static PixmapPtr samplePixmapPerDepth[1] = { 0 };
114 /* GJA -- Took this from miscrinit.c.
115 * We want that devKind contains the distance in bytes between two scanlines.
116 * The computation that mi does is not appropriate for planar VGA.
117 * Therefore we provide here our own routine.
120 /* GJA -- WARNING: this is an internal structure declaration, taken from
121 * miscrinit.c
123 typedef struct
125 pointer pbits; /* pointer to framebuffer */
126 int width; /* delta to add to a framebuffer addr to move one row down */
127 } miScreenInitParmsRec, *miScreenInitParmsPtr;
129 /* With the introduction of pixmap privates, the "screen pixmap" can no
130 * longer be created in miScreenInit, since all the modules that could
131 * possibly ask for pixmap private space have not been initialized at
132 * that time. pScreen->CreateScreenResources is called after all
133 * possible private-requesting modules have been inited; we create the
134 * screen pixmap here.
136 static Bool
137 v16CreateScreenResources
139 ScreenPtr pScreen
142 miScreenInitParmsPtr pScrInitParms;
143 pointer value;
145 pScrInitParms = (miScreenInitParmsPtr)pScreen->devPrivate;
147 /* if width is non-zero, pScreen->devPrivate will be a pixmap
148 * else it will just take the value pbits
150 if (pScrInitParms->width)
152 PixmapPtr pPixmap;
154 /* create a pixmap with no data, then redirect it to point to
155 * the screen
157 pPixmap = (*pScreen->CreatePixmap)(pScreen, 0, 0, pScreen->rootDepth);
158 if (!pPixmap)
159 return FALSE;
161 if (!(*pScreen->ModifyPixmapHeader)(pPixmap, pScreen->width,
162 pScreen->height, pScreen->rootDepth, 8 /* bits per pixel */,
163 /* GJA: was PixmapBytePad(pScrInitParms->width, pScreen->rootDepth), */
164 #define BITS_PER_BYTE_SHIFT 3
165 pScrInitParms->width >> BITS_PER_BYTE_SHIFT,
166 pScrInitParms->pbits))
167 return FALSE;
168 value = (pointer)pPixmap;
170 else
172 value = pScrInitParms->pbits;
174 xfree(pScreen->devPrivate); /* freeing miScreenInitParmsRec */
175 pScreen->devPrivate = value; /* pPixmap or pbits */
176 return TRUE;
180 Bool
181 xf4bppScreenInit( pScreen, pbits, virtx, virty, dpix, dpiy, width )
182 ScreenPtr pScreen;
183 pointer pbits;
184 int virtx, virty;
185 int dpix, dpiy;
186 int width;
188 Bool ret;
189 VisualPtr visuals;
190 DepthPtr depths;
191 int nvisuals;
192 int ndepths;
193 int rootdepth;
194 VisualID defaultVisual;
196 rootdepth = 0;
197 ret = miInitVisuals(&visuals, &depths, &nvisuals, &ndepths, &rootdepth,
198 &defaultVisual, (unsigned long)1 << 8, 6, -1);
199 if (!ret)
200 return FALSE;
202 pScreen-> id = 0;
203 pScreen->defColormap = FakeClientID(0);
204 pScreen-> whitePixel = VGA_WHITE_PIXEL;
205 pScreen-> blackPixel = VGA_BLACK_PIXEL;
206 pScreen-> rgf = 0;
207 *(pScreen-> GCperDepth) = *(sampleGCperDepth);
208 *(pScreen-> PixmapPerDepth) = *(samplePixmapPerDepth);
209 pScreen-> CloseScreen = vgaScreenClose;
210 pScreen-> QueryBestSize = xf4bppQueryBestSize;
211 pScreen-> GetImage = xf4bppGetImage;
212 pScreen-> GetSpans = xf4bppGetSpans;
213 pScreen-> CreateWindow = xf4bppCreateWindowForXYhardware;
214 pScreen-> DestroyWindow = xf4bppDestroyWindow;
215 pScreen-> PositionWindow = xf4bppPositionWindow;
216 pScreen-> PaintWindowBackground = xf4bppPaintWindow;
217 pScreen-> PaintWindowBorder = xf4bppPaintWindow;
218 pScreen-> CopyWindow = xf4bppCopyWindow;
219 pScreen-> CreatePixmap = xf4bppCreatePixmap;
220 pScreen-> SaveDoomedAreas = (SaveDoomedAreasProcPtr)NoopDDA;
221 pScreen-> RestoreAreas = (RestoreAreasProcPtr)NoopDDA;
222 pScreen-> ExposeCopy = (ExposeCopyProcPtr)NoopDDA;
223 pScreen-> TranslateBackingStore = (TranslateBackingStoreProcPtr)NoopDDA;
224 pScreen-> ClearBackingStore = (ClearBackingStoreProcPtr)NoopDDA;
225 pScreen-> DrawGuarantee = (DrawGuaranteeProcPtr)NoopDDA;
226 pScreen-> CreateGC = xf4bppCreateGC;
227 pScreen-> CreateColormap = xf4bppInitializeColormap;
228 pScreen-> DestroyColormap = (DestroyColormapProcPtr)NoopDDA;
229 pScreen-> InstallColormap = miInstallColormap;
230 pScreen-> UninstallColormap = miUninstallColormap;
231 pScreen-> ListInstalledColormaps = miListInstalledColormaps;
232 pScreen-> StoreColors = (StoreColorsProcPtr)NoopDDA;
233 pScreen-> ResolveColor = xf4bppResolveColor;
234 mfbFillInScreen(pScreen);
236 if (!mfbAllocatePrivates(pScreen, (int*)NULL, (int*)NULL))
237 return FALSE;
239 if (!miScreenInit(pScreen, pbits, virtx, virty, dpix, dpiy, width,
240 rootdepth, ndepths, depths, defaultVisual /* See above */,
241 nvisuals, visuals))
242 return FALSE;
243 pScreen->BackingStoreFuncs = ppcBSFuncRec;
245 /* GJA -- Now we override the supplied default: */
246 pScreen -> CreateScreenResources = v16CreateScreenResources;
248 mfbRegisterCopyPlaneProc(pScreen,miCopyPlane); /* GJA -- R4->R5 */
249 return TRUE;