2
* Copyright 2000 by Alan Hourihane, Sychdyn, North Wales, UK.
4
* Permission to use, copy, modify, distribute, and sell this software and its
5
* documentation for any purpose is hereby granted without fee, provided that
6
* the above copyright notice appear in all copies and that both that
7
* copyright notice and this permission notice appear in supporting
8
* documentation, and that the name of Alan Hourihane not be used in
9
* advertising or publicity pertaining to distribution of the software without
10
* specific, written prior permission. Alan Hourihane makes no representations
11
* about the suitability of this software for any purpose. It is provided
12
* "as is" without express or implied warranty.
14
* ALAN HOURIHANE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
15
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
16
* EVENT SHALL ALAN HOURIHANE BE LIABLE FOR ANY SPECIAL, INDIRECT OR
17
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
18
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
19
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
20
* PERFORMANCE OF THIS SOFTWARE.
22
* Authors: Alan Hourihane, <alanh@fairlite.demon.co.uk>
24
/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/neomagic/neo_dga.c,v 1.5 2002/04/04 14:05:44 eich Exp $ */
27
#include "xf86_OSproc.h"
28
#include "xf86_ansic.h"
30
#include "xf86PciInfo.h"
38
static Bool NEO_OpenFramebuffer(ScrnInfoPtr, char **, unsigned char **,
40
static Bool NEO_SetMode(ScrnInfoPtr, DGAModePtr);
41
static void NEO_Sync(ScrnInfoPtr);
42
static int NEO_GetViewport(ScrnInfoPtr);
43
static void NEO_SetViewport(ScrnInfoPtr, int, int, int);
44
static void NEO_FillRect(ScrnInfoPtr, int, int, int, int, unsigned long);
45
static void NEO_BlitRect(ScrnInfoPtr, int, int, int, int, int, int);
47
static void NEO_BlitTransRect(ScrnInfoPtr, int, int, int, int, int, int,
52
DGAFunctionRec NEODGAFuncs = {
69
NEODGAInit(ScreenPtr pScreen)
71
ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
72
NEOPtr pNEO = NEOPTR(pScrn);
73
DGAModePtr modes = NULL, newmodes = NULL, currentMode;
74
DisplayModePtr pMode, firstMode;
75
int Bpp = pScrn->bitsPerPixel >> 3;
76
int num = 0, imlines, pixlines;
78
imlines = (pScrn->videoRam * 1024) /
79
(pScrn->displayWidth * (pScrn->bitsPerPixel >> 3));
81
pixlines = (imlines > 1024 && !pNEO->noAccel) ? 1024 : imlines;
83
pMode = firstMode = pScrn->modes;
87
newmodes = xrealloc(modes, (num + 1) * sizeof(DGAModeRec));
95
currentMode = modes + num;
98
currentMode->mode = pMode;
99
currentMode->flags = DGA_CONCURRENT_ACCESS | DGA_PIXMAP_AVAILABLE;
101
currentMode->flags |= (DGA_FILL_RECT | DGA_BLIT_RECT);
102
if(pMode->Flags & V_DBLSCAN)
103
currentMode->flags |= DGA_DOUBLESCAN;
104
if(pMode->Flags & V_INTERLACE)
105
currentMode->flags |= DGA_INTERLACED;
106
currentMode->byteOrder = pScrn->imageByteOrder;
107
currentMode->depth = pScrn->depth;
108
currentMode->bitsPerPixel = pScrn->bitsPerPixel;
109
currentMode->red_mask = pScrn->mask.red;
110
currentMode->green_mask = pScrn->mask.green;
111
currentMode->blue_mask = pScrn->mask.blue;
112
currentMode->visualClass = (Bpp == 1) ? PseudoColor : TrueColor;
113
currentMode->viewportWidth = pMode->HDisplay;
114
currentMode->viewportHeight = pMode->VDisplay;
115
currentMode->xViewportStep = 1;
116
currentMode->yViewportStep = 1;
117
currentMode->viewportFlags = DGA_FLIP_RETRACE;
118
currentMode->offset = 0;
119
currentMode->address = pNEO->NeoFbBase;
121
currentMode->bytesPerScanline =
122
((pScrn->displayWidth * Bpp) + 3) & ~3L;
123
currentMode->imageWidth = pScrn->displayWidth;
124
currentMode->imageHeight = imlines;
125
currentMode->pixmapWidth = currentMode->imageWidth;
126
currentMode->pixmapHeight = pixlines;
127
currentMode->maxViewportX = currentMode->imageWidth -
128
currentMode->viewportWidth;
129
currentMode->maxViewportY = currentMode->imageHeight -
130
currentMode->viewportHeight;
133
if(pMode == firstMode)
137
pNEO->numDGAModes = num;
138
pNEO->DGAModes = modes;
140
return DGAInit(pScreen, &NEODGAFuncs, modes, num);
143
static DisplayModePtr NEOSavedDGAModes[MAXSCREENS];
150
int index = pScrn->pScreen->myNum;
151
NEOPtr pNEO = NEOPTR(pScrn);
153
if(!pMode) { /* restore the original mode */
154
if(pNEO->DGAactive) {
155
pScrn->currentMode = NEOSavedDGAModes[index];
156
NEOSwitchMode(index, pScrn->currentMode, 0);
157
NEOAdjustFrame(index, 0, 0, 0);
158
pNEO->DGAactive = FALSE;
161
if(!pNEO->DGAactive) { /* save the old parameters */
162
NEOSavedDGAModes[index] = pScrn->currentMode;
163
pNEO->DGAactive = TRUE;
166
NEOSwitchMode(index, pMode->mode, 0);
176
NEOPtr pNEO = NEOPTR(pScrn);
178
return pNEO->DGAViewportStatus;
187
NEOPtr pNEO = NEOPTR(pScrn);
188
vgaHWPtr hwp = VGAHWPTR(pScrn);
190
NEOAdjustFrame(pScrn->pScreen->myNum, x, y, flags);
191
/* wait for retrace */
192
while((hwp->readST01(hwp) & 0x08));
193
while(!(hwp->readST01(hwp) & 0x08));
195
pNEO->DGAViewportStatus = 0;
201
int x, int y, int w, int h,
204
NEOPtr pNEO = NEOPTR(pScrn);
206
if(pNEO->AccelInfoRec) {
207
(*pNEO->AccelInfoRec->SetupForSolidFill)(pScrn, color, GXcopy, ~0);
208
(*pNEO->AccelInfoRec->SubsequentSolidFillRect)(pScrn, x, y, w, h);
209
SET_SYNC_FLAG(pNEO->AccelInfoRec);
217
NEOPtr pNEO = NEOPTR(pScrn);
219
if(pNEO->AccelInfoRec) {
220
(*pNEO->AccelInfoRec->Sync)(pScrn);
231
NEOPtr pNEO = NEOPTR(pScrn);
233
if(pNEO->AccelInfoRec) {
234
int xdir = ((srcx < dstx) && (srcy == dsty)) ? -1 : 1;
235
int ydir = (srcy < dsty) ? -1 : 1;
237
(*pNEO->AccelInfoRec->SetupForScreenToScreenCopy)(
238
pScrn, xdir, ydir, GXcopy, ~0, -1);
239
(*pNEO->AccelInfoRec->SubsequentScreenToScreenCopy)(
240
pScrn, srcx, srcy, dstx, dsty, w, h);
241
SET_SYNC_FLAG(pNEO->AccelInfoRec);
254
/* this one should be separate since the XAA function would
255
prohibit usage of ~0 as the key */
268
NEOPtr pNEO = NEOPTR(pScrn);
270
*name = NULL; /* no special device */
271
*mem = (unsigned char*)pNEO->NeoLinearAddr;
272
*size = pNEO->NeoFbMapSize;
274
*flags = DGA_NEED_ROOT;