2
* Acceleration for the Creator and Creator3D framebuffer - DGA support.
4
* Copyright (C) 2000 David S. Miller (davem@redhat.com)
6
* Permission is hereby granted, free of charge, to any person obtaining a copy
7
* of this software and associated documentation files (the "Software"), to deal
8
* in the Software without restriction, including without limitation the rights
9
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
* copies of the Software, and to permit persons to whom the Software is
11
* furnished to do so, subject to the following conditions:
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
19
* DAVID MILLER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
20
* IN 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.
24
/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/sunffb/ffb_dga.c,v 1.2 2000/10/17 16:53:17 tsi Exp $ */
27
#include "xf86_OSproc.h"
28
#include "xf86_ansic.h"
33
#include "ffb_rcache.h"
36
#include "ffb_loops.h"
38
static Bool FFB_OpenFramebuffer(ScrnInfoPtr pScrn, char **name, unsigned char **mem,
39
int *size, int *offset, int *extra);
40
static void FFB_CloseFramebuffer(ScrnInfoPtr pScrn);
41
static Bool FFB_SetMode(ScrnInfoPtr pScrn, DGAModePtr pMode);
42
static void FFB_SetViewport(ScrnInfoPtr pScrn, int x, int y, int flags);
43
static int FFB_GetViewport(ScrnInfoPtr pScrn);
44
static void FFB_Flush(ScrnInfoPtr pScrn);
46
/* Have to disable all this stuff for now until I figure out where
47
* we should get the WID values from... ho hum... -DaveM
50
static void FFB_FillRect(ScrnInfoPtr pScrn, int x, int y, int w, int h, unsigned long color);
53
static void FFB_BlitRect(ScrnInfoPtr pScrn, int srcx, int srcy, int w, int h,
56
#define FFB_BlitRect NULL
59
#define FFB_FillRect NULL
60
#define FFB_BlitRect NULL
63
static DGAFunctionRec FFB_DGAFuncs = {
75
void FFB_InitDGA(ScreenPtr pScreen)
77
ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
82
pFfb = GET_FFB_FROM_SCRN(pScrn);
84
mode = xnfcalloc(sizeof(DGAModeRec), 1);
86
xf86Msg(X_WARNING, "%s: DGA init failed, cannot alloc DGAMode.\n",
92
mode->mode = pScrn->modes;
94
/* Hmmm, what does concurrent access really mean? -DaveM */
95
mode->flags = (DGA_CONCURRENT_ACCESS | DGA_PIXMAP_AVAILABLE | DGA_FILL_RECT);
98
mode->flags |= DGA_BLIT_RECT;
101
mode->imageWidth = 2048;
102
mode->imageHeight = 2048;
103
mode->pixmapWidth = 2048;
104
mode->pixmapHeight = 2048;
106
/* XXX I would imagine that this value states how many bytes
107
* XXX you add to advance exactly one full horizontal line in
108
* XXX the framebuffer addressing, but the way we set the pScrn
109
* XXX mode values do not match that definition.
111
* XXX Ask Jakub what is going on here. -DaveM
114
mode->bytesPerScanline = pScrn->modes->HDisplay * 4;
116
mode->bytesPerScanline = (2048 * 4);
119
mode->byteOrder = pScrn->imageByteOrder;
121
mode->bitsPerPixel = 32;
122
mode->red_mask = 0xff;
123
mode->green_mask = 0xff00;
124
mode->blue_mask = 0xff0000;
125
mode->visualClass = TrueColor;
126
mode->viewportWidth = pScrn->modes->HDisplay;
127
mode->viewportHeight = pScrn->modes->VDisplay;
129
/* Do these values even matter if we do not support
132
mode->xViewportStep = 0;
133
mode->yViewportStep = 0;
134
mode->maxViewportX = 0;
135
mode->maxViewportY = 0;
137
mode->viewportFlags = 0;
140
result = DGAInit(pScreen, &FFB_DGAFuncs, mode, 1);
141
if (result == FALSE) {
143
"%s: DGA init failed, DGAInit returns FALSE.\n",
146
xf86Msg(X_INFO, "%s: DGA support initialized.\n",
151
static Bool FFB_OpenFramebuffer(ScrnInfoPtr pScrn, char **name, unsigned char **mem,
152
int *size, int *offset, int *extra)
154
FFBPtr pFfb = GET_FFB_FROM_SCRN(pScrn);
156
*name = pFfb->psdp->device;
158
/* We give the user the dumb frame buffer. */
159
*mem = (unsigned char *)FFB_DFB24_VOFF;
167
static void FFB_CloseFramebuffer(ScrnInfoPtr pScrn)
171
static Bool FFB_SetMode(ScrnInfoPtr pScrn, DGAModePtr pMode)
173
/* Nothing to do, we currently only support one mode
174
* and we are always in it.
179
static void FFB_SetViewport(ScrnInfoPtr pScrn, int x, int y, int flags)
181
/* We don't support viewports, so... */
184
static int FFB_GetViewport(ScrnInfoPtr pScrn)
186
/* No viewports, none pending... */
190
static void FFB_Flush(ScrnInfoPtr pScrn)
192
FFBPtr pFfb = GET_FFB_FROM_SCRN(pScrn);
193
ffb_fbcPtr ffb = pFfb->regs;
200
extern void CreatorFillBoxSolid (DrawablePtr pDrawable, int nBox,
201
BoxPtr pBox, unsigned long pixel);
203
static void FFB_FillRect(ScrnInfoPtr pScrn, int x, int y, int w, int h, unsigned long color)
208
draw.pScreen = pScrn->pScreen;
214
CreatorFillBoxSolid(&draw, 1, &box, color);
218
extern void VISmoveImageLR(unsigned char *, unsigned char *, long, long, long, long);
219
extern void VISmoveImageRL(unsigned char *, unsigned char *, long, long, long, long);
221
static void FFB_BlitRect(ScrnInfoPtr pScrn, int srcx, int srcy,
222
int w, int h, int dstx, int dsty)
224
FFBPtr pFfb = GET_FFB_FROM_SCRN(pScrn);
225
ffb_fbcPtr ffb = pFfb->regs;
227
if (!pFfb->disable_vscroll &&
230
FFB_WRITE_ATTRIBUTES_VSCROLL(pFfb, 0x00ffffff);
232
ffb->drawop = FFB_DRAWOP_VSCROLL;
233
FFB_WRITE64(&ffb->by, srcy, srcx);
234
FFB_WRITE64_2(&ffb->dy, dsty, dstx);
235
FFB_WRITE64_3(&ffb->bh, h, w);
238
unsigned char *base = (unsigned char *)pFfb->fb;
239
int use_prefetch = pFfb->use_blkread_prefetch;
241
FFB_WRITE_ATTRIBUTES_SFB_VAR(pFfb, 0x00ffffff, GXcopy);
245
ffb->mer = FFB_MER_EIRA;
250
VISmoveImageRL((base +
251
((srcy + h - 1) * (2048 * 4)) +
254
((dsty + h - 1) * (2048 * 4)) +
258
-(2048 * 4), - (2048 * 4));
260
VISmoveImageLR((base +
261
((srcy + h - 1) * (2048 * 4)) +
264
((dsty + h - 1) * (2048 * 4)) +
268
-(2048 * 4), - (2048 * 4));
272
ffb->mer = FFB_MER_DRA;
274
FFBWait(pFfb, pFfb->regs);