1dfe64dd3Smacallan/*
2dfe64dd3Smacallan *  DGA handling
3dfe64dd3Smacallan *
4dfe64dd3Smacallan * Copyright (C) 2000 by Alan Hourihane, Sychdyn, North Wales, UK.
5dfe64dd3Smacallan * Copyright (C) 2001-2004 by Thomas Winischhofer, Vienna, Austria
6dfe64dd3Smacallan *
7dfe64dd3Smacallan * Portions from radeon_dga.c which is
8dfe64dd3Smacallan *          Copyright 2000 ATI Technologies Inc., Markham, Ontario, and
9dfe64dd3Smacallan *                         VA Linux Systems Inc., Fremont, California.
10dfe64dd3Smacallan *
11dfe64dd3Smacallan * Licensed under the following terms:
12dfe64dd3Smacallan *
13dfe64dd3Smacallan * Permission to use, copy, modify, distribute, and sell this software and its
14dfe64dd3Smacallan * documentation for any purpose is hereby granted without fee, provided that
15dfe64dd3Smacallan * the above copyright notice appear in all copies and that both that
16dfe64dd3Smacallan * copyright notice and this permission notice appear in supporting
17dfe64dd3Smacallan * documentation, and that the name of the providers not be used in
18dfe64dd3Smacallan * advertising or publicity pertaining to distribution of the software without
19dfe64dd3Smacallan * specific, written prior permission.  The providers make no representations
20dfe64dd3Smacallan * about the suitability of this software for any purpose.  It is provided
21dfe64dd3Smacallan * "as is" without express or implied warranty.
22dfe64dd3Smacallan *
23dfe64dd3Smacallan * THE PROVIDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
24dfe64dd3Smacallan * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
25dfe64dd3Smacallan * EVENT SHALL THE PROVIDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
26dfe64dd3Smacallan * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
27dfe64dd3Smacallan * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
28dfe64dd3Smacallan * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
29dfe64dd3Smacallan * PERFORMANCE OF THIS SOFTWARE.
30dfe64dd3Smacallan *
31dfe64dd3Smacallan * Authors:  Alan Hourihane, <alanh@fairlite.demon.co.uk>
32dfe64dd3Smacallan *           Thomas Winischhofer <thomas@winischhofer.net>
33dfe64dd3Smacallan */
34dfe64dd3Smacallan
35dfe64dd3Smacallan#ifdef HAVE_CONFIG_H
36dfe64dd3Smacallan#include "config.h"
37dfe64dd3Smacallan#endif
38dfe64dd3Smacallan
39dfe64dd3Smacallan#include "xf86.h"
40dfe64dd3Smacallan#include "xf86_OSproc.h"
41dfe64dd3Smacallan#include "xf86Pci.h"
42dfe64dd3Smacallan#include "xf86PciInfo.h"
43dfe64dd3Smacallan#include "xaa.h"
44dfe64dd3Smacallan#include "xaalocal.h"
45dfe64dd3Smacallan#include "xgi.h"
46dfe64dd3Smacallan#include "xgi_regs.h"
47dfe64dd3Smacallan#include "dgaproc.h"
48dfe64dd3Smacallan
49dfe64dd3Smacallan#ifndef NEW_DGAOPENFRAMEBUFFER
50dfe64dd3Smacallanstatic Bool XGI_OpenFramebuffer(ScrnInfoPtr, char **, unsigned char **,
51dfe64dd3Smacallan                                int *, int *, int *);
52dfe64dd3Smacallan#else
53dfe64dd3Smacallanstatic Bool XGI_OpenFramebuffer(ScrnInfoPtr, char **, unsigned int *,
54dfe64dd3Smacallan                                unsigned int *, unsigned int *, unsigned int *);
55dfe64dd3Smacallan#endif
56dfe64dd3Smacallan
57dfe64dd3Smacallanstatic Bool XGI_SetMode(ScrnInfoPtr, DGAModePtr);
58dfe64dd3Smacallanstatic void XGI_Sync(ScrnInfoPtr);
59dfe64dd3Smacallanstatic int  XGI_GetViewport(ScrnInfoPtr);
60dfe64dd3Smacallanstatic void XGI_SetViewport(ScrnInfoPtr, int, int, int);
61dfe64dd3Smacallanstatic void XGI_FillRect(ScrnInfoPtr, int, int, int, int, unsigned long);
62dfe64dd3Smacallanstatic void XGI_BlitRect(ScrnInfoPtr, int, int, int, int, int, int);
63dfe64dd3Smacallan
64dfe64dd3Smacallanstatic
65dfe64dd3SmacallanDGAFunctionRec XGIDGAFuncs = {
66dfe64dd3Smacallan   XGI_OpenFramebuffer,
67dfe64dd3Smacallan   NULL,
68dfe64dd3Smacallan   XGI_SetMode,
69dfe64dd3Smacallan   XGI_SetViewport,
70dfe64dd3Smacallan   XGI_GetViewport,
71dfe64dd3Smacallan   XGI_Sync,
72dfe64dd3Smacallan   XGI_FillRect,
73dfe64dd3Smacallan   XGI_BlitRect,
74dfe64dd3Smacallan   NULL
75dfe64dd3Smacallan};
76dfe64dd3Smacallan
77dfe64dd3Smacallan
78dfe64dd3Smacallanstatic DGAModePtr
79dfe64dd3SmacallanXGISetupDGAMode(
80dfe64dd3Smacallan   ScrnInfoPtr pScrn,
81dfe64dd3Smacallan   DGAModePtr modes,
82dfe64dd3Smacallan   int *num,
83dfe64dd3Smacallan   int bitsPerPixel,
84dfe64dd3Smacallan   int depth,
85dfe64dd3Smacallan   Bool pixmap,
86dfe64dd3Smacallan   int secondPitch,
87dfe64dd3Smacallan   unsigned long red,
88dfe64dd3Smacallan   unsigned long green,
89dfe64dd3Smacallan   unsigned long blue,
90dfe64dd3Smacallan   short visualClass
91dfe64dd3Smacallan){
92dfe64dd3Smacallan   XGIPtr pXGI = XGIPTR(pScrn);
93dfe64dd3Smacallan   DGAModePtr newmodes = NULL, currentMode;
94dfe64dd3Smacallan   DisplayModePtr pMode, firstMode;
95dfe64dd3Smacallan   int otherPitch, Bpp = bitsPerPixel >> 3;
96dfe64dd3Smacallan   Bool oneMore;
97dfe64dd3Smacallan
98dfe64dd3Smacallan   pMode = firstMode = pScrn->modes;
99dfe64dd3Smacallan
100dfe64dd3Smacallan   while(pMode) {
101dfe64dd3Smacallan
102dfe64dd3Smacallan	otherPitch = secondPitch ? secondPitch : pMode->HDisplay;
103dfe64dd3Smacallan
104dfe64dd3Smacallan	if(pMode->HDisplay != otherPitch) {
105dfe64dd3Smacallan
106dfe64dd3Smacallan	    newmodes = xrealloc(modes, (*num + 2) * sizeof(DGAModeRec));
107dfe64dd3Smacallan	    oneMore  = TRUE;
108dfe64dd3Smacallan
109dfe64dd3Smacallan	} else {
110dfe64dd3Smacallan
111dfe64dd3Smacallan	    newmodes = xrealloc(modes, (*num + 1) * sizeof(DGAModeRec));
112dfe64dd3Smacallan	    oneMore  = FALSE;
113dfe64dd3Smacallan
114dfe64dd3Smacallan	}
115dfe64dd3Smacallan
116dfe64dd3Smacallan	if(!newmodes) {
117dfe64dd3Smacallan	    xfree(modes);
118dfe64dd3Smacallan	    return NULL;
119dfe64dd3Smacallan	}
120dfe64dd3Smacallan	modes = newmodes;
121dfe64dd3Smacallan
122dfe64dd3SmacallanSECOND_PASS:
123dfe64dd3Smacallan
124dfe64dd3Smacallan	currentMode = modes + *num;
125dfe64dd3Smacallan	(*num)++;
126dfe64dd3Smacallan
127dfe64dd3Smacallan	currentMode->mode           = pMode;
128dfe64dd3Smacallan	currentMode->flags          = DGA_CONCURRENT_ACCESS;
129dfe64dd3Smacallan	if(pixmap)
130dfe64dd3Smacallan	    currentMode->flags     |= DGA_PIXMAP_AVAILABLE;
131dfe64dd3Smacallan	if(!pXGI->NoAccel) {
132dfe64dd3Smacallan	    currentMode->flags     |= DGA_FILL_RECT | DGA_BLIT_RECT;
133dfe64dd3Smacallan	}
134dfe64dd3Smacallan	if(pMode->Flags & V_DBLSCAN)
135dfe64dd3Smacallan	    currentMode->flags     |= DGA_DOUBLESCAN;
136dfe64dd3Smacallan	if(pMode->Flags & V_INTERLACE)
137dfe64dd3Smacallan	    currentMode->flags     |= DGA_INTERLACED;
138dfe64dd3Smacallan	currentMode->byteOrder      = pScrn->imageByteOrder;
139dfe64dd3Smacallan	currentMode->depth          = depth;
140dfe64dd3Smacallan	currentMode->bitsPerPixel   = bitsPerPixel;
141dfe64dd3Smacallan	currentMode->red_mask       = red;
142dfe64dd3Smacallan	currentMode->green_mask     = green;
143dfe64dd3Smacallan	currentMode->blue_mask      = blue;
144dfe64dd3Smacallan	currentMode->visualClass    = visualClass;
145dfe64dd3Smacallan	currentMode->viewportWidth  = pMode->HDisplay;
146dfe64dd3Smacallan	currentMode->viewportHeight = pMode->VDisplay;
147dfe64dd3Smacallan	currentMode->xViewportStep  = 1;
148dfe64dd3Smacallan	currentMode->yViewportStep  = 1;
149dfe64dd3Smacallan	currentMode->viewportFlags  = DGA_FLIP_RETRACE;
150dfe64dd3Smacallan	currentMode->offset         = 0;
151dfe64dd3Smacallan	currentMode->address        = pXGI->FbBase;
152dfe64dd3Smacallan
153dfe64dd3Smacallan	if(oneMore) {
154dfe64dd3Smacallan
155dfe64dd3Smacallan	    /* first one is narrow width */
156dfe64dd3Smacallan	    currentMode->bytesPerScanline = (((pMode->HDisplay * Bpp) + 3) & ~3L);
157dfe64dd3Smacallan	    currentMode->imageWidth   = pMode->HDisplay;
158dfe64dd3Smacallan	    currentMode->imageHeight  = pMode->VDisplay;
159dfe64dd3Smacallan	    currentMode->pixmapWidth  = currentMode->imageWidth;
160dfe64dd3Smacallan	    currentMode->pixmapHeight = currentMode->imageHeight;
161dfe64dd3Smacallan	    currentMode->maxViewportX = currentMode->imageWidth -
162dfe64dd3Smacallan					currentMode->viewportWidth;
163dfe64dd3Smacallan	    /* this might need to get clamped to some maximum */
164dfe64dd3Smacallan	    currentMode->maxViewportY = (currentMode->imageHeight -
165dfe64dd3Smacallan					 currentMode->viewportHeight);
166dfe64dd3Smacallan	    oneMore = FALSE;
167dfe64dd3Smacallan	    goto SECOND_PASS;
168dfe64dd3Smacallan
169dfe64dd3Smacallan	} else {
170dfe64dd3Smacallan
171dfe64dd3Smacallan	    currentMode->bytesPerScanline = ((otherPitch * Bpp) + 3) & ~3L;
172dfe64dd3Smacallan	    currentMode->imageWidth       = otherPitch;
173dfe64dd3Smacallan	    currentMode->imageHeight      = pMode->VDisplay;
174dfe64dd3Smacallan	    currentMode->pixmapWidth      = currentMode->imageWidth;
175dfe64dd3Smacallan	    currentMode->pixmapHeight     = currentMode->imageHeight;
176dfe64dd3Smacallan	    currentMode->maxViewportX     = (currentMode->imageWidth -
177dfe64dd3Smacallan					     currentMode->viewportWidth);
178dfe64dd3Smacallan            /* this might need to get clamped to some maximum */
179dfe64dd3Smacallan	    currentMode->maxViewportY     = (currentMode->imageHeight -
180dfe64dd3Smacallan					     currentMode->viewportHeight);
181dfe64dd3Smacallan	}
182dfe64dd3Smacallan
183dfe64dd3Smacallan	pMode = pMode->next;
184dfe64dd3Smacallan	if(pMode == firstMode)
185dfe64dd3Smacallan	   break;
186dfe64dd3Smacallan    }
187dfe64dd3Smacallan
188dfe64dd3Smacallan    return modes;
189dfe64dd3Smacallan}
190dfe64dd3Smacallan
191dfe64dd3Smacallan
192dfe64dd3SmacallanBool
193dfe64dd3SmacallanXGIDGAInit(ScreenPtr pScreen)
194dfe64dd3Smacallan{
195dfe64dd3Smacallan   ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
196dfe64dd3Smacallan   XGIPtr pXGI = XGIPTR(pScrn);
197dfe64dd3Smacallan   DGAModePtr modes = NULL;
198dfe64dd3Smacallan   int num = 0;
199dfe64dd3Smacallan
200dfe64dd3Smacallan   /* 8 */
201dfe64dd3Smacallan   /* We don't support 8bpp modes in dual head or MergedFB mode,
202dfe64dd3Smacallan    * so don't offer them to DGA either.
203dfe64dd3Smacallan    */
204dfe64dd3Smacallan   if (!IS_DUAL_HEAD(pXGI)
205dfe64dd3Smacallan#ifdef XGIMERGED
206dfe64dd3Smacallan       && !(pXGI->MergedFB)
207dfe64dd3Smacallan#endif
208dfe64dd3Smacallan       ) {
209dfe64dd3Smacallan       modes = XGISetupDGAMode(pScrn, modes, &num, 8, 8,
210dfe64dd3Smacallan			       (pScrn->bitsPerPixel == 8),
211dfe64dd3Smacallan			       ((pScrn->bitsPerPixel != 8)
212dfe64dd3Smacallan				? 0 : pScrn->displayWidth),
213dfe64dd3Smacallan			       0, 0, 0, PseudoColor);
214dfe64dd3Smacallan   }
215dfe64dd3Smacallan
216dfe64dd3Smacallan   /* 16 */
217dfe64dd3Smacallan   modes = XGISetupDGAMode(pScrn, modes, &num, 16, 16,
218dfe64dd3Smacallan			   (pScrn->bitsPerPixel == 16),
219dfe64dd3Smacallan			   ((pScrn->depth != 16)
220dfe64dd3Smacallan				? 0 : pScrn->displayWidth),
221dfe64dd3Smacallan			   0xf800, 0x07e0, 0x001f, TrueColor);
222dfe64dd3Smacallan
223dfe64dd3Smacallan    /* 32 */
224dfe64dd3Smacallan    modes = XGISetupDGAMode(pScrn, modes, &num, 32, 24,
225dfe64dd3Smacallan			    (pScrn->bitsPerPixel == 32),
226dfe64dd3Smacallan			    ((pScrn->bitsPerPixel != 32)
227dfe64dd3Smacallan			     ? 0 : pScrn->displayWidth),
228dfe64dd3Smacallan			    0xff0000, 0x00ff00, 0x0000ff, TrueColor);
229dfe64dd3Smacallan
230dfe64dd3Smacallan    pXGI->numDGAModes = num;
231dfe64dd3Smacallan    pXGI->DGAModes = modes;
232dfe64dd3Smacallan
233dfe64dd3Smacallan    if (num) {
234dfe64dd3Smacallan	return DGAInit(pScreen, &XGIDGAFuncs, modes, num);
235dfe64dd3Smacallan    }
236dfe64dd3Smacallan    else {
237dfe64dd3Smacallan	xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
238dfe64dd3Smacallan		   "No DGA-suitable modes found, disabling DGA\n");
239dfe64dd3Smacallan	return TRUE;
240dfe64dd3Smacallan    }
241dfe64dd3Smacallan}
242dfe64dd3Smacallan
243dfe64dd3Smacallan
244dfe64dd3Smacallanstatic Bool
245dfe64dd3SmacallanXGI_SetMode(
246dfe64dd3Smacallan   ScrnInfoPtr pScrn,
247dfe64dd3Smacallan   DGAModePtr pMode
248dfe64dd3Smacallan){
249dfe64dd3Smacallan   static XGIFBLayout BackupLayouts[MAXSCREENS];
250dfe64dd3Smacallan   int index = pScrn->pScreen->myNum;
251dfe64dd3Smacallan   XGIPtr pXGI = XGIPTR(pScrn);
252dfe64dd3Smacallan
253dfe64dd3Smacallan    if(!pMode) { /* restore the original mode */
254dfe64dd3Smacallan
255dfe64dd3Smacallan        if(pXGI->DGAactive) {
256dfe64dd3Smacallan           /* put the ScreenParameters back */
257dfe64dd3Smacallan	   memcpy(&pXGI->CurrentLayout, &BackupLayouts[index], sizeof(XGIFBLayout));
258dfe64dd3Smacallan        }
259dfe64dd3Smacallan
260dfe64dd3Smacallan	pScrn->currentMode = pXGI->CurrentLayout.mode;
261dfe64dd3Smacallan
262dfe64dd3Smacallan        (*pScrn->SwitchMode)(index, pScrn->currentMode, 0);
263dfe64dd3Smacallan	(*pScrn->AdjustFrame)(index, pScrn->frameX0, pScrn->frameY0, 0);
264dfe64dd3Smacallan        pXGI->DGAactive = FALSE;
265dfe64dd3Smacallan
266dfe64dd3Smacallan    } else {	/* set new mode */
267dfe64dd3Smacallan
268dfe64dd3Smacallan        if(!pXGI->DGAactive) {
269dfe64dd3Smacallan	    /* save the old parameters */
270dfe64dd3Smacallan            memcpy(&BackupLayouts[index], &pXGI->CurrentLayout, sizeof(XGIFBLayout));
271dfe64dd3Smacallan            pXGI->DGAactive = TRUE;
272dfe64dd3Smacallan    	}
273dfe64dd3Smacallan
274dfe64dd3Smacallan	pXGI->CurrentLayout.bitsPerPixel = pMode->bitsPerPixel;
275dfe64dd3Smacallan	pXGI->CurrentLayout.depth        = pMode->depth;
276dfe64dd3Smacallan	pXGI->CurrentLayout.displayWidth = pMode->bytesPerScanline / (pMode->bitsPerPixel >> 3);
277dfe64dd3Smacallan
278dfe64dd3Smacallan    	(*pScrn->SwitchMode)(index, pMode->mode, 0);
279dfe64dd3Smacallan	/* TW: Adjust viewport to 0/0 after mode switch */
280dfe64dd3Smacallan	/* This should fix the vmware-in-dualhead problems */
281dfe64dd3Smacallan	(*pScrn->AdjustFrame)(index, 0, 0, 0);
282dfe64dd3Smacallan    }
283dfe64dd3Smacallan
284dfe64dd3Smacallan    return TRUE;
285dfe64dd3Smacallan}
286dfe64dd3Smacallan
287dfe64dd3Smacallanstatic int
288dfe64dd3SmacallanXGI_GetViewport(ScrnInfoPtr pScrn)
289dfe64dd3Smacallan{
290dfe64dd3Smacallan    (void) pScrn;
291dfe64dd3Smacallan
292dfe64dd3Smacallan    /* There are never pending Adjusts */
293dfe64dd3Smacallan    return 0;
294dfe64dd3Smacallan}
295dfe64dd3Smacallan
296dfe64dd3Smacallanstatic void
297dfe64dd3SmacallanXGI_SetViewport(ScrnInfoPtr pScrn, int x, int y, int flags)
298dfe64dd3Smacallan{
299dfe64dd3Smacallan   (*pScrn->AdjustFrame)(pScrn->pScreen->myNum, x, y, flags);
300dfe64dd3Smacallan}
301dfe64dd3Smacallan
302dfe64dd3Smacallanstatic void
303dfe64dd3SmacallanXGI_FillRect (
304dfe64dd3Smacallan   ScrnInfoPtr pScrn,
305dfe64dd3Smacallan   int x, int y, int w, int h,
306dfe64dd3Smacallan   unsigned long color
307dfe64dd3Smacallan){
308dfe64dd3Smacallan    XGIPtr pXGI = XGIPTR(pScrn);
309dfe64dd3Smacallan
310dfe64dd3Smacallan#ifdef XGI_USE_XAA
311dfe64dd3Smacallan    if(pXGI->AccelInfoPtr) {
312dfe64dd3Smacallan      (*pXGI->AccelInfoPtr->SetupForSolidFill)(pScrn, color, GXcopy, ~0);
313dfe64dd3Smacallan      (*pXGI->AccelInfoPtr->SubsequentSolidFillRect)(pScrn, x, y, w, h);
314dfe64dd3Smacallan      SET_SYNC_FLAG(pXGI->AccelInfoPtr);
315dfe64dd3Smacallan    }
316dfe64dd3Smacallan#endif
317dfe64dd3Smacallan}
318dfe64dd3Smacallan
319dfe64dd3Smacallanstatic void
320dfe64dd3SmacallanXGI_Sync(
321dfe64dd3Smacallan   ScrnInfoPtr pScrn
322dfe64dd3Smacallan){
323dfe64dd3Smacallan    XGIPtr pXGI = XGIPTR(pScrn);
324dfe64dd3Smacallan
325dfe64dd3Smacallan#ifdef XGI_USE_XAA
326dfe64dd3Smacallan    if(pXGI->AccelInfoPtr) {
327dfe64dd3Smacallan      (*pXGI->AccelInfoPtr->Sync)(pScrn);
328dfe64dd3Smacallan    }
329dfe64dd3Smacallan#endif
330dfe64dd3Smacallan}
331dfe64dd3Smacallan
332dfe64dd3Smacallanstatic void
333dfe64dd3SmacallanXGI_BlitRect(
334dfe64dd3Smacallan   ScrnInfoPtr pScrn,
335dfe64dd3Smacallan   int srcx, int srcy,
336dfe64dd3Smacallan   int w, int h,
337dfe64dd3Smacallan   int dstx, int dsty
338dfe64dd3Smacallan){
339dfe64dd3Smacallan    XGIPtr pXGI = XGIPTR(pScrn);
340dfe64dd3Smacallan
341dfe64dd3Smacallan#ifdef XGI_USE_XAA
342dfe64dd3Smacallan    if(pXGI->AccelInfoPtr) {
343dfe64dd3Smacallan      int xdir = ((srcx < dstx) && (srcy == dsty)) ? -1 : 1;
344dfe64dd3Smacallan      int ydir = (srcy < dsty) ? -1 : 1;
345dfe64dd3Smacallan
346dfe64dd3Smacallan      (*pXGI->AccelInfoPtr->SetupForScreenToScreenCopy)(
347dfe64dd3Smacallan          pScrn, xdir, ydir, GXcopy, (CARD32)~0, -1);
348dfe64dd3Smacallan      (*pXGI->AccelInfoPtr->SubsequentScreenToScreenCopy)(
349dfe64dd3Smacallan          pScrn, srcx, srcy, dstx, dsty, w, h);
350dfe64dd3Smacallan      SET_SYNC_FLAG(pXGI->AccelInfoPtr);
351dfe64dd3Smacallan    }
352dfe64dd3Smacallan#endif
353dfe64dd3Smacallan}
354dfe64dd3Smacallan
355dfe64dd3Smacallanstatic Bool
356dfe64dd3SmacallanXGI_OpenFramebuffer(
357dfe64dd3Smacallan   ScrnInfoPtr pScrn,
358dfe64dd3Smacallan   char **name,
359dfe64dd3Smacallan#ifndef NEW_DGAOPENFRAMEBUFFER
360dfe64dd3Smacallan   unsigned char **mem,
361dfe64dd3Smacallan   int *size,
362dfe64dd3Smacallan   int *offset,
363dfe64dd3Smacallan   int *flags
364dfe64dd3Smacallan#else
365dfe64dd3Smacallan   unsigned int *mem,
366dfe64dd3Smacallan   unsigned int *size,
367dfe64dd3Smacallan   unsigned int *offset,
368dfe64dd3Smacallan   unsigned int *flags
369dfe64dd3Smacallan#endif
370dfe64dd3Smacallan){
371dfe64dd3Smacallan    XGIPtr pXGI = XGIPTR(pScrn);
372dfe64dd3Smacallan
373dfe64dd3Smacallan    *name = NULL;       /* no special device */
374dfe64dd3Smacallan#ifndef NEW_DGAOPENFRAMEBUFFER
375dfe64dd3Smacallan    *mem = (unsigned char*)pXGI->FbAddress;
376dfe64dd3Smacallan#else
377dfe64dd3Smacallan    *mem = pXGI->FbAddress;
378dfe64dd3Smacallan#endif
379dfe64dd3Smacallan    *size = pXGI->maxxfbmem;
380dfe64dd3Smacallan    *offset = 0;
381dfe64dd3Smacallan    *flags = DGA_NEED_ROOT;
382dfe64dd3Smacallan
383dfe64dd3Smacallan    return TRUE;
384dfe64dd3Smacallan}
385