Merge branch 'master' into mpx

Conflicts:

	Xext/xprint.c (removed in master)
	config/hal.c
	dix/main.c
	hw/kdrive/ati/ati_cursor.c (removed in master)
	hw/kdrive/i810/i810_cursor.c (removed in master)
	hw/xprint/ddxInit.c (removed in master)
	xkb/ddxLoad.c
This commit is contained in:
Peter Hutterer 2008-05-20 10:20:14 +09:30
commit 99d28c3ef3
763 changed files with 4491 additions and 104247 deletions

9
.gitignore vendored
View File

@ -278,8 +278,13 @@ hw/xprint/doc/Xprt.1x
hw/xprint/doc/Xprt.man
hw/xprint/dpmsstubs-wrapper.c
hw/xprint/miinitext-wrapper.c
hw/xquartz/xpr/Xquartz
hw/xquartz/xpr/Xquartz.1
hw/xquartz/mach-startup/mach_startup.h
hw/xquartz/mach-startup/mach_startupServer.c
hw/xquartz/mach-startup/mach_startupServer.h
hw/xquartz/mach-startup/mach_startupUser.c
hw/xquartz/mach-startup/X11
hw/xquartz/mach-startup/Xquartz
hw/xquartz/doc/Xquartz.1
include/dix-config.h
include/kdrive-config.h
include/xgl-config.h

View File

@ -99,12 +99,6 @@ if XEVIE
BUILTIN_SRCS += $(XEVIE_SRCS)
endif
# XPrint: Printing via X Protocol
XPRINT_SRCS = xprint.c
if XPRINT
BUILTIN_SRCS += $(XPRINT_SRCS)
endif
# Multi-buffering extension
MULTIBUFFER_SRCS = mbuf.c
EXTRA_MULTIBUFFER_SRCS = mbufbf.c mbufpx.c
@ -150,7 +144,6 @@ EXTRA_DIST = \
$(XCALIBRATE_SRCS) \
$(XINERAMA_SRCS) \
$(XEVIE_SRCS) \
$(XPRINT_SRCS) \
$(MULTIBUFFER_SRCS) \
$(EXTRA_MULTIBUFFER_SRCS) \
$(FONTCACHE_SRCS) \

View File

@ -87,6 +87,9 @@ _X_EXPORT unsigned long XRT_PIXMAP;
_X_EXPORT unsigned long XRT_GC;
_X_EXPORT unsigned long XRT_COLORMAP;
static Bool VisualsEqual(VisualPtr, ScreenPtr, VisualPtr);
_X_EXPORT XineramaVisualsEqualProcPtr XineramaVisualsEqualPtr = &VisualsEqual;
/*
* Function prototypes
*/
@ -668,10 +671,10 @@ Bool PanoramiXCreateConnectionBlock(void)
connSetupPrefix.length = length >> 2;
xfree(PanoramiXVisuals);
for (i = 0; i < PanoramiXNumDepths; i++)
xfree(PanoramiXDepths[i].vids);
xfree(PanoramiXDepths);
PanoramiXDepths = NULL;
/*
* OK, change some dimensions so it looks as if it were one big screen
@ -709,7 +712,7 @@ Bool PanoramiXCreateConnectionBlock(void)
* do their own back-mapping.
*/
static Bool
VisualsEqual(VisualPtr a, VisualPtr b)
VisualsEqual(VisualPtr a, ScreenPtr pScreenB, VisualPtr b)
{
return ((a->class == b->class) &&
(a->ColormapEntries == b->ColormapEntries) &&
@ -759,7 +762,6 @@ static void
PanoramiXMaybeAddVisual(VisualPtr pVisual)
{
ScreenPtr pScreen;
VisualPtr candidate = NULL;
int j, k;
Bool found = FALSE;
@ -767,10 +769,10 @@ PanoramiXMaybeAddVisual(VisualPtr pVisual)
pScreen = screenInfo.screens[j];
found = FALSE;
candidate = pScreen->visuals;
for (k = 0; k < pScreen->numVisuals; k++) {
candidate++;
if (VisualsEqual(pVisual, candidate)
VisualPtr candidate = &pScreen->visuals[k];
if ((*XineramaVisualsEqualPtr)(pVisual, pScreen, candidate)
#ifdef GLXPROXY
&& glxMatchVisual(screenInfo.screens[0], pVisual, pScreen)
#endif
@ -844,8 +846,13 @@ PanoramiXConsolidate(void)
_X_EXPORT VisualID
PanoramiXTranslateVisualID(int screen, VisualID orig)
{
ScreenPtr pOtherScreen = screenInfo.screens[screen];
VisualPtr pVisual = NULL;
int i, j;
int i;
/* if screen is 0, orig is already the correct visual ID */
if (screen == 0)
return orig;
for (i = 0; i < PanoramiXNumVisuals; i++) {
if (orig == PanoramiXVisuals[i].vid) {
@ -858,11 +865,13 @@ PanoramiXTranslateVisualID(int screen, VisualID orig)
return 0;
/* found the original, now translate it relative to the backend screen */
for (i = 0; i < PanoramiXNumScreens; i++)
for (j = 0; j < screenInfo.screens[i]->numVisuals; j++)
if (VisualsEqual(pVisual, &screenInfo.screens[i]->visuals[j]))
return screenInfo.screens[i]->visuals[j].vid;
for (i = 0; i < pOtherScreen->numVisuals; i++) {
VisualPtr pOtherVisual = &pOtherScreen->visuals[i];
if ((*XineramaVisualsEqualPtr)(pVisual, pOtherScreen, pOtherVisual))
return pOtherVisual->vid;
}
return 0;
}

View File

@ -30,6 +30,16 @@ extern unsigned long XRT_PIXMAP;
extern unsigned long XRT_GC;
extern unsigned long XRT_COLORMAP;
/*
* Drivers are allowed to wrap this function. Each wrapper can decide that the
* two visuals are unequal, but if they are deemed equal, the wrapper must call
* down and return FALSE if the wrapped function does. This ensures that all
* layers agree that the visuals are equal. The first visual is always from
* screen 0.
*/
typedef Bool (*XineramaVisualsEqualProcPtr)(VisualPtr, ScreenPtr, VisualPtr);
extern XineramaVisualsEqualProcPtr XineramaVisualsEqualPtr;
extern void XineramaGetImageData(
DrawablePtr *pDrawables,
int left,

File diff suppressed because it is too large Load Diff

View File

@ -7,4 +7,5 @@ libcomposite_la_SOURCES = \
compext.c \
compint.h \
compinit.c \
compoverlay.c \
compwindow.c

View File

@ -54,10 +54,7 @@ static CARD8 CompositeReqCode;
static DevPrivateKey CompositeClientPrivateKey = &CompositeClientPrivateKey;
RESTYPE CompositeClientWindowType;
RESTYPE CompositeClientSubwindowsType;
static RESTYPE CompositeClientOverlayType;
static void deleteCompOverlayClient (CompOverlayClientPtr pOcToDel,
ScreenPtr pScreen);
RESTYPE CompositeClientOverlayType;
typedef struct _CompositeClient {
int major_version;
@ -107,19 +104,8 @@ static int
FreeCompositeClientOverlay (pointer value, XID ccwid)
{
CompOverlayClientPtr pOc = (CompOverlayClientPtr) value;
ScreenPtr pScreen = pOc->pScreen;
CompScreenPtr cs;
deleteCompOverlayClient(pOc, pScreen);
/* Unmap overlay window when there are no more clients using it */
cs = GetCompScreen(pScreen);
if (cs->pOverlayClients == NULL) {
if (cs->pOverlayWin != NULL) {
UnmapWindow(cs->pOverlayWin, FALSE);
}
}
compFreeOverlayClient (pOc);
return Success;
}
@ -304,137 +290,6 @@ ProcCompositeNameWindowPixmap (ClientPtr client)
}
/*
* Routines for manipulating the per-screen overlay clients list.
* This list indicates which clients have called GetOverlayWindow
* for this screen.
*/
/* Return the screen's overlay client list element for the given client */
static CompOverlayClientPtr
findCompOverlayClient (ClientPtr pClient, ScreenPtr pScreen)
{
CompScreenPtr cs = GetCompScreen(pScreen);
CompOverlayClientPtr pOc;
for (pOc = cs->pOverlayClients; pOc != NULL; pOc = pOc->pNext) {
if (pOc->pClient == pClient) {
return pOc;
}
}
return NULL;
}
static int
createCompOverlayClient (ClientPtr pClient, ScreenPtr pScreen)
{
CompScreenPtr cs = GetCompScreen(pScreen);
CompOverlayClientPtr pOc;
pOc = (CompOverlayClientPtr) xalloc(sizeof(CompOverlayClientRec));
if (pOc == NULL) {
return BadAlloc;
}
pOc->pClient = pClient;
pOc->pScreen = pScreen;
pOc->resource = FakeClientID(pClient->index);
pOc->pNext = cs->pOverlayClients;
cs->pOverlayClients = pOc;
/*
* Create a resource for this element so it can be deleted
* when the client goes away.
*/
if (!AddResource (pOc->resource, CompositeClientOverlayType,
(pointer) pOc)) {
xfree(pOc);
return BadAlloc;
}
return Success;
}
/*
* Delete the given overlay client list element from its screen list.
*/
static void
deleteCompOverlayClient (CompOverlayClientPtr pOcToDel, ScreenPtr pScreen)
{
CompScreenPtr cs = GetCompScreen(pScreen);
CompOverlayClientPtr pOc, pNext;
CompOverlayClientPtr pOcLast = NULL;
pOc = cs->pOverlayClients;
while (pOc != NULL) {
pNext = pOc->pNext;
if (pOc == pOcToDel) {
xfree(pOc);
if (pOcLast == NULL) {
cs->pOverlayClients = pNext;
} else {
pOcLast->pNext = pNext;
}
break;
}
pOcLast = pOc;
pOc = pNext;
}
}
/*
* Delete all the hide-counts list elements for this screen.
*/
void
deleteCompOverlayClientsForScreen (ScreenPtr pScreen)
{
CompScreenPtr cs = GetCompScreen(pScreen);
CompOverlayClientPtr pOc, pTmp;
pOc = cs->pOverlayClients;
while (pOc != NULL) {
pTmp = pOc->pNext;
FreeResource(pOc->resource, 0);
pOc = pTmp;
}
cs->pOverlayClients = NULL;
}
/*
** If necessary, create the overlay window. And map it
** Note: I found it excessively difficult to destroy this window
** during compCloseScreen; DeleteWindow can't be called because
** the input devices are already shut down. So we are going to
** just allocate an overlay window once per screen per X server
** invocation.
*/
static WindowPtr
createOverlayWindow (ScreenPtr pScreen)
{
int wid = FakeClientID(0);
WindowPtr pWin;
XID overrideRedirect = TRUE;
int result;
pWin = CreateWindow (
wid, WindowTable[pScreen->myNum],
0, 0, pScreen->width, pScreen->height, 0,
InputOutput, CWOverrideRedirect, &overrideRedirect,
WindowTable[pScreen->myNum]->drawable.depth,
serverClient, pScreen->rootVisual, &result);
if (pWin == NULL) {
return NULL;
}
if (!AddResource(wid, RT_WINDOW, (pointer)pWin)) {
DeleteWindow(pWin, None);
return NULL;
}
return pWin;
}
static int
ProcCompositeGetOverlayWindow (ClientPtr client)
{
@ -456,28 +311,31 @@ ProcCompositeGetOverlayWindow (ClientPtr client)
}
pScreen = pWin->drawable.pScreen;
/*
* Create an OverlayClient structure to mark this client's
* interest in the overlay window
*/
pOc = compCreateOverlayClient(pScreen, client);
if (pOc == NULL)
return BadAlloc;
/*
* Make sure the overlay window exists
*/
cs = GetCompScreen(pScreen);
if (cs->pOverlayWin == NULL) {
cs->pOverlayWin = createOverlayWindow(pScreen);
if (cs->pOverlayWin == NULL) {
if (cs->pOverlayWin == NULL)
if (!compCreateOverlayWindow(pScreen))
{
FreeResource (pOc->resource, RT_NONE);
return BadAlloc;
}
}
rc = XaceHook(XACE_RESOURCE_ACCESS, client, cs->pOverlayWin->drawable.id,
RT_WINDOW, cs->pOverlayWin, RT_NONE, NULL, DixGetAttrAccess);
if (rc != Success)
{
FreeResource (pOc->resource, RT_NONE);
return rc;
MapWindow(cs->pOverlayWin, serverClient);
/* Record that client is using this overlay window */
pOc = findCompOverlayClient(client, pScreen);
if (pOc == NULL) {
int ret = createCompOverlayClient(client, pScreen);
if (ret != Success) {
return ret;
}
}
rep.type = X_Reply;
@ -504,7 +362,6 @@ ProcCompositeReleaseOverlayWindow (ClientPtr client)
WindowPtr pWin;
ScreenPtr pScreen;
CompOverlayClientPtr pOc;
CompScreenPtr cs;
REQUEST_SIZE_MATCH(xCompositeReleaseOverlayWindowReq);
pWin = (WindowPtr) LookupIDByType (stuff->window, RT_WINDOW);
@ -519,18 +376,12 @@ ProcCompositeReleaseOverlayWindow (ClientPtr client)
* Has client queried a reference to the overlay window
* on this screen? If not, generate an error.
*/
pOc = findCompOverlayClient(client, pWin->drawable.pScreen);
if (pOc == NULL) {
pOc = compFindOverlayClient (pWin->drawable.pScreen, client);
if (pOc == NULL)
return BadMatch;
}
/* The delete function will free the client structure */
FreeResource (pOc->resource, 0);
cs = GetCompScreen(pScreen);
if (cs->pOverlayClients == NULL) {
UnmapWindow(cs->pOverlayWin, FALSE);
}
FreeResource (pOc->resource, RT_NONE);
return client->noClientException;
}

View File

@ -76,14 +76,6 @@ compCloseScreen (int index, ScreenPtr pScreen)
pScreen->CopyWindow = cs->CopyWindow;
pScreen->PositionWindow = cs->PositionWindow;
deleteCompOverlayClientsForScreen(pScreen);
/*
** Note: no need to call DeleteWindow; the server has
** already destroyed it.
*/
cs->pOverlayWin = NULL;
xfree (cs);
dixSetPrivate(&pScreen->devPrivates, CompScreenPrivateKey, NULL);
ret = (*pScreen->CloseScreen) (index, pScreen);
@ -122,11 +114,11 @@ compChangeWindowAttributes(WindowPtr pWin, unsigned long mask)
if (ret && (mask & CWBackingStore)) {
if (pWin->backingStore != NotUseful) {
compRedirectWindow(serverClient, pWin, CompositeRedirectAutomatic);
pWin->backStorage = TRUE;
pWin->backStorage = (pointer) (intptr_t) 1;
} else {
compUnredirectWindow(serverClient, pWin,
CompositeRedirectAutomatic);
pWin->backStorage = FALSE;
pWin->backStorage = NULL;
}
}
@ -380,6 +372,7 @@ compScreenInit (ScreenPtr pScreen)
return FALSE;
cs->damaged = FALSE;
cs->overlayWid = FakeClientID(0);
cs->pOverlayWin = NULL;
cs->pOverlayClients = NULL;

View File

@ -155,6 +155,7 @@ typedef struct _CompScreen {
VisualID *alternateVisuals;
WindowPtr pOverlayWin;
Window overlayWid;
CompOverlayClientPtr pOverlayClients;
} CompScreenRec, *CompScreenPtr;
@ -172,6 +173,7 @@ extern DevPrivateKey CompSubwindowsPrivateKey;
extern RESTYPE CompositeClientWindowType;
extern RESTYPE CompositeClientSubwindowsType;
extern RESTYPE CompositeClientOverlayType;
/*
* compalloc.c
@ -229,6 +231,25 @@ CompositeRegisterAlternateVisuals (ScreenPtr pScreen,
Bool
compScreenInit (ScreenPtr pScreen);
/*
* compoverlay.c
*/
void
compFreeOverlayClient (CompOverlayClientPtr pOcToDel);
CompOverlayClientPtr
compFindOverlayClient (ScreenPtr pScreen, ClientPtr pClient);
CompOverlayClientPtr
compCreateOverlayClient (ScreenPtr pScreen, ClientPtr pClient);
Bool
compCreateOverlayWindow (ScreenPtr pScreen);
void
compDestroyOverlayWindow (ScreenPtr pScreen);
/*
* compwindow.c
*/
@ -292,9 +313,6 @@ compCopyWindow (WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc);
void
compWindowUpdate (WindowPtr pWin);
void
deleteCompOverlayClientsForScreen (ScreenPtr pScreen);
WindowPtr
CompositeRealChildHead (WindowPtr pWin);

159
composite/compoverlay.c Normal file
View File

@ -0,0 +1,159 @@
/*
* Copyright © 2006 Sun Microsystems
*
* 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 Sun Microsystems not be used in
* advertising or publicity pertaining to distribution of the software without
* specific, written prior permission. Sun Microsystems makes no
* representations about the suitability of this software for any purpose. It
* is provided "as is" without express or implied warranty.
*
* SUN MICROSYSTEMS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL SUN MICROSYSTEMS 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 © 2003 Keith Packard
*
* 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 Keith Packard not be used in
* advertising or publicity pertaining to distribution of the software without
* specific, written prior permission. Keith Packard makes no
* representations about the suitability of this software for any purpose. It
* is provided "as is" without express or implied warranty.
*
* KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL KEITH PACKARD 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.
*/
#ifdef HAVE_DIX_CONFIG_H
#include <dix-config.h>
#endif
#include "compint.h"
#include "xace.h"
/*
* Delete the given overlay client list element from its screen list.
*/
void
compFreeOverlayClient (CompOverlayClientPtr pOcToDel)
{
ScreenPtr pScreen = pOcToDel->pScreen;
CompScreenPtr cs = GetCompScreen (pScreen);
CompOverlayClientPtr *pPrev, pOc;
for (pPrev = &cs->pOverlayClients; (pOc = *pPrev); pPrev = &pOc->pNext)
{
if (pOc == pOcToDel) {
*pPrev = pOc->pNext;
xfree (pOc);
break;
}
}
/* Destroy overlay window when there are no more clients using it */
if (cs->pOverlayClients == NULL)
compDestroyOverlayWindow (pScreen);
}
/*
* Return the client's first overlay client rec from the given screen
*/
CompOverlayClientPtr
compFindOverlayClient (ScreenPtr pScreen, ClientPtr pClient)
{
CompScreenPtr cs = GetCompScreen(pScreen);
CompOverlayClientPtr pOc;
for (pOc = cs->pOverlayClients; pOc != NULL; pOc = pOc->pNext)
if (pOc->pClient == pClient)
return pOc;
return NULL;
}
/*
* Create an overlay client object for the given client
*/
CompOverlayClientPtr
compCreateOverlayClient (ScreenPtr pScreen, ClientPtr pClient)
{
CompScreenPtr cs = GetCompScreen(pScreen);
CompOverlayClientPtr pOc;
pOc = (CompOverlayClientPtr) xalloc(sizeof(CompOverlayClientRec));
if (pOc == NULL)
return NULL;
pOc->pClient = pClient;
pOc->pScreen = pScreen;
pOc->resource = FakeClientID(pClient->index);
pOc->pNext = cs->pOverlayClients;
cs->pOverlayClients = pOc;
/*
* Create a resource for this element so it can be deleted
* when the client goes away.
*/
if (!AddResource (pOc->resource, CompositeClientOverlayType, (pointer) pOc))
return NULL;
return pOc;
}
/*
* Create the overlay window and map it
*/
Bool
compCreateOverlayWindow (ScreenPtr pScreen)
{
CompScreenPtr cs = GetCompScreen(pScreen);
WindowPtr pRoot = WindowTable[pScreen->myNum];
WindowPtr pWin;
XID overrideRedirect = TRUE;
int result;
pWin = cs->pOverlayWin =
CreateWindow (cs->overlayWid, pRoot,
0, 0, pScreen->width, pScreen->height, 0,
InputOutput, CWOverrideRedirect, &overrideRedirect,
pRoot->drawable.depth,
serverClient, pScreen->rootVisual, &result);
if (pWin == NULL)
return FALSE;
if (!AddResource(pWin->drawable.id, RT_WINDOW, (pointer)pWin))
return FALSE;
MapWindow(pWin, serverClient);
return TRUE;
}
/*
* Destroy the overlay window
*/
void
compDestroyOverlayWindow (ScreenPtr pScreen)
{
CompScreenPtr cs = GetCompScreen(pScreen);
cs->pOverlayWin = NullWindow;
FreeResource (cs->overlayWid, RT_NONE);
}

View File

@ -54,7 +54,7 @@ compCheckWindow (WindowPtr pWin, pointer data)
PixmapPtr pWinPixmap = (*pScreen->GetWindowPixmap) (pWin);
PixmapPtr pParentPixmap = pWin->parent ? (*pScreen->GetWindowPixmap) (pWin->parent) : 0;
PixmapPtr pScreenPixmap = (*pScreen->GetScreenPixmap) (pScreen);
if (!pWin->parent)
{
assert (pWin->redirectDraw == RedirectDrawNone);
@ -122,7 +122,7 @@ compSetPixmapVisitWindow (WindowPtr pWindow, pointer data)
SetWinSize (pWindow);
SetBorderSize (pWindow);
if (HasBorder (pWindow))
QueueWorkProc (compRepaintBorder, serverClient,
QueueWorkProc (compRepaintBorder, serverClient,
(pointer) pWindow->drawable.id);
return WT_WALKCHILDREN;
}
@ -146,15 +146,15 @@ compCheckRedirect (WindowPtr pWin)
Bool should;
should = pWin->realized && (pWin->drawable.class != InputOnly) &&
(cw != NULL);
(cw != NULL) && (pWin->parent != NULL);
/* Never redirect the overlay window */
if (cs->pOverlayWin != NULL) {
if (pWin == cs->pOverlayWin) {
should = FALSE;
}
}
}
if (should != (pWin->redirectDraw != RedirectDrawNone))
{
if (should)
@ -276,10 +276,10 @@ compClipNotify (WindowPtr pWin, int dx, int dy)
ScreenPtr pScreen = pWin->drawable.pScreen;
CompScreenPtr cs = GetCompScreen (pScreen);
CompWindowPtr cw = GetCompWindow (pWin);
if (cw)
{
if (cw->borderClipX != pWin->drawable.x ||
if (cw->borderClipX != pWin->drawable.x ||
cw->borderClipY != pWin->drawable.y)
{
REGION_TRANSLATE (pScreen, &cw->borderClip,
@ -324,7 +324,7 @@ compImplicitRedirect (WindowPtr pWin, WindowPtr pParent)
ScreenPtr pScreen = pWin->drawable.pScreen;
XID winVisual = wVisual (pWin);
XID parentVisual = wVisual (pParent);
if (winVisual != parentVisual &&
(compIsAlternateVisual (pScreen, winVisual) ||
compIsAlternateVisual (pScreen, parentVisual)))
@ -345,11 +345,11 @@ compMoveWindow (WindowPtr pWin, int x, int y, WindowPtr pSib, VTKind kind)
WindowPtr pParent;
int draw_x, draw_y;
unsigned int w, h, bw;
/* if this is a root window, can't be moved */
if (!(pParent = pWin->parent))
return;
bw = wBorderWidth (pWin);
draw_x = pParent->drawable.x + x + (int)bw;
draw_y = pParent->drawable.y + y + (int)bw;
@ -390,18 +390,18 @@ compResizeWindow (WindowPtr pWin, int x, int y,
WindowPtr pParent;
int draw_x, draw_y;
unsigned int bw;
/* if this is a root window, can't be moved */
if (!(pParent = pWin->parent))
return;
bw = wBorderWidth (pWin);
draw_x = pParent->drawable.x + x + (int)bw;
draw_y = pParent->drawable.y + y + (int)bw;
compReallocPixmap (pWin, draw_x, draw_y, w, h, bw);
}
compCheckTree (pScreen);
pScreen->ResizeWindow = cs->ResizeWindow;
(*pScreen->ResizeWindow) (pWin, x, y, w, h, pSib);
cs->ResizeWindow = pScreen->ResizeWindow;
@ -430,11 +430,11 @@ compChangeBorderWidth (WindowPtr pWin, unsigned int bw)
WindowPtr pParent;
int draw_x, draw_y;
unsigned int w, h;
/* if this is a root window, can't be moved */
if (!(pParent = pWin->parent))
return;
draw_x = pWin->drawable.x;
draw_y = pWin->drawable.y;
w = pWin->drawable.width;
@ -481,13 +481,13 @@ compReparentWindow (WindowPtr pWin, WindowPtr pPriorParent)
*/
if (compImplicitRedirect (pWin, pWin->parent))
compRedirectWindow (serverClient, pWin, CompositeRedirectAutomatic);
/*
* Allocate any necessary redirect pixmap
* (this actually should never be true; pWin is always unmapped)
*/
compCheckRedirect (pWin);
/*
* Reset pixmap pointers as appropriate
*/
@ -514,7 +514,7 @@ compCopyWindow (WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
{
PixmapPtr pPixmap = (*pScreen->GetWindowPixmap) (pWin);
CompWindowPtr cw = GetCompWindow (pWin);
assert (cw->oldx != COMP_ORIGIN_INVALID);
assert (cw->oldy != COMP_ORIGIN_INVALID);
if (cw->pOldPixmap)
@ -526,7 +526,7 @@ compCopyWindow (WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
RegionRec rgnDst;
PixmapPtr pPixmap = (*pScreen->GetWindowPixmap) (pWin);
GCPtr pGC;
dx = ptOldOrg.x - pWin->drawable.x;
dy = ptOldOrg.y - pWin->drawable.y;
REGION_TRANSLATE(pWin->drawable.pScreen, prgnSrc, -dx, -dy);
@ -535,10 +535,10 @@ compCopyWindow (WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
REGION_INTERSECT(pWin->drawable.pScreen, &rgnDst,
&pWin->borderClip, prgnSrc);
REGION_TRANSLATE (pWin->drawable.pScreen, &rgnDst,
REGION_TRANSLATE (pWin->drawable.pScreen, &rgnDst,
-pPixmap->screen_x, -pPixmap->screen_y);
dx = dx + pPixmap->screen_x - cw->oldx;
dy = dy + pPixmap->screen_y - cw->oldy;
pGC = GetScratchGC (pPixmap->drawable.depth, pScreen);
@ -546,7 +546,7 @@ compCopyWindow (WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
{
BoxPtr pBox = REGION_RECTS (&rgnDst);
int nBox = REGION_NUM_RECTS (&rgnDst);
ValidateGC(&pPixmap->drawable, pGC);
while (nBox--)
{
@ -568,7 +568,7 @@ compCopyWindow (WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
ptOldOrg.x += dx;
ptOldOrg.y += dy;
}
pScreen->CopyWindow = cs->CopyWindow;
if (ptOldOrg.x != pWin->drawable.x || ptOldOrg.y != pWin->drawable.y)
{
@ -634,7 +634,7 @@ compDestroyWindow (WindowPtr pWin)
FreeResource (cw->clients->id, RT_NONE);
while ((csw = GetCompSubwindows (pWin)))
FreeResource (csw->clients->id, RT_NONE);
if (pWin->redirectDraw != RedirectDrawNone)
compFreePixmap (pWin);
ret = (*pScreen->DestroyWindow) (pWin);
@ -699,7 +699,7 @@ PictFormatPtr
compWindowFormat (WindowPtr pWin)
{
ScreenPtr pScreen = pWin->drawable.pScreen;
return PictureMatchVisual (pScreen, pWin->drawable.depth,
compGetWindowVisual (pWin));
}
@ -716,24 +716,24 @@ compWindowUpdateAutomatic (WindowPtr pWin)
int error;
RegionPtr pRegion = DamageRegion (cw->damage);
PicturePtr pSrcPicture = CreatePicture (0, &pSrcPixmap->drawable,
pSrcFormat,
pSrcFormat,
0, 0,
serverClient,
&error);
XID subwindowMode = IncludeInferiors;
PicturePtr pDstPicture = CreatePicture (0, &pParent->drawable,
pDstFormat,
CPSubwindowMode,
CPSubwindowMode,
&subwindowMode,
serverClient,
&error);
/*
* First move the region from window to screen coordinates
*/
REGION_TRANSLATE (pScreen, pRegion,
REGION_TRANSLATE (pScreen, pRegion,
pWin->drawable.x, pWin->drawable.y);
/*
* Clip against the "real" border clip
*/
@ -742,14 +742,14 @@ compWindowUpdateAutomatic (WindowPtr pWin)
/*
* Now translate from screen to dest coordinates
*/
REGION_TRANSLATE (pScreen, pRegion,
REGION_TRANSLATE (pScreen, pRegion,
-pParent->drawable.x, -pParent->drawable.y);
/*
* Clip the picture
*/
SetPictureClipRegion (pDstPicture, 0, 0, pRegion);
/*
* And paint
*/
@ -813,7 +813,7 @@ CompositeRealChildHead (WindowPtr pWin)
if (!pChild) {
return NullWindow;
}
cs = GetCompScreen(pWin->drawable.pScreen);
if (pChild == cs->pOverlayWin) {
return pChild;

View File

@ -74,7 +74,7 @@ remove_device(DeviceIntPtr dev)
static void
device_removed(LibHalContext *ctx, const char *udi)
{
DeviceIntPtr dev;
DeviceIntPtr dev, next;
char *value;
value = xalloc(strlen(udi) + 5); /* "hal:" + NULL */
@ -82,11 +82,13 @@ device_removed(LibHalContext *ctx, const char *udi)
return;
sprintf(value, "hal:%s", udi);
for (dev = inputInfo.devices; dev; dev = dev->next) {
for (dev = inputInfo.devices; dev; dev = next) {
next = dev->next;
if (dev->config_info && strcmp(dev->config_info, value) == 0)
remove_device(dev);
}
for (dev = inputInfo.off_devices; dev; dev = dev->next) {
for (dev = inputInfo.off_devices; dev; dev = next) {
next = dev->next;
if (dev->config_info && strcmp(dev->config_info, value) == 0)
remove_device(dev);
}
@ -260,7 +262,17 @@ device_added(LibHalContext *hal_ctx, const char *udi)
* Since we can't predict the order in which the keys
* arrive, we need to store them.
*/
#ifndef HAVE_STRCASESTR
int psi_key_len = strlen(psi_key);
char *lower_psi_key = xalloc(psi_key_len + 1);
CopyISOLatin1Lowered((unsigned char *) lower_psi_key,
(unsigned char *) psi_key,
psi_key_len);
if ((tmp = strstr(lower_psi_key, "xkb")))
#else
if ((tmp = strcasestr(psi_key, "xkb")))
#endif
{
if (!strcasecmp(&tmp[3], "layout"))
{
@ -289,6 +301,9 @@ device_added(LibHalContext *hal_ctx, const char *udi)
add_option(&options, psi_key + sizeof(LIBHAL_PROP_KEY)-1, tmp_val);
xfree(tmp_val);
}
#ifndef HAVE_STRCASESTR
xfree(lower_psi_key);
#endif
}
} else if (!strncasecmp(psi_key, LIBHAL_XKB_PROP_KEY, sizeof(LIBHAL_XKB_PROP_KEY)-1)){

View File

@ -179,6 +179,8 @@ AC_CHECK_FUNC([dlopen], [],
case $host_os in
linux*|darwin*)
AC_DEFINE(HAVE_URANDOM, 1, [Has /dev/urandom]) ;;
freebsd*|netbsd*|openbsd*|dragonfly*)
AC_DEFINE(HAVE_URANDOM, 1, [Has /dev/urandom]) ;;
solaris*)
# Solaris 8 with patches, or Solaris 9 or later have /dev/urandom
if test -r /dev/urandom ; then
@ -191,7 +193,7 @@ dnl Checks for library functions.
AC_FUNC_VPRINTF
AC_CHECK_FUNCS([geteuid getuid link memmove memset mkstemp strchr strrchr \
strtol getopt getopt_long vsnprintf walkcontext backtrace \
getisax getzoneid shmctl64])
getisax getzoneid shmctl64 strcasestr])
AC_FUNC_ALLOCA
dnl Old HAS_* names used in os/*.c.
AC_CHECK_FUNC([getdtablesize],
@ -402,6 +404,9 @@ case $host_os in
*solaris*)
PKG_CHECK_EXISTS(libdrm, DRI=yes, DRI=no)
;;
darwin*)
AC_DEFINE(CSRG_BASED, 1, [System is BSD-like])
;;
esac
AM_CONDITIONAL(KDRIVE_HW, test "x$KDRIVE_HW" = xyes)
@ -562,11 +567,7 @@ AC_ARG_ENABLE(dmx, AS_HELP_STRING([--enable-dmx], [Build DMX server (d
AC_ARG_ENABLE(xvfb, AS_HELP_STRING([--enable-xvfb], [Build Xvfb server (default: yes)]), [XVFB=$enableval], [XVFB=yes])
AC_ARG_ENABLE(xnest, AS_HELP_STRING([--enable-xnest], [Build Xnest server (default: auto)]), [XNEST=$enableval], [XNEST=auto])
AC_ARG_ENABLE(xquartz, AS_HELP_STRING([--enable-xquartz], [Build Xquartz server for OS-X (default: auto)]), [XQUARTZ=$enableval], [XQUARTZ=auto])
AC_ARG_ENABLE(x11app, AS_HELP_STRING([--enable-x11app], [Build Apple's X11.app for Xquartz (default: auto)]), [X11APP=$enableval], [X11APP=auto])
AC_ARG_WITH(x11app-archs, AS_HELP_STRING([--with-x11app-archs=ARCHS], [Architectures to build X11.app for, space delimeted (default: "ppc i386")]), [X11APP_ARCHS=$enableval], [X11APP_ARCHS="ppc i386"])
AC_SUBST([X11APP_ARCHS])
AC_ARG_ENABLE(xwin, AS_HELP_STRING([--enable-xwin], [Build XWin server (default: auto)]), [XWIN=$enableval], [XWIN=auto])
AC_ARG_ENABLE(xprint, AS_HELP_STRING([--enable-xprint], [Build Xprint extension and server (default: no)]), [XPRINT=$enableval], [XPRINT=no])
AC_ARG_ENABLE(xgl, AS_HELP_STRING([--enable-xgl], [Build Xgl server (default: no)]), [XGL=$enableval], [XGL=no])
AC_ARG_ENABLE(xglx, AS_HELP_STRING([--enable-xglx], [Build Xglx xgl module (default: no)]), [XGLX=$enableval], [XGLX=no])
AC_ARG_ENABLE(xegl, AS_HELP_STRING([--enable-xegl], [Build Xegl xgl module (default: no)]), [XEGL=$enableval], [XEGL=no])
@ -979,15 +980,6 @@ if test "x$DPMSExtension" = xyes; then
AC_DEFINE(DPMSExtension, 1, [Support DPMS extension])
fi
if test "x$XPRINT" = xauto; then
PKG_CHECK_MODULES([XPRINTPROTO], [printproto], [XPRINT=yes], [XPRINT=no])
fi
AM_CONDITIONAL(XPRINT, [test "x$XPRINT" = xyes])
if test "x$XPRINT" = xyes; then
AC_DEFINE(XPRINT, 1, [Build Print extension])
REQUIRED_MODULES="$REQUIRED_MODULES printproto"
fi
if test "x$BUILTIN_FONTS" = xyes; then
AC_DEFINE(BUILTIN_FONTS, 1, [Use only built-in fonts])
AC_DEFINE(NOFONTSERVERACCESS, 1, [Avoid using a font server])
@ -1140,15 +1132,25 @@ PKG_CHECK_MODULES([XSERVERLIBS], [$REQUIRED_LIBS])
# OpenSSL used for SHA1 hashing in render/glyph.c, but we don't need all of
# the OpenSSL libraries, just libcrypto
PKG_CHECK_EXISTS([openssl],
[PKG_CHECK_MODULES([OPENSSL], [openssl],
# Some systems have matching functionality in the smaller/simpler libmd
# Builders who want to force a choice can set SHA1_LIB and SHA1_CFLAGS
if test "x$SHA1_LIB" = "x" ; then
AC_CHECK_LIB([md], [SHA1Init], [SHA1_LIB="-lmd"
AC_DEFINE([HAVE_SHA1_IN_LIBMD], [1],
[Define to use libmd SHA1 functions instead of OpenSSL libcrypto])])
fi
if test "x$SHA1_LIB" = "x" ; then
PKG_CHECK_EXISTS([openssl],
[PKG_CHECK_MODULES([OPENSSL], [openssl],
[OPENSSL_LIB_FLAGS=`$PKG_CONFIG --libs-only-L --libs-only-other openssl`])])
LIBCRYPTO="$OPENSSL_LIB_FLAGS -lcrypto"
SHA1_LIB="$OPENSSL_LIB_FLAGS -lcrypto"
SHA1_CFLAGS="$OPENSSL_CFLAGS"
fi
# Autotools has some unfortunate issues with library handling. In order to
# get a server to rebuild when a dependency in the tree is changed, it must
# be listed in SERVERNAME_DEPENDENCIES. However, no system libraries may be
# listed there, or some versions of autotols will break (especially if a -L
# listed there, or some versions of autotools will break (especially if a -L
# is required to find the library). So, we keep two sets of libraries
# detected: NAMESPACE_LIBS for in-tree libraries to be linked against, which
# will go into the _DEPENDENCIES and _LDADD of the server, and
@ -1160,9 +1162,9 @@ LIBCRYPTO="$OPENSSL_LIB_FLAGS -lcrypto"
# XSERVER_SYS_LIBS is the set of out-of-tree libraries which all servers
# require.
#
XSERVER_CFLAGS="${XSERVERCFLAGS_CFLAGS} ${OPENSSL_CFLAGS}"
XSERVER_CFLAGS="${XSERVERCFLAGS_CFLAGS} ${SHA1_CFLAGS}"
XSERVER_LIBS="$DIX_LIB $CONFIG_LIB $MI_LIB $OS_LIB"
XSERVER_SYS_LIBS="${XSERVERLIBS_LIBS} ${SYS_LIBS} ${LIBS} ${LIBCRYPTO}"
XSERVER_SYS_LIBS="${XSERVERLIBS_LIBS} ${SYS_LIBS} ${LIBS} ${SHA1_LIB}"
AC_SUBST([XSERVER_LIBS])
AC_SUBST([XSERVER_SYS_LIBS])
@ -1602,62 +1604,6 @@ if test "x$MFB" = xyes -o "x$AFB" = xyes; then
fi
fi
dnl Xprint DDX
AC_MSG_CHECKING([whether to build Xprint DDX])
AC_MSG_RESULT([$XPRINT])
if test "x$XPRINT" = xyes; then
PKG_CHECK_MODULES([XPRINTMODULES], [printproto x11 xfont $XDMCP_MODULES xau])
XPRINT_CFLAGS="$XPRINTMODULES_CFLAGS -DXPRINT"
XPRINT_LIBS="$XEXT_LIB $CONFIG_LIB $DBE_LIB $XTRAP_LIB $RECORD_LIB $RENDER_LIB $COMPOSITE_LIB $RANDR_LIB $XI_LIB $FIXES_LIB $DAMAGE_LIB $XI_LIB $GLX_LIBS $MIEXT_DAMAGE_LIB $XKB_LIB $XKB_STUB_LIB"
XPRINT_SYS_LIBS="$XPRINTMODULES_LIBS"
xpconfigdir=$libdir/X11/xserver
AC_SUBST([xpconfigdir])
AC_PATH_PROG(MKFONTSCALE, mkfontscale)
AC_PATH_PROG(MKFONTDIR, mkfontdir)
# freetype support code borrowed from lib/XFont
if test x$XP_USE_FREETYPE = xyes; then
AC_DEFINE(XP_USE_FREETYPE,1,[Support FreeType rasterizer in Xprint for nearly all font file formats])
if test "$freetype_config" = "auto" ; then
PKG_CHECK_MODULES(FREETYPE, freetype2,
freetype_config=no, freetype_config=yes)
fi
if test "$freetype_config" = "yes"; then
AC_PATH_PROG(ft_config,freetype-config,no)
if test "$ft_config" = "no"; then
AC_MSG_ERROR([You must have freetype installed; see http://www.freetype.org/])
fi
else
ft_config="$freetype_config"
fi
if test "$freetype_config" != "no"; then
FREETYPE_CFLAGS="`$ft_config --cflags`"
FREETYPE_LIBS="`$ft_config --libs`"
fi
FREETYPE_REQUIRES="freetype2"
else
FREETYPE_CFLAGS=""
FREETYPE_LIBS=""
FREETYPE_REQUIRES=""
fi
XPRINT_CFLAGS="$XPRINT_CFLAGS $FREETYPE_CFLAGS"
XPRINT_SYS_LIBS="$XPRINT_SYS_LIBS $FREETYPE_LIBS"
# end freetype support
AC_SUBST([XPRINT_CFLAGS])
AC_SUBST([XPRINT_LIBS])
AC_SUBST([XPRINT_SYS_LIBS])
fi
AM_CONDITIONAL(XP_USE_FREETYPE, [test "x$XPRINT" = xyes && test "x$XP_USE_FREETYPE" = xyes])
dnl XWin DDX
AC_MSG_CHECKING([whether to build XWin DDX])
@ -1756,17 +1702,6 @@ AM_CONDITIONAL(HAVE_XPLUGIN, [test "x$ac_cv_lib_Xplugin_xp_init" = xyes])
AM_CONDITIONAL(HAVE_AGL_FRAMEWORK, [test "x$xorg_cv_AGL_framework" = xyes])
AM_CONDITIONAL(XQUARTZ, [test "x$XQUARTZ" = xyes])
if test "x$X11APP" = xauto; then
AC_MSG_CHECKING([whether to build X11.app])
if test "x$XQUARTZ" = xyes ; then
X11APP=yes
else
X11APP=no
fi
AC_MSG_RESULT([$X11APP])
fi
AM_CONDITIONAL(X11APP,[test "X$X11APP" = Xyes])
if test "x$LAUNCHD" = "xauto"; then
if test "x$XQUARTZ" = "xyes" ; then
LAUNCHD=yes
@ -2165,63 +2100,16 @@ hw/xwin/Makefile
hw/xquartz/Makefile
hw/xquartz/GL/Makefile
hw/xquartz/bundle/Makefile
hw/xquartz/doc/Makefile
hw/xquartz/mach-startup/Makefile
hw/xquartz/xpr/Makefile
hw/kdrive/Makefile
hw/kdrive/ati/Makefile
hw/kdrive/chips/Makefile
hw/kdrive/ephyr/Makefile
hw/kdrive/epson/Makefile
hw/kdrive/fake/Makefile
hw/kdrive/fbdev/Makefile
hw/kdrive/i810/Makefile
hw/kdrive/linux/Makefile
hw/kdrive/mach64/Makefile
hw/kdrive/mga/Makefile
hw/kdrive/neomagic/Makefile
hw/kdrive/nvidia/Makefile
hw/kdrive/pm2/Makefile
hw/kdrive/r128/Makefile
hw/kdrive/sdl/Makefile
hw/kdrive/sis300/Makefile
hw/kdrive/smi/Makefile
hw/kdrive/src/Makefile
hw/kdrive/vesa/Makefile
hw/kdrive/via/Makefile
hw/xprint/Makefile
hw/xprint/doc/Makefile
hw/xprint/pcl/Makefile
hw/xprint/pcl-mono/Makefile
hw/xprint/raster/Makefile
hw/xprint/ps/Makefile
hw/xprint/etc/Makefile
hw/xprint/etc/Xsession.d/Makefile
hw/xprint/etc/init.d/Makefile
hw/xprint/etc/profile.d/Makefile
hw/xprint/config/Makefile
hw/xprint/config/C/print/attributes/Makefile
hw/xprint/config/C/print/ddx-config/Makefile
hw/xprint/config/C/print/ddx-config/raster/Makefile
hw/xprint/config/C/print/models/CANONBJ10E-GS/Makefile
hw/xprint/config/C/print/models/PSdefault/fonts/Makefile
hw/xprint/config/C/print/models/PSdefault/Makefile
hw/xprint/config/C/print/models/PSspooldir/Makefile
hw/xprint/config/C/print/models/SPSPARC2/Makefile
hw/xprint/config/C/print/models/SPSPARC2/fonts/Makefile
hw/xprint/config/C/print/models/GSdefault/Makefile
hw/xprint/config/C/print/models/HPLJ4050-PS/Makefile
hw/xprint/config/C/print/models/HPLJ4050-PS/fonts/Makefile
hw/xprint/config/C/print/models/Makefile
hw/xprint/config/C/print/models/PS2PDFspooldir-GS/Makefile
hw/xprint/config/C/print/models/CANONC3200-PS/Makefile
hw/xprint/config/C/print/models/CANONC3200-PS/fonts/Makefile
hw/xprint/config/C/print/models/HPLJ4family/fonts/Makefile
hw/xprint/config/C/print/models/HPLJ4family/Makefile
hw/xprint/config/C/print/models/HPDJ1600C/Makefile
hw/xprint/config/C/print/models/HPDJ1600C/fonts/Makefile
hw/xprint/config/C/print/Makefile
hw/xprint/config/C/Makefile
hw/xprint/config/en_US/print/attributes/Makefile
hw/xprint/config/en_US/print/Makefile
hw/xprint/config/en_US/Makefile
xorg-server.pc
])

View File

@ -1,10 +1,6 @@
standard_dix_libs = libdix.la libxpstubs.la
if XPRINT
noinst_LTLIBRARIES = $(standard_dix_libs) libXpdix.la
else
noinst_LTLIBRARIES = $(standard_dix_libs)
endif
AM_CFLAGS = $(DIX_CFLAGS) \
-DVENDOR_NAME=\""@VENDOR_NAME@"\" \
@ -46,12 +42,6 @@ libdix_la_SOURCES = \
libxpstubs_la_SOURCES = \
xpstubs.c
if XPRINT
libXpdix_la_SOURCES = $(libdix_la_SOURCES)
libXpdix_la_CPPFLAGS = -I$(top_srcdir)/hw/xprint
libXpdix_la_CFLAGS = $(AM_CFLAGS) $(XPRINT_CFLAGS)
endif
EXTRA_DIST = buildatoms BuiltInAtoms CHANGES Xserver.d Xserver-dtrace.h.in
# Install list of protocol names

View File

@ -399,9 +399,6 @@ Dispatch(void)
}
isItTimeToYield = FALSE;
#ifdef XPRINT
requestingClient = client;
#endif
#ifdef SMART_SCHEDULE
start_tick = SmartScheduleTime;
#endif
@ -472,9 +469,6 @@ Dispatch(void)
client = clients[clientReady[nready]];
if (client)
client->smart_stop_tick = SmartScheduleTime;
#endif
#ifdef XPRINT
requestingClient = NULL;
#endif
}
dispatchException &= ~DE_PRIORITYCHANGE;

View File

@ -302,8 +302,14 @@ doOpenFont(ClientPtr client, OFclosurePtr c)
c->fontname = newname;
c->fnamelen = newlen;
c->current_fpe = 0;
if (--aliascount <= 0)
if (--aliascount <= 0) {
/* We've tried resolving this alias 20 times, we're
* probably stuck in an infinite loop of aliases pointing
* to each other - time to take emergency exit!
*/
err = BadImplementation;
break;
}
continue;
}
if (err == BadFontName) {
@ -1931,37 +1937,27 @@ GetDefaultPointSize ()
FontResolutionPtr
GetClientResolutions (int *num)
{
#ifdef XPRINT
if (requestingClient && requestingClient->fontResFunc != NULL &&
!requestingClient->clientGone)
{
return (*requestingClient->fontResFunc)(requestingClient, num);
}
else
#endif
{
static struct _FontResolution res;
ScreenPtr pScreen;
static struct _FontResolution res;
ScreenPtr pScreen;
pScreen = screenInfo.screens[0];
res.x_resolution = (pScreen->width * 25.4) / pScreen->mmWidth;
/*
* XXX - we'll want this as long as bitmap instances are prevalent
so that we can match them from scalable fonts
*/
if (res.x_resolution < 88)
res.x_resolution = 75;
else
res.x_resolution = 100;
res.y_resolution = (pScreen->height * 25.4) / pScreen->mmHeight;
if (res.y_resolution < 88)
res.y_resolution = 75;
else
res.y_resolution = 100;
res.point_size = 120;
*num = 1;
return &res;
}
pScreen = screenInfo.screens[0];
res.x_resolution = (pScreen->width * 25.4) / pScreen->mmWidth;
/*
* XXX - we'll want this as long as bitmap instances are prevalent
so that we can match them from scalable fonts
*/
if (res.x_resolution < 88)
res.x_resolution = 75;
else
res.x_resolution = 100;
res.y_resolution = (pScreen->height * 25.4) / pScreen->mmHeight;
if (res.y_resolution < 88)
res.y_resolution = 75;
else
res.y_resolution = 100;
res.point_size = 120;
*num = 1;
return &res;
}
/*

View File

@ -136,16 +136,11 @@ Bool screenSaverSuspended = FALSE;
char *defaultFontPath = COMPILEDDEFAULTFONTPATH;
char *defaultTextFont = COMPILEDDEFAULTFONT;
char *defaultCursorFont = COMPILEDCURSORFONT;
char *defaultDisplayClass = COMPILEDDISPLAYCLASS;
FontPtr defaultFont; /* not declared in dix.h to avoid including font.h in
every compilation of dix code */
Bool loadableFonts = FALSE;
CursorPtr rootCursor;
Bool blackRoot=FALSE;
Bool whiteRoot=FALSE;
#ifdef XPRINT
ClientPtr requestingClient; /* XXX this should be obsolete now, remove? */
#endif
_X_EXPORT TimeStamp currentTime;
_X_EXPORT TimeStamp lastDeviceEventTime;
@ -156,7 +151,5 @@ _X_EXPORT int monitorResolution = 0;
_X_EXPORT char *display;
CARD32 TimeOutValue = DEFAULT_TIMEOUT * MILLI_PER_SECOND;
int argcGlobal;
char **argvGlobal;
DDXPointRec dixScreenOrigins[MAXSCREENS];

View File

@ -103,9 +103,6 @@ Equipment Corporation.
#include "extnsionst.h"
#include "privates.h"
#include "registry.h"
#ifdef XPRINT
#include "DiPrint.h"
#endif
#ifdef PANORAMIX
#include "panoramiXsrv.h"
#else
@ -251,9 +248,6 @@ int main(int argc, char *argv[], char *envp[])
InitGlobals();
InitRegions();
#ifdef XPRINT
PrinterInitGlobals();
#endif
CheckUserParameters(argc, argv, envp);
@ -265,11 +259,6 @@ int main(int argc, char *argv[], char *envp[])
InitConnectionLimits();
/* These are needed by some routines which are called from interrupt
* handlers, thus have no direct calling path back to main and thus
* can't be passed argc, argv as parameters */
argcGlobal = argc;
argvGlobal = argv;
/* prep X authority file from environment; this can be overriden by a
* command line option */
xauthfile = getenv("XAUTHORITY");
@ -348,9 +337,6 @@ int main(int argc, char *argv[], char *envp[])
InitCallbackManager();
InitVisualWrap();
InitOutput(&screenInfo, argc, argv);
#ifdef XPRINT
PrinterInitOutput(&screenInfo, argc, argv);
#endif
if (screenInfo.numScreens < 1)
FatalError("no screens found");
@ -374,13 +360,8 @@ int main(int argc, char *argv[], char *envp[])
}
InitFonts();
if (loadableFonts)
SetFontPath(serverClient, 0, (unsigned char *)defaultFontPath,
&error);
else {
if (SetDefaultFontPath(defaultFontPath) != Success)
ErrorF("[dix] failed to set default font path '%s'",
defaultFontPath);
if (SetDefaultFontPath(defaultFontPath) != Success) {
ErrorF("[dix] failed to set default font path '%s'", defaultFontPath);
}
if (!SetDefaultFont(defaultTextFont)) {
FatalError("could not open default font '%s'", defaultTextFont);

View File

@ -31,12 +31,8 @@ from The Open Group.
#include "misc.h"
#include <X11/fonts/font.h>
#ifdef XPRINT
#include "DiPrint.h"
#else
extern Bool XpClientIsBitmapClient(ClientPtr client);
extern Bool XpClientIsPrintClient(ClientPtr client, FontPathElementPtr fpe);
#endif
Bool
XpClientIsBitmapClient(
@ -52,27 +48,3 @@ XpClientIsPrintClient(
{
return FALSE;
}
#ifdef XPRINT
int
PrinterOptions(
int argc,
char **argv,
int i)
{
return i;
}
void
PrinterInitOutput(
ScreenInfo *pScreenInfo,
int argc,
char **argv)
{
}
void PrinterUseMsg(void)
{
}
void PrinterInitGlobals(void)
{
}
#endif /* XPRINT */

View File

@ -26,10 +26,6 @@ if KDRIVE
KDRIVE_SUBDIRS = kdrive
endif
if XPRINT
XPRINT_SUBDIRS = xprint
endif
if XQUARTZ
XQUARTZ_SUBDIRS = xquartz
endif
@ -42,10 +38,9 @@ SUBDIRS = \
$(XNEST_SUBDIRS) \
$(DMX_SUBDIRS) \
$(KDRIVE_SUBDIRS) \
$(XQUARTZ_SUBDIRS) \
$(XPRINT_SUBDIRS)
$(XQUARTZ_SUBDIRS)
DIST_SUBDIRS = dmx xfree86 vfb xnest xwin xquartz kdrive xgl xprint
DIST_SUBDIRS = dmx xfree86 vfb xnest xwin xquartz kdrive xgl
relink:
for i in $(SUBDIRS) ; do $(MAKE) -C $$i relink ; done

View File

@ -1,10 +1,9 @@
if KDRIVEVESA
VESA_SUBDIRS = vesa ati chips i810 mach64 mga nvidia pm2 r128 \
smi via
VESA_SUBDIRS = vesa
endif
if BUILD_KDRIVEFBDEVLIB
FBDEV_SUBDIRS = fbdev epson
FBDEV_SUBDIRS = fbdev
endif
if XFAKESERVER
@ -35,8 +34,7 @@ SUBDIRS = \
$(LINUX_SUBDIRS) \
$(SERVER_SUBDIRS)
DIST_SUBDIRS = vesa ati chips epson i810 mach64 mga neomagic nvidia pm2 r128 \
smi via fbdev sdl ephyr src linux fake sis300
DIST_SUBDIRS = vesa fbdev sdl ephyr src linux fake
relink:
@for i in $(SERVER_SUBDIRS) ; do make -C $$i relink ; done

View File

@ -11,26 +11,6 @@ Xkdrive \- tiny X server
.B Xfbdev
.RI [ :display ]
.RI [ option ...]
.B Xigs
.RI [ :display ]
.RI [ option ...]
.B Xtrident
.RI [ :display ]
.RI [ option ...]
.B Xsis530
.RI [ :display ]
.RI [ option ...]
.B Xtrio
.RI [ :display ]
.RI [ option ...]
.B Xitsy
.RI [ :display ]
.RI [ option ...]
.SH DESCRIPTION
.B Xkdrive
is a family of X servers designed to be particularly small. This

View File

@ -1,74 +0,0 @@
#if DRI
#DRI_INCLUDES = -I$(top_srcdir)/dri \
# -I$(top_srcdir)/drm
#DRI_LIBS = $(top_builddir)/dri/libdri.a \
# $(top_builddir)/drm/libdrm.a
#DRI_SOURCES = ati_dri.c \
# ati_dri.h \
# ati_dripriv.h \
# r128_common.h \
# r128_sarea.h \
# radeon_common.h \
# radeon_sarea.h
#endif
if KDRIVEFBDEV
FBDEV_INCLUDES =-I$(top_srcdir)/hw/kdrive/fbdev
FBDEV_LIBS = $(top_builddir)/hw/kdrive/fbdev/libfbdev.a
endif
if KDRIVEVESA
VESA_INCLUDES = -I$(top_srcdir)/hw/kdrive/vesa
VESA_LIBS = $(top_builddir)/hw/kdrive/vesa/libvesa.a
endif
INCLUDES = \
@KDRIVE_INCS@ \
$(DRI_INCLUDES) \
$(FBDEV_INCLUDES) \
$(VESA_INCLUDES) \
@KDRIVE_CFLAGS@
bin_PROGRAMS = Xati
noinst_LIBRARIES = libati.a
libati_a_SOURCES = \
ati_cursor.c \
ati_dma.c \
ati_dma.h \
ati_draw.c \
ati_draw.h \
ati_microcode.c \
ati.c \
ati.h \
ati_reg.h \
r128_composite.c \
ati_video.c \
radeon_composite.c \
$(DRI_SOURCES)
Xati_SOURCES = \
ati_stub.c
ATI_LIBS = \
libati.a \
$(FBDEV_LIBS) \
$(VESA_LIBS) \
$(DRI_LIBS) \
@KDRIVE_LIBS@
if GLX
Xati_LDFLAGS = $(LD_EXPORT_SYMBOLS_FLAG)
endif
Xati_LDADD = \
$(ATI_LIBS) \
@KDRIVE_LIBS@
Xati_DEPENDENCIES = \
libati.a \
@KDRIVE_LOCAL_LIBS@
relink:
rm -f $(bin_PROGRAMS) && make $(bin_PROGRAMS)

View File

@ -1,761 +0,0 @@
/*
* Copyright © 2003 Eric Anholt
*
* 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 Eric Anholt not be used in
* advertising or publicity pertaining to distribution of the software without
* specific, written prior permission. Eric Anholt makes no
* representations about the suitability of this software for any purpose. It
* is provided "as is" without express or implied warranty.
*
* ERIC ANHOLT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL ERIC ANHOLT 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.
*/
#ifdef HAVE_CONFIG_H
#include <kdrive-config.h>
#endif
#include "ati.h"
#include "ati_reg.h"
#if defined(USE_DRI) && defined(GLXEXT)
#include "ati_sarea.h"
#endif
static Bool ATIIsAGP(ATICardInfo *atic);
#define CAP_SERIESMASK 0xf
#define CAP_R128 0x1 /* If it's a Rage 128 */
#define CAP_R100 0x2 /* If it's an r100 series radeon. */
#define CAP_R200 0x3 /* If it's an r200 series radeon. */
#define CAP_R300 0x4 /* If it's an r300 series radeon. */
#define CAP_FEATURESMASK 0xf0
#define CAP_NOAGP 0x10 /* If it's a PCI-only card. */
struct pci_id_entry ati_pci_ids[] = {
{0x1002, 0x4136, 0x2, "ATI Radeon RS100"},
{0x1002, 0x4137, 0x2, "ATI Radeon RS200"},
{0x1002, 0x4237, 0x2, "ATI Radeon RS250"},
{0x1002, 0x4144, 0x4, "ATI Radeon R300 AD"},
{0x1002, 0x4145, 0x4, "ATI Radeon R300 AE"},
{0x1002, 0x4146, 0x4, "ATI Radeon R300 AF"},
{0x1002, 0x4147, 0x4, "ATI Radeon R300 AG"},
{0x1002, 0x4148, 0x4, "ATI Radeon R350 AH"},
{0x1002, 0x4149, 0x4, "ATI Radeon R350 AI"},
{0x1002, 0x414a, 0x4, "ATI Radeon R350 AJ"},
{0x1002, 0x414b, 0x4, "ATI Radeon R350 AK"},
{0x1002, 0x4150, 0x4, "ATI Radeon RV350 AP"},
{0x1002, 0x4151, 0x4, "ATI Radeon RV350 AQ"},
{0x1002, 0x4152, 0x4, "ATI Radeon RV350 AR"},
{0x1002, 0x4153, 0x4, "ATI Radeon RV350 AS"},
{0x1002, 0x4154, 0x4, "ATI Radeon RV350 AT"},
{0x1002, 0x4156, 0x4, "ATI Radeon RV350 AV"},
{0x1002, 0x4242, 0x3, "ATI Radeon R200 BB"},
{0x1002, 0x4243, 0x3, "ATI Radeon R200 BC"},
{0x1002, 0x4336, 0x2, "ATI Radeon RS100"},
{0x1002, 0x4337, 0x2, "ATI Radeon RS200"},
{0x1002, 0x4437, 0x2, "ATI Radeon RS250"},
{0x1002, 0x4964, 0x2, "ATI Radeon RV250 Id"},
{0x1002, 0x4965, 0x2, "ATI Radeon RV250 Ie"},
{0x1002, 0x4966, 0x2, "ATI Radeon RV250 If"},
{0x1002, 0x4967, 0x2, "ATI Radeon R250 Ig"},
{0x1002, 0x4c45, 0x11, "ATI Rage 128 LE"},
{0x1002, 0x4c46, 0x1, "ATI Rage 128 LF"},
{0x1002, 0x4c57, 0x2, "ATI Radeon Mobiliy M7 RV200 LW (7500)"},
{0x1002, 0x4c58, 0x2, "ATI Radeon Mobiliy M7 RV200 LX (7500)"},
{0x1002, 0x4c59, 0x2, "ATI Radeon Mobility M6 LY"},
{0x1002, 0x4c5a, 0x2, "ATI Radeon Mobility M6 LZ"},
{0x1002, 0x4c64, 0x3, "ATI Radeon RV250 Ld"},
{0x1002, 0x4c65, 0x3, "ATI Radeon RV250 Le"},
{0x1002, 0x4c66, 0x3, "ATI Radeon Mobility M9 RV250 Lf"},
{0x1002, 0x4c67, 0x3, "ATI Radeon RV250 Lg"},
{0x1002, 0x4d46, 0x1, "ATI Rage 128 MF"},
{0x1002, 0x4d46, 0x1, "ATI Rage 128 ML"},
{0x1002, 0x4e44, 0x4, "ATI Radeon R300 ND"},
{0x1002, 0x4e45, 0x4, "ATI Radeon R300 NE"},
{0x1002, 0x4e46, 0x4, "ATI Radeon R300 NF"},
{0x1002, 0x4e47, 0x4, "ATI Radeon R300 NG"},
{0x1002, 0x4e48, 0x4, "ATI Radeon R350 NH"},
{0x1002, 0x4e49, 0x4, "ATI Radeon R350 NI"},
{0x1002, 0x4e4a, 0x4, "ATI Radeon R350 NJ"},
{0x1002, 0x4e4b, 0x4, "ATI Radeon R350 NK"},
{0x1002, 0x4e50, 0x4, "ATI Radeon Mobility RV350 NP"},
{0x1002, 0x4e51, 0x4, "ATI Radeon Mobility RV350 NQ"},
{0x1002, 0x4e52, 0x4, "ATI Radeon Mobility RV350 NR"},
{0x1002, 0x4e53, 0x4, "ATI Radeon Mobility RV350 NS"},
{0x1002, 0x4e54, 0x4, "ATI Radeon Mobility RV350 NT"},
{0x1002, 0x4e56, 0x4, "ATI Radeon Mobility RV350 NV"},
{0x1002, 0x5041, 0x1, "ATI Rage 128 PA"},
{0x1002, 0x5042, 0x1, "ATI Rage 128 PB"},
{0x1002, 0x5043, 0x1, "ATI Rage 128 PC"},
{0x1002, 0x5044, 0x11, "ATI Rage 128 PD"},
{0x1002, 0x5045, 0x1, "ATI Rage 128 PE"},
{0x1002, 0x5046, 0x1, "ATI Rage 128 PF"},
{0x1002, 0x5047, 0x1, "ATI Rage 128 PG"},
{0x1002, 0x5048, 0x1, "ATI Rage 128 PH"},
{0x1002, 0x5049, 0x1, "ATI Rage 128 PI"},
{0x1002, 0x504a, 0x1, "ATI Rage 128 PJ"},
{0x1002, 0x504b, 0x1, "ATI Rage 128 PK"},
{0x1002, 0x504c, 0x1, "ATI Rage 128 PL"},
{0x1002, 0x504d, 0x1, "ATI Rage 128 PM"},
{0x1002, 0x504e, 0x1, "ATI Rage 128 PN"},
{0x1002, 0x504f, 0x1, "ATI Rage 128 PO"},
{0x1002, 0x5050, 0x11, "ATI Rage 128 PP"},
{0x1002, 0x5051, 0x1, "ATI Rage 128 PQ"},
{0x1002, 0x5052, 0x11, "ATI Rage 128 PR"},
{0x1002, 0x5053, 0x1, "ATI Rage 128 PS"},
{0x1002, 0x5054, 0x1, "ATI Rage 128 PT"},
{0x1002, 0x5055, 0x1, "ATI Rage 128 PU"},
{0x1002, 0x5056, 0x1, "ATI Rage 128 PV"},
{0x1002, 0x5057, 0x1, "ATI Rage 128 PW"},
{0x1002, 0x5058, 0x1, "ATI Rage 128 PX"},
{0x1002, 0x5144, 0x2, "ATI Radeon R100 QD"},
{0x1002, 0x5145, 0x2, "ATI Radeon R100 QE"},
{0x1002, 0x5146, 0x2, "ATI Radeon R100 QF"},
{0x1002, 0x5147, 0x2, "ATI Radeon R100 QG"},
{0x1002, 0x5148, 0x3, "ATI Radeon R200 QH"},
{0x1002, 0x514c, 0x3, "ATI Radeon R200 QL"},
{0x1002, 0x514d, 0x3, "ATI Radeon R200 QM"},
{0x1002, 0x5157, 0x2, "ATI Radeon RV200 QW (7500)"},
{0x1002, 0x5158, 0x2, "ATI Radeon RV200 QX (7500)"},
{0x1002, 0x5159, 0x2, "ATI Radeon RV100 QY"},
{0x1002, 0x515a, 0x2, "ATI Radeon RV100 QZ"},
{0x1002, 0x5245, 0x11, "ATI Rage 128 RE"},
{0x1002, 0x5246, 0x1, "ATI Rage 128 RF"},
{0x1002, 0x5247, 0x1, "ATI Rage 128 RG"},
{0x1002, 0x524b, 0x11, "ATI Rage 128 RK"},
{0x1002, 0x524c, 0x1, "ATI Rage 128 RL"},
{0x1002, 0x5345, 0x1, "ATI Rage 128 SE"},
{0x1002, 0x5346, 0x1, "ATI Rage 128 SF"},
{0x1002, 0x5347, 0x1, "ATI Rage 128 SG"},
{0x1002, 0x5348, 0x1, "ATI Rage 128 SH"},
{0x1002, 0x534b, 0x1, "ATI Rage 128 SK"},
{0x1002, 0x534c, 0x1, "ATI Rage 128 SL"},
{0x1002, 0x534d, 0x1, "ATI Rage 128 SM"},
{0x1002, 0x534e, 0x1, "ATI Rage 128 SN"},
{0x1002, 0x5446, 0x1, "ATI Rage 128 TF"},
{0x1002, 0x544c, 0x1, "ATI Rage 128 TL"},
{0x1002, 0x5452, 0x1, "ATI Rage 128 TR"},
{0x1002, 0x5453, 0x1, "ATI Rage 128 TS"},
{0x1002, 0x5454, 0x1, "ATI Rage 128 TT"},
{0x1002, 0x5455, 0x1, "ATI Rage 128 TU"},
{0x1002, 0x5834, 0x3, "ATI Radeon RS300"},
{0x1002, 0x5835, 0x3, "ATI Radeon RS300 Mobility"},
{0x1002, 0x5941, 0x3, "ATI Radeon RV280 (9200)"},
{0x1002, 0x5961, 0x3, "ATI Radeon RV280 (9200 SE)"},
{0x1002, 0x5964, 0x3, "ATI Radeon RV280 (9200 SE)"},
{0x1002, 0x5c60, 0x3, "ATI Radeon RV280"},
{0x1002, 0x5c61, 0x3, "ATI Radeon RV280 Mobility"},
{0x1002, 0x5c62, 0x3, "ATI Radeon RV280"},
{0x1002, 0x5c63, 0x3, "ATI Radeon RV280 Mobility"},
{0x1002, 0x5c64, 0x3, "ATI Radeon RV280"},
{0, 0, 0, NULL}
};
static char *
make_busid(KdCardAttr *attr)
{
char *busid;
busid = xalloc(20);
if (busid == NULL)
return NULL;
snprintf(busid, 20, "pci:%04x:%02x:%02x.%d", attr->domain, attr->bus,
attr->slot, attr->func);
return busid;
}
static Bool
ATICardInit(KdCardInfo *card)
{
ATICardInfo *atic;
int i;
Bool initialized = FALSE;
atic = xcalloc(sizeof(ATICardInfo), 1);
if (atic == NULL)
return FALSE;
#ifdef KDRIVEFBDEV
if (!initialized && fbdevInitialize(card, &atic->backend_priv.fbdev)) {
atic->use_fbdev = TRUE;
initialized = TRUE;
atic->backend_funcs.cardfini = fbdevCardFini;
atic->backend_funcs.scrfini = fbdevScreenFini;
atic->backend_funcs.initScreen = fbdevInitScreen;
atic->backend_funcs.finishInitScreen = fbdevFinishInitScreen;
atic->backend_funcs.createRes = fbdevCreateResources;
atic->backend_funcs.preserve = fbdevPreserve;
atic->backend_funcs.restore = fbdevRestore;
atic->backend_funcs.dpms = fbdevDPMS;
atic->backend_funcs.enable = fbdevEnable;
atic->backend_funcs.disable = fbdevDisable;
atic->backend_funcs.getColors = fbdevGetColors;
atic->backend_funcs.putColors = fbdevPutColors;
#ifdef RANDR
atic->backend_funcs.randrSetConfig = fbdevRandRSetConfig;
#endif
}
#endif
#ifdef KDRIVEVESA
if (!initialized && vesaInitialize(card, &atic->backend_priv.vesa)) {
atic->use_vesa = TRUE;
initialized = TRUE;
atic->backend_funcs.cardfini = vesaCardFini;
atic->backend_funcs.scrfini = vesaScreenFini;
atic->backend_funcs.initScreen = vesaInitScreen;
atic->backend_funcs.finishInitScreen = vesaFinishInitScreen;
atic->backend_funcs.createRes = vesaCreateResources;
atic->backend_funcs.preserve = vesaPreserve;
atic->backend_funcs.restore = vesaRestore;
atic->backend_funcs.dpms = vesaDPMS;
atic->backend_funcs.enable = vesaEnable;
atic->backend_funcs.disable = vesaDisable;
atic->backend_funcs.getColors = vesaGetColors;
atic->backend_funcs.putColors = vesaPutColors;
#ifdef RANDR
atic->backend_funcs.randrSetConfig = vesaRandRSetConfig;
#endif
}
#endif
if (!initialized || !ATIMapReg(card, atic)) {
xfree(atic);
return FALSE;
}
atic->busid = make_busid(&card->attr);
if (atic->busid == NULL) {
xfree(atic);
return FALSE;
}
#ifdef USE_DRI
/* We demand identification by busid, not driver name */
atic->drmFd = drmOpen(NULL, atic->busid);
if (atic->drmFd < 0)
ErrorF("Failed to open DRM, DRI disabled.\n");
#endif /* USE_DRI */
card->driver = atic;
for (i = 0; ati_pci_ids[i].name != NULL; i++) {
if (ati_pci_ids[i].device == card->attr.deviceID) {
atic->pci_id = &ati_pci_ids[i];
break;
}
}
if ((atic->pci_id->caps & CAP_SERIESMASK) != CAP_R128)
atic->is_radeon = TRUE;
if ((atic->pci_id->caps & CAP_SERIESMASK) == CAP_R100)
atic->is_r100 = TRUE;
if ((atic->pci_id->caps & CAP_SERIESMASK) == CAP_R200)
atic->is_r200 = TRUE;
if ((atic->pci_id->caps & CAP_SERIESMASK) == CAP_R300)
atic->is_r300 = TRUE;
atic->is_agp = ATIIsAGP(atic);
ErrorF("Using ATI card: %s (%s) at %s\n", atic->pci_id->name,
atic->is_agp ? "AGP" : "PCI", atic->busid);
return TRUE;
}
static void
ATICardFini(KdCardInfo *card)
{
ATICardInfo *atic = (ATICardInfo *)card->driver;
ATIUnmapReg(card, atic);
atic->backend_funcs.cardfini(card);
}
/*
* Once screen->off_screen_base is set, this function
* allocates the remaining memory appropriately
*/
static void
ATISetOffscreen (KdScreenInfo *screen)
{
ATICardInfo(screen);
#if defined(USE_DRI) && defined(GLXEXT)
ATIScreenInfo *atis = (ATIScreenInfo *)screen->driver;
int l;
#endif
int screen_size;
char *mmio = atic->reg_base;
/* check (and adjust) pitch */
if (mmio)
{
int byteStride = screen->fb[0].byteStride;
int bitStride;
int pixelStride;
int bpp = screen->fb[0].bitsPerPixel;
/*
* Ensure frame buffer is correctly aligned
*/
if (byteStride & 0x3f)
{
byteStride = (byteStride + 0x3f) & ~0x3f;
bitStride = byteStride * 8;
pixelStride = bitStride / bpp;
screen->fb[0].byteStride = byteStride;
screen->fb[0].pixelStride = pixelStride;
}
}
screen_size = screen->fb[0].byteStride * screen->height;
screen->off_screen_base = screen_size;
#if defined(USE_DRI) && defined(GLXEXT)
/* Reserve a static area for the back buffer the same size as the
* visible screen. XXX: This would be better initialized in ati_dri.c
* when GLX is set up, but the offscreen memory manager's allocations
* don't last through VT switches, while the kernel's understanding of
* offscreen locations does.
*/
atis->frontOffset = 0;
atis->frontPitch = screen->fb[0].byteStride;
if (screen->off_screen_base + screen_size <= screen->memory_size) {
atis->backOffset = screen->off_screen_base;
atis->backPitch = screen->fb[0].byteStride;
screen->off_screen_base += screen_size;
}
/* Reserve the depth span for Rage 128 */
if (!atic->is_radeon && screen->off_screen_base +
screen->fb[0].byteStride <= screen->memory_size) {
atis->spanOffset = screen->off_screen_base;
screen->off_screen_base += screen->fb[0].byteStride;
}
/* Reserve the static depth buffer, which happens to be the same
* bitsPerPixel as the screen.
*/
if (screen->off_screen_base + screen_size <= screen->memory_size) {
atis->depthOffset = screen->off_screen_base;
atis->depthPitch = screen->fb[0].byteStride;
screen->off_screen_base += screen_size;
}
/* Reserve approx. half of remaining offscreen memory for local
* textures. Round down to a whole number of texture regions.
*/
atis->textureSize = (screen->memory_size - screen->off_screen_base) / 2;
l = ATILog2(atis->textureSize / ATI_NR_TEX_REGIONS);
if (l < ATI_LOG_TEX_GRANULARITY)
l = ATI_LOG_TEX_GRANULARITY;
atis->textureSize = (atis->textureSize >> l) << l;
if (atis->textureSize >= 512 * 1024) {
atis->textureOffset = screen->off_screen_base;
screen->off_screen_base += atis->textureSize;
} else {
/* Minimum texture size is for 2 256x256x32bpp textures */
atis->textureSize = 0;
}
#endif /* USE_DRI && GLXEXT */
}
static void
ATISetPitch (KdScreenInfo *screen)
{
ATICardInfo(screen);
#if defined(USE_DRI) && defined(GLXEXT)
ATIScreenInfo *atis = (ATIScreenInfo *)screen->driver;
int l;
#endif
char *mmio = atic->reg_base;
/* check (and adjust) pitch for radeon */
if (mmio)
{
int byteStride = screen->fb[0].byteStride;
int bitStride;
int pixelStride;
int bpp = screen->fb[0].bitsPerPixel;
CARD32 crtc_pitch;
CARD32 crtc2_pitch;
#if 0
CARD32 crtc_ext_cntl;
CARD32 dac_cntl;
#endif
bitStride = byteStride * 8;
pixelStride = bitStride / bpp;
crtc_pitch = (pixelStride >> 3);
crtc_pitch |= crtc_pitch << 16;
crtc2_pitch = (pixelStride >> 3);
crtc2_pitch |= crtc2_pitch << 16;
#if 0
crtc_ext_cntl = MMIO_IN32 (mmio, ATI_REG_CRTC_EXT_CNTL);
dac_cntl = MMIO_IN32 (mmio, ATI_REG_DAC_CNTL);
/* Turn off the screen */
MMIO_OUT32 (mmio, ATI_REG_CRTC_EXT_CNTL,
crtc_ext_cntl |
ATI_CRTC_VSYNC_DIS |
ATI_CRTC_HSYNC_DIS |
ATI_CRTC_DISPLAY_DIS);
MMIO_OUT32 (mmio, ATI_REG_DAC_CNTL,
dac_cntl |
ATI_DAC_RANGE_CNTL |
ATI_DAC_BLANKING);
#endif
MMIO_OUT32 (mmio, ATI_REG_CRTC_PITCH, crtc_pitch);
MMIO_OUT32 (mmio, ATI_REG_CRTC2_PITCH, crtc2_pitch);
#if 0
/* Turn the screen back on */
MMIO_OUT32 (mmio, ATI_REG_CRTC_EXT_CNTL,
crtc_ext_cntl);
MMIO_OUT32 (mmio, ATI_REG_DAC_CNTL,
dac_cntl);
#endif
}
}
static Bool
ATIScreenInit(KdScreenInfo *screen)
{
ATIScreenInfo *atis;
ATICardInfo(screen);
Bool success = FALSE;
atis = xcalloc(sizeof(ATIScreenInfo), 1);
if (atis == NULL)
return FALSE;
atis->atic = atic;
atis->screen = screen;
screen->driver = atis;
if (screen->fb[0].depth == 0)
screen->fb[0].depth = 16;
#ifdef KDRIVEFBDEV
if (atic->use_fbdev) {
success = fbdevScreenInitialize(screen,
&atis->backend_priv.fbdev);
}
#endif
#ifdef KDRIVEVESA
if (atic->use_vesa) {
success = vesaScreenInitialize(screen,
&atis->backend_priv.vesa);
}
#endif
if (!success) {
screen->driver = NULL;
xfree(atis);
return FALSE;
}
ATISetOffscreen (screen);
return TRUE;
}
#ifdef RANDR
static Bool
ATIRandRSetConfig (ScreenPtr pScreen,
Rotation randr,
int rate,
RRScreenSizePtr pSize)
{
KdScreenPriv(pScreen);
KdScreenInfo *screen = pScreenPriv->screen;
ATICardInfo *atic = screen->card->driver;
Bool ret;
ATIDrawDisable (pScreen);
ret = atic->backend_funcs.randrSetConfig(pScreen, randr, rate, pSize);
ATISetOffscreen (screen);
ATISetPitch (screen);
/*
* Set frame buffer mapping
*/
(*pScreen->ModifyPixmapHeader) (fbGetScreenPixmap (pScreen),
pScreen->width,
pScreen->height,
screen->fb[0].depth,
screen->fb[0].bitsPerPixel,
screen->fb[0].byteStride,
screen->fb[0].frameBuffer);
ATIDrawEnable (pScreen);
return ret;
}
static Bool
ATIRandRInit (ScreenPtr pScreen)
{
rrScrPrivPtr pScrPriv;
pScrPriv = rrGetScrPriv(pScreen);
pScrPriv->rrSetConfig = ATIRandRSetConfig;
return TRUE;
}
#endif
static void
ATIScreenFini(KdScreenInfo *screen)
{
ATIScreenInfo *atis = (ATIScreenInfo *)screen->driver;
ATICardInfo *atic = screen->card->driver;
#ifdef XV
ATIFiniVideo(screen->pScreen);
#endif
atic->backend_funcs.scrfini(screen);
xfree(atis);
screen->driver = 0;
}
Bool
ATIMapReg(KdCardInfo *card, ATICardInfo *atic)
{
atic->reg_base = (char *)KdMapDevice(ATI_REG_BASE(card),
ATI_REG_SIZE(card));
if (atic->reg_base == NULL)
return FALSE;
KdSetMappedMode(ATI_REG_BASE(card), ATI_REG_SIZE(card),
KD_MAPPED_MODE_REGISTERS);
return TRUE;
}
void
ATIUnmapReg(KdCardInfo *card, ATICardInfo *atic)
{
if (atic->reg_base) {
KdResetMappedMode(ATI_REG_BASE(card), ATI_REG_SIZE(card),
KD_MAPPED_MODE_REGISTERS);
KdUnmapDevice((void *)atic->reg_base, ATI_REG_SIZE(card));
atic->reg_base = 0;
}
}
static Bool
ATIInitScreen(ScreenPtr pScreen)
{
KdScreenPriv(pScreen);
ATICardInfo(pScreenPriv);
#ifdef XV
ATIInitVideo(pScreen);
#endif
return atic->backend_funcs.initScreen(pScreen);
}
static Bool
ATIFinishInitScreen(ScreenPtr pScreen)
{
KdScreenPriv(pScreen);
ATICardInfo(pScreenPriv);
if (!atic->backend_funcs.finishInitScreen(pScreen))
return FALSE;
#ifdef RANDR
if (!ATIRandRInit (pScreen))
return FALSE;
#endif
return TRUE;
}
static Bool
ATICreateResources(ScreenPtr pScreen)
{
KdScreenPriv(pScreen);
ATICardInfo(pScreenPriv);
return atic->backend_funcs.createRes(pScreen);
}
static void
ATIPreserve(KdCardInfo *card)
{
ATICardInfo *atic = card->driver;
char *mmio = atic->reg_base;
atic->backend_funcs.preserve(card);
if (atic->is_radeon && mmio)
{
atic->crtc_pitch = MMIO_IN32(mmio, ATI_REG_CRTC_PITCH);
atic->crtc2_pitch = MMIO_IN32(mmio, ATI_REG_CRTC2_PITCH);
}
}
static void
ATIRestore(KdCardInfo *card)
{
ATICardInfo *atic = card->driver;
char *mmio = atic->reg_base;
if (mmio)
{
MMIO_OUT32(mmio, ATI_REG_CRTC_PITCH, atic->crtc_pitch);
MMIO_OUT32(mmio, ATI_REG_CRTC2_PITCH, atic->crtc2_pitch);
}
ATIUnmapReg(card, atic);
atic->backend_funcs.restore(card);
}
static Bool
ATIDPMS(ScreenPtr pScreen, int mode)
{
KdScreenPriv(pScreen);
ATICardInfo(pScreenPriv);
return atic->backend_funcs.dpms(pScreen, mode);
}
static Bool
ATIEnable(ScreenPtr pScreen)
{
KdScreenPriv(pScreen);
ATICardInfo(pScreenPriv);
if (!atic->backend_funcs.enable(pScreen))
return FALSE;
if ((atic->reg_base == NULL) && !ATIMapReg(pScreenPriv->screen->card,
atic))
return FALSE;
ATISetOffscreen (pScreenPriv->screen);
ATISetPitch (pScreenPriv->screen);
return TRUE;
}
static void
ATIDisable(ScreenPtr pScreen)
{
KdScreenPriv(pScreen);
#if defined(USE_DRI) && defined(GLXEXT)
ATIScreenInfo(pScreenPriv);
#endif /* USE_DRI && GLXEXT */
ATICardInfo(pScreenPriv);
ATIUnmapReg(pScreenPriv->card, atic);
atic->backend_funcs.disable(pScreen);
}
static void
ATIGetColors(ScreenPtr pScreen, int fb, int n, xColorItem *pdefs)
{
KdScreenPriv(pScreen);
ATICardInfo(pScreenPriv);
atic->backend_funcs.getColors(pScreen, fb, n, pdefs);
}
static void
ATIPutColors(ScreenPtr pScreen, int fb, int n, xColorItem *pdefs)
{
KdScreenPriv(pScreen);
ATICardInfo(pScreenPriv);
atic->backend_funcs.putColors(pScreen, fb, n, pdefs);
}
/* Compute log base 2 of val. */
int
ATILog2(int val)
{
int bits;
for (bits = 0; val != 0; val >>= 1, ++bits)
;
return bits - 1;
}
static Bool
ATIIsAGP(ATICardInfo *atic)
{
char *mmio = atic->reg_base;
CARD32 cap_ptr, cap_id;
if (mmio == NULL)
return FALSE;
if (MMIO_IN32(mmio, ATI_REG_PCI_CFG_STATUS) & ATI_CAP_LIST) {
cap_ptr = MMIO_IN32(mmio, ATI_REG_PCI_CFG_CAPABILITIES_PTR) &
ATI_CAP_PTR_MASK;
while (cap_ptr != ATI_CAP_ID_NULL) {
cap_id = MMIO_IN32(mmio, ATI_PCI_CFG_OFFSET + cap_ptr);
if ((cap_id & 0xff) == ATI_CAP_ID_AGP)
return TRUE;
cap_ptr = (cap_id >> 8) & ATI_CAP_PTR_MASK;
}
}
return FALSE;
}
/* This function is required to work around a hardware bug in some (all?)
* revisions of the R300. This workaround should be called after every
* CLOCK_CNTL_INDEX register access. If not, register reads afterward
* may not be correct.
*/
void R300CGWorkaround(ATIScreenInfo *atis) {
ATICardInfo *atic = atis->atic;
char *mmio = atic->reg_base;
CARD32 save;
save = MMIO_IN32(mmio, ATI_REG_CLOCK_CNTL_INDEX);
MMIO_OUT32(mmio, ATI_REG_CLOCK_CNTL_INDEX, save & ~(0x3f |
ATI_PLL_WR_EN));
MMIO_IN32(mmio, ATI_REG_CLOCK_CNTL_INDEX);
MMIO_OUT32(mmio, ATI_REG_CLOCK_CNTL_INDEX, save);
}
KdCardFuncs ATIFuncs = {
ATICardInit, /* cardinit */
ATIScreenInit, /* scrinit */
ATIInitScreen, /* initScreen */
ATIFinishInitScreen, /* finishInitScreen */
ATICreateResources, /* createRes */
ATIPreserve, /* preserve */
ATIEnable, /* enable */
ATIDPMS, /* dpms */
ATIDisable, /* disable */
ATIRestore, /* restore */
ATIScreenFini, /* scrfini */
ATICardFini, /* cardfini */
ATICursorInit, /* initCursor */
ATICursorEnable, /* enableCursor */
ATICursorDisable, /* disableCursor */
ATICursorFini, /* finiCursor */
ATIRecolorCursor, /* recolorCursor */
ATIDrawInit, /* initAccel */
ATIDrawEnable, /* enableAccel */
ATIDrawDisable, /* disableAccel */
ATIDrawFini, /* finiAccel */
ATIGetColors, /* getColors */
ATIPutColors, /* putColors */
};

View File

@ -1,409 +0,0 @@
/*
* Copyright © 2003 Eric Anholt
*
* 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 Eric Anholt not be used in
* advertising or publicity pertaining to distribution of the software without
* specific, written prior permission. Eric Anholt makes no
* representations about the suitability of this software for any purpose. It
* is provided "as is" without express or implied warranty.
*
* ERIC ANHOLT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL ERIC ANHOLT 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.
*/
#ifndef _ATI_H_
#define _ATI_H_
#ifdef HAVE_CONFIG_H
#include <kdrive-config.h>
#endif
#ifdef KDRIVEFBDEV
#include <fbdev.h>
#endif
#ifdef KDRIVEVESA
#include <vesa.h>
#endif
#include "kxv.h"
#undef XF86DRI
#ifdef XF86DRI
#define USE_DRI
#include "xf86drm.h"
#include "dri.h"
#ifdef GLXEXT
#include "GL/glxint.h"
#include "GL/glxtokens.h"
#include "ati_dripriv.h"
#endif
#endif
#define ATI_REG_BASE(c) ((c)->attr.address[1])
#define ATI_REG_SIZE(c) (0x4000)
#ifdef __powerpc__
static __inline__ void
MMIO_OUT32(__volatile__ void *base, const unsigned long offset,
const unsigned int val)
{
__asm__ __volatile__(
"stwbrx %1,%2,%3\n\t"
"eieio"
: "=m" (*((volatile unsigned char *)base+offset))
: "r" (val), "b" (base), "r" (offset));
}
static __inline__ CARD32
MMIO_IN32(__volatile__ void *base, const unsigned long offset)
{
register unsigned int val;
__asm__ __volatile__(
"lwbrx %0,%1,%2\n\t"
"eieio"
: "=r" (val)
: "b" (base), "r" (offset),
"m" (*((volatile unsigned char *)base+offset)));
return val;
}
#else
#define MMIO_OUT32(mmio, a, v) (*(VOL32 *)((mmio) + (a)) = (v))
#define MMIO_IN32(mmio, a) (*(VOL32 *)((mmio) + (a)))
#endif
#define MMIO_OUT8(mmio, a, v) (*(VOL8 *)((mmio) + (a)) = (v))
#define MMIO_IN8(mmio, a, v) (*(VOL8 *)((mmio) + (a)))
#define INPLL(mmio, addr) \
(MMIO_OUT8(mmio, ATI_REG_CLOCK_CNTL_INDEX, addr), \
MMIO_IN32(mmio, ATI_REG_CLOCK_CNTL_DATA))
#define OUTPLL(mmio, addr, val) do { \
MMIO_OUT8(mmio, ATI_REG_CLOCK_CNTL_INDEX, (addr) | ATI_PLL_WR_EN); \
MMIO_OUT32(mmio, ATI_REG_CLOCK_CNTL_DATA, val); \
} while (0)
typedef volatile CARD8 VOL8;
typedef volatile CARD16 VOL16;
typedef volatile CARD32 VOL32;
struct pci_id_entry {
CARD16 vendor;
CARD16 device;
CARD8 caps;
char *name;
};
struct backend_funcs {
void (*cardfini)(KdCardInfo *);
void (*scrfini)(KdScreenInfo *);
Bool (*initScreen)(ScreenPtr);
Bool (*finishInitScreen)(ScreenPtr pScreen);
Bool (*createRes)(ScreenPtr);
void (*preserve)(KdCardInfo *);
void (*restore)(KdCardInfo *);
Bool (*dpms)(ScreenPtr, int);
Bool (*enable)(ScreenPtr);
void (*disable)(ScreenPtr);
void (*getColors)(ScreenPtr, int, int, xColorItem *);
void (*putColors)(ScreenPtr, int, int, xColorItem *);
#ifdef RANDR
Bool (*randrSetConfig) (ScreenPtr, Rotation, int, RRScreenSizePtr);
#endif
};
typedef struct _ATICardInfo {
union {
#ifdef KDRIVEFBDEV
FbdevPriv fbdev;
#endif
#ifdef KDRIVEVESA
VesaCardPrivRec vesa;
#endif
} backend_priv;
struct backend_funcs backend_funcs;
struct pci_id_entry *pci_id;
char *reg_base;
Bool is_radeon;
Bool is_r100;
Bool is_r200;
Bool is_r300;
Bool is_agp;
char *busid;
CARD32 crtc_pitch;
CARD32 crtc2_pitch;
#ifdef USE_DRI
int drmFd;
#endif /* USE_DRI */
Bool use_fbdev, use_vesa;
} ATICardInfo;
#define getATICardInfo(kd) ((ATICardInfo *) ((kd)->card->driver))
#define ATICardInfo(kd) ATICardInfo *atic = getATICardInfo(kd)
typedef struct _ATICursor {
int width, height;
int xhot, yhot;
Bool has_cursor;
CursorPtr pCursor;
Pixel source, mask;
KdOffscreenArea *area;
} ATICursor;
typedef struct _ATIPortPriv {
int brightness;
int saturation;
RegionRec clip;
CARD32 size;
KdOffscreenArea *off_screen;
DrawablePtr pDraw;
PixmapPtr pPixmap;
CARD32 src_offset;
CARD32 src_pitch;
CARD8 *src_addr;
int id;
int src_x1, src_y1, src_x2, src_y2;
int dst_x1, dst_y1, dst_x2, dst_y2;
int src_w, src_h, dst_w, dst_h;
} ATIPortPrivRec, *ATIPortPrivPtr;
typedef struct _dmaBuf {
int size;
int used;
void *address;
#ifdef USE_DRI
drmBufPtr drmBuf;
#endif
} dmaBuf;
typedef struct _ATIScreenInfo {
union {
#ifdef KDRIVEFBDEV
FbdevScrPriv fbdev;
#endif
#ifdef KDRIVEVESA
VesaScreenPrivRec vesa;
#endif
} backend_priv;
KaaScreenInfoRec kaa;
ATICardInfo *atic;
KdScreenInfo *screen;
int scratch_offset;
int scratch_next;
KdOffscreenArea *scratch_area;
ATICursor cursor;
KdVideoAdaptorPtr pAdaptor;
int num_texture_ports;
Bool using_pio; /* If we use decode DMA packets to MMIO. */
Bool using_pseudo; /* If we use MMIO to submit DMA packets. */
Bool using_dma; /* If we use non-DRI DMA to submit packets. */
Bool using_dri; /* If we use the DRM for DMA. */
Bool using_agp; /* If we are using AGP or not for DMA. */
KdOffscreenArea *dma_space; /* For "DMA" from framebuffer. */
void *agp_addr; /* Mapped AGP aperture */
int agp_size;
int agp_key; /* Key of AGP memory for DMA */
CARD32 *ring_addr; /* Beginning of ring buffer. */
int ring_write; /* Index of write ptr in ring. */
int ring_read; /* Index of read ptr in ring. */
int ring_len;
dmaBuf *indirectBuffer;
int indirectStart;
int mmio_avail;
int cce_pri_size;
int cce_pri_avail;
#ifdef USE_DRI
Bool dma_started;
drmSize registerSize;
drmHandle registerHandle;
drmHandle fbHandle;
drmSize gartSize;
drmHandle agpMemHandle; /* Handle from drmAgpAlloc */
unsigned long gartOffset;
unsigned char *AGP; /* Map */
int agpMode;
drmSize pciSize;
drmHandle pciMemHandle;
/* ring buffer data */
unsigned long ringStart; /* Offset into AGP space */
drmHandle ringHandle; /* Handle from drmAddMap */
drmSize ringMapSize; /* Size of map */
int ringSize; /* Size of ring (MB) */
unsigned char *ring; /* Map */
unsigned long ringReadOffset; /* Offset into AGP space */
drmHandle ringReadPtrHandle; /* Handle from drmAddMap */
drmSize ringReadMapSize; /* Size of map */
unsigned char *ringReadPtr; /* Map */
/* vertex/indirect buffer data */
unsigned long bufStart; /* Offset into AGP space */
drmHandle bufHandle; /* Handle from drmAddMap */
drmSize bufMapSize; /* Size of map */
int bufSize; /* Size of buffers (MB) */
unsigned char *buf; /* Map */
int bufNumBufs; /* Number of buffers */
drmBufMapPtr buffers; /* Buffer map */
/* AGP Texture data */
unsigned long gartTexStart; /* Offset into AGP space */
drmHandle gartTexHandle; /* Handle from drmAddMap */
drmSize gartTexMapSize; /* Size of map */
int gartTexSize; /* Size of AGP tex space (MB) */
unsigned char *gartTex; /* Map */
int log2GARTTexGran;
int DMAusecTimeout; /* CCE timeout in usecs */
/* DRI screen private data */
int frontOffset;
int frontPitch;
int backOffset;
int backPitch;
int depthOffset;
int depthPitch;
int spanOffset;
int textureOffset;
int textureSize;
int log2TexGran;
int irqEnabled;
int serverContext;
DRIInfoPtr pDRIInfo;
#ifdef GLXEXT
int numVisualConfigs;
__GLXvisualConfig *pVisualConfigs;
ATIConfigPrivPtr pVisualConfigsPriv;
#endif /* GLXEXT */
#endif /* USE_DRI */
} ATIScreenInfo;
#define getATIScreenInfo(kd) ((ATIScreenInfo *) ((kd)->screen->driver))
#define ATIScreenInfo(kd) ATIScreenInfo *atis = getATIScreenInfo(kd)
typedef union { float f; CARD32 i; } fi_type;
/* Surely there's a better way to go about this */
static inline CARD32
ATIFloatAsInt(float val)
{
fi_type fi;
fi.f = val;
return fi.i;
}
#define GET_FLOAT_BITS(x) ATIFloatAsInt(x)
/* ati.c */
Bool
ATIMapReg(KdCardInfo *card, ATICardInfo *atic);
void
ATIUnmapReg(KdCardInfo *card, ATICardInfo *atic);
void
R300CGWorkaround(ATIScreenInfo *atis);
/* ati_draw.c */
void
ATIDrawSetup(ScreenPtr pScreen);
Bool
ATIDrawInit(ScreenPtr pScreen);
void
ATIDrawEnable(ScreenPtr pScreen);
void
ATIDrawDisable(ScreenPtr pScreen);
void
ATIDrawFini(ScreenPtr pScreen);
/* ati_dri.c */
#ifdef USE_DRI
Bool
ATIDRIScreenInit(ScreenPtr pScreen);
void
ATIDRICloseScreen(ScreenPtr pScreen);
void
ATIDRIDMAStart(ATIScreenInfo *atis);
void
ATIDRIDMAStop(ATIScreenInfo *atis);
void
ATIDRIDMAReset(ATIScreenInfo *atis);
void
ATIDRIDispatchIndirect(ATIScreenInfo *atis, Bool discard);
drmBufPtr
ATIDRIGetBuffer(ATIScreenInfo *atis);
#endif /* USE_DRI */
/* ati_cursor.c */
Bool
ATICursorInit(ScreenPtr pScreen);
void
ATICursorEnable(ScreenPtr pScreen);
void
ATICursorDisable(ScreenPtr pScreen);
void
ATICursorFini(ScreenPtr pScreen);
void
ATIRecolorCursor(ScreenPtr pScreen, int ndef, xColorItem *pdef);
int
ATILog2(int val);
/* ati_video.c */
Bool
ATIInitVideo(ScreenPtr pScreen);
void
ATIFiniVideo(ScreenPtr pScreen);
extern KdCardFuncs ATIFuncs;
#endif /* _ATI_H_ */

View File

@ -1,561 +0,0 @@
/*
* Copyright © 2004 Eric Anholt
*
* 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 Eric Anholt not be used in
* advertising or publicity pertaining to distribution of the software without
* specific, written prior permission. Eric Anholt makes no
* representations about the suitability of this software for any purpose. It
* is provided "as is" without express or implied warranty.
*
* ERIC ANHOLT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL ERIC ANHOLT 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.
*/
#ifdef HAVE_CONFIG_H
#include <kdrive-config.h>
#endif
#include "ati.h"
#include "ati_reg.h"
#include "cursorstr.h"
#include "ati_draw.h"
#include "inputstr.h"
static void
ATIMoveCursor(DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y)
{
KdScreenPriv(pScreen);
ATICardInfo(pScreenPriv);
ATIScreenInfo(pScreenPriv);
ATICursor *pCurPriv = &atis->cursor;
CARD16 xoff, yoff;
char *mmio = atic->reg_base;
int stride = atic->is_radeon ? 256 : 16;
if (!pCurPriv->has_cursor)
return;
if (!pScreenPriv->enabled)
return;
x -= pCurPriv->xhot;
xoff = 0;
if (x < 0) {
xoff = -x;
x = 0;
}
y -= pCurPriv->yhot;
yoff = 0;
if (y < 0) {
yoff = -y;
y = 0;
}
MMIO_OUT32(mmio, ATI_REG_CUR_HORZ_VERT_OFF, ATI_CUR_LOCK |
(xoff << 16) | yoff);
MMIO_OUT32(mmio, ATI_REG_CUR_HORZ_VERT_POSN, ATI_CUR_LOCK |
(x << 16) | y);
MMIO_OUT32(mmio, ATI_REG_CUR_OFFSET, (pCurPriv->area->offset + yoff *
stride));
}
static void
ClassicAllocCursorColors(ScreenPtr pScreen)
{
KdScreenPriv(pScreen);
ATIScreenInfo(pScreenPriv);
ATICursor *pCurPriv = &atis->cursor;
CursorPtr pCursor = pCurPriv->pCursor;
KdAllocateCursorPixels(pScreen, 0, pCursor, &pCurPriv->source,
&pCurPriv->mask);
switch (pScreenPriv->screen->fb[0].bitsPerPixel) {
case 4:
pCurPriv->source |= pCurPriv->source << 4;
pCurPriv->mask |= pCurPriv->mask << 4;
/* FALLTHROUGH */
case 8:
pCurPriv->source |= pCurPriv->source << 8;
pCurPriv->mask |= pCurPriv->mask << 8;
/* FALLTHROUGH */
case 16:
pCurPriv->source |= pCurPriv->source << 16;
pCurPriv->mask |= pCurPriv->mask << 16;
}
}
static void
ClassicSetCursorColors(ScreenPtr pScreen)
{
KdScreenPriv(pScreen);
ATICardInfo(pScreenPriv);
ATIScreenInfo(pScreenPriv);
ATICursor *pCurPriv = &atis->cursor;
char *mmio = atic->reg_base;
MMIO_OUT32(mmio, ATI_REG_CUR_CLR0, pCurPriv->mask);
MMIO_OUT32(mmio, ATI_REG_CUR_CLR1, pCurPriv->source);
}
static void
ClassicRecolorCursor(ScreenPtr pScreen, int ndef, xColorItem *pdef)
{
KdScreenPriv(pScreen);
ATIScreenInfo(pScreenPriv);
ATICursor *pCurPriv = &atis->cursor;
CursorPtr pCursor = pCurPriv->pCursor;
if (!pCurPriv->has_cursor || !pCursor)
return;
if (!pScreenPriv->enabled)
return;
if (pdef) {
while (ndef != 0) {
if (pdef->pixel == pCurPriv->source ||
pdef->pixel == pCurPriv->mask)
break;
ndef--;
}
if (ndef == 0)
return;
}
ClassicAllocCursorColors(pScreen);
ClassicSetCursorColors(pScreen);
}
#define InvertBits32(v) do { \
v = ((v & 0x55555555) << 1) | ((v >> 1) & 0x55555555); \
v = ((v & 0x33333333) << 2) | ((v >> 2) & 0x33333333); \
v = ((v & 0x0f0f0f0f) << 4) | ((v >> 4) & 0x0f0f0f0f); \
} while (0)
static void
ClassicLoadCursor(ScreenPtr pScreen)
{
KdScreenPriv(pScreen);
ATICardInfo(pScreenPriv);
ATIScreenInfo(pScreenPriv);
ATICursor *pCurPriv = &atis->cursor;
CursorPtr pCursor = pCurPriv->pCursor;
CursorBitsPtr bits = pCursor->bits;
int h;
CARD32 *ram, *msk, *mskLine, *src, *srcLine;
int i;
int lwsrc;
CARD32 tmp;
char *mmio = atic->reg_base;
ClassicAllocCursorColors(pScreen);
pCurPriv->pCursor = pCursor;
pCurPriv->xhot = pCursor->bits->xhot;
pCurPriv->yhot = pCursor->bits->yhot;
/* Stick new image into cursor memory */
ram = (CARD32 *)(pScreenPriv->screen->memory_base +
pCurPriv->area->offset);
mskLine = (CARD32 *)bits->mask;
srcLine = (CARD32 *)bits->source;
h = bits->height;
if (h > ATI_CURSOR_HEIGHT)
h = ATI_CURSOR_HEIGHT;
lwsrc = BitmapBytePad(bits->width) / 4; /* words per line */
tmp = MMIO_IN32(mmio, ATI_REG_GEN_CNTL);
MMIO_OUT32(mmio, ATI_REG_GEN_CNTL, tmp & ~ATI_CRTC_CUR_EN);
for (i = 0; i < ATI_CURSOR_HEIGHT; i++) {
CARD32 m1, m2, s1, s2;
msk = mskLine;
src = srcLine;
mskLine += lwsrc;
srcLine += lwsrc;
if (i < h && 0 < lwsrc) {
m1 = ~*msk++;
s1 = *src++;
InvertBits32(m1);
InvertBits32(s1);
} else {
m1 = 0xffffffff;
s1 = 0x0;
}
if (i < h && 1 < lwsrc) {
m2 = ~*msk++;
s2 = *src++;
InvertBits32(m2);
InvertBits32(s2);
} else {
m2 = 0xffffffff;
s2 = 0x0;
}
*ram++ = m1;
*ram++ = m2;
*ram++ = s1;
*ram++ = s2;
}
/* Not sure why this is necessary, but it prevents some cursor
* corruption. Not even all of it.
*/
for (i = 0; i < ATI_CURSOR_HEIGHT; i++) {
*ram++ = 0xffffffff;
*ram++ = 0xffffffff;
*ram++ = 0x0;
*ram++ = 0x0;
}
/* Enable the cursor */
tmp = MMIO_IN32(mmio, ATI_REG_GEN_CNTL);
MMIO_OUT32(mmio, ATI_REG_GEN_CNTL, tmp | ATI_CRTC_CUR_EN);
/* Set new color */
ClassicSetCursorColors(pScreen);
}
static void
RadeonLoadCursor(ScreenPtr pScreen)
{
KdScreenPriv(pScreen);
ATICardInfo(pScreenPriv);
ATIScreenInfo(pScreenPriv);
ATICursor *pCurPriv = &atis->cursor;
CursorPtr pCursor = pCurPriv->pCursor;
CursorBitsPtr bits = pCursor->bits;
int h, w;
int x, y;
CARD32 *ram, *msk, *mskLine, *src, *srcLine;
int lwsrc;
CARD32 tmp;
char *mmio = atic->reg_base;
pCurPriv->pCursor = pCursor;
pCurPriv->xhot = pCursor->bits->xhot;
pCurPriv->yhot = pCursor->bits->yhot;
w = bits->width;
if (w > ATI_CURSOR_WIDTH)
w = ATI_CURSOR_WIDTH;
h = bits->height;
if (h > ATI_CURSOR_HEIGHT)
h = ATI_CURSOR_HEIGHT;
tmp = MMIO_IN32(mmio, 0x7c);
tmp = 0x00010f80;
MMIO_OUT32 (mmio, 0x7c, tmp);
tmp = MMIO_IN32(mmio, ATI_REG_GEN_CNTL);
tmp &= ~(ATI_CRTC_CUR_EN | ATI_CRTC_ICON_EN | ATI_CRTC_ARGB_EN);
MMIO_OUT32(mmio, ATI_REG_GEN_CNTL, tmp);
/* Stick new image into cursor memory */
ram = (CARD32 *)(pScreenPriv->screen->memory_base +
pCurPriv->area->offset);
if (pCursor->bits->argb)
{
srcLine = pCursor->bits->argb;
for (y = 0; y < h; y++)
{
src = srcLine;
srcLine += pCursor->bits->width;
for (x = 0; x < w; x++)
*ram++ = *src++;
for (; x < ATI_CURSOR_WIDTH; x++)
*ram++ = 0;
}
for (; y < ATI_CURSOR_HEIGHT; y++)
for (x = 0; x < ATI_CURSOR_WIDTH; x++)
*ram++ = 0;
}
else
{
CARD32 colors[4];
colors[0] = 0;
colors[1] = 0;
colors[2] = (((pCursor->backRed >> 8) << 16) |
((pCursor->backGreen >> 8) << 8) |
((pCursor->backBlue >> 8) << 0) |
0xff000000);
colors[3] = (((pCursor->foreRed >> 8) << 16) |
((pCursor->foreGreen >> 8) << 8) |
((pCursor->foreBlue >> 8) << 0) |
0xff000000);
mskLine = (CARD32 *)bits->mask;
srcLine = (CARD32 *)bits->source;
/* words per line */
lwsrc = BitmapBytePad(bits->width) / 4;
for (y = 0; y < ATI_CURSOR_HEIGHT; y++)
{
CARD32 m, s;
msk = mskLine;
src = srcLine;
mskLine += lwsrc;
srcLine += lwsrc;
for (x = 0; x < ATI_CURSOR_WIDTH / 32; x++)
{
int k;
if (y < h && x < lwsrc)
{
m = *msk++;
s = *src++;
}
else
{
m = 0x0;
s = 0x0;
}
for (k = 0; k < 32; k++)
{
CARD32 bits = (s & 1) | ((m & 1) << 1);
*ram++ = colors[bits];
s >>= 1;
m >>= 1;
}
}
}
}
/* Enable the cursor */
tmp &= ~(ATI_CRTC_ICON_EN);
tmp |= ATI_CRTC_ARGB_EN;
tmp |= ATI_CRTC_CUR_EN;
MMIO_OUT32(mmio, ATI_REG_GEN_CNTL, tmp);
}
static void
ATIUnloadCursor(ScreenPtr pScreen)
{
KdScreenPriv(pScreen);
ATICardInfo(pScreenPriv);
char *mmio = atic->reg_base;
CARD32 tmp;
tmp = MMIO_IN32(mmio, ATI_REG_GEN_CNTL);
tmp &= ~(ATI_CRTC_CUR_EN | ATI_CRTC_ICON_EN | ATI_CRTC_ARGB_EN);
MMIO_OUT32(mmio, ATI_REG_GEN_CNTL, tmp);
}
static Bool
ATIRealizeCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor)
{
KdScreenPriv(pScreen);
ATICardInfo(pScreenPriv);
ATIScreenInfo(pScreenPriv);
ATICursor *pCurPriv = &atis->cursor;
if (!pScreenPriv->enabled)
return TRUE;
/* miRecolorCursor does this */
if (pCursor && pCurPriv->pCursor == pCursor)
{
int x, y;
miPointerGetPosition(pDev, &x, &y);
if (atic->is_radeon)
RadeonLoadCursor (pScreen);
else
ClassicLoadCursor(pScreen);
/* Move to new position */
ATIMoveCursor(pDev, pScreen, x, y);
}
return TRUE;
}
static Bool
ATIUnrealizeCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor)
{
return TRUE;
}
static void
ATISetCursor(DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor, int x, int y)
{
KdScreenPriv(pScreen);
ATICardInfo(pScreenPriv);
ATIScreenInfo(pScreenPriv);
ATICursor *pCurPriv = &atis->cursor;
pCurPriv->pCursor = pCursor;
if (!pScreenPriv->enabled)
return;
if (pCursor)
{
if (atic->is_radeon)
RadeonLoadCursor (pScreen);
else
ClassicLoadCursor(pScreen);
/* Move to new position */
ATIMoveCursor(pDev, pScreen, x, y);
}
else
ATIUnloadCursor(pScreen);
}
miPointerSpriteFuncRec ATIPointerSpriteFuncs = {
ATIRealizeCursor,
ATIUnrealizeCursor,
ATISetCursor,
ATIMoveCursor,
};
static void
ATIQueryBestSize(int class, unsigned short *pwidth, unsigned short *pheight,
ScreenPtr pScreen)
{
KdScreenPriv(pScreen);
ATIScreenInfo(pScreenPriv);
ATICursor *pCurPriv = &atis->cursor;
switch (class)
{
case CursorShape:
if (*pwidth > pCurPriv->width)
*pwidth = pCurPriv->width;
if (*pheight > pCurPriv->height)
*pheight = pCurPriv->height;
if (*pwidth > pScreen->width)
*pwidth = pScreen->width;
if (*pheight > pScreen->height)
*pheight = pScreen->height;
break;
default:
fbQueryBestSize(class, pwidth, pheight, pScreen);
break;
}
}
static void
ATICursorSave(ScreenPtr pScreen, KdOffscreenArea *area)
{
KdScreenPriv(pScreen);
ATIScreenInfo(pScreenPriv);
ATICursor *pCurPriv = &atis->cursor;
pCurPriv->area = NULL;
}
void
ATICursorEnable(ScreenPtr pScreen)
{
DeviceIntPtr pDev = inputInfo.pointer;
KdScreenPriv(pScreen);
ATICardInfo(pScreenPriv);
ATIScreenInfo(pScreenPriv);
ATICursor *pCurPriv = &atis->cursor;
if (!pCurPriv->has_cursor)
return;
if (pCurPriv->area == NULL) {
if (atic->is_radeon)
pCurPriv->area = KdOffscreenAlloc(pScreen,
ATI_CURSOR_HEIGHT * ATI_CURSOR_WIDTH * 4,
128, TRUE, ATICursorSave, atis);
else
pCurPriv->area = KdOffscreenAlloc(pScreen,
ATI_CURSOR_HEIGHT * ATI_CURSOR_PITCH * 2,
32, TRUE, ATICursorSave, atis);
}
if (pCurPriv->area == NULL)
FatalError("Couldn't allocate offscreen memory for cursor.\n");
if (pCurPriv->pCursor) {
int x, y;
miPointerGetPosition(pDev, &x, &y);
if (atic->is_radeon)
RadeonLoadCursor(pScreen);
else
ClassicLoadCursor(pScreen);
/* Move to new position */
ATIMoveCursor(pDev, pScreen, x, y);
}
else
ATIUnloadCursor(pScreen);
}
void
ATICursorDisable(ScreenPtr pScreen)
{
KdScreenPriv(pScreen);
ATIScreenInfo(pScreenPriv);
ATICursor *pCurPriv = &atis->cursor;
if (!pScreenPriv->enabled || !pCurPriv->has_cursor)
return;
if (pCurPriv->pCursor)
ATIUnloadCursor(pScreen);
}
Bool
ATICursorInit(ScreenPtr pScreen)
{
KdScreenPriv(pScreen);
ATICardInfo(pScreenPriv);
ATIScreenInfo(pScreenPriv);
ATICursor *pCurPriv = &atis->cursor;
pCurPriv->has_cursor = FALSE;
if (atic->reg_base == NULL)
return FALSE;
pCurPriv->width = ATI_CURSOR_WIDTH;
pCurPriv->height= ATI_CURSOR_HEIGHT;
pScreen->QueryBestSize = ATIQueryBestSize;
miPointerInitialize(pScreen, &ATIPointerSpriteFuncs,
&kdPointerScreenFuncs, FALSE);
pCurPriv->has_cursor = TRUE;
pCurPriv->pCursor = NULL;
return TRUE;
}
void
ATIRecolorCursor (ScreenPtr pScreen, int ndef, xColorItem *pdef)
{
KdScreenPriv(pScreen);
ATICardInfo(pScreenPriv);
if (!atic->is_radeon)
ClassicRecolorCursor (pScreen, ndef, pdef);
}
void
ATICursorFini(ScreenPtr pScreen)
{
KdScreenPriv(pScreen);
ATIScreenInfo(pScreenPriv);
ATICursor *pCurPriv = &atis->cursor;
pCurPriv->has_cursor = FALSE;
pCurPriv->pCursor = NULL;
}

File diff suppressed because it is too large Load Diff

View File

@ -1,141 +0,0 @@
/*
* Copyright © 2004 Eric Anholt
*
* 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 Eric Anholt not be used in
* advertising or publicity pertaining to distribution of the software without
* specific, written prior permission. Eric Anholt makes no
* representations about the suitability of this software for any purpose. It
* is provided "as is" without express or implied warranty.
*
* ERIC ANHOLT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL ERIC ANHOLT 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.
*/
#ifndef _ATI_DMA_H_
#define _ATI_DMA_H_
#define CCE_DEBUG 1
#if !CCE_DEBUG
#define DMA_PACKET0(reg, count) \
(ATI_CCE_PACKET0 | (((count) - 1) << 16) | ((reg) >> 2))
#else
#define DMA_PACKET0(reg, count) \
(__packet0count = (count), __reg = (reg), \
ATI_CCE_PACKET0 | (((count) - 1) << 16) | ((reg) >> 2))
#endif
#define DMA_PACKET1(reg1, reg2) \
(ATI_CCE_PACKET1 | \
(((reg2) >> 2) << ATI_CCE_PACKET1_REG_2_SHIFT) | ((reg1) >> 2))
#define DMA_PACKET3(type, count) \
((type) | (((count) - 1) << 16))
#if !CCE_DEBUG
#define RING_LOCALS CARD32 *__head; int __count
#define BEGIN_DMA(n) \
do { \
if ((atis->indirectBuffer->used + 4*(n)) > \
atis->indirectBuffer->size) { \
ATIFlushIndirect(atis, 1); \
} \
__head = (CARD32 *)((char *)atis->indirectBuffer->address + \
atis->indirectBuffer->used); \
__count = 0; \
} while (0)
#define END_DMA() do { \
atis->indirectBuffer->used += __count * 4; \
} while (0)
#else
#define RING_LOCALS \
CARD32 *__head; int __count, __total, __reg, __packet0count
#define BEGIN_DMA(n) \
do { \
if ((atis->indirectBuffer->used + 4*(n)) > \
atis->indirectBuffer->size) { \
ATIFlushIndirect(atis, 1); \
} \
__head = (CARD32 *)((char *)atis->indirectBuffer->address + \
atis->indirectBuffer->used); \
__count = 0; \
__total = n; \
__reg = 0; \
__packet0count = 0; \
} while (0)
#define END_DMA() do { \
if (__count != __total) \
FatalError("count != total (%d vs %d) at %s:%d\n", \
__count, __total, __FILE__, __LINE__); \
atis->indirectBuffer->used += __count * 4; \
} while (0)
#endif
#define OUT_RING(val) do { \
__head[__count++] = (val); \
} while (0)
#define OUT_RING_REG(reg, val) do { \
if (__reg != reg) \
FatalError("unexpected reg (0x%x vs 0x%x) at %s:%d\n", \
reg, __reg, __FILE__, __LINE__); \
if (__packet0count-- <= 0) \
FatalError("overrun of packet0 at %s:%d\n", \
__FILE__, __LINE__); \
__head[__count++] = (val); \
__reg += 4; \
} while (0)
#define OUT_RING_F(x) OUT_RING(GET_FLOAT_BITS(x))
#define OUT_REG(reg, val) \
do { \
OUT_RING(DMA_PACKET0(reg, 1)); \
OUT_RING(val); \
} while (0)
#define TIMEOUT_LOCALS struct timeval _target, _curtime
static inline Bool
tv_le(struct timeval *tv1, struct timeval *tv2)
{
if (tv1->tv_sec < tv2->tv_sec ||
(tv1->tv_sec == tv2->tv_sec && tv1->tv_usec < tv2->tv_usec))
return TRUE;
else
return FALSE;
}
#define WHILE_NOT_TIMEOUT(_timeout) \
gettimeofday(&_target, NULL); \
_target.tv_usec += ((_timeout) * 1000000); \
_target.tv_sec += _target.tv_usec / 1000000; \
_target.tv_usec = _target.tv_usec % 1000000; \
while (gettimeofday(&_curtime, NULL), tv_le(&_curtime, &_target))
#define TIMEDOUT() (!tv_le(&_curtime, &_target))
dmaBuf *
ATIGetDMABuffer(ATIScreenInfo *atis);
void
ATIFlushIndirect(ATIScreenInfo *atis, Bool discard);
void
ATIDMASetup(ScreenPtr pScreen);
void
ATIDMATeardown(ScreenPtr pScreen);
#endif /* _ATI_DMA_H_ */

View File

@ -1,918 +0,0 @@
/*
* Copyright © 2003 Eric Anholt
*
* 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 Eric Anholt not be used in
* advertising or publicity pertaining to distribution of the software without
* specific, written prior permission. Eric Anholt makes no
* representations about the suitability of this software for any purpose. It
* is provided "as is" without express or implied warranty.
*
* ERIC ANHOLT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL ERIC ANHOLT 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.
*/
#ifdef HAVE_CONFIG_H
#include <kdrive-config.h>
#endif
#include "ati.h"
#include "ati_reg.h"
#include "ati_dma.h"
#include "ati_draw.h"
#include "kaa.h"
CARD8 ATISolidRop[16] = {
/* GXclear */ 0x00, /* 0 */
/* GXand */ 0xa0, /* src AND dst */
/* GXandReverse */ 0x50, /* src AND NOT dst */
/* GXcopy */ 0xf0, /* src */
/* GXandInverted*/ 0x0a, /* NOT src AND dst */
/* GXnoop */ 0xaa, /* dst */
/* GXxor */ 0x5a, /* src XOR dst */
/* GXor */ 0xfa, /* src OR dst */
/* GXnor */ 0x05, /* NOT src AND NOT dst */
/* GXequiv */ 0xa5, /* NOT src XOR dst */
/* GXinvert */ 0x55, /* NOT dst */
/* GXorReverse */ 0xf5, /* src OR NOT dst */
/* GXcopyInverted*/ 0x0f, /* NOT src */
/* GXorInverted */ 0xaf, /* NOT src OR dst */
/* GXnand */ 0x5f, /* NOT src OR NOT dst */
/* GXset */ 0xff, /* 1 */
};
CARD8 ATIBltRop[16] = {
/* GXclear */ 0x00, /* 0 */
/* GXand */ 0x88, /* src AND dst */
/* GXandReverse */ 0x44, /* src AND NOT dst */
/* GXcopy */ 0xcc, /* src */
/* GXandInverted*/ 0x22, /* NOT src AND dst */
/* GXnoop */ 0xaa, /* dst */
/* GXxor */ 0x66, /* src XOR dst */
/* GXor */ 0xee, /* src OR dst */
/* GXnor */ 0x11, /* NOT src AND NOT dst */
/* GXequiv */ 0x99, /* NOT src XOR dst */
/* GXinvert */ 0x55, /* NOT dst */
/* GXorReverse */ 0xdd, /* src OR NOT dst */
/* GXcopyInverted*/ 0x33, /* NOT src */
/* GXorInverted */ 0xbb, /* NOT src OR dst */
/* GXnand */ 0x77, /* NOT src OR NOT dst */
/* GXset */ 0xff, /* 1 */
};
int copydx, copydy;
ATIScreenInfo *accel_atis;
/* If is_24bpp is set, then we are using the accelerator in 8-bit mode due
* to it being broken for 24bpp, so coordinates have to be multiplied by 3.
*/
Bool is_24bpp;
CARD32 settings, color, src_pitch_offset, dst_pitch_offset;
int sample_count;
float sample_offsets_x[255];
float sample_offsets_y[255];
#define DRAW_USING_PACKET3 0
void
ATIDrawSetup(ScreenPtr pScreen)
{
KdScreenPriv(pScreen);
ATIScreenInfo(pScreenPriv);
ATICardInfo(pScreenPriv);
RING_LOCALS;
/* XXX: this shouldn't be necessary, but fixes some R128 composite
* issues.
*/
/*if (!atic->is_radeon) {
char *mmio = atic->reg_base;
ATIWaitIdle(atis);
MMIO_OUT32(mmio, R128_REG_PC_GUI_MODE,
R128_PC_BYPASS_EN);
}*/
BEGIN_DMA(2);
OUT_REG(ATI_REG_DEFAULT_SC_BOTTOM_RIGHT,
ATI_DEFAULT_SC_RIGHT_MAX | ATI_DEFAULT_SC_BOTTOM_MAX);
END_DMA();
if (!atic->is_radeon) {
/* Setup for R128 Composite */
BEGIN_DMA(12);
OUT_REG(R128_REG_SCALE_3D_CNTL,
R128_SCALE_3D_TEXMAP_SHADE |
R128_SCALE_PIX_REPLICATE |
R128_TEX_CACHE_SPLIT |
R128_TEX_MAP_ALPHA_IN_TEXTURE |
R128_TEX_CACHE_LINE_SIZE_4QW);
OUT_REG(R128_REG_SETUP_CNTL,
R128_COLOR_SOLID_COLOR |
R128_PRIM_TYPE_TRI |
R128_TEXTURE_ST_MULT_W |
R128_STARTING_VERTEX_1 |
R128_ENDING_VERTEX_3 |
R128_SUB_PIX_4BITS);
OUT_REG(R128_REG_PM4_VC_FPU_SETUP,
R128_FRONT_DIR_CCW |
R128_BACKFACE_CULL |
R128_FRONTFACE_SOLID |
R128_FPU_COLOR_SOLID |
R128_FPU_SUB_PIX_4BITS |
R128_FPU_MODE_3D |
R128_TRAP_BITS_DISABLE |
R128_XFACTOR_2 |
R128_YFACTOR_2 |
R128_FLAT_SHADE_VERTEX_OGL |
R128_FPU_ROUND_TRUNCATE |
R128_WM_SEL_8DW);
OUT_REG(R128_REG_PLANE_3D_MASK_C, 0xffffffff);
OUT_REG(R128_REG_CONSTANT_COLOR_C, 0xff000000);
OUT_REG(R128_REG_WINDOW_XY_OFFSET, 0x00000000);
END_DMA();
} else if (!atic->is_r300) {
/* Setup for R100/R200 Composite */
BEGIN_DMA(8);
OUT_REG(RADEON_REG_RE_TOP_LEFT, 0);
OUT_REG(RADEON_REG_RE_WIDTH_HEIGHT, 0xffffffff);
OUT_REG(RADEON_REG_RB3D_PLANEMASK, 0xffffffff);
OUT_REG(RADEON_REG_SE_CNTL,
RADEON_FFACE_CULL_CCW |
RADEON_FFACE_SOLID |
RADEON_VTX_PIX_CENTER_OGL);
END_DMA();
if (atic->is_r100) {
BEGIN_DMA(6);
OUT_REG(RADEON_REG_SE_CNTL_STATUS, RADEON_TCL_BYPASS);
OUT_REG(RADEON_REG_SE_COORD_FMT,
RADEON_VTX_XY_PRE_MULT_1_OVER_W0 |
RADEON_VTX_ST0_NONPARAMETRIC |
RADEON_VTX_ST1_NONPARAMETRIC |
RADEON_TEX1_W_ROUTING_USE_W0);
OUT_REG(RADEON_REG_RB3D_DSTCACHE_MODE,
RADEON_RB3D_DC_2D_CACHE_AUTOFLUSH |
RADEON_RB3D_DC_3D_CACHE_AUTOFLUSH);
END_DMA();
} else {
BEGIN_DMA(18);
/* XXX: The 0 below should be RADEON_TCL_BYPASS on
* RS300s.
*/
OUT_REG(R200_REG_SE_VAP_CNTL_STATUS, 0);
OUT_REG(R200_REG_PP_CNTL_X, 0);
OUT_REG(R200_REG_PP_TXMULTI_CTL_0, 0);
OUT_REG(R200_REG_SE_VTX_STATE_CNTL, 0);
OUT_REG(R200_REG_RE_CNTL, 0);
/* XXX: VTX_ST_DENORMALIZED is illegal for the case of
* repeating textures.
*/
OUT_REG(R200_REG_SE_VTE_CNTL, R200_VTX_ST_DENORMALIZED);
OUT_REG(R200_REG_SE_VAP_CNTL,
R200_VAP_FORCE_W_TO_ONE |
R200_VAP_VF_MAX_VTX_NUM);
OUT_REG(R200_REG_RE_AUX_SCISSOR_CNTL, 0);
OUT_REG(RADEON_REG_RB3D_DSTCACHE_MODE,
RADEON_RB3D_DC_2D_CACHE_AUTOFLUSH |
RADEON_RB3D_DC_3D_CACHE_AUTOFLUSH |
R200_RB3D_DC_2D_CACHE_AUTOFREE |
R200_RB3D_DC_3D_CACHE_AUTOFREE);
END_DMA();
}
}
}
static void
ATIWaitMarker(ScreenPtr pScreen, int marker)
{
KdScreenPriv(pScreen);
ATIScreenInfo(pScreenPriv);
ENTER_DRAW(0);
ATIWaitIdle(atis);
LEAVE_DRAW(0);
}
void
RadeonSwitchTo2D(ATIScreenInfo *atis)
{
RING_LOCALS;
ENTER_DRAW(0);
BEGIN_DMA(4);
OUT_REG(RADEON_REG_RB3D_DSTCACHE_CTLSTAT, RADEON_RB3D_DC_FLUSH);
OUT_REG(ATI_REG_WAIT_UNTIL,
RADEON_WAIT_HOST_IDLECLEAN | RADEON_WAIT_3D_IDLECLEAN);
END_DMA();
LEAVE_DRAW(0);
}
void
RadeonSwitchTo3D(ATIScreenInfo *atis)
{
RING_LOCALS;
ENTER_DRAW(0);
BEGIN_DMA(4);
OUT_REG(RADEON_REG_RB3D_DSTCACHE_CTLSTAT, RADEON_RB3D_DC_FLUSH);
/* We must wait for 3d to idle, in case source was just written as a dest. */
OUT_REG(ATI_REG_WAIT_UNTIL,
RADEON_WAIT_HOST_IDLECLEAN | RADEON_WAIT_2D_IDLECLEAN | RADEON_WAIT_3D_IDLECLEAN);
END_DMA();
LEAVE_DRAW(0);
}
#if ATI_TRACE_DRAW
void
ATIEnterDraw (PixmapPtr pPix, char *function)
{
if (pPix != NULL) {
KdScreenPriv(pPix->drawable.pScreen);
CARD32 offset;
offset = ((CARD8 *)pPix->devPrivate.ptr -
pScreenPriv->screen->memory_base);
ErrorF ("Enter %s 0x%x (%dx%dx%d/%d)\n", function, offset,
pPix->drawable.width, pPix->drawable.height, pPix->drawable.depth,
pPix->drawable.bitsPerPixel);
} else
ErrorF ("Enter %s\n", function);
}
void
ATILeaveDraw (PixmapPtr pPix, char *function)
{
if (pPix != NULL) {
KdScreenPriv(pPix->drawable.pScreen);
CARD32 offset;
offset = ((CARD8 *)pPix->devPrivate.ptr -
pScreenPriv->screen->memory_base);
ErrorF ("Leave %s 0x%x\n", function, offset);
} else
ErrorF ("Leave %s\n", function);
}
#endif
/* Assumes that depth 15 and 16 can be used as depth 16, which is okay since we
* require src and dest datatypes to be equal.
*/
static Bool
ATIGetDatatypeBpp(int bpp, CARD32 *type)
{
switch (bpp) {
case 8:
*type = R128_DATATYPE_CI8;
return TRUE;
case 16:
*type = R128_DATATYPE_RGB565;
return TRUE;
case 24:
*type = R128_DATATYPE_CI8;
return TRUE;
case 32:
*type = R128_DATATYPE_ARGB8888;
return TRUE;
default:
ATI_FALLBACK(("Unsupported bpp: %d\n", bpp));
return FALSE;
}
}
Bool
ATIGetOffsetPitch(ATIScreenInfo *atis, int bpp, CARD32 *pitch_offset,
int offset, int pitch)
{
ATICardInfo *atic = atis->atic;
/* On the R128, depending on the bpp the screen can be set up so that it
* doesn't meet the pitchAlign requirement but can still be
* accelerated, so we check the specific pitch requirement of alignment
* to 8 pixels.
*/
if (atic->is_radeon) {
if (pitch % atis->kaa.pitchAlign != 0)
ATI_FALLBACK(("Bad pitch 0x%08x\n", pitch));
*pitch_offset = ((pitch >> 6) << 22) | (offset >> 10);
} else {
if (pitch % bpp != 0)
ATI_FALLBACK(("Bad pitch 0x%08x\n", pitch));
*pitch_offset = ((pitch / bpp) << 21) | (offset >> 5);
}
if (offset % atis->kaa.offsetAlign != 0)
ATI_FALLBACK(("Bad offset 0x%08x\n", offset));
return TRUE;
}
Bool
ATIGetPixmapOffsetPitch(PixmapPtr pPix, CARD32 *pitch_offset)
{
KdScreenPriv(pPix->drawable.pScreen);
ATIScreenInfo(pScreenPriv);
CARD32 pitch, offset;
int bpp;
bpp = pPix->drawable.bitsPerPixel;
if (bpp == 24)
bpp = 8;
offset = ((CARD8 *)pPix->devPrivate.ptr -
pScreenPriv->screen->memory_base);
pitch = pPix->devKind;
return ATIGetOffsetPitch(atis, bpp, pitch_offset, offset, pitch);
}
static Bool
ATIPrepareSolid(PixmapPtr pPix, int alu, Pixel pm, Pixel fg)
{
KdScreenPriv(pPix->drawable.pScreen);
ATIScreenInfo(pScreenPriv);
ATICardInfo(pScreenPriv);
CARD32 datatype;
RING_LOCALS;
is_24bpp = (pPix->drawable.bitsPerPixel == 24);
accel_atis = atis;
if (is_24bpp) {
/* Solid fills in fake-24bpp mode only work if the pixel color
* and planemask are all the same byte.
*/
if ((fg & 0xffffff) != (((fg & 0xff) << 16) | ((fg >> 8) &
0xffff)))
ATI_FALLBACK(("Can't do solid color 0x%08x in 24bpp\n",
fg));
if ((pm & 0xffffff) != (((pm & 0xff) << 16) | ((pm >> 8) &
0xffff)))
ATI_FALLBACK(("Can't do planemask 0x%08x in 24bpp\n",
pm));
}
if (!ATIGetDatatypeBpp(pPix->drawable.bitsPerPixel, &datatype))
return FALSE;
if (!ATIGetPixmapOffsetPitch(pPix, &dst_pitch_offset))
return FALSE;
ENTER_DRAW(pPix);
if (atic->is_radeon)
RadeonSwitchTo2D(atis);
settings =
ATI_GMC_DST_PITCH_OFFSET_CNTL |
ATI_GMC_BRUSH_SOLID_COLOR |
(datatype << 8) |
ATI_GMC_SRC_DATATYPE_COLOR |
(ATISolidRop[alu] << 16) |
ATI_GMC_CLR_CMP_CNTL_DIS |
R128_GMC_AUX_CLIP_DIS;
color = fg;
#if DRAW_USING_PACKET3
BEGIN_DMA(6);
OUT_REG(ATI_REG_DEFAULT_SC_BOTTOM_RIGHT,
ATI_DEFAULT_SC_RIGHT_MAX | ATI_DEFAULT_SC_BOTTOM_MAX);
OUT_REG(ATI_REG_DP_WRITE_MASK, pm);
OUT_REG(ATI_REG_DP_CNTL, ATI_DST_X_LEFT_TO_RIGHT |
ATI_DST_Y_TOP_TO_BOTTOM);
END_DMA();
#else
BEGIN_DMA(12);
OUT_REG(ATI_REG_DEFAULT_SC_BOTTOM_RIGHT,
ATI_DEFAULT_SC_RIGHT_MAX | ATI_DEFAULT_SC_BOTTOM_MAX);
OUT_REG(ATI_REG_DST_PITCH_OFFSET, dst_pitch_offset);
OUT_REG(ATI_REG_DP_GUI_MASTER_CNTL, settings);
OUT_REG(ATI_REG_DP_BRUSH_FRGD_CLR, fg);
OUT_REG(ATI_REG_DP_WRITE_MASK, pm);
OUT_REG(ATI_REG_DP_CNTL, ATI_DST_X_LEFT_TO_RIGHT |
ATI_DST_Y_TOP_TO_BOTTOM);
END_DMA();
#endif
LEAVE_DRAW(pPix);
return TRUE;
}
static void
ATISolid(int x1, int y1, int x2, int y2)
{
ENTER_DRAW(0);
ATIScreenInfo *atis = accel_atis;
RING_LOCALS;
if (is_24bpp) {
x1 *= 3;
x2 *= 3;
}
#if DRAW_USING_PACKET3
BEGIN_DMA(6);
OUT_RING(DMA_PACKET3(ATI_CCE_PACKET3_PAINT_MULTI, 5));
OUT_RING(settings);
OUT_RING(dst_pitch_offset);
OUT_RING(color);
OUT_RING((x1 << 16) | y1);
OUT_RING(((x2 - x1) << 16) | (y2 - y1));
END_DMA();
#else
BEGIN_DMA(3);
OUT_RING(DMA_PACKET0(ATI_REG_DST_Y_X, 2));
OUT_RING_REG(ATI_REG_DST_Y_X, (y1 << 16) | x1);
OUT_RING_REG(ATI_REG_DST_HEIGHT_WIDTH, ((y2 - y1) << 16) | (x2 - x1));
END_DMA();
#endif
LEAVE_DRAW(0);
}
static void
ATIDoneSolid(void)
{
ENTER_DRAW(0);
LEAVE_DRAW(0);
}
static Bool
ATIPrepareCopy(PixmapPtr pSrc, PixmapPtr pDst, int dx, int dy, int alu, Pixel pm)
{
KdScreenPriv(pDst->drawable.pScreen);
ATIScreenInfo(pScreenPriv);
ATICardInfo(pScreenPriv);
CARD32 datatype;
RING_LOCALS;
copydx = dx;
copydy = dy;
is_24bpp = pDst->drawable.bitsPerPixel == 24;
accel_atis = atis;
if (is_24bpp && ((pm & 0xffffff) != (((pm & 0xff) << 16) | ((pm >> 8) &
0xffff))))
ATI_FALLBACK(("Can't do planemask 0x%08x in 24bpp\n", pm));
if (!ATIGetDatatypeBpp(pDst->drawable.bitsPerPixel, &datatype))
return FALSE;
if (!ATIGetPixmapOffsetPitch(pSrc, &src_pitch_offset))
return FALSE;
if (!ATIGetPixmapOffsetPitch(pDst, &dst_pitch_offset))
return FALSE;
ENTER_DRAW (pDst);
if (atic->is_radeon)
RadeonSwitchTo2D(atis);
settings =
ATI_GMC_SRC_PITCH_OFFSET_CNTL |
ATI_GMC_DST_PITCH_OFFSET_CNTL |
ATI_GMC_BRUSH_NONE |
(datatype << 8) |
ATI_GMC_SRC_DATATYPE_COLOR |
(ATIBltRop[alu] << 16) |
ATI_DP_SRC_SOURCE_MEMORY |
ATI_GMC_CLR_CMP_CNTL_DIS |
R128_GMC_AUX_CLIP_DIS;
#if DRAW_USING_PACKET3
BEGIN_DMA(6);
OUT_REG(ATI_REG_DEFAULT_SC_BOTTOM_RIGHT,
ATI_DEFAULT_SC_RIGHT_MAX | ATI_DEFAULT_SC_BOTTOM_MAX);
OUT_REG(ATI_REG_DP_WRITE_MASK, pm);
OUT_REG(ATI_REG_DP_CNTL,
(dx >= 0 ? ATI_DST_X_LEFT_TO_RIGHT : 0) |
(dy >= 0 ? ATI_DST_Y_TOP_TO_BOTTOM : 0));
END_DMA();
#else
BEGIN_DMA(12);
OUT_REG(ATI_REG_DEFAULT_SC_BOTTOM_RIGHT,
ATI_DEFAULT_SC_RIGHT_MAX | ATI_DEFAULT_SC_BOTTOM_MAX);
OUT_REG(ATI_REG_SRC_PITCH_OFFSET, src_pitch_offset);
OUT_REG(ATI_REG_DST_PITCH_OFFSET, dst_pitch_offset);
OUT_REG(ATI_REG_DP_GUI_MASTER_CNTL, settings);
OUT_REG(ATI_REG_DP_WRITE_MASK, pm);
OUT_REG(ATI_REG_DP_CNTL,
(dx >= 0 ? ATI_DST_X_LEFT_TO_RIGHT : 0) |
(dy >= 0 ? ATI_DST_Y_TOP_TO_BOTTOM : 0));
END_DMA();
#endif
LEAVE_DRAW(pDst);
return TRUE;
}
static void
ATICopy(int srcX, int srcY, int dstX, int dstY, int w, int h)
{
ATIScreenInfo *atis = accel_atis;
RING_LOCALS;
if (is_24bpp) {
srcX *= 3;
dstX *= 3;
w *= 3;
}
#if !DRAW_USING_PACKET3
if (copydx < 0) {
srcX += w - 1;
dstX += w - 1;
}
if (copydy < 0) {
srcY += h - 1;
dstY += h - 1;
}
#endif
#if DRAW_USING_PACKET3
BEGIN_DMA(7);
OUT_RING(DMA_PACKET3(ATI_CCE_PACKET3_BITBLT_MULTI, 6));
OUT_RING(settings);
OUT_RING(src_pitch_offset);
OUT_RING(dst_pitch_offset);
OUT_RING((srcX << 16) | srcY);
OUT_RING((dstX << 16) | dstY);
OUT_RING((w << 16) | h);
END_DMA();
#else
BEGIN_DMA(4);
OUT_RING(DMA_PACKET0(ATI_REG_SRC_Y_X, 3));
OUT_RING_REG(ATI_REG_SRC_Y_X, (srcY << 16) | srcX);
OUT_RING_REG(ATI_REG_DST_Y_X, (dstY << 16) | dstX);
OUT_RING_REG(ATI_REG_DST_HEIGHT_WIDTH, (h << 16) | w);
END_DMA();
#endif
}
static void
ATIDoneCopy(void)
{
}
static Bool
ATIUploadToScreen(PixmapPtr pDst, char *src, int src_pitch)
{
ScreenPtr pScreen = pDst->drawable.pScreen;
KdScreenPriv(pScreen);
ATIScreenInfo(pScreenPriv);
ATICardInfo(pScreenPriv);
int width, height, bpp, i, dwords;
int dst_pitch, dst_offset;
CARD32 dst_pitch_offset, datatype;
Bool success;
RING_LOCALS;
ENTER_DRAW (pDst);
LEAVE_DRAW (pDst);
/* XXX: Hostdata uploads aren't working yet. */
return FALSE;
dst_offset = ((CARD8 *)pDst->devPrivate.ptr -
pScreenPriv->screen->memory_base);
dst_pitch = pDst->devKind;
width = pDst->drawable.width;
height = pDst->drawable.height;
bpp = pDst->drawable.bitsPerPixel;
success = ATIGetDatatypeBpp(bpp, &datatype);
if (bpp == 24) {
is_24bpp = TRUE;
bpp = 8;
} else
is_24bpp = FALSE;
if (!ATIGetOffsetPitch(atis, bpp, &dst_pitch_offset, dst_offset,
dst_pitch))
return FALSE;
if (src_pitch != (width * bpp / 8))
return FALSE;
/* No PACKET3 packets when in PIO mode. */
if (atis->using_pio)
return FALSE;
dwords = (width * height * (bpp / 8) + 3) / 4;
/* Flush pixel cache so nothing being written to the destination
* previously gets mixed up with the hostdata blit.
*/
if (atic->is_radeon) {
BEGIN_DMA(4);
OUT_REG(RADEON_REG_RB3D_DSTCACHE_CTLSTAT, RADEON_RB3D_DC_FLUSH);
OUT_REG(ATI_REG_WAIT_UNTIL,
RADEON_WAIT_2D_IDLECLEAN |
RADEON_WAIT_3D_IDLECLEAN |
RADEON_WAIT_HOST_IDLECLEAN);
END_DMA();
} else {
BEGIN_DMA(2);
OUT_REG(R128_REG_PC_GUI_CTLSTAT,
R128_PC_FLUSH_GUI | R128_PC_RI_GUI);
END_DMA();
}
BEGIN_DMA(8);
OUT_RING(DMA_PACKET3(ATI_CCE_PACKET3_HOSTDATA_BLT, 7 + dwords));
OUT_RING(ATI_GMC_DST_PITCH_OFFSET_CNTL |
ATI_GMC_BRUSH_NONE |
(datatype << 8) |
ATI_GMC_SRC_DATATYPE_COLOR |
(ATISolidRop[GXcopy] << 16) |
ATI_DP_SRC_SOURCE_HOST_DATA |
ATI_GMC_CLR_CMP_CNTL_DIS |
R128_GMC_AUX_CLIP_DIS |
ATI_GMC_WR_MSK_DIS);
OUT_RING(dst_pitch_offset);
OUT_RING(0xffffffff);
OUT_RING(0xffffffff);
OUT_RING((0 << 16) | 0);
OUT_RING((height << 16) | width);
OUT_RING(dwords);
END_DMA();
for (i = 0; i < dwords; i++) {
BEGIN_DMA(1);
OUT_RING(((CARD32 *)src)[i]);
END_DMA();
}
if (atic->is_radeon) {
BEGIN_DMA(4);
OUT_REG(RADEON_REG_RB3D_DSTCACHE_CTLSTAT,
RADEON_RB3D_DC_FLUSH_ALL);
OUT_REG(ATI_REG_WAIT_UNTIL,
RADEON_WAIT_2D_IDLECLEAN |
RADEON_WAIT_HOST_IDLECLEAN);
END_DMA();
} else {
BEGIN_DMA(2);
OUT_REG(R128_REG_PC_GUI_CTLSTAT, R128_PC_FLUSH_GUI);
END_DMA();
}
kaaMarkSync(pScreen);
ErrorF("hostdata upload %d,%d %dbpp\n", width, height, bpp);
return TRUE;
}
static Bool
ATIUploadToScratch(PixmapPtr pSrc, PixmapPtr pDst)
{
KdScreenPriv(pSrc->drawable.pScreen);
ATICardInfo(pScreenPriv);
ATIScreenInfo(pScreenPriv);
int dst_pitch, src_pitch, w, i, size, bytes;
unsigned char *dst, *src;
RING_LOCALS;
ENTER_DRAW(pSrc);
/* Align width to log 2, useful for R128 composite. This should be a
* KAA flag we check for (and supported in kaa.c in general) since many
* older bits of hardware are going to want POT pitches.
*/
w = pSrc->drawable.width;
if (atis->kaa.flags & KAA_OFFSCREEN_ALIGN_POT)
w = 1 << (ATILog2(w - 1) + 1);
dst_pitch = (w * pSrc->drawable.bitsPerPixel / 8 +
atis->kaa.pitchAlign - 1) & ~(atis->kaa.pitchAlign - 1);
size = dst_pitch * pSrc->drawable.height;
if (size > atis->scratch_area->size)
ATI_FALLBACK(("Pixmap too large for scratch (%d,%d)\n",
pSrc->drawable.width, pSrc->drawable.height));
atis->scratch_next = (atis->scratch_next + atis->kaa.offsetAlign - 1) &
~(atis->kaa.offsetAlign - 1);
if (atis->scratch_next + size > atis->scratch_area->offset +
atis->scratch_area->size) {
/* Only sync when we've used all of the scratch area. */
kaaWaitSync(pSrc->drawable.pScreen);
atis->scratch_next = atis->scratch_area->offset;
}
memcpy(pDst, pSrc, sizeof(*pDst));
pDst->devKind = dst_pitch;
pDst->devPrivate.ptr = pScreenPriv->screen->memory_base +
atis->scratch_next;
atis->scratch_next += size;
src = pSrc->devPrivate.ptr;
src_pitch = pSrc->devKind;
dst = pDst->devPrivate.ptr;
bytes = src_pitch < dst_pitch ? src_pitch : dst_pitch;
i = pSrc->drawable.height;
while (i--) {
memcpy(dst, src, bytes);
dst += dst_pitch;
src += src_pitch;
}
/* Flush the pixel cache */
if (atic->is_radeon) {
BEGIN_DMA(4);
OUT_REG(RADEON_REG_RB3D_DSTCACHE_CTLSTAT,
RADEON_RB3D_DC_FLUSH_ALL);
OUT_REG(ATI_REG_WAIT_UNTIL, RADEON_WAIT_HOST_IDLECLEAN);
END_DMA();
} else {
BEGIN_DMA(2);
OUT_REG(R128_REG_PC_GUI_CTLSTAT, R128_PC_FLUSH_ALL);
END_DMA();
}
LEAVE_DRAW(pSrc);
return TRUE;
}
static void
ATIBlockHandler(pointer blockData, OSTimePtr timeout, pointer readmask)
{
ScreenPtr pScreen = (ScreenPtr) blockData;
KdScreenPriv(pScreen);
ATIScreenInfo(pScreenPriv);
/* When the server is going to sleep, make sure that all DMA data has
* been flushed.
*/
if (atis->indirectBuffer)
ATIFlushIndirect(atis, 1);
}
static void
ATIWakeupHandler(pointer blockData, int result, pointer readmask)
{
}
Bool
ATIDrawInit(ScreenPtr pScreen)
{
KdScreenPriv(pScreen);
ATIScreenInfo(pScreenPriv);
ATICardInfo(pScreenPriv);
ErrorF("Screen: %d/%d depth/bpp\n", pScreenPriv->screen->fb[0].depth,
pScreenPriv->screen->fb[0].bitsPerPixel);
RegisterBlockAndWakeupHandlers(ATIBlockHandler, ATIWakeupHandler,
pScreen);
#ifdef USE_DRI
atis->using_dri = ATIDRIScreenInit(pScreen);
#endif /* USE_DRI */
memset(&atis->kaa, 0, sizeof(KaaScreenInfoRec));
atis->kaa.waitMarker = ATIWaitMarker;
atis->kaa.PrepareSolid = ATIPrepareSolid;
atis->kaa.Solid = ATISolid;
atis->kaa.DoneSolid = ATIDoneSolid;
atis->kaa.PrepareCopy = ATIPrepareCopy;
atis->kaa.Copy = ATICopy;
atis->kaa.DoneCopy = ATIDoneCopy;
/* Other acceleration will be hooked in in DrawEnable depending on
* what type of DMA gets initialized.
*/
atis->kaa.flags = KAA_OFFSCREEN_PIXMAPS;
if (atic->is_radeon) {
atis->kaa.offsetAlign = 1024;
atis->kaa.pitchAlign = 64;
} else {
/* Rage 128 compositing wants power-of-two pitches. */
atis->kaa.flags |= KAA_OFFSCREEN_ALIGN_POT;
atis->kaa.offsetAlign = 32;
/* Pitch alignment is in sets of 8 pixels, and we need to cover
* 32bpp, so 32 bytes.
*/
atis->kaa.pitchAlign = 32;
}
kaaInitTrapOffsets(8, sample_offsets_x, sample_offsets_y, 0.0, 0.0);
sample_count = (1 << 8) - 1;
if (!kaaDrawInit(pScreen, &atis->kaa))
return FALSE;
return TRUE;
}
static void
ATIScratchSave(ScreenPtr pScreen, KdOffscreenArea *area)
{
KdScreenPriv(pScreen);
ATIScreenInfo(pScreenPriv);
atis->scratch_area = NULL;
}
void
ATIDrawEnable(ScreenPtr pScreen)
{
KdScreenPriv(pScreen);
ATIScreenInfo(pScreenPriv);
ATICardInfo(pScreenPriv);
ATIDMASetup(pScreen);
ATIDrawSetup(pScreen);
atis->scratch_area = NULL;
atis->kaa.PrepareBlend = NULL;
atis->kaa.Blend = NULL;
atis->kaa.DoneBlend = NULL;
atis->kaa.CheckComposite = NULL;
atis->kaa.PrepareComposite = NULL;
atis->kaa.Composite = NULL;
atis->kaa.DoneComposite = NULL;
atis->kaa.UploadToScreen = NULL;
atis->kaa.UploadToScratch = NULL;
/* We can't dispatch 3d commands in PIO mode. */
if (!atis->using_pio) {
if (!atic->is_radeon) {
atis->kaa.CheckComposite = R128CheckComposite;
atis->kaa.PrepareComposite = R128PrepareComposite;
atis->kaa.Composite = R128Composite;
atis->kaa.DoneComposite = R128DoneComposite;
} else if (atic->is_r100) {
atis->kaa.CheckComposite = R100CheckComposite;
atis->kaa.PrepareComposite = R100PrepareComposite;
atis->kaa.Composite = RadeonComposite;
atis->kaa.DoneComposite = RadeonDoneComposite;
} else if (atic->is_r200) {
atis->kaa.CheckComposite = R200CheckComposite;
atis->kaa.PrepareComposite = R200PrepareComposite;
atis->kaa.Composite = RadeonComposite;
atis->kaa.DoneComposite = RadeonDoneComposite;
}
}
#ifdef USE_DRI
if (atis->using_dri) {
if (!atic->is_radeon) {
/*atis->kaa.PrepareTrapezoids = R128PrepareTrapezoids;
atis->kaa.Trapezoids = R128Trapezoids;
atis->kaa.DoneTrapezoids = R128DoneTrapezoids;*/
} else if (atic->is_r100 || atic->is_r200) {
atis->kaa.PrepareTrapezoids = RadeonPrepareTrapezoids;
atis->kaa.Trapezoids = RadeonTrapezoids;
atis->kaa.DoneTrapezoids = RadeonDoneTrapezoids;
}
}
#endif /* USE_DRI */
atis->kaa.UploadToScreen = ATIUploadToScreen;
/* Reserve a scratch area. It'll be used for storing glyph data during
* Composite operations, because glyphs aren't in real pixmaps and thus
* can't be migrated.
*/
atis->scratch_area = KdOffscreenAlloc(pScreen, 131072,
atis->kaa.offsetAlign, TRUE, ATIScratchSave, atis);
if (atis->scratch_area != NULL) {
atis->scratch_next = atis->scratch_area->offset;
atis->kaa.UploadToScratch = ATIUploadToScratch;
}
kaaMarkSync(pScreen);
}
void
ATIDrawDisable(ScreenPtr pScreen)
{
kaaWaitSync(pScreen);
ATIDMATeardown(pScreen);
}
void
ATIDrawFini(ScreenPtr pScreen)
{
#ifdef USE_DRI
KdScreenPriv(pScreen);
ATIScreenInfo(pScreenPriv);
if (atis->using_dri) {
ATIDRICloseScreen(pScreen);
atis->using_dri = FALSE;
}
#endif /* USE_DRI */
RemoveBlockAndWakeupHandlers(ATIBlockHandler, ATIWakeupHandler,
pScreen);
kaaDrawFini(pScreen);
}

View File

@ -1,93 +0,0 @@
/*
* Copyright © 2004 Eric Anholt
*
* 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 Eric Anholt not be used in
* advertising or publicity pertaining to distribution of the software without
* specific, written prior permission. Eric Anholt makes no
* representations about the suitability of this software for any purpose. It
* is provided "as is" without express or implied warranty.
*
* ERIC ANHOLT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL ERIC ANHOLT 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.
*/
#ifndef _ATI_DRAW_H_
#define _ATI_DRAW_H_
Bool ATIGetOffsetPitch(ATIScreenInfo *atis, int bpp, CARD32 *pitch_offset,
int offset, int pitch);
Bool ATIGetPixmapOffsetPitch(PixmapPtr pPix, CARD32 *pitch_offset);
Bool R128CheckComposite(int op, PicturePtr pSrcPicture, PicturePtr pMaskPicture,
PicturePtr pDstPicture);
Bool R128PrepareComposite(int op, PicturePtr pSrcPicture,
PicturePtr pMaskPicture, PicturePtr pDstPicture, PixmapPtr pSrc,
PixmapPtr pMask, PixmapPtr pDst);
void R128Composite(int srcX, int srcY, int maskX, int maskY, int dstX, int dstY,
int w, int h);
void R128DoneComposite(void);
Bool R128PrepareTrapezoids(PicturePtr pDstPicture, PixmapPtr pDst);
void R128Trapezoids(KaaTrapezoid *traps, int ntraps);
void R128DoneTrapezoids(void);
Bool R100CheckComposite(int op, PicturePtr pSrcPicture, PicturePtr pMaskPicture,
PicturePtr pDstPicture);
Bool R100PrepareComposite(int op, PicturePtr pSrcPicture,
PicturePtr pMaskPicture, PicturePtr pDstPicture, PixmapPtr pSrc,
PixmapPtr pMask, PixmapPtr pDst);
Bool R200CheckComposite(int op, PicturePtr pSrcPicture, PicturePtr pMaskPicture,
PicturePtr pDstPicture);
Bool R200PrepareComposite(int op, PicturePtr pSrcPicture,
PicturePtr pMaskPicture, PicturePtr pDstPicture, PixmapPtr pSrc,
PixmapPtr pMask, PixmapPtr pDst);
void RadeonComposite(int srcX, int srcY, int maskX, int maskY, int dstX,
int dstY, int w, int h);
void RadeonDoneComposite(void);
Bool RadeonPrepareTrapezoids(PicturePtr pDstPicture, PixmapPtr pDst);
void RadeonTrapezoids(KaaTrapezoid *traps, int ntraps);
void RadeonDoneTrapezoids(void);
void RadeonSwitchTo2D(ATIScreenInfo *atis);
void RadeonSwitchTo3D(ATIScreenInfo *atis);
void ATIWaitIdle(ATIScreenInfo *atis);
#define ATI_TRACE_FALL 0
#define ATI_TRACE_DRAW 0
#if ATI_TRACE_FALL
#define ATI_FALLBACK(x) \
do { \
ErrorF("%s: ", __FUNCTION__); \
ErrorF x; \
return FALSE; \
} while (0)
#else
#define ATI_FALLBACK(x) return FALSE
#endif
#if ATI_TRACE_DRAW
#define ENTER_DRAW(pix) ATIEnterDraw(pix, __FUNCTION__)
#define LEAVE_DRAW(pix) ATILeaveDraw(pix, __FUNCTION__)
void
ATIEnterDraw (PixmapPtr pPixmap, char *function);
void
ATILeaveDraw (PixmapPtr pPixmap, char *function);
#else /* ATI_TRACE */
#define ENTER_DRAW(pix)
#define LEAVE_DRAW(pix)
#endif /* !ATI_TRACE */
#endif /* _ATI_DRAW_H_ */

View File

@ -1,237 +0,0 @@
/*
* Copyright © 2003 Eric Anholt
*
* 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 Eric Anholt not be used in
* advertising or publicity pertaining to distribution of the software without
* specific, written prior permission. Eric Anholt makes no
* representations about the suitability of this software for any purpose. It
* is provided "as is" without express or implied warranty.
*
* ERIC ANHOLT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL ERIC ANHOLT 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.
*/
#ifdef USE_DMA
#define TAG(x) x##DMA
#define LOCALS RING_LOCALS; \
(void)atic
#define BEGIN(x) BEGIN_RING(x * 2)
#define OUT_REG(reg, val) OUT_RING_REG(reg, val)
#define END() ADVANCE_RING()
#else
#define TAG(x) x##MMIO
#define LOCALS char *mmio = atic->reg_base; \
(void)atis
#define BEGIN(x) ATIWaitAvailMMIO(x)
#define OUT_REG(reg, val) MMIO_OUT32((mmio), (reg), (val))
#define END()
#endif
static Bool
TAG(ATISetup)(PixmapPtr pDst, PixmapPtr pSrc)
{
KdScreenPriv(pDst->drawable.pScreen);
ATIScreenInfo(pScreenPriv);
ATICardInfo(pScreenPriv);
int dst_offset, dst_pitch;
int bpp = pDst->drawable.bitsPerPixel;
LOCALS;
accel_atis = atis;
dst_pitch = pDst->devKind;
dst_offset = ((CARD8 *)pDst->devPrivate.ptr -
pScreenPriv->screen->memory_base);
if ((dst_pitch & (atis->kaa.offscreenPitch - 1)) != 0)
ATI_FALLBACK(("Bad dst pitch 0x%x\n", dst_pitch));
if ((dst_offset & (atis->kaa.offscreenByteAlign - 1)) != 0)
ATI_FALLBACK(("Bad dst offset 0x%x\n", dst_offset));
if (pSrc != NULL) {
src_pitch = pSrc->devKind;
src_offset = ((CARD8 *)pSrc->devPrivate.ptr -
pScreenPriv->screen->memory_base);
if ((src_pitch & (atis->kaa.offscreenPitch - 1)) != 0)
ATI_FALLBACK(("Bad src pitch 0x%x\n", src_pitch));
if ((src_offset & (atis->kaa.offscreenByteAlign - 1)) != 0)
ATI_FALLBACK(("Bad src offset 0x%x\n", src_offset));
}
#ifdef USE_DMA
if (atic->is_radeon && !atic->is_r200)
RadeonSwitchTo2D();
#endif
BEGIN((pSrc != NULL) ? 3 : 2);
if (atic->is_radeon) {
OUT_REG(RADEON_REG_DST_PITCH_OFFSET,
((dst_pitch >> 6) << 22) | (dst_offset >> 10));
if (pSrc != NULL) {
OUT_REG(RADEON_REG_SRC_PITCH_OFFSET,
((src_pitch >> 6) << 22) | (src_offset >> 10));
}
} else {
if (is_24bpp) {
dst_pitch *= 3;
src_pitch *= 3;
}
/* R128 pitch is in units of 8 pixels, offset in 32 bytes */
OUT_REG(RADEON_REG_DST_PITCH_OFFSET,
((dst_pitch/bpp) << 21) | (dst_offset >> 5));
if (pSrc != NULL) {
OUT_REG(RADEON_REG_SRC_PITCH_OFFSET,
((src_pitch/bpp) << 21) | (src_offset >> 5));
}
}
OUT_REG(RADEON_REG_DEFAULT_SC_BOTTOM_RIGHT,
(RADEON_DEFAULT_SC_RIGHT_MAX | RADEON_DEFAULT_SC_BOTTOM_MAX));
END();
return TRUE;
}
static Bool
TAG(ATIPrepareSolid)(PixmapPtr pPixmap, int alu, Pixel pm, Pixel fg)
{
KdScreenPriv(pPixmap->drawable.pScreen);
ATIScreenInfo(pScreenPriv);
ATICardInfo(pScreenPriv);
CARD32 datatype;
LOCALS;
if (is_24bpp) {
/* Solid fills in fake-24bpp mode only work if the pixel color
* and planemask are all the same byte.
*/
if ((fg & 0xffffff) != (((fg & 0xff) << 16) | ((fg >> 8) &
0xffff)))
ATI_FALLBACK(("Can't do solid color %d in 24bpp\n"));
if ((pm & 0xffffff) != (((pm & 0xff) << 16) | ((pm >> 8) &
0xffff)))
ATI_FALLBACK(("Can't do planemask %d in 24bpp\n"));
}
if (!ATIGetDatatypeBpp(pPixmap->drawable.bitsPerPixel, &datatype))
return FALSE;
if (!TAG(ATISetup)(pPixmap, NULL))
return FALSE;
BEGIN(4);
OUT_REG(RADEON_REG_DP_GUI_MASTER_CNTL,
(datatype << 8) |
RADEON_GMC_CLR_CMP_CNTL_DIS |
RADEON_GMC_AUX_CLIP_DIS |
RADEON_GMC_BRUSH_SOLID_COLOR |
RADEON_GMC_DST_PITCH_OFFSET_CNTL |
RADEON_GMC_SRC_DATATYPE_COLOR |
(ATISolidRop[alu] << 16));
OUT_REG(RADEON_REG_DP_BRUSH_FRGD_CLR, fg);
OUT_REG(RADEON_REG_DP_WRITE_MASK, pm);
OUT_REG(RADEON_REG_DP_CNTL, RADEON_DST_X_LEFT_TO_RIGHT |
RADEON_DST_Y_TOP_TO_BOTTOM);
END();
return TRUE;
}
static void
TAG(ATISolid)(int x1, int y1, int x2, int y2)
{
ATIScreenInfo *atis = accel_atis;
ATICardInfo *atic = atis->atic;
LOCALS;
if (is_24bpp) {
x1 *= 3;
x2 *= 3;
}
BEGIN(2);
OUT_REG(RADEON_REG_DST_Y_X, (y1 << 16) | x1);
OUT_REG(RADEON_REG_DST_WIDTH_HEIGHT, ((x2 - x1) << 16) | (y2 - y1));
END();
}
static Bool
TAG(ATIPrepareCopy)(PixmapPtr pSrc, PixmapPtr pDst, int dx, int dy, int alu, Pixel pm)
{
KdScreenPriv(pDst->drawable.pScreen);
ATIScreenInfo(pScreenPriv);
ATICardInfo(pScreenPriv);
CARD32 datatype;
LOCALS;
copydx = dx;
copydy = dy;
if (is_24bpp && ((pm & 0xffffff) != (((pm & 0xff) << 16) | ((pm >> 8) &
0xffff))))
ATI_FALLBACK(("Can't do planemask %d in 24bpp\n"));
if (!ATIGetDatatypeBpp(pDst->drawable.bitsPerPixel, &datatype))
return FALSE;
if (!TAG(ATISetup)(pDst, pSrc))
return FALSE;
BEGIN(3);
OUT_REG(RADEON_REG_DP_GUI_MASTER_CNTL,
(datatype << 8) |
RADEON_GMC_CLR_CMP_CNTL_DIS |
RADEON_GMC_AUX_CLIP_DIS |
RADEON_GMC_BRUSH_SOLID_COLOR |
RADEON_GMC_SRC_DATATYPE_COLOR |
(ATIBltRop[alu] << 16) |
RADEON_GMC_SRC_PITCH_OFFSET_CNTL |
RADEON_GMC_DST_PITCH_OFFSET_CNTL |
RADEON_DP_SRC_SOURCE_MEMORY);
OUT_REG(RADEON_REG_DP_WRITE_MASK, pm);
OUT_REG(RADEON_REG_DP_CNTL,
(dx >= 0 ? RADEON_DST_X_LEFT_TO_RIGHT : 0) |
(dy >= 0 ? RADEON_DST_Y_TOP_TO_BOTTOM : 0));
END();
return TRUE;
}
static void
TAG(ATICopy)(int srcX, int srcY, int dstX, int dstY, int w, int h)
{
ATIScreenInfo *atis = accel_atis;
ATICardInfo *atic = atis->atic;
LOCALS;
if (is_24bpp) {
srcX *= 3;
dstX *= 3;
w *= 3;
}
if (copydx < 0) {
srcX += w - 1;
dstX += w - 1;
}
if (copydy < 0) {
srcY += h - 1;
dstY += h - 1;
}
BEGIN(3);
OUT_REG(RADEON_REG_SRC_Y_X, (srcY << 16) | srcX);
OUT_REG(RADEON_REG_DST_Y_X, (dstY << 16) | dstX);
OUT_REG(RADEON_REG_DST_HEIGHT_WIDTH, (h << 16) | w);
END();
}
#undef TAG
#undef LOCALS
#undef BEGIN
#undef OUT_REG
#undef END

File diff suppressed because it is too large Load Diff

View File

@ -1,97 +0,0 @@
/*
* Copyright © 2003 Eric Anholt
*
* 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 Eric Anholt not be used in
* advertising or publicity pertaining to distribution of the software without
* specific, written prior permission. Eric Anholt makes no
* representations about the suitability of this software for any purpose. It
* is provided "as is" without express or implied warranty.
*
* ERIC ANHOLT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL ERIC ANHOLT 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.
*/
#ifndef _ATI_DRI_H_
#define _ATI_DRI_H_
typedef struct {
/* DRI screen private data */
int deviceID; /* PCI device ID */
int width; /* Width in pixels of display */
int height; /* Height in scanlines of display */
int depth; /* Depth of display (8, 15, 16, 24) */
int bpp; /* Bit depth of display (8, 16, 24, 32) */
int IsPCI; /* Current card is a PCI card */
int AGPMode;
int frontOffset; /* Start of front buffer */
int frontPitch;
int backOffset; /* Start of shared back buffer */
int backPitch;
int depthOffset; /* Start of shared depth buffer */
int depthPitch;
int spanOffset; /* Start of scratch spanline */
int textureOffset; /* Start of texture data in frame buffer */
int textureSize;
int log2TexGran;
/* MMIO register data */
drmHandle registerHandle;
drmSize registerSize;
/* CCE AGP Texture data */
drmHandle gartTexHandle;
drmSize gartTexMapSize;
int log2AGPTexGran;
int gartTexOffset;
unsigned int sarea_priv_offset;
} R128DRIRec, *R128DRIPtr;
typedef struct {
/* DRI screen private data */
int deviceID; /* PCI device ID */
int width; /* Width in pixels of display */
int height; /* Height in scanlines of display */
int depth; /* Depth of display (8, 15, 16, 24) */
int bpp; /* Bit depth of display (8, 16, 24, 32) */
int IsPCI; /* Current card is a PCI card */
int AGPMode;
int frontOffset; /* Start of front buffer */
int frontPitch;
int backOffset; /* Start of shared back buffer */
int backPitch;
int depthOffset; /* Start of shared depth buffer */
int depthPitch;
int textureOffset; /* Start of texture data in frame buffer */
int textureSize;
int log2TexGran;
/* MMIO register data */
drmHandle registerHandle;
drmSize registerSize;
/* CP in-memory status information */
drmHandle statusHandle;
drmSize statusSize;
/* CP GART Texture data */
drmHandle gartTexHandle;
drmSize gartTexMapSize;
int log2GARTTexGran;
int gartTexOffset;
unsigned int sarea_priv_offset;
} RADEONDRIRec, *RADEONDRIPtr;
#endif /* _ATI_DRI_H_ */

View File

@ -1,57 +0,0 @@
/*
* Copyright 1999, 2000 ATI Technologies Inc., Markham, Ontario,
* Precision Insight, Inc., Cedar Park, Texas, and
* VA Linux Systems Inc., Fremont, California.
*
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation on the rights to use, copy, modify, merge,
* publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) 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
* NON-INFRINGEMENT. IN NO EVENT SHALL ATI, PRECISION INSIGHT, VA LINUX
* SYSTEMS AND/OR THEIR SUPPLIERS 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.
*/
/*
* Authors:
* Rickard E. Faith <faith@valinux.com>
* Kevin E. Martin <martin@valinux.com>
*
*/
#ifndef _ATI_DRIPRIV_H_
#define _ATI_DRIPRIV_H_
#ifdef GLXEXT
#include "GL/glxint.h"
extern void GlxSetVisualConfigs(int nconfigs, __GLXvisualConfig *configs,
void **configprivs);
#endif
typedef struct {
/* Nothing here yet */
int dummy;
} ATIConfigPrivRec, *ATIConfigPrivPtr;
typedef struct {
/* Nothing here yet */
int dummy;
} ATIDRIContextRec, *ATIDRIContextPtr;
#endif

View File

@ -1,857 +0,0 @@
/* r128_cce.c -- ATI Rage 128 driver -*- linux-c -*-
* radeon_cp.c -- CP support for Radeon -*- linux-c -*-
*
* Copyright 2000 Precision Insight, Inc., Cedar Park, Texas.
* Copyright 2000 VA Linux Systems, Inc., Fremont, California.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) 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
* PRECISION INSIGHT AND/OR ITS SUPPLIERS 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.
*
* Authors:
* Kevin E. Martin <martin@valinux.com>
* Gareth Hughes <gareth@valinux.com>
*/
/* CCE microcode (from ATI) */
#include "ati.h"
CARD32 r128_cce_microcode[] = {
0, 276838400, 0, 268449792, 2, 142, 2, 145, 0, 1076765731, 0,
1617039951, 0, 774592877, 0, 1987540286, 0, 2307490946U, 0,
599558925, 0, 589505315, 0, 596487092, 0, 589505315, 1,
11544576, 1, 206848, 1, 311296, 1, 198656, 2, 912273422, 11,
262144, 0, 0, 1, 33559837, 1, 7438, 1, 14809, 1, 6615, 12, 28,
1, 6614, 12, 28, 2, 23, 11, 18874368, 0, 16790922, 1, 409600, 9,
30, 1, 147854772, 16, 420483072, 3, 8192, 0, 10240, 1, 198656,
1, 15630, 1, 51200, 10, 34858, 9, 42, 1, 33559823, 2, 10276, 1,
15717, 1, 15718, 2, 43, 1, 15936948, 1, 570480831, 1, 14715071,
12, 322123831, 1, 33953125, 12, 55, 1, 33559908, 1, 15718, 2,
46, 4, 2099258, 1, 526336, 1, 442623, 4, 4194365, 1, 509952, 1,
459007, 3, 0, 12, 92, 2, 46, 12, 176, 1, 15734, 1, 206848, 1,
18432, 1, 133120, 1, 100670734, 1, 149504, 1, 165888, 1,
15975928, 1, 1048576, 6, 3145806, 1, 15715, 16, 2150645232U, 2,
268449859, 2, 10307, 12, 176, 1, 15734, 1, 15735, 1, 15630, 1,
15631, 1, 5253120, 6, 3145810, 16, 2150645232U, 1, 15864, 2, 82,
1, 343310, 1, 1064207, 2, 3145813, 1, 15728, 1, 7817, 1, 15729,
3, 15730, 12, 92, 2, 98, 1, 16168, 1, 16167, 1, 16002, 1, 16008,
1, 15974, 1, 15975, 1, 15990, 1, 15976, 1, 15977, 1, 15980, 0,
15981, 1, 10240, 1, 5253120, 1, 15720, 1, 198656, 6, 110, 1,
180224, 1, 103824738, 2, 112, 2, 3145839, 0, 536885440, 1,
114880, 14, 125, 12, 206975, 1, 33559995, 12, 198784, 0,
33570236, 1, 15803, 0, 15804, 3, 294912, 1, 294912, 3, 442370,
1, 11544576, 0, 811612160, 1, 12593152, 1, 11536384, 1,
14024704, 7, 310382726, 0, 10240, 1, 14796, 1, 14797, 1, 14793,
1, 14794, 0, 14795, 1, 268679168, 1, 9437184, 1, 268449792, 1,
198656, 1, 9452827, 1, 1075854602, 1, 1075854603, 1, 557056, 1,
114880, 14, 159, 12, 198784, 1, 1109409213, 12, 198783, 1,
1107312059, 12, 198784, 1, 1109409212, 2, 162, 1, 1075854781, 1,
1073757627, 1, 1075854780, 1, 540672, 1, 10485760, 6, 3145894,
16, 274741248, 9, 168, 3, 4194304, 3, 4209949, 0, 0, 0, 256, 14,
174, 1, 114857, 1, 33560007, 12, 176, 0, 10240, 1, 114858, 1,
33560018, 1, 114857, 3, 33560007, 1, 16008, 1, 114874, 1,
33560360, 1, 114875, 1, 33560154, 0, 15963, 0, 256, 0, 4096, 1,
409611, 9, 188, 0, 10240, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};
CARD32 radeon_cp_microcode[][2] = {
{ 0x21007000, 0000000000 },
{ 0x20007000, 0000000000 },
{ 0x000000b4, 0x00000004 },
{ 0x000000b8, 0x00000004 },
{ 0x6f5b4d4c, 0000000000 },
{ 0x4c4c427f, 0000000000 },
{ 0x5b568a92, 0000000000 },
{ 0x4ca09c6d, 0000000000 },
{ 0xad4c4c4c, 0000000000 },
{ 0x4ce1af3d, 0000000000 },
{ 0xd8afafaf, 0000000000 },
{ 0xd64c4cdc, 0000000000 },
{ 0x4cd10d10, 0000000000 },
{ 0x000f0000, 0x00000016 },
{ 0x362f242d, 0000000000 },
{ 0x00000012, 0x00000004 },
{ 0x000f0000, 0x00000016 },
{ 0x362f282d, 0000000000 },
{ 0x000380e7, 0x00000002 },
{ 0x04002c97, 0x00000002 },
{ 0x000f0001, 0x00000016 },
{ 0x333a3730, 0000000000 },
{ 0x000077ef, 0x00000002 },
{ 0x00061000, 0x00000002 },
{ 0x00000021, 0x0000001a },
{ 0x00004000, 0x0000001e },
{ 0x00061000, 0x00000002 },
{ 0x00000021, 0x0000001a },
{ 0x00004000, 0x0000001e },
{ 0x00061000, 0x00000002 },
{ 0x00000021, 0x0000001a },
{ 0x00004000, 0x0000001e },
{ 0x00000017, 0x00000004 },
{ 0x0003802b, 0x00000002 },
{ 0x040067e0, 0x00000002 },
{ 0x00000017, 0x00000004 },
{ 0x000077e0, 0x00000002 },
{ 0x00065000, 0x00000002 },
{ 0x000037e1, 0x00000002 },
{ 0x040067e1, 0x00000006 },
{ 0x000077e0, 0x00000002 },
{ 0x000077e1, 0x00000002 },
{ 0x000077e1, 0x00000006 },
{ 0xffffffff, 0000000000 },
{ 0x10000000, 0000000000 },
{ 0x0003802b, 0x00000002 },
{ 0x040067e0, 0x00000006 },
{ 0x00007675, 0x00000002 },
{ 0x00007676, 0x00000002 },
{ 0x00007677, 0x00000002 },
{ 0x00007678, 0x00000006 },
{ 0x0003802c, 0x00000002 },
{ 0x04002676, 0x00000002 },
{ 0x00007677, 0x00000002 },
{ 0x00007678, 0x00000006 },
{ 0x0000002f, 0x00000018 },
{ 0x0000002f, 0x00000018 },
{ 0000000000, 0x00000006 },
{ 0x00000030, 0x00000018 },
{ 0x00000030, 0x00000018 },
{ 0000000000, 0x00000006 },
{ 0x01605000, 0x00000002 },
{ 0x00065000, 0x00000002 },
{ 0x00098000, 0x00000002 },
{ 0x00061000, 0x00000002 },
{ 0x64c0603e, 0x00000004 },
{ 0x000380e6, 0x00000002 },
{ 0x040025c5, 0x00000002 },
{ 0x00080000, 0x00000016 },
{ 0000000000, 0000000000 },
{ 0x0400251d, 0x00000002 },
{ 0x00007580, 0x00000002 },
{ 0x00067581, 0x00000002 },
{ 0x04002580, 0x00000002 },
{ 0x00067581, 0x00000002 },
{ 0x00000049, 0x00000004 },
{ 0x00005000, 0000000000 },
{ 0x000380e6, 0x00000002 },
{ 0x040025c5, 0x00000002 },
{ 0x00061000, 0x00000002 },
{ 0x0000750e, 0x00000002 },
{ 0x00019000, 0x00000002 },
{ 0x00011055, 0x00000014 },
{ 0x00000055, 0x00000012 },
{ 0x0400250f, 0x00000002 },
{ 0x0000504f, 0x00000004 },
{ 0x000380e6, 0x00000002 },
{ 0x040025c5, 0x00000002 },
{ 0x00007565, 0x00000002 },
{ 0x00007566, 0x00000002 },
{ 0x00000058, 0x00000004 },
{ 0x000380e6, 0x00000002 },
{ 0x040025c5, 0x00000002 },
{ 0x01e655b4, 0x00000002 },
{ 0x4401b0e4, 0x00000002 },
{ 0x01c110e4, 0x00000002 },
{ 0x26667066, 0x00000018 },
{ 0x040c2565, 0x00000002 },
{ 0x00000066, 0x00000018 },
{ 0x04002564, 0x00000002 },
{ 0x00007566, 0x00000002 },
{ 0x0000005d, 0x00000004 },
{ 0x00401069, 0x00000008 },
{ 0x00101000, 0x00000002 },
{ 0x000d80ff, 0x00000002 },
{ 0x0080006c, 0x00000008 },
{ 0x000f9000, 0x00000002 },
{ 0x000e00ff, 0x00000002 },
{ 0000000000, 0x00000006 },
{ 0x0000008f, 0x00000018 },
{ 0x0000005b, 0x00000004 },
{ 0x000380e6, 0x00000002 },
{ 0x040025c5, 0x00000002 },
{ 0x00007576, 0x00000002 },
{ 0x00065000, 0x00000002 },
{ 0x00009000, 0x00000002 },
{ 0x00041000, 0x00000002 },
{ 0x0c00350e, 0x00000002 },
{ 0x00049000, 0x00000002 },
{ 0x00051000, 0x00000002 },
{ 0x01e785f8, 0x00000002 },
{ 0x00200000, 0x00000002 },
{ 0x0060007e, 0x0000000c },
{ 0x00007563, 0x00000002 },
{ 0x006075f0, 0x00000021 },
{ 0x20007073, 0x00000004 },
{ 0x00005073, 0x00000004 },
{ 0x000380e6, 0x00000002 },
{ 0x040025c5, 0x00000002 },
{ 0x00007576, 0x00000002 },
{ 0x00007577, 0x00000002 },
{ 0x0000750e, 0x00000002 },
{ 0x0000750f, 0x00000002 },
{ 0x00a05000, 0x00000002 },
{ 0x00600083, 0x0000000c },
{ 0x006075f0, 0x00000021 },
{ 0x000075f8, 0x00000002 },
{ 0x00000083, 0x00000004 },
{ 0x000a750e, 0x00000002 },
{ 0x000380e6, 0x00000002 },
{ 0x040025c5, 0x00000002 },
{ 0x0020750f, 0x00000002 },
{ 0x00600086, 0x00000004 },
{ 0x00007570, 0x00000002 },
{ 0x00007571, 0x00000002 },
{ 0x00007572, 0x00000006 },
{ 0x000380e6, 0x00000002 },
{ 0x040025c5, 0x00000002 },
{ 0x00005000, 0x00000002 },
{ 0x00a05000, 0x00000002 },
{ 0x00007568, 0x00000002 },
{ 0x00061000, 0x00000002 },
{ 0x00000095, 0x0000000c },
{ 0x00058000, 0x00000002 },
{ 0x0c607562, 0x00000002 },
{ 0x00000097, 0x00000004 },
{ 0x000380e6, 0x00000002 },
{ 0x040025c5, 0x00000002 },
{ 0x00600096, 0x00000004 },
{ 0x400070e5, 0000000000 },
{ 0x000380e6, 0x00000002 },
{ 0x040025c5, 0x00000002 },
{ 0x000380e5, 0x00000002 },
{ 0x000000a8, 0x0000001c },
{ 0x000650aa, 0x00000018 },
{ 0x040025bb, 0x00000002 },
{ 0x000610ab, 0x00000018 },
{ 0x040075bc, 0000000000 },
{ 0x000075bb, 0x00000002 },
{ 0x000075bc, 0000000000 },
{ 0x00090000, 0x00000006 },
{ 0x00090000, 0x00000002 },
{ 0x000d8002, 0x00000006 },
{ 0x00007832, 0x00000002 },
{ 0x00005000, 0x00000002 },
{ 0x000380e7, 0x00000002 },
{ 0x04002c97, 0x00000002 },
{ 0x00007820, 0x00000002 },
{ 0x00007821, 0x00000002 },
{ 0x00007800, 0000000000 },
{ 0x01200000, 0x00000002 },
{ 0x20077000, 0x00000002 },
{ 0x01200000, 0x00000002 },
{ 0x20007000, 0x00000002 },
{ 0x00061000, 0x00000002 },
{ 0x0120751b, 0x00000002 },
{ 0x8040750a, 0x00000002 },
{ 0x8040750b, 0x00000002 },
{ 0x00110000, 0x00000002 },
{ 0x000380e5, 0x00000002 },
{ 0x000000c6, 0x0000001c },
{ 0x000610ab, 0x00000018 },
{ 0x844075bd, 0x00000002 },
{ 0x000610aa, 0x00000018 },
{ 0x840075bb, 0x00000002 },
{ 0x000610ab, 0x00000018 },
{ 0x844075bc, 0x00000002 },
{ 0x000000c9, 0x00000004 },
{ 0x804075bd, 0x00000002 },
{ 0x800075bb, 0x00000002 },
{ 0x804075bc, 0x00000002 },
{ 0x00108000, 0x00000002 },
{ 0x01400000, 0x00000002 },
{ 0x006000cd, 0x0000000c },
{ 0x20c07000, 0x00000020 },
{ 0x000000cf, 0x00000012 },
{ 0x00800000, 0x00000006 },
{ 0x0080751d, 0x00000006 },
{ 0000000000, 0000000000 },
{ 0x0000775c, 0x00000002 },
{ 0x00a05000, 0x00000002 },
{ 0x00661000, 0x00000002 },
{ 0x0460275d, 0x00000020 },
{ 0x00004000, 0000000000 },
{ 0x01e00830, 0x00000002 },
{ 0x21007000, 0000000000 },
{ 0x6464614d, 0000000000 },
{ 0x69687420, 0000000000 },
{ 0x00000073, 0000000000 },
{ 0000000000, 0000000000 },
{ 0x00005000, 0x00000002 },
{ 0x000380d0, 0x00000002 },
{ 0x040025e0, 0x00000002 },
{ 0x000075e1, 0000000000 },
{ 0x00000001, 0000000000 },
{ 0x000380e0, 0x00000002 },
{ 0x04002394, 0x00000002 },
{ 0x00005000, 0000000000 },
{ 0000000000, 0000000000 },
{ 0000000000, 0000000000 },
{ 0x00000008, 0000000000 },
{ 0x00000004, 0000000000 },
{ 0000000000, 0000000000 },
{ 0000000000, 0000000000 },
{ 0000000000, 0000000000 },
{ 0000000000, 0000000000 },
{ 0000000000, 0000000000 },
{ 0000000000, 0000000000 },
{ 0000000000, 0000000000 },
{ 0000000000, 0000000000 },
{ 0000000000, 0000000000 },
{ 0000000000, 0000000000 },
{ 0000000000, 0000000000 },
{ 0000000000, 0000000000 },
{ 0000000000, 0000000000 },
{ 0000000000, 0000000000 },
{ 0000000000, 0000000000 },
{ 0000000000, 0000000000 },
{ 0000000000, 0000000000 },
{ 0000000000, 0000000000 },
{ 0000000000, 0000000000 },
{ 0000000000, 0000000000 },
{ 0000000000, 0000000000 },
{ 0000000000, 0000000000 },
{ 0000000000, 0000000000 },
{ 0000000000, 0000000000 },
};
CARD32 r200_cp_microcode[][2] = {
{ 0x21007000, 0000000000 },
{ 0x20007000, 0000000000 },
{ 0x000000ab, 0x00000004 },
{ 0x000000af, 0x00000004 },
{ 0x66544a49, 0000000000 },
{ 0x49494174, 0000000000 },
{ 0x54517d83, 0000000000 },
{ 0x498d8b64, 0000000000 },
{ 0x49494949, 0000000000 },
{ 0x49da493c, 0000000000 },
{ 0x49989898, 0000000000 },
{ 0xd34949d5, 0000000000 },
{ 0x9dc90e11, 0000000000 },
{ 0xce9b9b9b, 0000000000 },
{ 0x000f0000, 0x00000016 },
{ 0x352e232c, 0000000000 },
{ 0x00000013, 0x00000004 },
{ 0x000f0000, 0x00000016 },
{ 0x352e272c, 0000000000 },
{ 0x000f0001, 0x00000016 },
{ 0x3239362f, 0000000000 },
{ 0x000077ef, 0x00000002 },
{ 0x00061000, 0x00000002 },
{ 0x00000020, 0x0000001a },
{ 0x00004000, 0x0000001e },
{ 0x00061000, 0x00000002 },
{ 0x00000020, 0x0000001a },
{ 0x00004000, 0x0000001e },
{ 0x00061000, 0x00000002 },
{ 0x00000020, 0x0000001a },
{ 0x00004000, 0x0000001e },
{ 0x00000016, 0x00000004 },
{ 0x0003802a, 0x00000002 },
{ 0x040067e0, 0x00000002 },
{ 0x00000016, 0x00000004 },
{ 0x000077e0, 0x00000002 },
{ 0x00065000, 0x00000002 },
{ 0x000037e1, 0x00000002 },
{ 0x040067e1, 0x00000006 },
{ 0x000077e0, 0x00000002 },
{ 0x000077e1, 0x00000002 },
{ 0x000077e1, 0x00000006 },
{ 0xffffffff, 0000000000 },
{ 0x10000000, 0000000000 },
{ 0x0003802a, 0x00000002 },
{ 0x040067e0, 0x00000006 },
{ 0x00007675, 0x00000002 },
{ 0x00007676, 0x00000002 },
{ 0x00007677, 0x00000002 },
{ 0x00007678, 0x00000006 },
{ 0x0003802b, 0x00000002 },
{ 0x04002676, 0x00000002 },
{ 0x00007677, 0x00000002 },
{ 0x00007678, 0x00000006 },
{ 0x0000002e, 0x00000018 },
{ 0x0000002e, 0x00000018 },
{ 0000000000, 0x00000006 },
{ 0x0000002f, 0x00000018 },
{ 0x0000002f, 0x00000018 },
{ 0000000000, 0x00000006 },
{ 0x01605000, 0x00000002 },
{ 0x00065000, 0x00000002 },
{ 0x00098000, 0x00000002 },
{ 0x00061000, 0x00000002 },
{ 0x64c0603d, 0x00000004 },
{ 0x00080000, 0x00000016 },
{ 0000000000, 0000000000 },
{ 0x0400251d, 0x00000002 },
{ 0x00007580, 0x00000002 },
{ 0x00067581, 0x00000002 },
{ 0x04002580, 0x00000002 },
{ 0x00067581, 0x00000002 },
{ 0x00000046, 0x00000004 },
{ 0x00005000, 0000000000 },
{ 0x00061000, 0x00000002 },
{ 0x0000750e, 0x00000002 },
{ 0x00019000, 0x00000002 },
{ 0x00011055, 0x00000014 },
{ 0x00000055, 0x00000012 },
{ 0x0400250f, 0x00000002 },
{ 0x0000504a, 0x00000004 },
{ 0x00007565, 0x00000002 },
{ 0x00007566, 0x00000002 },
{ 0x00000051, 0x00000004 },
{ 0x01e655b4, 0x00000002 },
{ 0x4401b0dc, 0x00000002 },
{ 0x01c110dc, 0x00000002 },
{ 0x2666705d, 0x00000018 },
{ 0x040c2565, 0x00000002 },
{ 0x0000005d, 0x00000018 },
{ 0x04002564, 0x00000002 },
{ 0x00007566, 0x00000002 },
{ 0x00000054, 0x00000004 },
{ 0x00401060, 0x00000008 },
{ 0x00101000, 0x00000002 },
{ 0x000d80ff, 0x00000002 },
{ 0x00800063, 0x00000008 },
{ 0x000f9000, 0x00000002 },
{ 0x000e00ff, 0x00000002 },
{ 0000000000, 0x00000006 },
{ 0x00000080, 0x00000018 },
{ 0x00000054, 0x00000004 },
{ 0x00007576, 0x00000002 },
{ 0x00065000, 0x00000002 },
{ 0x00009000, 0x00000002 },
{ 0x00041000, 0x00000002 },
{ 0x0c00350e, 0x00000002 },
{ 0x00049000, 0x00000002 },
{ 0x00051000, 0x00000002 },
{ 0x01e785f8, 0x00000002 },
{ 0x00200000, 0x00000002 },
{ 0x00600073, 0x0000000c },
{ 0x00007563, 0x00000002 },
{ 0x006075f0, 0x00000021 },
{ 0x20007068, 0x00000004 },
{ 0x00005068, 0x00000004 },
{ 0x00007576, 0x00000002 },
{ 0x00007577, 0x00000002 },
{ 0x0000750e, 0x00000002 },
{ 0x0000750f, 0x00000002 },
{ 0x00a05000, 0x00000002 },
{ 0x00600076, 0x0000000c },
{ 0x006075f0, 0x00000021 },
{ 0x000075f8, 0x00000002 },
{ 0x00000076, 0x00000004 },
{ 0x000a750e, 0x00000002 },
{ 0x0020750f, 0x00000002 },
{ 0x00600079, 0x00000004 },
{ 0x00007570, 0x00000002 },
{ 0x00007571, 0x00000002 },
{ 0x00007572, 0x00000006 },
{ 0x00005000, 0x00000002 },
{ 0x00a05000, 0x00000002 },
{ 0x00007568, 0x00000002 },
{ 0x00061000, 0x00000002 },
{ 0x00000084, 0x0000000c },
{ 0x00058000, 0x00000002 },
{ 0x0c607562, 0x00000002 },
{ 0x00000086, 0x00000004 },
{ 0x00600085, 0x00000004 },
{ 0x400070dd, 0000000000 },
{ 0x000380dd, 0x00000002 },
{ 0x00000093, 0x0000001c },
{ 0x00065095, 0x00000018 },
{ 0x040025bb, 0x00000002 },
{ 0x00061096, 0x00000018 },
{ 0x040075bc, 0000000000 },
{ 0x000075bb, 0x00000002 },
{ 0x000075bc, 0000000000 },
{ 0x00090000, 0x00000006 },
{ 0x00090000, 0x00000002 },
{ 0x000d8002, 0x00000006 },
{ 0x00005000, 0x00000002 },
{ 0x00007821, 0x00000002 },
{ 0x00007800, 0000000000 },
{ 0x00007821, 0x00000002 },
{ 0x00007800, 0000000000 },
{ 0x01665000, 0x00000002 },
{ 0x000a0000, 0x00000002 },
{ 0x000671cc, 0x00000002 },
{ 0x0286f1cd, 0x00000002 },
{ 0x000000a3, 0x00000010 },
{ 0x21007000, 0000000000 },
{ 0x000000aa, 0x0000001c },
{ 0x00065000, 0x00000002 },
{ 0x000a0000, 0x00000002 },
{ 0x00061000, 0x00000002 },
{ 0x000b0000, 0x00000002 },
{ 0x38067000, 0x00000002 },
{ 0x000a00a6, 0x00000004 },
{ 0x20007000, 0000000000 },
{ 0x01200000, 0x00000002 },
{ 0x20077000, 0x00000002 },
{ 0x01200000, 0x00000002 },
{ 0x20007000, 0000000000 },
{ 0x00061000, 0x00000002 },
{ 0x0120751b, 0x00000002 },
{ 0x8040750a, 0x00000002 },
{ 0x8040750b, 0x00000002 },
{ 0x00110000, 0x00000002 },
{ 0x000380dd, 0x00000002 },
{ 0x000000bd, 0x0000001c },
{ 0x00061096, 0x00000018 },
{ 0x844075bd, 0x00000002 },
{ 0x00061095, 0x00000018 },
{ 0x840075bb, 0x00000002 },
{ 0x00061096, 0x00000018 },
{ 0x844075bc, 0x00000002 },
{ 0x000000c0, 0x00000004 },
{ 0x804075bd, 0x00000002 },
{ 0x800075bb, 0x00000002 },
{ 0x804075bc, 0x00000002 },
{ 0x00108000, 0x00000002 },
{ 0x01400000, 0x00000002 },
{ 0x006000c4, 0x0000000c },
{ 0x20c07000, 0x00000020 },
{ 0x000000c6, 0x00000012 },
{ 0x00800000, 0x00000006 },
{ 0x0080751d, 0x00000006 },
{ 0x000025bb, 0x00000002 },
{ 0x000040c0, 0x00000004 },
{ 0x0000775c, 0x00000002 },
{ 0x00a05000, 0x00000002 },
{ 0x00661000, 0x00000002 },
{ 0x0460275d, 0x00000020 },
{ 0x00004000, 0000000000 },
{ 0x00007999, 0x00000002 },
{ 0x00a05000, 0x00000002 },
{ 0x00661000, 0x00000002 },
{ 0x0460299b, 0x00000020 },
{ 0x00004000, 0000000000 },
{ 0x01e00830, 0x00000002 },
{ 0x21007000, 0000000000 },
{ 0x00005000, 0x00000002 },
{ 0x00038042, 0x00000002 },
{ 0x040025e0, 0x00000002 },
{ 0x000075e1, 0000000000 },
{ 0x00000001, 0000000000 },
{ 0x000380d9, 0x00000002 },
{ 0x04007394, 0000000000 },
{ 0000000000, 0000000000 },
{ 0000000000, 0000000000 },
{ 0000000000, 0000000000 },
{ 0000000000, 0000000000 },
{ 0000000000, 0000000000 },
{ 0000000000, 0000000000 },
{ 0000000000, 0000000000 },
{ 0000000000, 0000000000 },
{ 0000000000, 0000000000 },
{ 0000000000, 0000000000 },
{ 0000000000, 0000000000 },
{ 0000000000, 0000000000 },
{ 0000000000, 0000000000 },
{ 0000000000, 0000000000 },
{ 0000000000, 0000000000 },
{ 0000000000, 0000000000 },
{ 0000000000, 0000000000 },
{ 0000000000, 0000000000 },
{ 0000000000, 0000000000 },
{ 0000000000, 0000000000 },
{ 0000000000, 0000000000 },
{ 0000000000, 0000000000 },
{ 0000000000, 0000000000 },
{ 0000000000, 0000000000 },
{ 0000000000, 0000000000 },
{ 0000000000, 0000000000 },
{ 0000000000, 0000000000 },
{ 0000000000, 0000000000 },
{ 0000000000, 0000000000 },
{ 0000000000, 0000000000 },
{ 0000000000, 0000000000 },
{ 0000000000, 0000000000 },
{ 0000000000, 0000000000 },
{ 0000000000, 0000000000 },
{ 0000000000, 0000000000 },
{ 0000000000, 0000000000 },
};
/* Microcode from http://volodya-project.sourceforge.net/ */
CARD32 r300_cp_microcode[][2] = {
{ 0x4200e000, 0000000000 },
{ 0x4000e000, 0000000000 },
{ 0x000000af, 0x00000008 },
{ 0x000000b3, 0x00000008 },
{ 0x6c5a504f, 0000000000 },
{ 0x4f4f497a, 0000000000 },
{ 0x5a578288, 0000000000 },
{ 0x4f91906a, 0000000000 },
{ 0x4f4f4f4f, 0000000000 },
{ 0x4fe24f44, 0000000000 },
{ 0x4f9c9c9c, 0000000000 },
{ 0xdc4f4fde, 0000000000 },
{ 0xa1cd4f4f, 0000000000 },
{ 0xd29d9d9d, 0000000000 },
{ 0x4f0f9fd7, 0000000000 },
{ 0x000ca000, 0x00000004 },
{ 0x000d0012, 0x00000038 },
{ 0x0000e8b4, 0x00000004 },
{ 0x000d0014, 0x00000038 },
{ 0x0000e8b6, 0x00000004 },
{ 0x000d0016, 0x00000038 },
{ 0x0000e854, 0x00000004 },
{ 0x000d0018, 0x00000038 },
{ 0x0000e855, 0x00000004 },
{ 0x000d001a, 0x00000038 },
{ 0x0000e856, 0x00000004 },
{ 0x000d001c, 0x00000038 },
{ 0x0000e857, 0x00000004 },
{ 0x000d001e, 0x00000038 },
{ 0x0000e824, 0x00000004 },
{ 0x000d0020, 0x00000038 },
{ 0x0000e825, 0x00000004 },
{ 0x000d0022, 0x00000038 },
{ 0x0000e830, 0x00000004 },
{ 0x000d0024, 0x00000038 },
{ 0x0000f0c0, 0x00000004 },
{ 0x000d0026, 0x00000038 },
{ 0x0000f0c1, 0x00000004 },
{ 0x000d0028, 0x00000038 },
{ 0x0000f041, 0x00000004 },
{ 0x000d002a, 0x00000038 },
{ 0x0000f184, 0x00000004 },
{ 0x000d002c, 0x00000038 },
{ 0x0000f185, 0x00000004 },
{ 0x000d002e, 0x00000038 },
{ 0x0000f186, 0x00000004 },
{ 0x000d0030, 0x00000038 },
{ 0x0000f187, 0x00000004 },
{ 0x000d0032, 0x00000038 },
{ 0x0000f180, 0x00000004 },
{ 0x000d0034, 0x00000038 },
{ 0x0000f393, 0x00000004 },
{ 0x000d0036, 0x00000038 },
{ 0x0000f38a, 0x00000004 },
{ 0x000d0038, 0x00000038 },
{ 0x0000f38e, 0x00000004 },
{ 0x0000e821, 0x00000004 },
{ 0x0140a000, 0x00000004 },
{ 0x00000043, 0x00000018 },
{ 0x00cce800, 0x00000004 },
{ 0x001b0001, 0x00000004 },
{ 0x08004800, 0x00000004 },
{ 0x001b0001, 0x00000004 },
{ 0x08004800, 0x00000004 },
{ 0x001b0001, 0x00000004 },
{ 0x08004800, 0x00000004 },
{ 0x0000003a, 0x00000008 },
{ 0x0000a000, 0000000000 },
{ 0x02c0a000, 0x00000004 },
{ 0x000ca000, 0x00000004 },
{ 0x00130000, 0x00000004 },
{ 0x000c2000, 0x00000004 },
{ 0xc980c045, 0x00000008 },
{ 0x2000451d, 0x00000004 },
{ 0x0000e580, 0x00000004 },
{ 0x000ce581, 0x00000004 },
{ 0x08004580, 0x00000004 },
{ 0x000ce581, 0x00000004 },
{ 0x0000004c, 0x00000008 },
{ 0x0000a000, 0000000000 },
{ 0x000c2000, 0x00000004 },
{ 0x0000e50e, 0x00000004 },
{ 0x00032000, 0x00000004 },
{ 0x00022056, 0x00000028 },
{ 0x00000056, 0x00000024 },
{ 0x0800450f, 0x00000004 },
{ 0x0000a050, 0x00000008 },
{ 0x0000e565, 0x00000004 },
{ 0x0000e566, 0x00000004 },
{ 0x00000057, 0x00000008 },
{ 0x03cca5b4, 0x00000004 },
{ 0x05432000, 0x00000004 },
{ 0x00022000, 0x00000004 },
{ 0x4ccce063, 0x00000030 },
{ 0x08274565, 0x00000004 },
{ 0x00000063, 0x00000030 },
{ 0x08004564, 0x00000004 },
{ 0x0000e566, 0x00000004 },
{ 0x0000005a, 0x00000008 },
{ 0x00802066, 0x00000010 },
{ 0x00202000, 0x00000004 },
{ 0x001b00ff, 0x00000004 },
{ 0x01000069, 0x00000010 },
{ 0x001f2000, 0x00000004 },
{ 0x001c00ff, 0x00000004 },
{ 0000000000, 0x0000000c },
{ 0x00000085, 0x00000030 },
{ 0x0000005a, 0x00000008 },
{ 0x0000e576, 0x00000004 },
{ 0x000ca000, 0x00000004 },
{ 0x00012000, 0x00000004 },
{ 0x00082000, 0x00000004 },
{ 0x1800650e, 0x00000004 },
{ 0x00092000, 0x00000004 },
{ 0x000a2000, 0x00000004 },
{ 0x000f0000, 0x00000004 },
{ 0x00400000, 0x00000004 },
{ 0x00000079, 0x00000018 },
{ 0x0000e563, 0x00000004 },
{ 0x00c0e5f9, 0x000000c2 },
{ 0x0000006e, 0x00000008 },
{ 0x0000a06e, 0x00000008 },
{ 0x0000e576, 0x00000004 },
{ 0x0000e577, 0x00000004 },
{ 0x0000e50e, 0x00000004 },
{ 0x0000e50f, 0x00000004 },
{ 0x0140a000, 0x00000004 },
{ 0x0000007c, 0x00000018 },
{ 0x00c0e5f9, 0x000000c2 },
{ 0x0000007c, 0x00000008 },
{ 0x0014e50e, 0x00000004 },
{ 0x0040e50f, 0x00000004 },
{ 0x00c0007f, 0x00000008 },
{ 0x0000e570, 0x00000004 },
{ 0x0000e571, 0x00000004 },
{ 0x0000e572, 0x0000000c },
{ 0x0000a000, 0x00000004 },
{ 0x0140a000, 0x00000004 },
{ 0x0000e568, 0x00000004 },
{ 0x000c2000, 0x00000004 },
{ 0x00000089, 0x00000018 },
{ 0x000b0000, 0x00000004 },
{ 0x18c0e562, 0x00000004 },
{ 0x0000008b, 0x00000008 },
{ 0x00c0008a, 0x00000008 },
{ 0x000700e4, 0x00000004 },
{ 0x00000097, 0x00000038 },
{ 0x000ca099, 0x00000030 },
{ 0x080045bb, 0x00000004 },
{ 0x000c209a, 0x00000030 },
{ 0x0800e5bc, 0000000000 },
{ 0x0000e5bb, 0x00000004 },
{ 0x0000e5bc, 0000000000 },
{ 0x00120000, 0x0000000c },
{ 0x00120000, 0x00000004 },
{ 0x001b0002, 0x0000000c },
{ 0x0000a000, 0x00000004 },
{ 0x0000e821, 0x00000004 },
{ 0x0000e800, 0000000000 },
{ 0x0000e821, 0x00000004 },
{ 0x0000e82e, 0000000000 },
{ 0x02cca000, 0x00000004 },
{ 0x00140000, 0x00000004 },
{ 0x000ce1cc, 0x00000004 },
{ 0x050de1cd, 0x00000004 },
{ 0x000000a7, 0x00000020 },
{ 0x4200e000, 0000000000 },
{ 0x000000ae, 0x00000038 },
{ 0x000ca000, 0x00000004 },
{ 0x00140000, 0x00000004 },
{ 0x000c2000, 0x00000004 },
{ 0x00160000, 0x00000004 },
{ 0x700ce000, 0x00000004 },
{ 0x001400aa, 0x00000008 },
{ 0x4000e000, 0000000000 },
{ 0x02400000, 0x00000004 },
{ 0x400ee000, 0x00000004 },
{ 0x02400000, 0x00000004 },
{ 0x4000e000, 0000000000 },
{ 0x000c2000, 0x00000004 },
{ 0x0240e51b, 0x00000004 },
{ 0x0080e50a, 0x00000005 },
{ 0x0080e50b, 0x00000005 },
{ 0x00220000, 0x00000004 },
{ 0x000700e4, 0x00000004 },
{ 0x000000c1, 0x00000038 },
{ 0x000c209a, 0x00000030 },
{ 0x0880e5bd, 0x00000005 },
{ 0x000c2099, 0x00000030 },
{ 0x0800e5bb, 0x00000005 },
{ 0x000c209a, 0x00000030 },
{ 0x0880e5bc, 0x00000005 },
{ 0x000000c4, 0x00000008 },
{ 0x0080e5bd, 0x00000005 },
{ 0x0000e5bb, 0x00000005 },
{ 0x0080e5bc, 0x00000005 },
{ 0x00210000, 0x00000004 },
{ 0x02800000, 0x00000004 },
{ 0x00c000c8, 0x00000018 },
{ 0x4180e000, 0x00000040 },
{ 0x000000ca, 0x00000024 },
{ 0x01000000, 0x0000000c },
{ 0x0100e51d, 0x0000000c },
{ 0x000045bb, 0x00000004 },
{ 0x000080c4, 0x00000008 },
{ 0x0000f3ce, 0x00000004 },
{ 0x0140a000, 0x00000004 },
{ 0x00cc2000, 0x00000004 },
{ 0x08c053cf, 0x00000040 },
{ 0x00008000, 0000000000 },
{ 0x0000f3d2, 0x00000004 },
{ 0x0140a000, 0x00000004 },
{ 0x00cc2000, 0x00000004 },
{ 0x08c053d3, 0x00000040 },
{ 0x00008000, 0000000000 },
{ 0x0000f39d, 0x00000004 },
{ 0x0140a000, 0x00000004 },
{ 0x00cc2000, 0x00000004 },
{ 0x08c0539e, 0x00000040 },
{ 0x00008000, 0000000000 },
{ 0x03c00830, 0x00000004 },
{ 0x4200e000, 0000000000 },
{ 0x0000a000, 0x00000004 },
{ 0x200045e0, 0x00000004 },
{ 0x0000e5e1, 0000000000 },
{ 0x00000001, 0000000000 },
{ 0x000700e1, 0x00000004 },
{ 0x0800e394, 0000000000 },
{ 0000000000, 0000000000 },
{ 0000000000, 0000000000 },
{ 0000000000, 0000000000 },
{ 0000000000, 0000000000 },
{ 0000000000, 0000000000 },
{ 0000000000, 0000000000 },
{ 0000000000, 0000000000 },
{ 0000000000, 0000000000 },
{ 0000000000, 0000000000 },
{ 0000000000, 0000000000 },
{ 0000000000, 0000000000 },
{ 0000000000, 0000000000 },
{ 0000000000, 0000000000 },
{ 0000000000, 0000000000 },
{ 0000000000, 0000000000 },
{ 0000000000, 0000000000 },
{ 0000000000, 0000000000 },
{ 0000000000, 0000000000 },
{ 0000000000, 0000000000 },
{ 0000000000, 0000000000 },
{ 0000000000, 0000000000 },
{ 0000000000, 0000000000 },
{ 0000000000, 0000000000 },
{ 0000000000, 0000000000 },
{ 0000000000, 0000000000 },
{ 0000000000, 0000000000 },
{ 0000000000, 0000000000 },
{ 0000000000, 0000000000 },
};

File diff suppressed because it is too large Load Diff

View File

@ -1,38 +0,0 @@
/*
* Copyright © 2003 Eric Anholt
*
* 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 Eric Anholt not be used in
* advertising or publicity pertaining to distribution of the software without
* specific, written prior permission. Eric Anholt makes no
* representations about the suitability of this software for any purpose. It
* is provided "as is" without express or implied warranty.
*
* ERIC ANHOLT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL ERIC ANHOLT 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.
*/
#ifndef _ATI_SAREA_H_
#define _ATI_SAREA_H_
/* There are 2 heaps (local/AGP). Each region within a heap is a
* minimum of 64k, and there are at most 64 of them per heap.
*/
#define ATI_CARD_HEAP 0
#define ATI_GART_HEAP 1
#define ATI_NR_TEX_HEAPS 2
#define ATI_NR_TEX_REGIONS 64
#define ATI_LOG_TEX_GRANULARITY 16
#include "r128_sarea.h"
#include "radeon_sarea.h"
#endif /* _ATI_SAREA_H_ */

View File

@ -1,77 +0,0 @@
/*
* Copyright © 2003 Eric Anholt
*
* 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 Eric Anholt not be used in
* advertising or publicity pertaining to distribution of the software without
* specific, written prior permission. Eric Anholt makes no
* representations about the suitability of this software for any purpose. It
* is provided "as is" without express or implied warranty.
*
* ERIC ANHOLT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL ERIC ANHOLT 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.
*/
#ifdef HAVE_CONFIG_H
#include <kdrive-config.h>
#endif
#include "ati.h"
#include "klinux.h"
extern struct pci_id_entry ati_pci_ids[];
void
InitCard(char *name)
{
struct pci_id_entry *id;
KdCardAttr attr;
for (id = ati_pci_ids; id->name != NULL; id++) {
int j = 0;
while (LinuxFindPci(id->vendor, id->device, j++, &attr))
KdCardInfoAdd(&ATIFuncs, &attr, 0);
}
}
void
InitOutput(ScreenInfo *pScreenInfo, int argc, char **argv)
{
KdInitOutput(pScreenInfo, argc, argv);
}
void
InitInput(int argc, char **argv)
{
KdOsAddInputDrivers();
KdInitInput();
}
void
ddxUseMsg (void)
{
KdUseMsg();
#ifdef KDRIVEVESA
vesaUseMsg();
#endif
}
int
ddxProcessArgument(int argc, char **argv, int i)
{
int ret;
#ifdef KDRIVEVESA
if (!(ret = vesaProcessArgument (argc, argv, i)))
#endif
ret = KdProcessArgument(argc, argv, i);
return ret;
}

View File

@ -1,988 +0,0 @@
/*
* Copyright © 2004 Keith Packard
* Copyright © 2005 Eric Anholt
*
* 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 Eric Anholt not be used in
* advertising or publicity pertaining to distribution of the software without
* specific, written prior permission. Eric Anholt makes no
* representations about the suitability of this software for any purpose. It
* is provided "as is" without express or implied warranty.
*
* ERIC ANHOLT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL ERIC ANHOLT 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.
*
* Based on mach64video.c by Keith Packard.
*/
#ifdef HAVE_CONFIG_H
#include <kdrive-config.h>
#endif
#include "ati.h"
#include "ati_dma.h"
#include "ati_draw.h"
#include "ati_reg.h"
#include "kaa.h"
#include <X11/extensions/Xv.h>
#include "fourcc.h"
#define MAKE_ATOM(a) MakeAtom(a, sizeof(a) - 1, TRUE)
static Atom xvBrightness, xvSaturation;
extern CARD8 ATIBltRop[16];
#define IMAGE_MAX_WIDTH 2048
#define IMAGE_MAX_HEIGHT 2048
static void
ATIStopVideo(KdScreenInfo *screen, pointer data, Bool exit)
{
ScreenPtr pScreen = screen->pScreen;
ATIPortPrivPtr pPortPriv = (ATIPortPrivPtr)data;
REGION_EMPTY(screen->pScreen, &pPortPriv->clip);
if (pPortPriv->off_screen) {
KdOffscreenFree (pScreen, pPortPriv->off_screen);
pPortPriv->off_screen = 0;
}
}
static int
ATISetPortAttribute(KdScreenInfo *screen, Atom attribute, int value,
pointer data)
{
return BadMatch;
}
static int
ATIGetPortAttribute(KdScreenInfo *screen, Atom attribute, int *value,
pointer data)
{
return BadMatch;
}
static void
ATIQueryBestSize(KdScreenInfo *screen, Bool motion, short vid_w, short vid_h,
short drw_w, short drw_h, unsigned int *p_w, unsigned int *p_h,
pointer data)
{
*p_w = drw_w;
*p_h = drw_h;
}
/* ATIClipVideo -
Takes the dst box in standard X BoxRec form (top and left
edges inclusive, bottom and right exclusive). The new dst
box is returned. The source boundaries are given (x1, y1
inclusive, x2, y2 exclusive) and returned are the new source
boundaries in 16.16 fixed point.
*/
static void
ATIClipVideo(BoxPtr dst, INT32 *x1, INT32 *x2, INT32 *y1, INT32 *y2,
BoxPtr extents, INT32 width, INT32 height)
{
INT32 vscale, hscale, delta;
int diff;
hscale = ((*x2 - *x1) << 16) / (dst->x2 - dst->x1);
vscale = ((*y2 - *y1) << 16) / (dst->y2 - dst->y1);
*x1 <<= 16; *x2 <<= 16;
*y1 <<= 16; *y2 <<= 16;
diff = extents->x1 - dst->x1;
if (diff > 0) {
dst->x1 = extents->x1;
*x1 += diff * hscale;
}
diff = dst->x2 - extents->x2;
if (diff > 0) {
dst->x2 = extents->x2;
*x2 -= diff * hscale;
}
diff = extents->y1 - dst->y1;
if (diff > 0) {
dst->y1 = extents->y1;
*y1 += diff * vscale;
}
diff = dst->y2 - extents->y2;
if (diff > 0) {
dst->y2 = extents->y2;
*y2 -= diff * vscale;
}
if (*x1 < 0) {
diff = (- *x1 + hscale - 1)/ hscale;
dst->x1 += diff;
*x1 += diff * hscale;
}
delta = *x2 - (width << 16);
if (delta > 0) {
diff = (delta + hscale - 1)/ hscale;
dst->x2 -= diff;
*x2 -= diff * hscale;
}
if (*y1 < 0) {
diff = (- *y1 + vscale - 1)/ vscale;
dst->y1 += diff;
*y1 += diff * vscale;
}
delta = *y2 - (height << 16);
if (delta > 0) {
diff = (delta + vscale - 1)/ vscale;
dst->y2 -= diff;
*y2 -= diff * vscale;
}
}
static void
R128DisplayVideo(KdScreenInfo *screen, ATIPortPrivPtr pPortPriv)
{
ScreenPtr pScreen = screen->pScreen;
KdScreenPriv(pScreen);
ATIScreenInfo(pScreenPriv);
CARD32 dstDatatype, srcDatatype;
CARD32 dst_offset, dst_pitch;
int dstxoff, dstyoff;
PixmapPtr pPixmap = pPortPriv->pPixmap;
int bpp = pPixmap->drawable.bitsPerPixel;
RING_LOCALS;
BoxPtr pBox = REGION_RECTS(&pPortPriv->clip);
int nBox = REGION_NUM_RECTS(&pPortPriv->clip);
if (pPortPriv->id == FOURCC_UYVY)
srcDatatype = R128_DATATYPE_YVYU_422;
else
srcDatatype = R128_DATATYPE_VYUY_422;
switch (bpp)
{
case 16:
if (pPixmap->drawable.depth == 15)
dstDatatype = R128_DATATYPE_ARGB1555;
else
dstDatatype = R128_DATATYPE_RGB565;
break;
case 32:
dstDatatype = R128_DATATYPE_ARGB8888;
break;
default:
return;
}
dst_offset = ((CARD8 *)pPixmap->devPrivate.ptr -
pScreenPriv->screen->memory_base);
dst_pitch = pPixmap->devKind;
#ifdef COMPOSITE
dstxoff = -pPixmap->screen_x + pPixmap->drawable.x;
dstyoff = -pPixmap->screen_y + pPixmap->drawable.y;
#else
dstxoff = 0;
dstyoff = 0;
#endif
BEGIN_DMA(18);
OUT_REG(ATI_REG_DST_PITCH_OFFSET,
((dst_pitch / bpp) << 21) | (dst_offset >> 5));
OUT_REG(ATI_REG_DP_GUI_MASTER_CNTL,
ATI_GMC_DST_PITCH_OFFSET_CNTL |
ATI_GMC_BRUSH_NONE |
(dstDatatype << 8) |
ATI_GMC_SRC_DATATYPE_COLOR |
(ATIBltRop[GXcopy] << 16) |
R128_GMC_3D_FCN_EN |
ATI_GMC_CLR_CMP_CNTL_DIS |
R128_GMC_AUX_CLIP_DIS);
OUT_REG(ATI_REG_DP_CNTL,
ATI_DST_X_LEFT_TO_RIGHT | ATI_DST_Y_TOP_TO_BOTTOM );
OUT_REG(R128_REG_SCALE_3D_CNTL,
R128_SCALE_3D_SCALE |
R128_SBLEND_ONE |
R128_DBLEND_ZERO);
OUT_REG(R128_REG_TEX_CNTL_C, R128_TEX_CACHE_FLUSH);
OUT_REG(R128_REG_SCALE_3D_DATATYPE, srcDatatype);
OUT_RING(DMA_PACKET0(R128_REG_SCALE_PITCH, 5));
OUT_RING_REG(R128_REG_SCALE_PITCH, pPortPriv->src_pitch / 16);
OUT_RING_REG(R128_REG_SCALE_X_INC,
(pPortPriv->src_w << 16) / pPortPriv->dst_w);
OUT_RING_REG(R128_REG_SCALE_Y_INC,
(pPortPriv->src_h << 16) / pPortPriv->dst_h);
OUT_RING_REG(R128_REG_SCALE_HACC, 0x0);
OUT_RING_REG(R128_REG_SCALE_VACC, 0x0);
END_DMA();
while (nBox--) {
int srcX, srcY, dstX, dstY, srcw, srch, dstw, dsth;
dstX = pBox->x1 + dstxoff;
dstY = pBox->y1 + dstyoff;
dstw = pBox->x2 - pBox->x1;
dsth = pBox->y2 - pBox->y1;
srcX = (pBox->x1 - pPortPriv->dst_x1) *
pPortPriv->src_w / pPortPriv->dst_w;
srcY = (pBox->y1 - pPortPriv->dst_y1) *
pPortPriv->src_h / pPortPriv->dst_h;
srcw = pPortPriv->src_w - srcX;
srch = pPortPriv->src_h - srcY;
BEGIN_DMA(6);
OUT_RING(DMA_PACKET0(R128_REG_SCALE_SRC_HEIGHT_WIDTH, 2));
OUT_RING_REG(R128_REG_SCALE_SRC_HEIGHT_WIDTH,
(srch << 16) | srcw);
OUT_RING_REG(R128_REG_SCALE_OFFSET_0, pPortPriv->src_offset +
srcY * pPortPriv->src_pitch + srcX * 2);
OUT_RING(DMA_PACKET0(R128_REG_SCALE_DST_X_Y, 2));
OUT_RING_REG(R128_REG_SCALE_DST_X_Y, (dstX << 16) | dstY);
OUT_RING_REG(R128_REG_SCALE_DST_HEIGHT_WIDTH,
(dsth << 16) | dstw);
END_DMA();
pBox++;
}
#ifdef DAMAGEEXT
/* XXX: Shouldn't this be in kxv.c instead? */
DamageDamageRegion(pPortPriv->pDraw, &pPortPriv->clip);
#endif
kaaMarkSync(pScreen);
}
union intfloat {
float f;
CARD32 i;
};
struct blend_vertex {
union intfloat x, y;
union intfloat s0, t0;
};
#define VTX_DWORD_COUNT 4
#define VTX_OUT(vtx) \
do { \
OUT_RING(vtx.x.i); \
OUT_RING(vtx.y.i); \
OUT_RING(vtx.s0.i); \
OUT_RING(vtx.t0.i); \
} while (0)
static void
RadeonDisplayVideo(KdScreenInfo *screen, ATIPortPrivPtr pPortPriv)
{
ScreenPtr pScreen = screen->pScreen;
KdScreenPriv(pScreen);
ATICardInfo(pScreenPriv);
ATIScreenInfo(pScreenPriv);
struct blend_vertex vtx[4];
PixmapPtr pPixmap = pPortPriv->pPixmap;
CARD32 txformat;
CARD32 dst_offset, dst_pitch, dst_format;
int dstxoff, dstyoff, pixel_shift;
RING_LOCALS;
BoxPtr pBox = REGION_RECTS(&pPortPriv->clip);
int nBox = REGION_NUM_RECTS(&pPortPriv->clip);
switch (pPixmap->drawable.bitsPerPixel) {
case 16:
if (pPixmap->drawable.depth == 15)
dst_format = RADEON_COLOR_FORMAT_ARGB1555;
else
dst_format = RADEON_COLOR_FORMAT_RGB565;
pixel_shift = 1;
break;
case 32:
dst_format = RADEON_COLOR_FORMAT_ARGB8888;
pixel_shift = 2;
break;
default:
return;
}
dst_offset = ((CARD8 *)pPixmap->devPrivate.ptr -
pScreenPriv->screen->memory_base);
dst_pitch = pPixmap->devKind;
#ifdef COMPOSITE
dstxoff = -pPixmap->screen_x + pPixmap->drawable.x;
dstyoff = -pPixmap->screen_y + pPixmap->drawable.y;
#else
dstxoff = 0;
dstyoff = 0;
#endif
/* Same for R100/R200 */
if (pPortPriv->id == FOURCC_UYVY)
txformat = RADEON_TXFORMAT_YVYU422;
else
txformat = RADEON_TXFORMAT_VYUY422;
txformat |= RADEON_TXFORMAT_NON_POWER2;
RadeonSwitchTo3D(atis);
BEGIN_DMA(8);
OUT_RING(DMA_PACKET0(RADEON_REG_PP_CNTL, 3));
OUT_RING_REG(RADEON_REG_PP_CNTL,
RADEON_TEX_0_ENABLE | RADEON_TEX_BLEND_0_ENABLE);
OUT_RING_REG(RADEON_REG_RB3D_CNTL,
dst_format | RADEON_ALPHA_BLEND_ENABLE);
OUT_RING_REG(RADEON_REG_RB3D_COLOROFFSET, dst_offset);
OUT_REG(RADEON_REG_RB3D_COLORPITCH, dst_pitch >> pixel_shift);
OUT_REG(RADEON_REG_RB3D_BLENDCNTL,
RADEON_SBLEND_GL_ONE | RADEON_DBLEND_GL_ZERO);
END_DMA();
if (atic->is_r200) {
BEGIN_DMA(17);
OUT_REG(R200_REG_SE_VTX_FMT_0, R200_VTX_XY);
OUT_REG(R200_REG_SE_VTX_FMT_1,
(2 << R200_VTX_TEX0_COMP_CNT_SHIFT));
OUT_RING(DMA_PACKET0(R200_REG_PP_TXFILTER_0, 5));
OUT_RING_REG(R200_REG_PP_TXFILTER_0,
R200_MAG_FILTER_LINEAR |
R200_MIN_FILTER_LINEAR |
R200_YUV_TO_RGB);
OUT_RING_REG(R200_REG_PP_TXFORMAT_0, txformat);
OUT_RING_REG(R200_REG_PP_TXFORMAT_X_0, 0);
OUT_RING_REG(R200_REG_PP_TXSIZE_0,
(pPixmap->drawable.width - 1) |
((pPixmap->drawable.height - 1) << RADEON_TEX_VSIZE_SHIFT));
OUT_RING_REG(R200_REG_PP_TXPITCH_0, pPortPriv->src_pitch - 32);
OUT_REG(R200_PP_TXOFFSET_0, pPortPriv->src_offset);
OUT_RING(DMA_PACKET0(R200_REG_PP_TXCBLEND_0, 4));
OUT_RING_REG(R200_REG_PP_TXCBLEND_0,
R200_TXC_ARG_A_ZERO |
R200_TXC_ARG_B_ZERO |
R200_TXC_ARG_C_R0_COLOR |
R200_TXC_OP_MADD);
OUT_RING_REG(R200_REG_PP_TXCBLEND2_0,
R200_TXC_CLAMP_0_1 | R200_TXC_OUTPUT_REG_R0);
OUT_RING_REG(R200_REG_PP_TXABLEND_0,
R200_TXA_ARG_A_ZERO |
R200_TXA_ARG_B_ZERO |
R200_TXA_ARG_C_R0_ALPHA |
R200_TXA_OP_MADD);
OUT_RING_REG(R200_REG_PP_TXABLEND2_0,
R200_TXA_CLAMP_0_1 | R200_TXA_OUTPUT_REG_R0);
END_DMA();
} else {
// BEGIN_DMA(11);
BEGIN_DMA(9);
OUT_RING(DMA_PACKET0(RADEON_REG_PP_TXFILTER_0, 5));
OUT_RING_REG(RADEON_REG_PP_TXFILTER_0, RADEON_MAG_FILTER_LINEAR |
RADEON_MIN_FILTER_LINEAR |
RADEON_YUV_TO_RGB);
OUT_RING_REG(RADEON_REG_PP_TXFORMAT_0, txformat);
OUT_RING_REG(RADEON_REG_PP_TXOFFSET_0, pPortPriv->src_offset);
OUT_RING_REG(RADEON_REG_PP_TXCBLEND_0,
RADEON_COLOR_ARG_A_ZERO |
RADEON_COLOR_ARG_B_ZERO |
RADEON_COLOR_ARG_C_T0_COLOR |
RADEON_BLEND_CTL_ADD |
RADEON_CLAMP_TX);
OUT_RING_REG(RADEON_REG_PP_TXABLEND_0,
RADEON_ALPHA_ARG_A_ZERO |
RADEON_ALPHA_ARG_B_ZERO |
RADEON_ALPHA_ARG_C_T0_ALPHA |
RADEON_BLEND_CTL_ADD |
RADEON_CLAMP_TX);
OUT_RING(DMA_PACKET0(RADEON_REG_PP_TEX_SIZE_0, 2));
OUT_RING_REG(RADEON_REG_PP_TEX_SIZE_0,
(pPixmap->drawable.width - 1) |
((pPixmap->drawable.height - 1) << RADEON_TEX_VSIZE_SHIFT));
OUT_RING_REG(RADEON_REG_PP_TEX_PITCH_0,
pPortPriv->src_pitch - 32);
// OUT_RING_REG(ATI_REG_WAIT_UNTIL, ATI_WAIT_CRTC_VLINE);
END_DMA();
}
while (nBox--) {
float srcX, srcY, dstX, dstY, srcw, srch, dstw, dsth;
dstX = pBox->x1 + dstxoff;
dstY = pBox->y1 + dstyoff;
dstw = pBox->x2 - pBox->x1;
dsth = pBox->y2 - pBox->y1;
srcX = (pBox->x1 - pPortPriv->dst_x1) *
pPortPriv->src_w / pPortPriv->dst_w;
srcY = (pBox->y1 - pPortPriv->dst_y1) *
pPortPriv->src_h / pPortPriv->dst_h;
srcw = pPortPriv->src_w * (dstw / pPortPriv->dst_w);
srch = pPortPriv->src_h * (dsth / pPortPriv->dst_h);
/*
* rectangle:
*
* +---------2
* | |
* | |
* 0---------1
*/
vtx[0].x.f = dstX;
vtx[0].y.f = dstY + dsth;
vtx[0].s0.f = srcX;
vtx[0].t0.f = srcY + srch;
vtx[1].x.f = dstX + dstw;
vtx[1].y.f = dstY + dsth;
vtx[1].s0.f = srcX + srcw;
vtx[1].t0.f = srcY + srch;
vtx[2].x.f = dstX + dstw;
vtx[2].y.f = dstY;
vtx[2].s0.f = srcX + srcw;
vtx[2].t0.f = srcY;
if (atic->is_r100) {
BEGIN_DMA(3 * VTX_DWORD_COUNT + 3);
OUT_RING(DMA_PACKET3(RADEON_CP_PACKET3_3D_DRAW_IMMD,
3 * VTX_DWORD_COUNT + 2));
OUT_RING(RADEON_CP_VC_FRMT_XY |
RADEON_CP_VC_FRMT_ST0);
OUT_RING(RADEON_CP_VC_CNTL_PRIM_TYPE_RECT_LIST |
RADEON_CP_VC_CNTL_PRIM_WALK_RING |
RADEON_CP_VC_CNTL_MAOS_ENABLE |
RADEON_CP_VC_CNTL_VTX_FMT_RADEON_MODE |
(3 << RADEON_CP_VC_CNTL_NUM_SHIFT));
} else {
BEGIN_DMA(3 * VTX_DWORD_COUNT + 2);
OUT_RING(DMA_PACKET3(R200_CP_PACKET3_3D_DRAW_IMMD_2,
3 * VTX_DWORD_COUNT + 1));
OUT_RING(RADEON_CP_VC_CNTL_PRIM_TYPE_RECT_LIST |
RADEON_CP_VC_CNTL_PRIM_WALK_RING |
(3 << RADEON_CP_VC_CNTL_NUM_SHIFT));
}
VTX_OUT(vtx[0]);
VTX_OUT(vtx[1]);
VTX_OUT(vtx[2]);
END_DMA();
pBox++;
}
#ifdef DAMAGEEXT
/* XXX: Shouldn't this be in kxv.c instead? */
DamageDamageRegion(pPortPriv->pDraw, &pPortPriv->clip);
#endif
kaaMarkSync(pScreen);
}
static void
ATIVideoSave(ScreenPtr pScreen, KdOffscreenArea *area)
{
KdScreenPriv(pScreen);
ATIScreenInfo(pScreenPriv);
ATIPortPrivPtr pPortPriv = atis->pAdaptor->pPortPrivates[0].ptr;
if (pPortPriv->off_screen == area)
pPortPriv->off_screen = 0;
}
static int
ATIPutImage(KdScreenInfo *screen, DrawablePtr pDraw,
short src_x, short src_y,
short drw_x, short drw_y,
short src_w, short src_h,
short drw_w, short drw_h,
int id,
unsigned char *buf,
short width,
short height,
Bool sync,
RegionPtr clipBoxes,
pointer data)
{
ScreenPtr pScreen = screen->pScreen;
KdScreenPriv(pScreen);
ATICardInfo(pScreenPriv);
ATIScreenInfo(pScreenPriv);
ATIPortPrivPtr pPortPriv = (ATIPortPrivPtr)data;
char *mmio = atic->reg_base;
INT32 x1, x2, y1, y2;
int randr = RR_Rotate_0 /* XXX */;
int srcPitch, srcPitch2, dstPitch;
int top, left, npixels, nlines, size;
BoxRec dstBox;
int dst_width = width, dst_height = height;
int rot_x1, rot_y1, rot_x2, rot_y2;
int dst_x1, dst_y1, dst_x2, dst_y2;
int rot_src_w, rot_src_h, rot_drw_w, rot_drw_h;
/* Clip */
x1 = src_x;
x2 = src_x + src_w;
y1 = src_y;
y2 = src_y + src_h;
dstBox.x1 = drw_x;
dstBox.x2 = drw_x + drw_w;
dstBox.y1 = drw_y;
dstBox.y2 = drw_y + drw_h;
ATIClipVideo(&dstBox, &x1, &x2, &y1, &y2,
REGION_EXTENTS(pScreen, clipBoxes), width, height);
src_w = (x2 - x1) >> 16;
src_h = (y2 - y1) >> 16;
drw_w = dstBox.x2 - dstBox.x1;
drw_h = dstBox.y2 - dstBox.y1;
if ((x1 >= x2) || (y1 >= y2))
return Success;
if (mmio == NULL)
return BadAlloc;
if (randr & (RR_Rotate_0|RR_Rotate_180)) {
dst_width = width;
dst_height = height;
rot_src_w = src_w;
rot_src_h = src_h;
rot_drw_w = drw_w;
rot_drw_h = drw_h;
} else {
dst_width = height;
dst_height = width;
rot_src_w = src_h;
rot_src_h = src_w;
rot_drw_w = drw_h;
rot_drw_h = drw_w;
}
switch (randr & RR_Rotate_All) {
case RR_Rotate_0:
default:
dst_x1 = dstBox.x1;
dst_y1 = dstBox.y1;
dst_x2 = dstBox.x2;
dst_y2 = dstBox.y2;
rot_x1 = x1;
rot_y1 = y1;
rot_x2 = x2;
rot_y2 = y2;
break;
case RR_Rotate_90:
dst_x1 = dstBox.y1;
dst_y1 = screen->height - dstBox.x2;
dst_x2 = dstBox.y2;
dst_y2 = screen->height - dstBox.x1;
rot_x1 = y1;
rot_y1 = (src_w << 16) - x2;
rot_x2 = y2;
rot_y2 = (src_w << 16) - x1;
break;
case RR_Rotate_180:
dst_x1 = screen->width - dstBox.x2;
dst_y1 = screen->height - dstBox.y2;
dst_x2 = screen->width - dstBox.x1;
dst_y2 = screen->height - dstBox.y1;
rot_x1 = (src_w << 16) - x2;
rot_y1 = (src_h << 16) - y2;
rot_x2 = (src_w << 16) - x1;
rot_y2 = (src_h << 16) - y1;
break;
case RR_Rotate_270:
dst_x1 = screen->width - dstBox.y2;
dst_y1 = dstBox.x1;
dst_x2 = screen->width - dstBox.y1;
dst_y2 = dstBox.x2;
rot_x1 = (src_h << 16) - y2;
rot_y1 = x1;
rot_x2 = (src_h << 16) - y1;
rot_y2 = x2;
break;
}
switch(id) {
case FOURCC_YV12:
case FOURCC_I420:
dstPitch = ((dst_width << 1) + 15) & ~15;
srcPitch = (width + 3) & ~3;
srcPitch2 = ((width >> 1) + 3) & ~3;
size = dstPitch * dst_height;
break;
case FOURCC_UYVY:
case FOURCC_YUY2:
default:
dstPitch = ((dst_width << 1) + 15) & ~15;
srcPitch = (width << 1);
srcPitch2 = 0;
size = dstPitch * dst_height;
break;
}
if (pPortPriv->off_screen != NULL && size != pPortPriv->size) {
KdOffscreenFree(screen->pScreen, pPortPriv->off_screen);
pPortPriv->off_screen = 0;
}
if (pPortPriv->off_screen == NULL) {
pPortPriv->off_screen = KdOffscreenAlloc(screen->pScreen,
size * 2, 64, TRUE, ATIVideoSave, pPortPriv);
if (pPortPriv->off_screen == NULL)
return BadAlloc;
}
if (pDraw->type == DRAWABLE_WINDOW)
pPortPriv->pPixmap =
(*pScreen->GetWindowPixmap)((WindowPtr)pDraw);
else
pPortPriv->pPixmap = (PixmapPtr)pDraw;
/* Migrate the pixmap to offscreen if necessary. */
if (!kaaPixmapIsOffscreen(pPortPriv->pPixmap))
kaaMoveInPixmap(pPortPriv->pPixmap);
if (!kaaPixmapIsOffscreen(pPortPriv->pPixmap)) {
return BadAlloc;
}
pPortPriv->src_offset = pPortPriv->off_screen->offset;
pPortPriv->src_addr = (CARD8 *)(pScreenPriv->screen->memory_base +
pPortPriv->src_offset);
pPortPriv->src_pitch = dstPitch;
pPortPriv->size = size;
pPortPriv->pDraw = pDraw;
/* copy data */
top = rot_y1 >> 16;
left = (rot_x1 >> 16) & ~1;
npixels = ((((rot_x2 + 0xffff) >> 16) + 1) & ~1) - left;
/* Since we're probably overwriting the area that might still be used
* for the last PutImage request, wait for idle.
*/
ATIWaitIdle(atis);
switch(id) {
case FOURCC_YV12:
case FOURCC_I420:
top &= ~1;
nlines = ((((rot_y2 + 0xffff) >> 16) + 1) & ~1) - top;
KdXVCopyPlanarData(screen, buf, pPortPriv->src_addr, randr,
srcPitch, srcPitch2, dstPitch, rot_src_w, rot_src_h,
height, top, left, nlines, npixels, id);
break;
case FOURCC_UYVY:
case FOURCC_YUY2:
default:
nlines = ((rot_y2 + 0xffff) >> 16) - top;
KdXVCopyPackedData(screen, buf, pPortPriv->src_addr, randr,
srcPitch, dstPitch, rot_src_w, rot_src_h, top, left,
nlines, npixels);
break;
}
/* update cliplist */
if (!REGION_EQUAL(screen->pScreen, &pPortPriv->clip, clipBoxes)) {
REGION_COPY(screen->pScreen, &pPortPriv->clip, clipBoxes);
}
pPortPriv->id = id;
pPortPriv->src_x1 = rot_x1;
pPortPriv->src_y1 = rot_y1;
pPortPriv->src_x2 = rot_x2;
pPortPriv->src_y2 = rot_y2;
pPortPriv->src_w = rot_src_w;
pPortPriv->src_h = rot_src_h;
pPortPriv->dst_x1 = dst_x1;
pPortPriv->dst_y1 = dst_y1;
pPortPriv->dst_x2 = dst_x2;
pPortPriv->dst_y2 = dst_y2;
pPortPriv->dst_w = rot_drw_w;
pPortPriv->dst_h = rot_drw_h;
if (atic->is_radeon)
RadeonDisplayVideo(screen, pPortPriv);
else
R128DisplayVideo(screen, pPortPriv);
return Success;
}
static int
ATIReputImage(KdScreenInfo *screen, DrawablePtr pDraw, short drw_x, short drw_y,
RegionPtr clipBoxes, pointer data)
{
ScreenPtr pScreen = screen->pScreen;
KdScreenPriv(pScreen);
ATICardInfo(pScreenPriv);
ATIPortPrivPtr pPortPriv = (ATIPortPrivPtr)data;
BoxPtr pOldExtents = REGION_EXTENTS(screen->pScreen, &pPortPriv->clip);
BoxPtr pNewExtents = REGION_EXTENTS(screen->pScreen, clipBoxes);
if (pOldExtents->x1 != pNewExtents->x1 ||
pOldExtents->x2 != pNewExtents->x2 ||
pOldExtents->y1 != pNewExtents->y1 ||
pOldExtents->y2 != pNewExtents->y2)
return BadMatch;
if (pDraw->type == DRAWABLE_WINDOW)
pPortPriv->pPixmap =
(*pScreen->GetWindowPixmap)((WindowPtr)pDraw);
else
pPortPriv->pPixmap = (PixmapPtr)pDraw;
if (!kaaPixmapIsOffscreen(pPortPriv->pPixmap))
kaaMoveInPixmap(pPortPriv->pPixmap);
if (!kaaPixmapIsOffscreen(pPortPriv->pPixmap)) {
ErrorF("err\n");
return BadAlloc;
}
/* update cliplist */
if (!REGION_EQUAL(screen->pScreen, &pPortPriv->clip, clipBoxes))
REGION_COPY(screen->pScreen, &pPortPriv->clip, clipBoxes);
/* XXX: What do the drw_x and drw_y here mean for us? */
if (atic->is_radeon)
RadeonDisplayVideo(screen, pPortPriv);
else
R128DisplayVideo(screen, pPortPriv);
return Success;
}
static int
ATIQueryImageAttributes(KdScreenInfo *screen, int id, unsigned short *w,
unsigned short *h, int *pitches, int *offsets)
{
int size, tmp;
if (*w > IMAGE_MAX_WIDTH)
*w = IMAGE_MAX_WIDTH;
if (*h > IMAGE_MAX_HEIGHT)
*h = IMAGE_MAX_HEIGHT;
*w = (*w + 1) & ~1;
if (offsets)
offsets[0] = 0;
switch (id)
{
case FOURCC_YV12:
case FOURCC_I420:
*h = (*h + 1) & ~1;
size = (*w + 3) & ~3;
if (pitches)
pitches[0] = size;
size *= *h;
if (offsets)
offsets[1] = size;
tmp = ((*w >> 1) + 3) & ~3;
if (pitches)
pitches[1] = pitches[2] = tmp;
tmp *= (*h >> 1);
size += tmp;
if (offsets)
offsets[2] = size;
size += tmp;
break;
case FOURCC_UYVY:
case FOURCC_YUY2:
default:
size = *w << 1;
if (pitches)
pitches[0] = size;
size *= *h;
break;
}
return size;
}
/* client libraries expect an encoding */
static KdVideoEncodingRec DummyEncoding[1] =
{
{
0,
"XV_IMAGE",
IMAGE_MAX_WIDTH, IMAGE_MAX_HEIGHT,
{1, 1}
}
};
#define NUM_FORMATS 3
static KdVideoFormatRec Formats[NUM_FORMATS] =
{
{15, TrueColor}, {16, TrueColor}, {24, TrueColor}
};
#define NUM_ATTRIBUTES 0
static KdAttributeRec Attributes[NUM_ATTRIBUTES] =
{
};
#define NUM_IMAGES 4
static KdImageRec Images[NUM_IMAGES] =
{
XVIMAGE_YUY2,
XVIMAGE_YV12,
XVIMAGE_I420,
XVIMAGE_UYVY
};
static KdVideoAdaptorPtr
ATISetupImageVideo(ScreenPtr pScreen)
{
KdScreenPriv(pScreen);
ATIScreenInfo(pScreenPriv);
KdVideoAdaptorPtr adapt;
ATIPortPrivPtr pPortPriv;
int i;
atis->num_texture_ports = 16;
adapt = xcalloc(1, sizeof(KdVideoAdaptorRec) + atis->num_texture_ports *
(sizeof(ATIPortPrivRec) + sizeof(DevUnion)));
if (adapt == NULL)
return NULL;
adapt->type = XvWindowMask | XvInputMask | XvImageMask;
adapt->flags = VIDEO_CLIP_TO_VIEWPORT;
adapt->name = "ATI Texture Video";
adapt->nEncodings = 1;
adapt->pEncodings = DummyEncoding;
adapt->nFormats = NUM_FORMATS;
adapt->pFormats = Formats;
adapt->nPorts = atis->num_texture_ports;
adapt->pPortPrivates = (DevUnion*)(&adapt[1]);
pPortPriv =
(ATIPortPrivPtr)(&adapt->pPortPrivates[atis->num_texture_ports]);
for (i = 0; i < atis->num_texture_ports; i++)
adapt->pPortPrivates[i].ptr = &pPortPriv[i];
adapt->nAttributes = NUM_ATTRIBUTES;
adapt->pAttributes = Attributes;
adapt->pImages = Images;
adapt->nImages = NUM_IMAGES;
adapt->PutVideo = NULL;
adapt->PutStill = NULL;
adapt->GetVideo = NULL;
adapt->GetStill = NULL;
adapt->StopVideo = ATIStopVideo;
adapt->SetPortAttribute = ATISetPortAttribute;
adapt->GetPortAttribute = ATIGetPortAttribute;
adapt->QueryBestSize = ATIQueryBestSize;
adapt->PutImage = ATIPutImage;
adapt->ReputImage = ATIReputImage;
adapt->QueryImageAttributes = ATIQueryImageAttributes;
/* gotta uninit this someplace */
REGION_INIT(pScreen, &pPortPriv->clip, NullBox, 0);
atis->pAdaptor = adapt;
xvBrightness = MAKE_ATOM("XV_BRIGHTNESS");
xvSaturation = MAKE_ATOM("XV_SATURATION");
return adapt;
}
Bool ATIInitVideo(ScreenPtr pScreen)
{
KdScreenPriv(pScreen);
ATIScreenInfo(pScreenPriv);
ATICardInfo(pScreenPriv);
KdScreenInfo *screen = pScreenPriv->screen;
KdVideoAdaptorPtr *adaptors, *newAdaptors = NULL;
KdVideoAdaptorPtr newAdaptor = NULL;
int num_adaptors;
atis->pAdaptor = NULL;
if (atic->reg_base == NULL)
return FALSE;
if (atic->is_r300)
return FALSE;
num_adaptors = KdXVListGenericAdaptors(screen, &adaptors);
newAdaptor = ATISetupImageVideo(pScreen);
if (newAdaptor) {
if (!num_adaptors) {
num_adaptors = 1;
adaptors = &newAdaptor;
} else {
newAdaptors = xalloc((num_adaptors + 1) *
sizeof(KdVideoAdaptorPtr *));
if (newAdaptors) {
memcpy(newAdaptors, adaptors, num_adaptors *
sizeof(KdVideoAdaptorPtr));
newAdaptors[num_adaptors] = newAdaptor;
adaptors = newAdaptors;
num_adaptors++;
}
}
}
if (num_adaptors)
KdXVScreenInit(pScreen, adaptors, num_adaptors);
if (newAdaptors)
xfree(newAdaptors);
return TRUE;
}
void
ATIFiniVideo(ScreenPtr pScreen)
{
KdScreenPriv(pScreen);
ATIScreenInfo(pScreenPriv);
KdVideoAdaptorPtr adapt = atis->pAdaptor;
ATIPortPrivPtr pPortPriv;
int i;
if (!adapt)
return;
for (i = 0; i < atis->num_texture_ports; i++) {
pPortPriv = (ATIPortPrivPtr)(&adapt->pPortPrivates[i].ptr);
REGION_UNINIT(pScreen, &pPortPriv->clip);
}
xfree(adapt);
atis->pAdaptor = NULL;
}

View File

@ -1,134 +0,0 @@
/*
* Copyright © 2003 Eric Anholt, Anders Carlsson
*
* 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 Eric Anholt not be used in
* advertising or publicity pertaining to distribution of the software without
* specific, written prior permission. Eric Anholt makes no
* representations about the suitability of this software for any purpose. It
* is provided "as is" without express or implied warranty.
*
* ERIC ANHOLT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL ERIC ANHOLT 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.
*/
#ifdef USE_DMA
#define TAG(x) x##DMA
#define LOCALS RING_LOCALS; \
(void)atic
#define BEGIN(x) BEGIN_RING(x * 2)
#define OUT_REG(reg, val) OUT_RING_REG(reg, val)
#define END() ADVANCE_RING()
#else
#define TAG(x) x##MMIO
#define LOCALS char *mmio = atic->reg_base
#define BEGIN(x) ATIWaitAvailMMIO(x)
#define OUT_REG(reg, val) MMIO_OUT32(mmio, (reg), (val))
#define END()
#endif
static Bool
TAG(R128PrepareBlend)(int op, PicturePtr pSrcPicture, PicturePtr pDstPicture,
PixmapPtr pSrc, PixmapPtr pDst)
{
KdScreenPriv(pDst->drawable.pScreen);
ATIScreenInfo(pScreenPriv);
ATICardInfo(pScreenPriv);
CARD32 dstDatatype, srcDatatype;
LOCALS;
accel_atis = atis;
if (!TAG(ATISetup)(pDst, pSrc))
return FALSE;
src_bpp = pSrc->drawable.bitsPerPixel;
is_repeat = pSrcPicture->repeat;
if (op >= sizeof(R128BlendOp)/sizeof(R128BlendOp[0]))
ATI_FALLBACK(("Unsupported op 0x%x\n", op));
if (pSrcPicture->repeat && (pSrc->drawable.width != 1 ||
pSrc->drawable.height != 1))
ATI_FALLBACK(("repeat unsupported\n"));
if (pSrcPicture->transform != NULL)
ATI_FALLBACK(("transform unsupported\n"));
if (!R128GetDatatypePict(pDstPicture->format, &dstDatatype))
ATI_FALLBACK(("Unsupported dest format 0x%x\n",
pDstPicture->format));
if (!R128GetDatatypePict(pSrcPicture->format, &srcDatatype))
ATI_FALLBACK(("Unsupported src format 0x%x\n",
pSrcPicture->format));
BEGIN(11);
OUT_REG(RADEON_REG_DP_GUI_MASTER_CNTL,
(dstDatatype << 8) |
RADEON_GMC_SRC_DATATYPE_COLOR |
RADEON_GMC_DST_PITCH_OFFSET_CNTL |
RADEON_GMC_CLR_CMP_CNTL_DIS |
RADEON_GMC_AUX_CLIP_DIS |
(ATIBltRop[3] << 16) |
RADEON_GMC_3D_FCN_EN);
OUT_REG(R128_REG_TEX_CNTL_C, R128_TEX_ALPHA_EN | R128_TEX_CACHE_FLUSH);
OUT_REG(R128_REG_PRIM_TEXTURE_COMBINE_CNTL_C, 0);
OUT_REG(R128_REG_SCALE_3D_CNTL,
R128_SCALE_3D_SCALE |
R128BlendOp[op] |
R128_TEX_MAP_ALPHA_IN_TEXTURE);
OUT_REG(R128_REG_SCALE_3D_DATATYPE, srcDatatype);
OUT_REG(R128_REG_SCALE_PITCH, src_pitch / src_bpp);
/* 4.16 fixed point scaling factor? */
if (is_repeat) {
OUT_REG(R128_REG_SCALE_X_INC, 0);
OUT_REG(R128_REG_SCALE_Y_INC, 0);
} else {
OUT_REG(R128_REG_SCALE_X_INC, 65536);
OUT_REG(R128_REG_SCALE_Y_INC, 65536);
}
OUT_REG(R128_REG_SCALE_HACC, 0x00000000);
OUT_REG(R128_REG_SCALE_VACC, 0x00000000);
OUT_REG(RADEON_REG_DP_CNTL,
RADEON_DST_X_LEFT_TO_RIGHT | RADEON_DST_Y_TOP_TO_BOTTOM );
END();
return TRUE;
}
static void
TAG(R128Blend)(int srcX, int srcY, int dstX, int dstY, int width, int height)
{
ATIScreenInfo *atis = accel_atis;
ATICardInfo *atic = atis->atic;
LOCALS;
if (is_repeat) {
srcX = 0;
srcY = 0;
}
BEGIN(4);
OUT_REG(R128_REG_SCALE_OFFSET_0, src_offset + srcY * src_pitch + srcX *
(src_bpp >> 3));
OUT_REG(R128_REG_SCALE_SRC_HEIGHT_WIDTH, (height << 16) | width);
OUT_REG(R128_REG_SCALE_DST_X_Y, (dstX << 16) | dstY);
OUT_REG(R128_REG_SCALE_DST_HEIGHT_WIDTH, (height << 16) | width);
END();
}
static void
TAG(R128DoneBlend)(void)
{
}
#undef TAG
#undef LOCALS
#undef BEGIN
#undef OUT_REG
#undef END

View File

@ -1,170 +0,0 @@
/* r128_common.h -- common header definitions for R128 2D/3D/DRM suite
* Created: Sun Apr 9 18:16:28 2000 by kevin@precisioninsight.com
*
* Copyright 1999, 2000 Precision Insight, Inc., Cedar Park, Texas.
* Copyright 2002 Tungsten Graphics, Inc., Cedar Park, Texas.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) 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
* PRECISION INSIGHT AND/OR ITS SUPPLIERS 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.
*
* Author:
* Gareth Hughes <gareth@valinux.com>
* Kevin E. Martin <martin@valinux.com>
*
* Converted to common header format:
* Jens Owen <jens@tungstengraphics.com>
*
*
*/
#ifndef _R128_COMMON_H_
#define _R128_COMMON_H_
#include "X11/Xmd.h"
/*
* WARNING: If you change any of these defines, make sure to change
* the kernel include file as well (r128_drm.h)
*/
/* Driver specific DRM command indices
* NOTE: these are not OS specific, but they are driver specific
*/
#define DRM_R128_INIT 0x00
#define DRM_R128_CCE_START 0x01
#define DRM_R128_CCE_STOP 0x02
#define DRM_R128_CCE_RESET 0x03
#define DRM_R128_CCE_IDLE 0x04
#define DRM_R128_UNDEFINED1 0x05
#define DRM_R128_RESET 0x06
#define DRM_R128_SWAP 0x07
#define DRM_R128_CLEAR 0x08
#define DRM_R128_VERTEX 0x09
#define DRM_R128_INDICES 0x0a
#define DRM_R128_BLIT 0x0b
#define DRM_R128_DEPTH 0x0c
#define DRM_R128_STIPPLE 0x0d
#define DRM_R128_UNDEFINED2 0x0e
#define DRM_R128_INDIRECT 0x0f
#define DRM_R128_FULLSCREEN 0x10
#define DRM_R128_CLEAR2 0x11
#define DRM_R128_GETPARAM 0x12
#define DRM_R128_FLIP 0x13
#define DRM_R128_FRONT_BUFFER 0x1
#define DRM_R128_BACK_BUFFER 0x2
#define DRM_R128_DEPTH_BUFFER 0x4
typedef struct {
enum {
DRM_R128_INIT_CCE = 0x01,
DRM_R128_CLEANUP_CCE = 0x02
} func;
unsigned long sarea_priv_offset;
int is_pci;
int cce_mode;
int cce_secure; /* FIXME: Deprecated, we should remove this */
int ring_size;
int usec_timeout;
unsigned int fb_bpp;
unsigned int front_offset, front_pitch;
unsigned int back_offset, back_pitch;
unsigned int depth_bpp;
unsigned int depth_offset, depth_pitch;
unsigned int span_offset;
unsigned long fb_offset;
unsigned long mmio_offset;
unsigned long ring_offset;
unsigned long ring_rptr_offset;
unsigned long buffers_offset;
unsigned long agp_textures_offset;
} drmR128Init;
typedef struct {
int flush;
int idle;
} drmR128CCEStop;
typedef struct {
int idx;
int start;
int end;
int discard;
} drmR128Indirect;
typedef struct {
int idx;
int pitch;
int offset;
int format;
unsigned short x, y;
unsigned short width, height;
} drmR128Blit;
typedef struct {
enum {
DRM_R128_WRITE_SPAN = 0x01,
DRM_R128_WRITE_PIXELS = 0x02,
DRM_R128_READ_SPAN = 0x03,
DRM_R128_READ_PIXELS = 0x04
} func;
int n;
int *x;
int *y;
unsigned int *buffer;
unsigned char *mask;
} drmR128Depth;
typedef struct {
int prim;
int idx; /* Index of vertex buffer */
int count; /* Number of vertices in buffer */
int discard; /* Client finished with buffer? */
} drmR128Vertex;
typedef struct {
unsigned int *mask;
} drmR128Stipple;
typedef struct {
unsigned int flags;
unsigned int clear_color;
unsigned int clear_depth;
unsigned int color_mask;
unsigned int depth_mask;
} drmR128Clear;
typedef struct {
enum {
DRM_R128_INIT_FULLSCREEN = 0x01,
DRM_R128_CLEANUP_FULLSCREEN = 0x02
} func;
} drmR128Fullscreen;
typedef struct drm_r128_getparam {
int param;
int *value;
} drmR128GetParam;
#define R128_PARAM_IRQ_NR 1
#endif

View File

@ -1,564 +0,0 @@
/*
* Copyright © 2003 Eric Anholt, Anders Carlsson
*
* 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 Eric Anholt not be used in
* advertising or publicity pertaining to distribution of the software without
* specific, written prior permission. Eric Anholt makes no
* representations about the suitability of this software for any purpose. It
* is provided "as is" without express or implied warranty.
*
* ERIC ANHOLT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL ERIC ANHOLT 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.
*/
#include "ati.h"
#include "ati_reg.h"
#include "ati_dma.h"
#include "ati_draw.h"
extern ATIScreenInfo *accel_atis;
extern int sample_count;
extern float sample_offsets_x[255];
extern float sample_offsets_y[255];
extern CARD8 ATIBltRop[16];
static int widths[2] = {1,1};
static int heights[2] = {1,1};
static Bool is_transform[2];
static PictTransform *transform[2];
struct blendinfo {
Bool dst_alpha;
Bool src_alpha;
CARD32 blendctl;
};
static struct blendinfo R128BlendOp[] = {
/* Clear */
{0, 0, R128_SBLEND_ZERO | R128_DBLEND_ZERO},
/* Src */
{0, 0, R128_SBLEND_ONE | R128_DBLEND_ZERO},
/* Dst */
{0, 0, R128_SBLEND_ZERO | R128_DBLEND_ONE},
/* Over */
{0, 1, R128_SBLEND_ONE | R128_DBLEND_INV_SRC_ALPHA},
/* OverReverse */
{1, 0, R128_SBLEND_INV_DST_ALPHA | R128_DBLEND_ONE},
/* In */
{1, 0, R128_SBLEND_DST_ALPHA | R128_DBLEND_ZERO},
/* InReverse */
{0, 1, R128_SBLEND_ZERO | R128_DBLEND_SRC_ALPHA},
/* Out */
{1, 0, R128_SBLEND_INV_DST_ALPHA | R128_DBLEND_ZERO},
/* OutReverse */
{0, 1, R128_SBLEND_ZERO | R128_DBLEND_INV_SRC_ALPHA},
/* Atop */
{1, 1, R128_SBLEND_DST_ALPHA | R128_DBLEND_INV_SRC_ALPHA},
/* AtopReverse */
{1, 1, R128_SBLEND_INV_DST_ALPHA | R128_DBLEND_SRC_ALPHA},
/* Xor */
{1, 1, R128_SBLEND_INV_DST_ALPHA | R128_DBLEND_INV_SRC_ALPHA},
/* Add */
{0, 0, R128_SBLEND_ONE | R128_DBLEND_ONE},
};
static Bool
R128GetDatatypePict(CARD32 format, CARD32 *type)
{
switch (format) {
case PICT_a1r5g5b5:
case PICT_x1r5g5b5:
*type = R128_DATATYPE_ARGB1555;
return TRUE;
case PICT_r5g6b5:
*type = R128_DATATYPE_RGB565;
return TRUE;
case PICT_a8r8g8b8:
case PICT_x8r8g8b8:
*type = R128_DATATYPE_ARGB8888;
return TRUE;
default:
return FALSE;
}
}
static Bool
R128CheckCompositeTexture(PicturePtr pPict)
{
int w = pPict->pDrawable->width;
int h = pPict->pDrawable->height;
if (w > (1 << 10) || h > (1 << 10))
ATI_FALLBACK(("Picture w/h too large (%dx%d)\n", w, h));
if (pPict->repeat && ((w & (w - 1)) != 0 || (h & (h - 1)) != 0))
ATI_FALLBACK(("NPOT repeat unsupported (%dx%d)\n", w, h));
switch (pPict->format) {
case PICT_a8:
case PICT_a1r5g5b5:
case PICT_a4r4g4b4:
case PICT_r5g6b5:
case PICT_a8r8g8b8:
break;
default:
ATI_FALLBACK(("Unsupported picture format 0x%x\n",
pPict->format));
}
return TRUE;
}
Bool
R128CheckComposite(int op, PicturePtr pSrcPicture, PicturePtr pMaskPicture,
PicturePtr pDstPicture)
{
CARD32 dstDatatype;
if (op >= sizeof(R128BlendOp)/sizeof(R128BlendOp[0]))
ATI_FALLBACK(("Unsupported op 0x%x\n", op));
if (pDstPicture->format == PICT_a8) {
if (R128BlendOp[op].src_alpha || R128BlendOp[op].dst_alpha ||
pMaskPicture != NULL)
ATI_FALLBACK(("alpha blending unsupported with "
"A8 dst?\n"));
} else if (!R128GetDatatypePict(pDstPicture->format, &dstDatatype)) {
ATI_FALLBACK(("Unsupported dest format 0x%x\n",
pDstPicture->format));
}
if (pMaskPicture != NULL && pMaskPicture->componentAlpha &&
R128BlendOp[op].src_alpha)
ATI_FALLBACK(("Component alpha not supported with source alpha "
"blending.\n"));
if (!R128CheckCompositeTexture(pSrcPicture))
return FALSE;
if (pMaskPicture != NULL && !R128CheckCompositeTexture(pMaskPicture))
return FALSE;
return TRUE;
}
static Bool
R128TextureSetup(PicturePtr pPict, PixmapPtr pPix, int unit, CARD32 *txsize,
CARD32 *tex_cntl_c)
{
int w = pPict->pDrawable->width;
int h = pPict->pDrawable->height;
int bytepp, shift, l2w, l2h, l2p;
int pitch;
pitch = pPix->devKind;
if ((pitch & (pitch - 1)) != 0)
ATI_FALLBACK(("NPOT pitch 0x%x unsupported\n", pitch));
switch (pPict->format) {
case PICT_a8:
/* DATATYPE_RGB8 appears to expand the value into the alpha
* channel like we want. We then blank out the R,G,B channels
* as necessary using the combiners.
*/
*tex_cntl_c = R128_DATATYPE_RGB8 << R128_TEX_DATATYPE_SHIFT;
break;
case PICT_a1r5g5b5:
*tex_cntl_c = R128_DATATYPE_ARGB1555 << R128_TEX_DATATYPE_SHIFT;
break;
case PICT_a4r4g4b4:
*tex_cntl_c = R128_DATATYPE_ARGB4444 << R128_TEX_DATATYPE_SHIFT;
break;
case PICT_r5g6b5:
*tex_cntl_c = R128_DATATYPE_RGB565 << R128_TEX_DATATYPE_SHIFT;
break;
case PICT_a8r8g8b8:
*tex_cntl_c = R128_DATATYPE_ARGB8888 << R128_TEX_DATATYPE_SHIFT;
break;
default:
return FALSE;
}
bytepp = PICT_FORMAT_BPP(pPict->format) / 8;
*tex_cntl_c |= R128_MIP_MAP_DISABLE;
if (pPict->filter == PictFilterBilinear)
*tex_cntl_c |= R128_MIN_BLEND_LINEAR | R128_MAG_BLEND_LINEAR;
if (unit == 0)
shift = 0;
else {
shift = 16;
*tex_cntl_c |= R128_SEC_SELECT_SEC_ST;
}
/* ATILog2 returns -1 for value of 0 */
l2w = ATILog2(w - 1) + 1;
l2h = ATILog2(h - 1) + 1;
l2p = ATILog2(pPix->devKind / bytepp);
if (pPict->repeat && w == 1 && h == 1)
l2p = 0;
else if (pPict->repeat && l2p != l2w)
ATI_FALLBACK(("Repeat not supported for pitch != width\n"));
l2w = l2p;
widths[unit] = 1 << l2w;
heights[unit] = 1 << l2h;
*txsize |= l2p << (R128_TEX_PITCH_SHIFT + shift);
*txsize |= ((l2w > l2h) ? l2w : l2h) << (R128_TEX_SIZE_SHIFT + shift);
*txsize |= l2h << (R128_TEX_HEIGHT_SHIFT + shift);
if (pPict->transform != 0) {
is_transform[unit] = TRUE;
transform[unit] = pPict->transform;
} else {
is_transform[unit] = FALSE;
}
return TRUE;
}
Bool
R128PrepareComposite(int op, PicturePtr pSrcPicture, PicturePtr pMaskPicture,
PicturePtr pDstPicture, PixmapPtr pSrc, PixmapPtr pMask, PixmapPtr pDst)
{
KdScreenPriv(pDst->drawable.pScreen);
ATIScreenInfo(pScreenPriv);
CARD32 txsize = 0, prim_tex_cntl_c, sec_tex_cntl_c = 0, dstDatatype;
CARD32 dst_pitch_offset, color_factor, in_color_factor, alpha_comb;
CARD32 blend_cntl;
int i;
RING_LOCALS;
accel_atis = atis;
if (pDstPicture->format == PICT_a8)
dstDatatype = R128_DATATYPE_Y8;
else
R128GetDatatypePict(pDstPicture->format, &dstDatatype);
if (!R128TextureSetup(pSrcPicture, pSrc, 0, &txsize, &prim_tex_cntl_c))
return FALSE;
if (pMask != NULL && !R128TextureSetup(pMaskPicture, pMask, 1, &txsize,
&sec_tex_cntl_c))
return FALSE;
else if (pMask == NULL)
is_transform[1] = FALSE;
if (!ATIGetPixmapOffsetPitch(pDst, &dst_pitch_offset))
return FALSE;
blend_cntl = R128BlendOp[op].blendctl;
if (PICT_FORMAT_A(pDstPicture->format) == 0 &&
R128BlendOp[op].dst_alpha) {
if ((blend_cntl & R128_SBLEND_MASK) ==
R128_SBLEND_DST_ALPHA)
blend_cntl = (blend_cntl & ~R128_SBLEND_MASK) |
R128_SBLEND_ONE;
else if ((blend_cntl & R128_SBLEND_MASK) ==
R128_SBLEND_INV_DST_ALPHA)
blend_cntl = (blend_cntl & ~R128_SBLEND_MASK) |
R128_SBLEND_ZERO;
}
BEGIN_DMA(12);
OUT_REG(R128_REG_SCALE_3D_CNTL,
R128_SCALE_3D_TEXMAP_SHADE |
R128_SCALE_PIX_REPLICATE |
R128_TEX_CACHE_SPLIT |
R128_TEX_MAP_ALPHA_IN_TEXTURE |
R128_TEX_CACHE_LINE_SIZE_4QW);
OUT_REG(ATI_REG_DST_PITCH_OFFSET, dst_pitch_offset);
OUT_REG(ATI_REG_DP_GUI_MASTER_CNTL,
ATI_GMC_DST_PITCH_OFFSET_CNTL |
ATI_GMC_BRUSH_SOLID_COLOR |
(dstDatatype << 8) |
ATI_GMC_SRC_DATATYPE_COLOR |
(ATIBltRop[GXcopy] << 16) |
ATI_DP_SRC_SOURCE_MEMORY |
R128_GMC_3D_FCN_EN |
ATI_GMC_CLR_CMP_CNTL_DIS |
R128_GMC_AUX_CLIP_DIS |
ATI_GMC_WR_MSK_DIS);
OUT_REG(R128_REG_MISC_3D_STATE_CNTL,
R128_MISC_SCALE_3D_TEXMAP_SHADE |
R128_MISC_SCALE_PIX_REPLICATE |
R128_ALPHA_COMB_ADD_CLAMP |
blend_cntl);
OUT_REG(R128_REG_TEX_CNTL_C,
R128_TEXMAP_ENABLE |
((pMask != NULL) ? R128_SEC_TEXMAP_ENABLE : 0) |
R128_ALPHA_ENABLE |
R128_TEX_CACHE_FLUSH);
OUT_REG(R128_REG_PC_GUI_CTLSTAT, R128_PC_FLUSH_GUI);
END_DMA();
/* IN operator: Without a mask, only the first texture unit is enabled.
* With a mask, we put the source in the first unit and have it pass
* through as input to the 2nd. The 2nd unit takes the incoming source
* pixel and modulates it with either the alpha or each of the channels
* in the mask, depending on componentAlpha.
*/
BEGIN_DMA(15);
OUT_RING(DMA_PACKET0(R128_REG_PRIM_TEX_CNTL_C, 14));
OUT_RING_REG(R128_REG_PRIM_TEX_CNTL_C, prim_tex_cntl_c);
/* If this is the only stage and the dest is a8, route the alpha result
* to the color (red channel, in particular), too. Otherwise, be sure
* to zero out color channels of an a8 source.
*/
if (pMaskPicture == NULL && pDstPicture->format == PICT_a8)
color_factor = R128_COLOR_FACTOR_ALPHA;
else if (pSrcPicture->format == PICT_a8)
color_factor = R128_COLOR_FACTOR_CONST_COLOR;
else
color_factor = R128_COLOR_FACTOR_TEX;
if (PICT_FORMAT_A(pSrcPicture->format) == 0)
alpha_comb = R128_COMB_ALPHA_COPY_INP;
else
alpha_comb = R128_COMB_ALPHA_DIS;
OUT_RING_REG(R128_REG_PRIM_TEXTURE_COMBINE_CNTL_C,
R128_COMB_COPY |
color_factor |
R128_INPUT_FACTOR_INT_COLOR |
alpha_comb |
R128_ALPHA_FACTOR_TEX_ALPHA |
R128_INP_FACTOR_A_CONST_ALPHA);
OUT_RING_REG(R128_REG_TEX_SIZE_PITCH_C, txsize);
/* We could save some output by only writing the offset register that
* will actually be used. On the other hand, this is easy.
*/
for (i = 0; i <= 10; i++) {
OUT_RING_REG(R128_REG_PRIM_TEX_0_OFFSET_C + 4 * i,
((CARD8 *)pSrc->devPrivate.ptr -
pScreenPriv->screen->memory_base));
}
END_DMA();
if (pMask != NULL) {
BEGIN_DMA(14);
OUT_RING(DMA_PACKET0(R128_REG_SEC_TEX_CNTL_C, 13));
OUT_RING_REG(R128_REG_SEC_TEX_CNTL_C, sec_tex_cntl_c);
if (pDstPicture->format == PICT_a8) {
color_factor = R128_COLOR_FACTOR_ALPHA;
in_color_factor = R128_INPUT_FACTOR_PREV_ALPHA;
} else if (pMaskPicture->componentAlpha) {
color_factor = R128_COLOR_FACTOR_TEX;
in_color_factor = R128_INPUT_FACTOR_PREV_COLOR;
} else {
color_factor = R128_COLOR_FACTOR_ALPHA;
in_color_factor = R128_INPUT_FACTOR_PREV_COLOR;
}
OUT_RING_REG(R128_REG_SEC_TEXTURE_COMBINE_CNTL_C,
R128_COMB_MODULATE |
color_factor |
in_color_factor |
R128_COMB_ALPHA_MODULATE |
R128_ALPHA_FACTOR_TEX_ALPHA |
R128_INP_FACTOR_A_PREV_ALPHA);
for (i = 0; i <= 10; i++) {
OUT_RING_REG(R128_REG_SEC_TEX_0_OFFSET_C + 4 * i,
((CARD8 *)pMask->devPrivate.ptr -
pScreenPriv->screen->memory_base));
}
END_DMA();
}
return TRUE;
}
#define VTX_RING_COUNT 8
#define VTX_OUT(_dstX, _dstY, _srcX, _srcY, _maskX, _maskY) \
do { \
OUT_RING_F((_dstX)); \
OUT_RING_F(((float)(_dstY)) + .125); \
OUT_RING_F(0.0); \
OUT_RING_F(1.0); \
OUT_RING_F((((float)(_srcX)) + 0.5) / (widths[0])); \
OUT_RING_F((((float)(_srcY)) + 0.5) / (heights[0])); \
OUT_RING_F((((float)(_maskX)) + 0.5) / (widths[1])); \
OUT_RING_F((((float)(_maskY)) + 0.5) / (heights[1])); \
} while (0)
void
R128Composite(int srcX, int srcY, int maskX, int maskY, int dstX, int dstY,
int w, int h)
{
ATIScreenInfo *atis = accel_atis;
int srcXend, srcYend, maskXend, maskYend;
PictVector v;
RING_LOCALS;
/*ErrorF("R128Composite (%d,%d) (%d,%d) (%d,%d) (%d,%d)\n",
srcX, srcY, maskX, maskY,dstX, dstY, w, h);*/
srcXend = srcX + w;
srcYend = srcY + h;
maskXend = maskX + w;
maskYend = maskY + h;
if (is_transform[0]) {
v.vector[0] = IntToxFixed(srcX);
v.vector[1] = IntToxFixed(srcY);
v.vector[2] = xFixed1;
PictureTransformPoint(transform[0], &v);
srcX = xFixedToInt(v.vector[0]);
srcY = xFixedToInt(v.vector[1]);
v.vector[0] = IntToxFixed(srcXend);
v.vector[1] = IntToxFixed(srcYend);
v.vector[2] = xFixed1;
PictureTransformPoint(transform[0], &v);
srcXend = xFixedToInt(v.vector[0]);
srcYend = xFixedToInt(v.vector[1]);
}
if (is_transform[1]) {
v.vector[0] = IntToxFixed(maskX);
v.vector[1] = IntToxFixed(maskY);
v.vector[2] = xFixed1;
PictureTransformPoint(transform[1], &v);
maskX = xFixedToInt(v.vector[0]);
maskY = xFixedToInt(v.vector[1]);
v.vector[0] = IntToxFixed(maskXend);
v.vector[1] = IntToxFixed(maskYend);
v.vector[2] = xFixed1;
PictureTransformPoint(transform[1], &v);
maskXend = xFixedToInt(v.vector[0]);
maskYend = xFixedToInt(v.vector[1]);
}
BEGIN_DMA(3 + 4 * VTX_RING_COUNT);
OUT_RING(DMA_PACKET3(ATI_CCE_PACKET3_3D_RNDR_GEN_PRIM,
2 + 4 * VTX_RING_COUNT));
OUT_RING(R128_CCE_VC_FRMT_RHW |
R128_CCE_VC_FRMT_S_T |
R128_CCE_VC_FRMT_S2_T2);
OUT_RING(R128_CCE_VC_CNTL_PRIM_TYPE_TRI_FAN |
R128_CCE_VC_CNTL_PRIM_WALK_RING |
(4 << R128_CCE_VC_CNTL_NUM_SHIFT));
VTX_OUT(dstX, dstY, srcX, srcY, maskX, maskY);
VTX_OUT(dstX, dstY + h, srcX, srcYend, maskX, maskYend);
VTX_OUT(dstX + w, dstY + h, srcXend, srcYend, maskXend, maskYend);
VTX_OUT(dstX + w, dstY, srcXend, srcY, maskXend, maskY);
END_DMA();
}
void
R128DoneComposite(void)
{
}
Bool
R128PrepareTrapezoids(PicturePtr pDstPicture, PixmapPtr pDst)
{
KdScreenPriv(pDst->drawable.pScreen);
ATIScreenInfo(pScreenPriv);
CARD32 dst_pitch_offset;
RING_LOCALS;
accel_atis = atis;
if (!ATIGetPixmapOffsetPitch(pDst, &dst_pitch_offset))
return FALSE;
BEGIN_DMA(18);
OUT_REG(R128_REG_SCALE_3D_CNTL,
R128_SCALE_3D_TEXMAP_SHADE |
R128_SCALE_PIX_REPLICATE |
R128_TEX_CACHE_SPLIT |
R128_TEX_CACHE_LINE_SIZE_4QW);
OUT_REG(ATI_REG_DST_PITCH_OFFSET, dst_pitch_offset);
OUT_REG(ATI_REG_DP_GUI_MASTER_CNTL,
ATI_GMC_DST_PITCH_OFFSET_CNTL |
ATI_GMC_BRUSH_SOLID_COLOR |
(R128_DATATYPE_RGB8 << 8) |
ATI_GMC_SRC_DATATYPE_COLOR |
(ATIBltRop[GXcopy] << 16) |
ATI_DP_SRC_SOURCE_MEMORY |
R128_GMC_3D_FCN_EN |
ATI_GMC_CLR_CMP_CNTL_DIS |
ATI_GMC_WR_MSK_DIS);
OUT_REG(R128_REG_MISC_3D_STATE_CNTL,
R128_MISC_SCALE_3D_TEXMAP_SHADE |
R128_MISC_SCALE_PIX_REPLICATE |
R128_ALPHA_COMB_ADD_CLAMP |
R128BlendOp[PictOpAdd].blendctl);
OUT_REG(R128_REG_TEX_CNTL_C,
R128_ALPHA_ENABLE);
OUT_REG(R128_REG_PC_GUI_CTLSTAT, R128_PC_FLUSH_GUI);
OUT_RING(DMA_PACKET0(R128_REG_AUX_SC_CNTL, 5));
OUT_RING_REG(R128_REG_AUX_SC_CNTL, R128_AUX1_SC_ENB);
OUT_RING_REG(R128_REG_AUX1_SC_LEFT, 0);
OUT_RING_REG(R128_REG_AUX1_SC_RIGHT, pDst->drawable.width);
OUT_RING_REG(R128_REG_AUX1_SC_TOP, 0);
OUT_RING_REG(R128_REG_AUX1_SC_BOTTOM, pDst->drawable.height);
END_DMA();
return TRUE;
}
#define TRAP_VERT_RING_COUNT 4
#define TRAP_VERT(_x, _y) \
do { \
OUT_RING_F((_x) + sample_x); \
OUT_RING_F((_y) + 0.125 + sample_y); \
OUT_RING_F(0.0); \
OUT_RING(0x01010101); \
} while (0)
void
R128Trapezoids(KaaTrapezoid *traps, int ntraps)
{
ATIScreenInfo *atis = accel_atis;
RING_LOCALS;
while (ntraps > 0) {
int i, sample, count, vertcount;
count = 0xffff / 4 / sample_count;
if (count > ntraps)
count = ntraps;
vertcount = count * sample_count * 4;
BEGIN_DMA(3 + vertcount * TRAP_VERT_RING_COUNT);
OUT_RING(DMA_PACKET3(ATI_CCE_PACKET3_3D_RNDR_GEN_PRIM,
2 + vertcount * TRAP_VERT_RING_COUNT));
OUT_RING(R128_CCE_VC_FRMT_DIFFUSE_ARGB);
OUT_RING(R128_CCE_VC_CNTL_PRIM_TYPE_TRI_FAN |
R128_CCE_VC_CNTL_PRIM_WALK_RING |
(vertcount << R128_CCE_VC_CNTL_NUM_SHIFT));
for (i = 0; i < count; i++) {
for (sample = 0; sample < sample_count; sample++) {
float sample_x = sample_offsets_x[sample];
float sample_y = sample_offsets_y[sample];
TRAP_VERT(traps[i].tl, traps[i].ty);
TRAP_VERT(traps[i].bl, traps[i].by);
TRAP_VERT(traps[i].br, traps[i].by);
TRAP_VERT(traps[i].tr, traps[i].ty);
}
}
END_DMA();
ntraps -= count;
traps += count;
}
}
void
R128DoneTrapezoids(void)
{
}

View File

@ -1,185 +0,0 @@
/*
* Copyright 1999, 2000 ATI Technologies Inc., Markham, Ontario,
* Precision Insight, Inc., Cedar Park, Texas, and
* VA Linux Systems Inc., Fremont, California.
*
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation on the rights to use, copy, modify, merge,
* publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) 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
* NON-INFRINGEMENT. IN NO EVENT SHALL ATI, PRECISION INSIGHT, VA LINUX
* SYSTEMS AND/OR THEIR SUPPLIERS 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.
*/
/*
* Authors:
* Kevin E. Martin <martin@valinux.com>
* Gareth Hughes <gareth@valinux.com>
*
*/
#ifndef _R128_SAREA_H_
#define _R128_SAREA_H_
/* WARNING: If you change any of these defines, make sure to change the
* defines in the kernel file (r128_drm.h)
*/
#ifndef __R128_SAREA_DEFINES__
#define __R128_SAREA_DEFINES__
/* What needs to be changed for the current vertex buffer?
*/
#define R128_UPLOAD_CONTEXT 0x001
#define R128_UPLOAD_SETUP 0x002
#define R128_UPLOAD_TEX0 0x004
#define R128_UPLOAD_TEX1 0x008
#define R128_UPLOAD_TEX0IMAGES 0x010
#define R128_UPLOAD_TEX1IMAGES 0x020
#define R128_UPLOAD_CORE 0x040
#define R128_UPLOAD_MASKS 0x080
#define R128_UPLOAD_WINDOW 0x100
#define R128_UPLOAD_CLIPRECTS 0x200 /* handled client-side */
#define R128_REQUIRE_QUIESCENCE 0x400
#define R128_UPLOAD_ALL 0x7ff
#define R128_FRONT 0x1
#define R128_BACK 0x2
#define R128_DEPTH 0x4
/* Primitive types
*/
#define R128_POINTS 0x1
#define R128_LINES 0x2
#define R128_LINE_STRIP 0x3
#define R128_TRIANGLES 0x4
#define R128_TRIANGLE_FAN 0x5
#define R128_TRIANGLE_STRIP 0x6
/* Vertex/indirect buffer size
*/
#define R128_BUFFER_SIZE 16384
/* Byte offsets for indirect buffer data
*/
#define R128_INDEX_PRIM_OFFSET 20
#define R128_HOSTDATA_BLIT_OFFSET 32
/* Keep these small for testing
*/
#define R128_NR_SAREA_CLIPRECTS 12
#define R128_NR_CONTEXT_REGS 12
#define R128_MAX_TEXTURE_LEVELS 11
#define R128_MAX_TEXTURE_UNITS 2
#endif /* __R128_SAREA_DEFINES__ */
typedef struct {
/* Context state - can be written in one large chunk */
unsigned int dst_pitch_offset_c;
unsigned int dp_gui_master_cntl_c;
unsigned int sc_top_left_c;
unsigned int sc_bottom_right_c;
unsigned int z_offset_c;
unsigned int z_pitch_c;
unsigned int z_sten_cntl_c;
unsigned int tex_cntl_c;
unsigned int misc_3d_state_cntl_reg;
unsigned int texture_clr_cmp_clr_c;
unsigned int texture_clr_cmp_msk_c;
unsigned int fog_color_c;
/* Texture state */
unsigned int tex_size_pitch_c;
unsigned int constant_color_c;
/* Setup state */
unsigned int pm4_vc_fpu_setup;
unsigned int setup_cntl;
/* Mask state */
unsigned int dp_write_mask;
unsigned int sten_ref_mask_c;
unsigned int plane_3d_mask_c;
/* Window state */
unsigned int window_xy_offset;
/* Core state */
unsigned int scale_3d_cntl;
} r128_context_regs_t;
/* Setup registers for each texture unit
*/
typedef struct {
unsigned int tex_cntl;
unsigned int tex_combine_cntl;
unsigned int tex_size_pitch;
unsigned int tex_offset[R128_MAX_TEXTURE_LEVELS];
unsigned int tex_border_color;
} r128_texture_regs_t;
typedef struct {
/* The channel for communication of state information to the kernel
* on firing a vertex buffer.
*/
r128_context_regs_t ContextState;
r128_texture_regs_t TexState[R128_MAX_TEXTURE_UNITS];
unsigned int dirty;
unsigned int vertsize;
unsigned int vc_format;
#ifdef XF86DRI
/* The current cliprects, or a subset thereof.
*/
XF86DRIClipRectRec boxes[R128_NR_SAREA_CLIPRECTS];
unsigned int nbox;
#endif
/* Counters for throttling of rendering clients.
*/
unsigned int last_frame;
unsigned int last_dispatch;
/* Maintain an LRU of contiguous regions of texture space. If you
* think you own a region of texture memory, and it has an age
* different to the one you set, then you are mistaken and it has
* been stolen by another client. If global texAge hasn't changed,
* there is no need to walk the list.
*
* These regions can be used as a proxy for the fine-grained texture
* information of other clients - by maintaining them in the same
* lru which is used to age their own textures, clients have an
* approximate lru for the whole of global texture space, and can
* make informed decisions as to which areas to kick out. There is
* no need to choose whether to kick out your own texture or someone
* else's - simply eject them all in LRU order.
*/
/* Last elt is sentinal */
drmTextureRegion texList[ATI_NR_TEX_HEAPS][ATI_NR_TEX_REGIONS+1];
/* last time texture was uploaded */
unsigned int texAge[ATI_NR_TEX_HEAPS];
int ctxOwner; /* last context to upload state */
int pfAllowPageFlip; /* set by the 2d driver, read by the client */
int pfCurrentPage; /* set by kernel, read by others */
} R128SAREAPriv, *R128SAREAPrivPtr;
#endif

View File

@ -1,460 +0,0 @@
/* radeon_common.h -- common header definitions for Radeon 2D/3D/DRM suite
*
* Copyright 2000 VA Linux Systems, Inc., Fremont, California.
* Copyright 2002 Tungsten Graphics, Inc., Cedar Park, Texas.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) 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
* PRECISION INSIGHT AND/OR ITS SUPPLIERS 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.
*
* Author:
* Gareth Hughes <gareth@valinux.com>
* Kevin E. Martin <martin@valinux.com>
* Keith Whitwell <keith@tungstengraphics.com>
*
* Converted to common header format:
* Jens Owen <jens@tungstengraphics.com>
*
*
*/
#ifndef _RADEON_COMMON_H_
#define _RADEON_COMMON_H_
#include <inttypes.h>
/* WARNING: If you change any of these defines, make sure to change
* the kernel include file as well (radeon_drm.h)
*/
/* Driver specific DRM command indices
* NOTE: these are not OS specific, but they are driver specific
*/
#define DRM_RADEON_CP_INIT 0x00
#define DRM_RADEON_CP_START 0x01
#define DRM_RADEON_CP_STOP 0x02
#define DRM_RADEON_CP_RESET 0x03
#define DRM_RADEON_CP_IDLE 0x04
#define DRM_RADEON_RESET 0x05
#define DRM_RADEON_FULLSCREEN 0x06
#define DRM_RADEON_SWAP 0x07
#define DRM_RADEON_CLEAR 0x08
#define DRM_RADEON_VERTEX 0x09
#define DRM_RADEON_INDICES 0x0a
#define DRM_RADEON_STIPPLE 0x0c
#define DRM_RADEON_INDIRECT 0x0d
#define DRM_RADEON_TEXTURE 0x0e
#define DRM_RADEON_VERTEX2 0x0f
#define DRM_RADEON_CMDBUF 0x10
#define DRM_RADEON_GETPARAM 0x11
#define DRM_RADEON_FLIP 0x12
#define DRM_RADEON_ALLOC 0x13
#define DRM_RADEON_FREE 0x14
#define DRM_RADEON_INIT_HEAP 0x15
#define DRM_RADEON_IRQ_EMIT 0x16
#define DRM_RADEON_IRQ_WAIT 0x17
#define DRM_RADEON_CP_RESUME 0x18
#define DRM_RADEON_SETPARAM 0x19
#define DRM_RADEON_MAX_DRM_COMMAND_INDEX 0x39
#define RADEON_FRONT 0x1
#define RADEON_BACK 0x2
#define RADEON_DEPTH 0x4
#define RADEON_STENCIL 0x8
#define RADEON_CLEAR_X1 0
#define RADEON_CLEAR_Y1 1
#define RADEON_CLEAR_X2 2
#define RADEON_CLEAR_Y2 3
#define RADEON_CLEAR_DEPTH 4
typedef struct {
enum {
DRM_RADEON_INIT_CP = 0x01,
DRM_RADEON_CLEANUP_CP = 0x02,
DRM_RADEON_INIT_R200_CP = 0x03
} func;
unsigned long sarea_priv_offset;
int is_pci;
int cp_mode;
int gart_size;
int ring_size;
int usec_timeout;
unsigned int fb_bpp;
unsigned int front_offset, front_pitch;
unsigned int back_offset, back_pitch;
unsigned int depth_bpp;
unsigned int depth_offset, depth_pitch;
unsigned long fb_offset;
unsigned long mmio_offset;
unsigned long ring_offset;
unsigned long ring_rptr_offset;
unsigned long buffers_offset;
unsigned long gart_textures_offset;
} drmRadeonInit;
typedef struct {
int flush;
int idle;
} drmRadeonCPStop;
typedef struct {
int idx;
int start;
int end;
int discard;
} drmRadeonIndirect;
typedef union drmRadeonClearR {
float f[5];
unsigned int ui[5];
} drmRadeonClearRect;
typedef struct drmRadeonClearT {
unsigned int flags;
unsigned int clear_color;
unsigned int clear_depth;
unsigned int color_mask;
unsigned int depth_mask; /* misnamed field: should be stencil */
drmRadeonClearRect *depth_boxes;
} drmRadeonClearType;
typedef struct drmRadeonFullscreenT {
enum {
RADEON_INIT_FULLSCREEN = 0x01,
RADEON_CLEANUP_FULLSCREEN = 0x02
} func;
} drmRadeonFullscreenType;
typedef struct {
unsigned int *mask;
} drmRadeonStipple;
typedef struct {
unsigned int x;
unsigned int y;
unsigned int width;
unsigned int height;
const void *data;
} drmRadeonTexImage;
typedef struct {
unsigned int offset;
int pitch;
int format;
int width; /* Texture image coordinates */
int height;
drmRadeonTexImage *image;
} drmRadeonTexture;
#define RADEON_MAX_TEXTURE_UNITS 3
/* Layout matches drm_radeon_state_t in linux drm_radeon.h.
*/
typedef struct {
struct {
unsigned int pp_misc; /* 0x1c14 */
unsigned int pp_fog_color;
unsigned int re_solid_color;
unsigned int rb3d_blendcntl;
unsigned int rb3d_depthoffset;
unsigned int rb3d_depthpitch;
unsigned int rb3d_zstencilcntl;
unsigned int pp_cntl; /* 0x1c38 */
unsigned int rb3d_cntl;
unsigned int rb3d_coloroffset;
unsigned int re_width_height;
unsigned int rb3d_colorpitch;
} context;
struct {
unsigned int se_cntl;
} setup1;
struct {
unsigned int se_coord_fmt; /* 0x1c50 */
} vertex;
struct {
unsigned int re_line_pattern; /* 0x1cd0 */
unsigned int re_line_state;
unsigned int se_line_width; /* 0x1db8 */
} line;
struct {
unsigned int pp_lum_matrix; /* 0x1d00 */
unsigned int pp_rot_matrix_0; /* 0x1d58 */
unsigned int pp_rot_matrix_1;
} bumpmap;
struct {
unsigned int rb3d_stencilrefmask; /* 0x1d7c */
unsigned int rb3d_ropcntl;
unsigned int rb3d_planemask;
} mask;
struct {
unsigned int se_vport_xscale; /* 0x1d98 */
unsigned int se_vport_xoffset;
unsigned int se_vport_yscale;
unsigned int se_vport_yoffset;
unsigned int se_vport_zscale;
unsigned int se_vport_zoffset;
} viewport;
struct {
unsigned int se_cntl_status; /* 0x2140 */
} setup2;
struct {
unsigned int re_top_left; /*ignored*/ /* 0x26c0 */
unsigned int re_misc;
} misc;
struct {
unsigned int pp_txfilter;
unsigned int pp_txformat;
unsigned int pp_txoffset;
unsigned int pp_txcblend;
unsigned int pp_txablend;
unsigned int pp_tfactor;
unsigned int pp_border_color;
} texture[RADEON_MAX_TEXTURE_UNITS];
struct {
unsigned int se_zbias_factor;
unsigned int se_zbias_constant;
} zbias;
unsigned int dirty;
} drmRadeonState;
/* 1.1 vertex ioctl. Used in compatibility modes.
*/
typedef struct {
int prim;
int idx; /* Index of vertex buffer */
int count; /* Number of vertices in buffer */
int discard; /* Client finished with buffer? */
} drmRadeonVertex;
typedef struct {
unsigned int start;
unsigned int finish;
unsigned int prim:8;
unsigned int stateidx:8;
unsigned int numverts:16; /* overloaded as offset/64 for elt prims */
unsigned int vc_format;
} drmRadeonPrim;
typedef struct {
int idx; /* Index of vertex buffer */
int discard; /* Client finished with buffer? */
int nr_states;
drmRadeonState *state;
int nr_prims;
drmRadeonPrim *prim;
} drmRadeonVertex2;
#define RADEON_MAX_STATES 16
#define RADEON_MAX_PRIMS 64
/* Command buffer. Replace with true dma stream?
*/
typedef struct {
int bufsz;
char *buf;
int nbox;
drmClipRect *boxes;
} drmRadeonCmdBuffer;
/* New style per-packet identifiers for use in cmd_buffer ioctl with
* the RADEON_EMIT_PACKET command. Comments relate new packets to old
* state bits and the packet size:
*/
#define RADEON_EMIT_PP_MISC 0 /* context/7 */
#define RADEON_EMIT_PP_CNTL 1 /* context/3 */
#define RADEON_EMIT_RB3D_COLORPITCH 2 /* context/1 */
#define RADEON_EMIT_RE_LINE_PATTERN 3 /* line/2 */
#define RADEON_EMIT_SE_LINE_WIDTH 4 /* line/1 */
#define RADEON_EMIT_PP_LUM_MATRIX 5 /* bumpmap/1 */
#define RADEON_EMIT_PP_ROT_MATRIX_0 6 /* bumpmap/2 */
#define RADEON_EMIT_RB3D_STENCILREFMASK 7 /* masks/3 */
#define RADEON_EMIT_SE_VPORT_XSCALE 8 /* viewport/6 */
#define RADEON_EMIT_SE_CNTL 9 /* setup/2 */
#define RADEON_EMIT_SE_CNTL_STATUS 10 /* setup/1 */
#define RADEON_EMIT_RE_MISC 11 /* misc/1 */
#define RADEON_EMIT_PP_TXFILTER_0 12 /* tex0/6 */
#define RADEON_EMIT_PP_BORDER_COLOR_0 13 /* tex0/1 */
#define RADEON_EMIT_PP_TXFILTER_1 14 /* tex1/6 */
#define RADEON_EMIT_PP_BORDER_COLOR_1 15 /* tex1/1 */
#define RADEON_EMIT_PP_TXFILTER_2 16 /* tex2/6 */
#define RADEON_EMIT_PP_BORDER_COLOR_2 17 /* tex2/1 */
#define RADEON_EMIT_SE_ZBIAS_FACTOR 18 /* zbias/2 */
#define RADEON_EMIT_SE_TCL_OUTPUT_VTX_FMT 19 /* tcl/11 */
#define RADEON_EMIT_SE_TCL_MATERIAL_EMMISSIVE_RED 20 /* material/17 */
#define R200_EMIT_PP_TXCBLEND_0 21 /* tex0/4 */
#define R200_EMIT_PP_TXCBLEND_1 22 /* tex1/4 */
#define R200_EMIT_PP_TXCBLEND_2 23 /* tex2/4 */
#define R200_EMIT_PP_TXCBLEND_3 24 /* tex3/4 */
#define R200_EMIT_PP_TXCBLEND_4 25 /* tex4/4 */
#define R200_EMIT_PP_TXCBLEND_5 26 /* tex5/4 */
#define R200_EMIT_PP_TXCBLEND_6 27 /* /4 */
#define R200_EMIT_PP_TXCBLEND_7 28 /* /4 */
#define R200_EMIT_TCL_LIGHT_MODEL_CTL_0 29 /* tcl/6 */
#define R200_EMIT_TFACTOR_0 30 /* tf/6 */
#define R200_EMIT_VTX_FMT_0 31 /* vtx/4 */
#define R200_EMIT_VAP_CTL 32 /* vap/1 */
#define R200_EMIT_MATRIX_SELECT_0 33 /* msl/5 */
#define R200_EMIT_TEX_PROC_CTL_2 34 /* tcg/5 */
#define R200_EMIT_TCL_UCP_VERT_BLEND_CTL 35 /* tcl/1 */
#define R200_EMIT_PP_TXFILTER_0 36 /* tex0/6 */
#define R200_EMIT_PP_TXFILTER_1 37 /* tex1/6 */
#define R200_EMIT_PP_TXFILTER_2 38 /* tex2/6 */
#define R200_EMIT_PP_TXFILTER_3 39 /* tex3/6 */
#define R200_EMIT_PP_TXFILTER_4 40 /* tex4/6 */
#define R200_EMIT_PP_TXFILTER_5 41 /* tex5/6 */
#define R200_EMIT_PP_TXOFFSET_0 42 /* tex0/1 */
#define R200_EMIT_PP_TXOFFSET_1 43 /* tex1/1 */
#define R200_EMIT_PP_TXOFFSET_2 44 /* tex2/1 */
#define R200_EMIT_PP_TXOFFSET_3 45 /* tex3/1 */
#define R200_EMIT_PP_TXOFFSET_4 46 /* tex4/1 */
#define R200_EMIT_PP_TXOFFSET_5 47 /* tex5/1 */
#define R200_EMIT_VTE_CNTL 48 /* vte/1 */
#define R200_EMIT_OUTPUT_VTX_COMP_SEL 49 /* vtx/1 */
#define R200_EMIT_PP_TAM_DEBUG3 50 /* tam/1 */
#define R200_EMIT_PP_CNTL_X 51 /* cst/1 */
#define R200_EMIT_RB3D_DEPTHXY_OFFSET 52 /* cst/1 */
#define R200_EMIT_RE_AUX_SCISSOR_CNTL 53 /* cst/1 */
#define R200_EMIT_RE_SCISSOR_TL_0 54 /* cst/2 */
#define R200_EMIT_RE_SCISSOR_TL_1 55 /* cst/2 */
#define R200_EMIT_RE_SCISSOR_TL_2 56 /* cst/2 */
#define R200_EMIT_SE_VAP_CNTL_STATUS 57 /* cst/1 */
#define R200_EMIT_SE_VTX_STATE_CNTL 58 /* cst/1 */
#define R200_EMIT_RE_POINTSIZE 59 /* cst/1 */
#define R200_EMIT_TCL_INPUT_VTX_VECTOR_ADDR_0 60 /* cst/4 */
#define R200_EMIT_PP_CUBIC_FACES_0 61
#define R200_EMIT_PP_CUBIC_OFFSETS_0 62
#define R200_EMIT_PP_CUBIC_FACES_1 63
#define R200_EMIT_PP_CUBIC_OFFSETS_1 64
#define R200_EMIT_PP_CUBIC_FACES_2 65
#define R200_EMIT_PP_CUBIC_OFFSETS_2 66
#define R200_EMIT_PP_CUBIC_FACES_3 67
#define R200_EMIT_PP_CUBIC_OFFSETS_3 68
#define R200_EMIT_PP_CUBIC_FACES_4 69
#define R200_EMIT_PP_CUBIC_OFFSETS_4 70
#define R200_EMIT_PP_CUBIC_FACES_5 71
#define R200_EMIT_PP_CUBIC_OFFSETS_5 72
#define RADEON_EMIT_PP_TEX_SIZE_0 73
#define RADEON_EMIT_PP_TEX_SIZE_1 74
#define RADEON_EMIT_PP_TEX_SIZE_2 75
#define RADEON_MAX_STATE_PACKETS 76
/* Commands understood by cmd_buffer ioctl. More can be added but
* obviously these can't be removed or changed:
*/
#define RADEON_CMD_PACKET 1 /* emit one of the register packets above */
#define RADEON_CMD_SCALARS 2 /* emit scalar data */
#define RADEON_CMD_VECTORS 3 /* emit vector data */
#define RADEON_CMD_DMA_DISCARD 4 /* discard current dma buf */
#define RADEON_CMD_PACKET3 5 /* emit hw packet */
#define RADEON_CMD_PACKET3_CLIP 6 /* emit hw packet wrapped in cliprects */
#define RADEON_CMD_SCALARS2 7 /* R200 stopgap */
#define RADEON_CMD_WAIT 8 /* synchronization */
typedef union {
int i;
struct {
unsigned char cmd_type, pad0, pad1, pad2;
} header;
struct {
unsigned char cmd_type, packet_id, pad0, pad1;
} packet;
struct {
unsigned char cmd_type, offset, stride, count;
} scalars;
struct {
unsigned char cmd_type, offset, stride, count;
} vectors;
struct {
unsigned char cmd_type, buf_idx, pad0, pad1;
} dma;
struct {
unsigned char cmd_type, flags, pad0, pad1;
} wait;
} drmRadeonCmdHeader;
#define RADEON_WAIT_2D 0x1
#define RADEON_WAIT_3D 0x2
typedef struct drm_radeon_getparam {
int param;
int *value;
} drmRadeonGetParam;
#define RADEON_PARAM_GART_BUFFER_OFFSET 1
#define RADEON_PARAM_LAST_FRAME 2
#define RADEON_PARAM_LAST_DISPATCH 3
#define RADEON_PARAM_LAST_CLEAR 4
#define RADEON_PARAM_IRQ_NR 5
#define RADEON_PARAM_GART_BASE 6
#define RADEON_MEM_REGION_GART 1
#define RADEON_MEM_REGION_FB 2
typedef struct drm_radeon_mem_alloc {
int region;
int alignment;
int size;
int *region_offset; /* offset from start of fb or GART */
} drmRadeonMemAlloc;
typedef struct drm_radeon_mem_free {
int region;
int region_offset;
} drmRadeonMemFree;
typedef struct drm_radeon_mem_init_heap {
int region;
int size;
int start;
} drmRadeonMemInitHeap;
/* 1.6: Userspace can request & wait on irq's:
*/
typedef struct drm_radeon_irq_emit {
int *irq_seq;
} drmRadeonIrqEmit;
typedef struct drm_radeon_irq_wait {
int irq_seq;
} drmRadeonIrqWait;
/* 1.10: Clients tell the DRM where they think the framebuffer is located in
* the card's address space, via a new generic ioctl to set parameters
*/
typedef struct drm_radeon_set_param {
unsigned int param;
int64_t value;
} drmRadeonSetParam;
#define RADEON_SETPARAM_FB_LOCATION 1
#endif

View File

@ -1,875 +0,0 @@
/*
* Copyright © 2003 Eric Anholt
*
* 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 Eric Anholt not be used in
* advertising or publicity pertaining to distribution of the software without
* specific, written prior permission. Eric Anholt makes no
* representations about the suitability of this software for any purpose. It
* is provided "as is" without express or implied warranty.
*
* ERIC ANHOLT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL ERIC ANHOLT 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.
*/
#ifdef HAVE_CONFIG_H
#include <kdrive-config.h>
#endif
#include "ati.h"
#include "ati_reg.h"
#include "ati_dma.h"
#include "ati_draw.h"
extern ATIScreenInfo *accel_atis;
extern int sample_count;
extern float sample_offsets_x[255];
extern float sample_offsets_y[255];
static Bool is_transform[2];
static PictTransform *transform[2];
struct blendinfo {
Bool dst_alpha;
Bool src_alpha;
CARD32 blend_cntl;
};
static struct blendinfo RadeonBlendOp[] = {
/* Clear */
{0, 0, RADEON_SBLEND_GL_ZERO | RADEON_DBLEND_GL_ZERO},
/* Src */
{0, 0, RADEON_SBLEND_GL_ONE | RADEON_DBLEND_GL_ZERO},
/* Dst */
{0, 0, RADEON_SBLEND_GL_ZERO | RADEON_DBLEND_GL_ONE},
/* Over */
{0, 1, RADEON_SBLEND_GL_ONE | RADEON_DBLEND_GL_INV_SRC_ALPHA},
/* OverReverse */
{1, 0, RADEON_SBLEND_GL_INV_DST_ALPHA | RADEON_DBLEND_GL_ONE},
/* In */
{1, 0, RADEON_SBLEND_GL_DST_ALPHA | RADEON_DBLEND_GL_ZERO},
/* InReverse */
{0, 1, RADEON_SBLEND_GL_ZERO | RADEON_DBLEND_GL_SRC_ALPHA},
/* Out */
{1, 0, RADEON_SBLEND_GL_INV_DST_ALPHA | RADEON_DBLEND_GL_ZERO},
/* OutReverse */
{0, 1, RADEON_SBLEND_GL_ZERO | RADEON_DBLEND_GL_INV_SRC_ALPHA},
/* Atop */
{1, 1, RADEON_SBLEND_GL_DST_ALPHA | RADEON_DBLEND_GL_INV_SRC_ALPHA},
/* AtopReverse */
{1, 1, RADEON_SBLEND_GL_INV_DST_ALPHA | RADEON_DBLEND_GL_SRC_ALPHA},
/* Xor */
{1, 1, RADEON_SBLEND_GL_INV_DST_ALPHA | RADEON_DBLEND_GL_INV_SRC_ALPHA},
/* Add */
{0, 0, RADEON_SBLEND_GL_ONE | RADEON_DBLEND_GL_ONE},
};
struct formatinfo {
int fmt;
Bool byte_swap;
CARD32 card_fmt;
};
/* Note on texture formats:
* TXFORMAT_Y8 expands to (Y,Y,Y,1). TXFORMAT_I8 expands to (I,I,I,I)
*/
static struct formatinfo R100TexFormats[] = {
{PICT_a8r8g8b8, 0, RADEON_TXFORMAT_ARGB8888 | RADEON_TXFORMAT_ALPHA_IN_MAP},
{PICT_x8r8g8b8, 0, RADEON_TXFORMAT_ARGB8888},
{PICT_a8b8g8r8, 1, RADEON_TXFORMAT_RGBA8888 | RADEON_TXFORMAT_ALPHA_IN_MAP},
{PICT_x8b8g8r8, 1, RADEON_TXFORMAT_RGBA8888},
{PICT_r5g6b5, 0, RADEON_TXFORMAT_RGB565},
{PICT_a1r5g5b5, 0, RADEON_TXFORMAT_ARGB1555 | RADEON_TXFORMAT_ALPHA_IN_MAP},
{PICT_x1r5g5b5, 0, RADEON_TXFORMAT_ARGB1555},
{PICT_a8, 0, RADEON_TXFORMAT_I8 | RADEON_TXFORMAT_ALPHA_IN_MAP},
};
static struct formatinfo R200TexFormats[] = {
{PICT_a8r8g8b8, 0, R200_TXFORMAT_ARGB8888 | R200_TXFORMAT_ALPHA_IN_MAP},
{PICT_x8r8g8b8, 0, R200_TXFORMAT_ARGB8888},
{PICT_a8r8g8b8, 1, R200_TXFORMAT_RGBA8888 | R200_TXFORMAT_ALPHA_IN_MAP},
{PICT_x8r8g8b8, 1, R200_TXFORMAT_RGBA8888},
{PICT_r5g6b5, 0, R200_TXFORMAT_RGB565},
{PICT_a1r5g5b5, 0, R200_TXFORMAT_ARGB1555 | R200_TXFORMAT_ALPHA_IN_MAP},
{PICT_x1r5g5b5, 0, R200_TXFORMAT_ARGB1555},
{PICT_a8, 0, R200_TXFORMAT_I8 | R200_TXFORMAT_ALPHA_IN_MAP},
};
/* Common Radeon setup code */
static Bool
RadeonGetDestFormat(PicturePtr pDstPicture, CARD32 *dst_format)
{
switch (pDstPicture->format) {
case PICT_a8r8g8b8:
case PICT_x8r8g8b8:
*dst_format = RADEON_COLOR_FORMAT_ARGB8888;
break;
case PICT_r5g6b5:
*dst_format = RADEON_COLOR_FORMAT_RGB565;
break;
case PICT_a1r5g5b5:
case PICT_x1r5g5b5:
*dst_format = RADEON_COLOR_FORMAT_ARGB1555;
break;
case PICT_a8:
*dst_format = RADEON_COLOR_FORMAT_RGB8;
break;
default:
ATI_FALLBACK(("Unsupported dest format 0x%x\n",
pDstPicture->format));
}
return TRUE;
}
/* R100-specific code */
static Bool
R100CheckCompositeTexture(PicturePtr pPict, int unit)
{
int w = pPict->pDrawable->width;
int h = pPict->pDrawable->height;
int i;
if ((w > 0x7ff) || (h > 0x7ff))
ATI_FALLBACK(("Picture w/h too large (%dx%d)\n", w, h));
for (i = 0; i < sizeof(R100TexFormats) / sizeof(R100TexFormats[0]); i++)
{
if (R100TexFormats[i].fmt == pPict->format)
break;
}
if (i == sizeof(R100TexFormats) / sizeof(R100TexFormats[0]))
ATI_FALLBACK(("Unsupported picture format 0x%x\n",
pPict->format));
if (pPict->repeat && ((w & (w - 1)) != 0 || (h & (h - 1)) != 0))
ATI_FALLBACK(("NPOT repeat unsupported (%dx%d)\n", w, h));
if (pPict->filter != PictFilterNearest &&
pPict->filter != PictFilterBilinear)
ATI_FALLBACK(("Unsupported filter 0x%x\n", pPict->filter));
return TRUE;
}
static Bool
R100TextureSetup(PicturePtr pPict, PixmapPtr pPix, int unit)
{
ATIScreenInfo *atis = accel_atis;
KdScreenPriv(pPix->drawable.pScreen);
CARD32 txfilter, txformat, txoffset, txpitch;
int w = pPict->pDrawable->width;
int h = pPict->pDrawable->height;
int i;
RING_LOCALS;
txpitch = pPix->devKind;
txoffset = ((CARD8 *)pPix->devPrivate.ptr -
pScreenPriv->screen->memory_base);
for (i = 0; i < sizeof(R100TexFormats) / sizeof(R100TexFormats[0]); i++)
{
if (R100TexFormats[i].fmt == pPict->format)
break;
}
txformat = R100TexFormats[i].card_fmt;
if (R100TexFormats[i].byte_swap)
txoffset |= RADEON_TXO_ENDIAN_BYTE_SWAP;
if (pPict->repeat) {
txformat |= ATILog2(w) << RADEON_TXFORMAT_WIDTH_SHIFT;
txformat |= ATILog2(h) << RADEON_TXFORMAT_HEIGHT_SHIFT;
} else
txformat |= RADEON_TXFORMAT_NON_POWER2;
txformat |= unit << 24; /* RADEON_TXFORMAT_ST_ROUTE_STQX */
if ((txoffset & 0x1f) != 0)
ATI_FALLBACK(("Bad texture offset 0x%x\n", txoffset));
if ((txpitch & 0x1f) != 0)
ATI_FALLBACK(("Bad texture pitch 0x%x\n", txpitch));
switch (pPict->filter) {
case PictFilterNearest:
txfilter = (RADEON_MAG_FILTER_NEAREST |
RADEON_MIN_FILTER_NEAREST);
break;
case PictFilterBilinear:
txfilter = (RADEON_MAG_FILTER_LINEAR |
RADEON_MIN_FILTER_LINEAR);
break;
default:
ATI_FALLBACK(("Bad filter 0x%x\n", pPict->filter));
}
BEGIN_DMA(7);
if (unit == 0) {
OUT_RING(DMA_PACKET0(RADEON_REG_PP_TXFILTER_0, 3));
OUT_RING_REG(RADEON_REG_PP_TXFILTER_0, txfilter);
OUT_RING_REG(RADEON_REG_PP_TXFORMAT_0, txformat);
OUT_RING_REG(RADEON_REG_PP_TXOFFSET_0, txoffset);
OUT_RING(DMA_PACKET0(RADEON_REG_PP_TEX_SIZE_0, 2));
OUT_RING_REG(RADEON_REG_PP_TEX_SIZE_0,
(pPix->drawable.width - 1) |
((pPix->drawable.height - 1) << RADEON_TEX_VSIZE_SHIFT));
OUT_RING_REG(RADEON_REG_PP_TEX_PITCH_0, txpitch - 32);
} else {
OUT_RING(DMA_PACKET0(RADEON_REG_PP_TXFILTER_1, 3));
OUT_RING_REG(RADEON_REG_PP_TXFILTER_1, txfilter);
OUT_RING_REG(RADEON_REG_PP_TXFORMAT_1, txformat);
OUT_RING_REG(RADEON_REG_PP_TXOFFSET_1, txoffset);
OUT_RING(DMA_PACKET0(RADEON_REG_PP_TEX_SIZE_1, 2));
OUT_RING_REG(RADEON_REG_PP_TEX_SIZE_1,
(pPix->drawable.width - 1) |
((pPix->drawable.height - 1) << RADEON_TEX_VSIZE_SHIFT));
OUT_RING_REG(RADEON_REG_PP_TEX_PITCH_1, txpitch - 32);
}
END_DMA();
if (pPict->transform != 0) {
is_transform[unit] = TRUE;
transform[unit] = pPict->transform;
} else {
is_transform[unit] = FALSE;
}
return TRUE;
}
Bool
R100CheckComposite(int op, PicturePtr pSrcPicture, PicturePtr pMaskPicture,
PicturePtr pDstPicture)
{
CARD32 tmp1;
/* Check for unsupported compositing operations. */
if (op >= sizeof(RadeonBlendOp) / sizeof(RadeonBlendOp[0]))
ATI_FALLBACK(("Unsupported Composite op 0x%x\n", op));
if (pMaskPicture != NULL && pMaskPicture->componentAlpha &&
RadeonBlendOp[op].src_alpha)
ATI_FALLBACK(("Component alpha not supported with source "
"alpha blending.\n"));
if (pDstPicture->pDrawable->width >= (1 << 11) ||
pDstPicture->pDrawable->height >= (1 << 11))
ATI_FALLBACK(("Dest w/h too large (%d,%d).\n",
pDstPicture->pDrawable->width,
pDstPicture->pDrawable->height));
if (!R100CheckCompositeTexture(pSrcPicture, 0))
return FALSE;
if (pMaskPicture != NULL && !R100CheckCompositeTexture(pMaskPicture, 1))
return FALSE;
if (pDstPicture->componentAlpha)
return FALSE;
if (!RadeonGetDestFormat(pDstPicture, &tmp1))
return FALSE;
return TRUE;
}
Bool
R100PrepareComposite(int op, PicturePtr pSrcPicture, PicturePtr pMaskPicture,
PicturePtr pDstPicture, PixmapPtr pSrc, PixmapPtr pMask, PixmapPtr pDst)
{
KdScreenPriv(pDst->drawable.pScreen);
ATIScreenInfo(pScreenPriv);
CARD32 dst_format, dst_offset, dst_pitch;
CARD32 pp_cntl, blendcntl, cblend, ablend;
int pixel_shift;
RING_LOCALS;
accel_atis = atis;
RadeonGetDestFormat(pDstPicture, &dst_format);
pixel_shift = pDst->drawable.bitsPerPixel >> 4;
dst_offset = ((CARD8 *)pDst->devPrivate.ptr -
pScreenPriv->screen->memory_base);
dst_pitch = pDst->devKind;
if ((dst_offset & 0x0f) != 0)
ATI_FALLBACK(("Bad destination offset 0x%x\n", dst_offset));
if (((dst_pitch >> pixel_shift) & 0x7) != 0)
ATI_FALLBACK(("Bad destination pitch 0x%x\n", dst_pitch));
if (!R100TextureSetup(pSrcPicture, pSrc, 0))
return FALSE;
pp_cntl = RADEON_TEX_0_ENABLE | RADEON_TEX_BLEND_0_ENABLE;
if (pMask != NULL) {
if (!R100TextureSetup(pMaskPicture, pMask, 1))
return FALSE;
pp_cntl |= RADEON_TEX_1_ENABLE;
} else {
is_transform[1] = FALSE;
}
ENTER_DRAW(pDst);
RadeonSwitchTo3D(atis);
BEGIN_DMA(12);
OUT_RING(DMA_PACKET0(RADEON_REG_PP_CNTL, 3));
OUT_RING_REG(RADEON_REG_PP_CNTL, pp_cntl);
OUT_RING_REG(RADEON_REG_RB3D_CNTL,
dst_format | RADEON_ALPHA_BLEND_ENABLE);
OUT_RING_REG(RADEON_REG_RB3D_COLOROFFSET, dst_offset);
OUT_REG(RADEON_REG_RB3D_COLORPITCH, dst_pitch >> pixel_shift);
/* IN operator: Multiply src by mask components or mask alpha.
* BLEND_CTL_ADD is A * B + C.
* If a picture is a8, we have to explicitly zero its color values.
* If the destination is a8, we have to route the alpha to red, I think.
*/
cblend = RADEON_BLEND_CTL_ADD | RADEON_CLAMP_TX |
RADEON_COLOR_ARG_C_ZERO;
ablend = RADEON_BLEND_CTL_ADD | RADEON_CLAMP_TX |
RADEON_ALPHA_ARG_C_ZERO;
if (pDstPicture->format == PICT_a8)
cblend |= RADEON_COLOR_ARG_A_T0_ALPHA;
else if (pSrcPicture->format == PICT_a8)
cblend |= RADEON_COLOR_ARG_A_ZERO;
else
cblend |= RADEON_COLOR_ARG_A_T0_COLOR;
ablend |= RADEON_ALPHA_ARG_A_T0_ALPHA;
if (pMask) {
if (pMaskPicture->componentAlpha &&
pDstPicture->format != PICT_a8)
cblend |= RADEON_COLOR_ARG_B_T1_COLOR;
else
cblend |= RADEON_COLOR_ARG_B_T1_ALPHA;
ablend |= RADEON_ALPHA_ARG_B_T1_ALPHA;
} else {
cblend |= RADEON_COLOR_ARG_B_ZERO | RADEON_COMP_ARG_B;
ablend |= RADEON_ALPHA_ARG_B_ZERO | RADEON_COMP_ARG_B;
}
OUT_REG(RADEON_REG_PP_TXCBLEND_0, cblend);
OUT_REG(RADEON_REG_PP_TXABLEND_0, ablend);
/* Op operator. */
blendcntl = RadeonBlendOp[op].blend_cntl;
if (PICT_FORMAT_A(pDstPicture->format) == 0 &&
RadeonBlendOp[op].dst_alpha) {
if ((blendcntl & RADEON_SBLEND_MASK) ==
RADEON_SBLEND_GL_DST_ALPHA)
blendcntl = (blendcntl & ~RADEON_SBLEND_MASK) |
RADEON_SBLEND_GL_ONE;
else if ((blendcntl & RADEON_SBLEND_MASK) ==
RADEON_SBLEND_GL_INV_DST_ALPHA)
blendcntl = (blendcntl & ~RADEON_SBLEND_MASK) |
RADEON_SBLEND_GL_ZERO;
}
OUT_REG(RADEON_REG_RB3D_BLENDCNTL, blendcntl);
END_DMA();
LEAVE_DRAW(pDst);
return TRUE;
}
static Bool
R200CheckCompositeTexture(PicturePtr pPict, int unit)
{
int w = pPict->pDrawable->width;
int h = pPict->pDrawable->height;
int i;
if ((w > 0x7ff) || (h > 0x7ff))
ATI_FALLBACK(("Picture w/h too large (%dx%d)\n", w, h));
for (i = 0; i < sizeof(R200TexFormats) / sizeof(R200TexFormats[0]); i++)
{
if (R200TexFormats[i].fmt == pPict->format)
break;
}
if (i == sizeof(R200TexFormats) / sizeof(R200TexFormats[0]))
ATI_FALLBACK(("Unsupported picture format 0x%x\n",
pPict->format));
if (pPict->repeat && ((w & (w - 1)) != 0 || (h & (h - 1)) != 0))
ATI_FALLBACK(("NPOT repeat unsupported (%dx%d)\n", w, h));
if (pPict->filter != PictFilterNearest &&
pPict->filter != PictFilterBilinear)
ATI_FALLBACK(("Unsupported filter 0x%x\n", pPict->filter));
return TRUE;
}
static Bool
R200TextureSetup(PicturePtr pPict, PixmapPtr pPix, int unit)
{
ATIScreenInfo *atis = accel_atis;
KdScreenPriv(pPix->drawable.pScreen);
CARD32 txfilter, txformat, txoffset, txpitch;
int w = pPict->pDrawable->width;
int h = pPict->pDrawable->height;
int i;
RING_LOCALS;
txpitch = pPix->devKind;
txoffset = ((CARD8 *)pPix->devPrivate.ptr -
pScreenPriv->screen->memory_base);
for (i = 0; i < sizeof(R200TexFormats) / sizeof(R200TexFormats[0]); i++)
{
if (R200TexFormats[i].fmt == pPict->format)
break;
}
txformat = R200TexFormats[i].card_fmt;
if (R200TexFormats[i].byte_swap)
txoffset |= R200_TXO_ENDIAN_BYTE_SWAP;
if (pPict->repeat) {
txformat |= ATILog2(w) << R200_TXFORMAT_WIDTH_SHIFT;
txformat |= ATILog2(h) << R200_TXFORMAT_HEIGHT_SHIFT;
} else
txformat |= R200_TXFORMAT_NON_POWER2;
txformat |= unit << R200_TXFORMAT_ST_ROUTE_SHIFT;
if ((txoffset & 0x1f) != 0)
ATI_FALLBACK(("Bad texture offset 0x%x\n", txoffset));
if ((txpitch & 0x1f) != 0)
ATI_FALLBACK(("Bad texture pitch 0x%x\n", txpitch));
switch (pPict->filter) {
case PictFilterNearest:
txfilter = (R200_MAG_FILTER_NEAREST |
R200_MIN_FILTER_NEAREST);
break;
case PictFilterBilinear:
txfilter = (R200_MAG_FILTER_LINEAR |
R200_MIN_FILTER_LINEAR);
break;
default:
ATI_FALLBACK(("Bad filter 0x%x\n", pPict->filter));
}
if (unit == 0) {
BEGIN_DMA(6);
OUT_RING(DMA_PACKET0(R200_REG_PP_TXFILTER_0 + 0x20 * unit, 5));
OUT_RING_REG(R200_REG_PP_TXFILTER_0, txfilter);
OUT_RING_REG(R200_REG_PP_TXFORMAT_0, txformat);
OUT_RING_REG(R200_REG_PP_TXFORMAT_X_0, 0);
OUT_RING_REG(R200_REG_PP_TXSIZE_0,
(pPix->drawable.width - 1) |
((pPix->drawable.height - 1) << RADEON_TEX_VSIZE_SHIFT));
OUT_RING_REG(R200_REG_PP_TXPITCH_0, txpitch - 32);
END_DMA();
} else {
BEGIN_DMA(6);
OUT_RING(DMA_PACKET0(R200_REG_PP_TXFILTER_1, 5));
OUT_RING_REG(R200_REG_PP_TXFILTER_1, txfilter);
OUT_RING_REG(R200_REG_PP_TXFORMAT_1, txformat);
OUT_RING_REG(R200_REG_PP_TXFORMAT_X_1, 0);
OUT_RING_REG(R200_REG_PP_TXSIZE_1,
(pPix->drawable.width - 1) |
((pPix->drawable.height - 1) << RADEON_TEX_VSIZE_SHIFT));
OUT_RING_REG(R200_REG_PP_TXPITCH_1, txpitch - 32);
END_DMA();
}
BEGIN_DMA(2);
OUT_REG(R200_PP_TXOFFSET_0 + 0x18 * unit, txoffset);
END_DMA();
if (pPict->transform != 0) {
is_transform[unit] = TRUE;
transform[unit] = pPict->transform;
} else {
is_transform[unit] = FALSE;
}
return TRUE;
}
Bool
R200CheckComposite(int op, PicturePtr pSrcPicture, PicturePtr pMaskPicture,
PicturePtr pDstPicture)
{
CARD32 tmp1;
/* Check for unsupported compositing operations. */
if (op >= sizeof(RadeonBlendOp) / sizeof(RadeonBlendOp[0]))
ATI_FALLBACK(("Unsupported Composite op 0x%x\n", op));
if (pMaskPicture != NULL && pMaskPicture->componentAlpha &&
RadeonBlendOp[op].src_alpha)
ATI_FALLBACK(("Component alpha not supported with source "
"alpha blending.\n"));
if (!R200CheckCompositeTexture(pSrcPicture, 0))
return FALSE;
if (pMaskPicture != NULL && !R200CheckCompositeTexture(pMaskPicture, 1))
return FALSE;
if (!RadeonGetDestFormat(pDstPicture, &tmp1))
return FALSE;
return TRUE;
}
Bool
R200PrepareComposite(int op, PicturePtr pSrcPicture, PicturePtr pMaskPicture,
PicturePtr pDstPicture, PixmapPtr pSrc, PixmapPtr pMask, PixmapPtr pDst)
{
KdScreenPriv(pDst->drawable.pScreen);
ATIScreenInfo(pScreenPriv);
CARD32 dst_format, dst_offset, dst_pitch;
CARD32 pp_cntl, blendcntl, cblend, ablend;
int pixel_shift;
RING_LOCALS;
RadeonGetDestFormat(pDstPicture, &dst_format);
pixel_shift = pDst->drawable.bitsPerPixel >> 4;
accel_atis = atis;
dst_offset = ((CARD8 *)pDst->devPrivate.ptr -
pScreenPriv->screen->memory_base);
dst_pitch = pDst->devKind;
if ((dst_offset & 0x0f) != 0)
ATI_FALLBACK(("Bad destination offset 0x%x\n", dst_offset));
if (((dst_pitch >> pixel_shift) & 0x7) != 0)
ATI_FALLBACK(("Bad destination pitch 0x%x\n", dst_pitch));
if (!R200TextureSetup(pSrcPicture, pSrc, 0))
return FALSE;
pp_cntl = RADEON_TEX_0_ENABLE | RADEON_TEX_BLEND_0_ENABLE;
if (pMask != NULL) {
if (!R200TextureSetup(pMaskPicture, pMask, 1))
return FALSE;
pp_cntl |= RADEON_TEX_1_ENABLE;
} else {
is_transform[1] = FALSE;
}
RadeonSwitchTo3D(atis);
BEGIN_DMA(17);
OUT_RING(DMA_PACKET0(RADEON_REG_PP_CNTL, 3));
OUT_RING_REG(RADEON_REG_PP_CNTL, pp_cntl);
OUT_RING_REG(RADEON_REG_RB3D_CNTL, dst_format | RADEON_ALPHA_BLEND_ENABLE);
OUT_RING_REG(RADEON_REG_RB3D_COLOROFFSET, dst_offset);
OUT_REG(R200_REG_SE_VTX_FMT_0, R200_VTX_XY);
OUT_REG(R200_REG_SE_VTX_FMT_1,
(2 << R200_VTX_TEX0_COMP_CNT_SHIFT) |
(2 << R200_VTX_TEX1_COMP_CNT_SHIFT));
OUT_REG(RADEON_REG_RB3D_COLORPITCH, dst_pitch >> pixel_shift);
/* IN operator: Multiply src by mask components or mask alpha.
* BLEND_CTL_ADD is A * B + C.
* If a picture is a8, we have to explicitly zero its color values.
* If the destination is a8, we have to route the alpha to red, I think.
*/
cblend = R200_TXC_OP_MADD | R200_TXC_ARG_C_ZERO;
ablend = R200_TXA_OP_MADD | R200_TXA_ARG_C_ZERO;
if (pDstPicture->format == PICT_a8)
cblend |= R200_TXC_ARG_A_R0_ALPHA;
else if (pSrcPicture->format == PICT_a8)
cblend |= R200_TXC_ARG_A_ZERO;
else
cblend |= R200_TXC_ARG_A_R0_COLOR;
ablend |= R200_TXA_ARG_A_R0_ALPHA;
if (pMask) {
if (pMaskPicture->componentAlpha &&
pDstPicture->format != PICT_a8)
cblend |= R200_TXC_ARG_B_R1_COLOR;
else
cblend |= R200_TXC_ARG_B_R1_ALPHA;
ablend |= R200_TXA_ARG_B_R1_ALPHA;
} else {
cblend |= R200_TXC_ARG_B_ZERO | R200_TXC_COMP_ARG_B;
ablend |= R200_TXA_ARG_B_ZERO | R200_TXA_COMP_ARG_B;
}
OUT_RING(DMA_PACKET0(R200_REG_PP_TXCBLEND_0, 4));
OUT_RING_REG(R200_REG_PP_TXCBLEND_0, cblend);
OUT_RING_REG(R200_REG_PP_TXCBLEND2_0,
R200_TXC_CLAMP_0_1 | R200_TXC_OUTPUT_REG_R0);
OUT_RING_REG(R200_REG_PP_TXABLEND_0, ablend);
OUT_RING_REG(R200_REG_PP_TXABLEND2_0,
R200_TXA_CLAMP_0_1 | R200_TXA_OUTPUT_REG_R0);
/* Op operator. */
blendcntl = RadeonBlendOp[op].blend_cntl;
if (PICT_FORMAT_A(pDstPicture->format) == 0 &&
RadeonBlendOp[op].dst_alpha) {
if ((blendcntl & RADEON_SBLEND_MASK) ==
RADEON_SBLEND_GL_DST_ALPHA)
blendcntl = (blendcntl & ~RADEON_SBLEND_MASK) |
RADEON_SBLEND_GL_ONE;
else if ((blendcntl & RADEON_SBLEND_MASK) ==
RADEON_SBLEND_GL_INV_DST_ALPHA)
blendcntl = (blendcntl & ~RADEON_SBLEND_MASK) |
RADEON_SBLEND_GL_ZERO;
}
OUT_REG(RADEON_REG_RB3D_BLENDCNTL, blendcntl);
END_DMA();
return TRUE;
}
union intfloat {
float f;
CARD32 i;
};
struct blend_vertex {
union intfloat x, y;
union intfloat s0, t0;
union intfloat s1, t1;
};
#define VTX_DWORD_COUNT 6
#define VTX_OUT(_dstX, _dstY, _srcX, _srcY, _maskX, _maskY) \
do { \
OUT_RING_F(_dstX); \
OUT_RING_F(_dstY); \
OUT_RING_F(_srcX); \
OUT_RING_F(_srcY); \
OUT_RING_F(_maskX); \
OUT_RING_F(_maskY); \
} while (0)
void
RadeonComposite(int srcX, int srcY, int maskX, int maskY, int dstX, int dstY,
int w, int h)
{
ATIScreenInfo *atis = accel_atis;
ATICardInfo *atic = atis->atic;
int srcXend, srcYend, maskXend, maskYend;
RING_LOCALS;
PictVector v;
ENTER_DRAW(0);
/*ErrorF("RadeonComposite (%d,%d) (%d,%d) (%d,%d) (%d,%d)\n",
srcX, srcY, maskX, maskY,dstX, dstY, w, h);*/
srcXend = srcX + w;
srcYend = srcY + h;
maskXend = maskX + w;
maskYend = maskY + h;
if (is_transform[0]) {
v.vector[0] = IntToxFixed(srcX);
v.vector[1] = IntToxFixed(srcY);
v.vector[2] = xFixed1;
PictureTransformPoint(transform[0], &v);
srcX = xFixedToInt(v.vector[0]);
srcY = xFixedToInt(v.vector[1]);
v.vector[0] = IntToxFixed(srcXend);
v.vector[1] = IntToxFixed(srcYend);
v.vector[2] = xFixed1;
PictureTransformPoint(transform[0], &v);
srcXend = xFixedToInt(v.vector[0]);
srcYend = xFixedToInt(v.vector[1]);
}
if (is_transform[1]) {
v.vector[0] = IntToxFixed(maskX);
v.vector[1] = IntToxFixed(maskY);
v.vector[2] = xFixed1;
PictureTransformPoint(transform[1], &v);
maskX = xFixedToInt(v.vector[0]);
maskY = xFixedToInt(v.vector[1]);
v.vector[0] = IntToxFixed(maskXend);
v.vector[1] = IntToxFixed(maskYend);
v.vector[2] = xFixed1;
PictureTransformPoint(transform[1], &v);
maskXend = xFixedToInt(v.vector[0]);
maskYend = xFixedToInt(v.vector[1]);
}
if (atic->is_r100) {
BEGIN_DMA(4 * VTX_DWORD_COUNT + 3);
OUT_RING(DMA_PACKET3(RADEON_CP_PACKET3_3D_DRAW_IMMD,
4 * VTX_DWORD_COUNT + 2));
OUT_RING(RADEON_CP_VC_FRMT_XY |
RADEON_CP_VC_FRMT_ST0 |
RADEON_CP_VC_FRMT_ST1);
OUT_RING(RADEON_CP_VC_CNTL_PRIM_TYPE_TRI_FAN |
RADEON_CP_VC_CNTL_PRIM_WALK_RING |
RADEON_CP_VC_CNTL_MAOS_ENABLE |
RADEON_CP_VC_CNTL_VTX_FMT_RADEON_MODE |
(4 << RADEON_CP_VC_CNTL_NUM_SHIFT));
} else {
BEGIN_DMA(4 * VTX_DWORD_COUNT + 2);
OUT_RING(DMA_PACKET3(R200_CP_PACKET3_3D_DRAW_IMMD_2,
4 * VTX_DWORD_COUNT + 1));
OUT_RING(RADEON_CP_VC_CNTL_PRIM_TYPE_TRI_FAN |
RADEON_CP_VC_CNTL_PRIM_WALK_RING |
(4 << RADEON_CP_VC_CNTL_NUM_SHIFT));
}
VTX_OUT(dstX, dstY, srcX, srcY, maskX, maskY);
VTX_OUT(dstX, dstY + h, srcX, srcYend, maskX, maskYend);
VTX_OUT(dstX + w, dstY + h, srcXend, srcYend, maskXend, maskYend);
VTX_OUT(dstX + w, dstY, srcXend, srcY, maskXend, maskY);
LEAVE_DRAW(0);
END_DMA();
}
void
RadeonDoneComposite(void)
{
ENTER_DRAW(0);
LEAVE_DRAW(0);
}
Bool
RadeonPrepareTrapezoids(PicturePtr pDstPicture, PixmapPtr pDst)
{
KdScreenPriv(pDst->drawable.pScreen);
ATIScreenInfo(pScreenPriv);
ATICardInfo(pScreenPriv);
CARD32 dst_offset, dst_pitch;
int pixel_shift;
RING_LOCALS;
pixel_shift = pDst->drawable.bitsPerPixel >> 4;
accel_atis = atis;
dst_offset = ((CARD8 *)pDst->devPrivate.ptr -
pScreenPriv->screen->memory_base);
dst_pitch = pDst->devKind;
if ((dst_offset & 0x0f) != 0)
ATI_FALLBACK(("Bad destination offset 0x%x\n", dst_offset));
if (((dst_pitch >> pixel_shift) & 0x7) != 0)
ATI_FALLBACK(("Bad destination pitch 0x%x\n", dst_pitch));
RadeonSwitchTo3D(atis);
BEGIN_DMA(8);
OUT_RING(DMA_PACKET0(RADEON_REG_PP_CNTL, 5));
OUT_RING_REG(RADEON_REG_PP_CNTL, RADEON_TEX_BLEND_0_ENABLE);
OUT_RING_REG(RADEON_REG_RB3D_CNTL,
RADEON_COLOR_FORMAT_RGB8 | RADEON_ALPHA_BLEND_ENABLE);
OUT_RING_REG(RADEON_REG_RB3D_COLOROFFSET, dst_offset);
OUT_RING_REG(RADEON_REG_RE_WIDTH_HEIGHT,
((pDst->drawable.height - 1) << 16) |
(pDst->drawable.width - 1));
OUT_RING_REG(RADEON_REG_RB3D_COLORPITCH, dst_pitch >> pixel_shift);
OUT_REG(RADEON_REG_RB3D_BLENDCNTL, RadeonBlendOp[PictOpAdd].blend_cntl);
END_DMA();
if (atic->is_r100) {
BEGIN_DMA(4);
OUT_RING(DMA_PACKET0(RADEON_REG_PP_TXCBLEND_0, 3));
OUT_RING_REG(RADEON_REG_PP_TXCBLEND_0,
RADEON_BLEND_CTL_ADD | RADEON_CLAMP_TX |
RADEON_COLOR_ARG_C_TFACTOR_ALPHA);
OUT_RING_REG(RADEON_REG_PP_TXABLEND_0,
RADEON_BLEND_CTL_ADD | RADEON_CLAMP_TX |
RADEON_ALPHA_ARG_C_TFACTOR_ALPHA);
OUT_RING_REG(RADEON_REG_PP_TFACTOR_0, 0x01000000);
END_DMA();
} else if (atic->is_r200) {
BEGIN_DMA(14);
OUT_REG(R200_REG_SE_VTX_FMT_0, R200_VTX_XY);
OUT_REG(R200_REG_SE_VTX_FMT_1, 0);
OUT_REG(R200_REG_PP_TXCBLEND_0,
R200_TXC_ARG_C_TFACTOR_COLOR);
OUT_REG(R200_REG_PP_TXABLEND_0,
R200_TXA_ARG_C_TFACTOR_ALPHA);
OUT_REG(R200_REG_PP_TXCBLEND2_0, R200_TXC_OUTPUT_REG_R0);
OUT_REG(R200_REG_PP_TXABLEND2_0, R200_TXA_OUTPUT_REG_R0);
OUT_REG(RADEON_REG_PP_TFACTOR_0, 0x01000000);
END_DMA();
}
return TRUE;
}
#define TRAP_VERT_RING_COUNT 2
#define TRAP_VERT(_x, _y) \
do { \
OUT_RING_F((_x) + sample_x); \
OUT_RING_F((_y) + sample_y); \
} while (0)
void
RadeonTrapezoids(KaaTrapezoid *traps, int ntraps)
{
ATIScreenInfo *atis = accel_atis;
ATICardInfo *atic = atis->atic;
RING_LOCALS;
while (ntraps > 0) {
int i, sample, count, vertcount;
count = 0xffff / 4 / sample_count;
if (count > ntraps)
count = ntraps;
vertcount = count * sample_count * 4;
if (atic->is_r100) {
BEGIN_DMA(3 + vertcount * TRAP_VERT_RING_COUNT);
OUT_RING(DMA_PACKET3(RADEON_CP_PACKET3_3D_DRAW_IMMD,
2 + vertcount * TRAP_VERT_RING_COUNT));
OUT_RING(RADEON_CP_VC_FRMT_XY);
OUT_RING(RADEON_CP_VC_CNTL_PRIM_TYPE_TRI_FAN |
RADEON_CP_VC_CNTL_PRIM_WALK_RING |
RADEON_CP_VC_CNTL_MAOS_ENABLE |
RADEON_CP_VC_CNTL_VTX_FMT_RADEON_MODE |
(vertcount << RADEON_CP_VC_CNTL_NUM_SHIFT));
} else {
BEGIN_DMA(2 + vertcount * TRAP_VERT_RING_COUNT);
OUT_RING(DMA_PACKET3(R200_CP_PACKET3_3D_DRAW_IMMD_2,
1 + vertcount * TRAP_VERT_RING_COUNT));
OUT_RING(RADEON_CP_VC_CNTL_PRIM_TYPE_TRI_FAN |
RADEON_CP_VC_CNTL_PRIM_WALK_RING |
(vertcount << RADEON_CP_VC_CNTL_NUM_SHIFT));
}
for (i = 0; i < count; i++) {
for (sample = 0; sample < sample_count; sample++) {
float sample_x = sample_offsets_x[sample];
float sample_y = sample_offsets_y[sample];
TRAP_VERT(traps[i].tl, traps[i].ty);
TRAP_VERT(traps[i].bl, traps[i].by);
TRAP_VERT(traps[i].br, traps[i].by);
TRAP_VERT(traps[i].tr, traps[i].ty);
}
}
END_DMA();
ntraps -= count;
traps += count;
}
}
void
RadeonDoneTrapezoids(void)
{
ATIScreenInfo *atis = accel_atis;
RING_LOCALS;
BEGIN_DMA(2);
OUT_REG(RADEON_REG_RE_WIDTH_HEIGHT, 0xffffffff);
END_DMA();
}

View File

@ -1,221 +0,0 @@
/*
* Copyright 2000 ATI Technologies Inc., Markham, Ontario,
* VA Linux Systems Inc., Fremont, California.
*
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation on the rights to use, copy, modify, merge,
* publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) 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
* NON-INFRINGEMENT. IN NO EVENT SHALL ATI, VA LINUX SYSTEMS AND/OR
* THEIR SUPPLIERS 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.
*/
/*
* Authors:
* Kevin E. Martin <martin@xfree86.org>
* Gareth Hughes <gareth@valinux.com>
*
*/
#ifndef _RADEON_SAREA_H_
#define _RADEON_SAREA_H_
/* WARNING: If you change any of these defines, make sure to change the
* defines in the kernel file (radeon_drm.h)
*/
#ifndef __RADEON_SAREA_DEFINES__
#define __RADEON_SAREA_DEFINES__
/* What needs to be changed for the current vertex buffer? */
#define RADEON_UPLOAD_CONTEXT 0x00000001
#define RADEON_UPLOAD_VERTFMT 0x00000002
#define RADEON_UPLOAD_LINE 0x00000004
#define RADEON_UPLOAD_BUMPMAP 0x00000008
#define RADEON_UPLOAD_MASKS 0x00000010
#define RADEON_UPLOAD_VIEWPORT 0x00000020
#define RADEON_UPLOAD_SETUP 0x00000040
#define RADEON_UPLOAD_TCL 0x00000080
#define RADEON_UPLOAD_MISC 0x00000100
#define RADEON_UPLOAD_TEX0 0x00000200
#define RADEON_UPLOAD_TEX1 0x00000400
#define RADEON_UPLOAD_TEX2 0x00000800
#define RADEON_UPLOAD_TEX0IMAGES 0x00001000
#define RADEON_UPLOAD_TEX1IMAGES 0x00002000
#define RADEON_UPLOAD_TEX2IMAGES 0x00004000
#define RADEON_UPLOAD_CLIPRECTS 0x00008000 /* handled client-side */
#define RADEON_REQUIRE_QUIESCENCE 0x00010000
#define RADEON_UPLOAD_ZBIAS 0x00020000
#define RADEON_UPLOAD_ALL 0x0002ffff
#define RADEON_UPLOAD_CONTEXT_ALL 0x000201ff
#define RADEON_FRONT 0x1
#define RADEON_BACK 0x2
#define RADEON_DEPTH 0x4
#define RADEON_STENCIL 0x8
/* Primitive types */
#define RADEON_POINTS 0x1
#define RADEON_LINES 0x2
#define RADEON_LINE_STRIP 0x3
#define RADEON_TRIANGLES 0x4
#define RADEON_TRIANGLE_FAN 0x5
#define RADEON_TRIANGLE_STRIP 0x6
#define RADEON_3VTX_POINTS 0x9
#define RADEON_3VTX_LINES 0xa
/* Vertex/indirect buffer size */
#define RADEON_BUFFER_SIZE 65536
/* Byte offsets for indirect buffer data */
#define RADEON_INDEX_PRIM_OFFSET 20
#define RADEON_HOSTDATA_BLIT_OFFSET 32
#define RADEON_SCRATCH_REG_OFFSET 32
/* Keep these small for testing */
#define RADEON_NR_SAREA_CLIPRECTS 12
#define RADEON_MAX_TEXTURE_LEVELS 12
#define RADEON_MAX_TEXTURE_UNITS 3
/* Blits have strict offset rules. All blit offset must be aligned on
* a 1K-byte boundary.
*/
#define RADEON_OFFSET_SHIFT 10
#define RADEON_OFFSET_ALIGN (1 << RADEON_OFFSET_SHIFT)
#define RADEON_OFFSET_MASK (RADEON_OFFSET_ALIGN - 1)
#endif /* __RADEON_SAREA_DEFINES__ */
typedef struct {
unsigned int red;
unsigned int green;
unsigned int blue;
unsigned int alpha;
} radeon_color_regs_t;
typedef struct {
/* Context state */
unsigned int pp_misc;
unsigned int pp_fog_color;
unsigned int re_solid_color;
unsigned int rb3d_blendcntl;
unsigned int rb3d_depthoffset;
unsigned int rb3d_depthpitch;
unsigned int rb3d_zstencilcntl;
unsigned int pp_cntl;
unsigned int rb3d_cntl;
unsigned int rb3d_coloroffset;
unsigned int re_width_height;
unsigned int rb3d_colorpitch;
unsigned int se_cntl;
/* Vertex format state */
unsigned int se_coord_fmt;
/* Line state */
unsigned int re_line_pattern;
unsigned int re_line_state;
unsigned int se_line_width;
/* Bumpmap state */
unsigned int pp_lum_matrix;
unsigned int pp_rot_matrix_0;
unsigned int pp_rot_matrix_1;
/* Mask state */
unsigned int rb3d_stencilrefmask;
unsigned int rb3d_ropcntl;
unsigned int rb3d_planemask;
/* Viewport state */
unsigned int se_vport_xscale;
unsigned int se_vport_xoffset;
unsigned int se_vport_yscale;
unsigned int se_vport_yoffset;
unsigned int se_vport_zscale;
unsigned int se_vport_zoffset;
/* Setup state */
unsigned int se_cntl_status;
/* Misc state */
unsigned int re_top_left;
unsigned int re_misc;
} radeon_context_regs_t;
/* Setup registers for each texture unit */
typedef struct {
unsigned int pp_txfilter;
unsigned int pp_txformat;
unsigned int pp_txoffset;
unsigned int pp_txcblend;
unsigned int pp_txablend;
unsigned int pp_tfactor;
unsigned int pp_border_color;
} radeon_texture_regs_t;
typedef struct {
/* The channel for communication of state information to the kernel
* on firing a vertex buffer.
*/
radeon_context_regs_t ContextState;
radeon_texture_regs_t TexState[RADEON_MAX_TEXTURE_UNITS];
unsigned int dirty;
unsigned int vertsize;
unsigned int vc_format;
/* The current cliprects, or a subset thereof */
XF86DRIClipRectRec boxes[RADEON_NR_SAREA_CLIPRECTS];
unsigned int nbox;
/* Counters for throttling of rendering clients */
unsigned int last_frame;
unsigned int last_dispatch;
unsigned int last_clear;
/* Maintain an LRU of contiguous regions of texture space. If you
* think you own a region of texture memory, and it has an age
* different to the one you set, then you are mistaken and it has
* been stolen by another client. If global texAge hasn't changed,
* there is no need to walk the list.
*
* These regions can be used as a proxy for the fine-grained texture
* information of other clients - by maintaining them in the same
* lru which is used to age their own textures, clients have an
* approximate lru for the whole of global texture space, and can
* make informed decisions as to which areas to kick out. There is
* no need to choose whether to kick out your own texture or someone
* else's - simply eject them all in LRU order.
*/
/* Last elt is sentinal */
drmTextureRegion texList[ATI_NR_TEX_HEAPS][ATI_NR_TEX_REGIONS+1];
/* last time texture was uploaded */
unsigned int texAge[ATI_NR_TEX_HEAPS];
int ctxOwner; /* last context to upload state */
int pfAllowPageFlip; /* set by the 2d driver, read by the client */
int pfCurrentPage; /* set by kernel, read by others */
int crtc2_base; /* for pageflipping with CloneMode */
} RADEONSAREAPriv, *RADEONSAREAPrivPtr;
#endif

View File

@ -1,36 +0,0 @@
INCLUDES = \
@KDRIVE_INCS@ \
-I$(top_srcdir)/hw/kdrive/vesa \
@KDRIVE_CFLAGS@
bin_PROGRAMS = Xchips
noinst_LIBRARIES = libchips.a
libchips_a_SOURCES = \
chipsdraw.c \
chips.c \
chips.h
Xchips_SOURCES = \
chipsstub.c
CHIPS_LIBS = \
libchips.a \
$(top_builddir)/hw/kdrive/vesa/libvesa.a \
@KDRIVE_LIBS@
if GLX
Xchips_LDFLAGS = $(LD_EXPORT_SYMBOLS_FLAG)
endif
Xchips_LDADD = \
$(CHIPS_LIBS) \
@KDRIVE_LIBS@
Xchips_DEPENDENCIES = \
libchips.a \
@KDRIVE_LOCAL_LIBS@
relink:
rm -f $(bin_PROGRAMS) && make $(bin_PROGRAMS)

View File

@ -1,334 +0,0 @@
/*
* Copyright © 2001 Keith Packard
*
* 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 Keith Packard not be used in
* advertising or publicity pertaining to distribution of the software without
* specific, written prior permission. Keith Packard makes no
* representations about the suitability of this software for any purpose. It
* is provided "as is" without express or implied warranty.
*
* KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL KEITH PACKARD 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.
*/
#ifdef HAVE_CONFIG_H
#include <kdrive-config.h>
#endif
#include "chips.h"
#include "kaa.h"
#include <sys/io.h>
#undef CHIPS_DEBUG
static Bool
chipsCardInit (KdCardInfo *card)
{
ChipsCardInfo *chipsc;
chipsc = (ChipsCardInfo *) xalloc (sizeof (ChipsCardInfo));
if (!chipsc)
return FALSE;
iopl (3);
if (!vesaInitialize (card, &chipsc->vesa))
{
xfree (chipsc);
return FALSE;
}
#ifdef USE_PCI
chipsc->window = (CARD32 *) (chipsc->cop_base + 0x10000);
#else
chipsc->window = 0;
#endif
card->driver = chipsc;
return TRUE;
}
static Bool
chipsScreenInit (KdScreenInfo *screen)
{
ChipsScreenInfo *chipss;
int screen_size, memory;
chipss = (ChipsScreenInfo *) xalloc (sizeof (ChipsScreenInfo));
if (!chipss)
return FALSE;
memset (chipss, '\0', sizeof (ChipsScreenInfo));
if (!vesaScreenInitialize (screen, &chipss->vesa))
{
xfree (chipss);
return FALSE;
}
if (chipss->vesa.mapping != VESA_LINEAR)
screen->dumb = TRUE;
if (!screen->dumb)
{
chipss->mmio_base = (CARD8 *) KdMapDevice (CHIPS_MMIO_BASE(chipss),
CHIPS_MMIO_SIZE(chipss));
if (chipss->mmio_base)
{
KdSetMappedMode (CHIPS_MMIO_BASE(chipss),
CHIPS_MMIO_SIZE(chipss),
KD_MAPPED_MODE_REGISTERS);
}
else
screen->dumb = TRUE;
}
else
chipss->mmio_base = 0;
chipss->screen = chipss->vesa.fb;
memory = chipss->vesa.fb_size;
screen_size = screen->fb[0].byteStride * screen->height;
if (chipss->screen && memory >= screen_size + 2048)
{
memory -= 2048;
chipss->cursor_base = chipss->screen + memory - 2048;
}
else
chipss->cursor_base = 0;
memory -= screen_size;
if (memory > screen->fb[0].byteStride)
{
chipss->off_screen = chipss->screen + screen_size;
chipss->off_screen_size = memory;
}
else
{
chipss->off_screen = 0;
chipss->off_screen_size = 0;
}
screen->driver = chipss;
return TRUE;
}
static Bool
chipsInitScreen (ScreenPtr pScreen)
{
return vesaInitScreen (pScreen);
}
#ifdef RANDR
static Bool
chipsRandRSetConfig (ScreenPtr pScreen,
Rotation rotation,
int rate,
RRScreenSizePtr pSize)
{
kaaWaitSync (pScreen);
if (!vesaRandRSetConfig (pScreen, rotation, rate, pSize))
return FALSE;
return TRUE;
}
static void
chipsRandRInit (ScreenPtr pScreen)
{
rrScrPriv(pScreen);
pScrPriv->rrSetConfig = chipsRandRSetConfig;
}
#endif
static Bool
chipsFinishInitScreen (ScreenPtr pScreen)
{
Bool ret;
ret = vesaFinishInitScreen (pScreen);
#ifdef RANDR
chipsRandRInit (pScreen);
#endif
return ret;
}
static Bool
chipsCreateResources (ScreenPtr pScreen)
{
return vesaCreateResources (pScreen);
}
CARD8
chipsReadXR (ChipsScreenInfo *chipss, CARD8 index)
{
CARD8 value;
outb (index, 0x3d6);
value = inb (0x3d7);
return value;
}
void
chipsWriteXR (ChipsScreenInfo *chipss, CARD8 index, CARD8 value)
{
outb (index, 0x3d6);
outb (value, 0x3d7);
}
#if 0
static CARD8
chipsReadFR (ChipsScreenInfo *chipss, CARD8 index)
{
CARD8 value;
outb (index, 0x3d0);
value = inb (0x3d1);
return value;
}
static void
chipsWriteFR (ChipsScreenInfo *chipss, CARD8 index, CARD8 value)
{
outb (index, 0x3d0);
outb (value, 0x3d1);
}
static CARD8
chipsReadSeq (ChipsScreenInfo *chipss, CARD8 index)
{
CARD8 value;
outb (index, 0x3c4);
value = inb (0x3c5);
return value;
}
static void
chipsWriteSeq (ChipsScreenInfo *chipss, CARD8 index, CARD8 value)
{
outb (index, 0x3c4);
outb (value, 0x3c5);
}
#endif
static void
chipsPreserve (KdCardInfo *card)
{
vesaPreserve(card);
}
static void
chipsSetMMIO (ChipsCardInfo *chipsc)
{
}
static void
chipsResetMMIO (ChipsCardInfo *chipsc)
{
}
static Bool
chipsEnable (ScreenPtr pScreen)
{
KdScreenPriv(pScreen);
ChipsCardInfo *chipsc = pScreenPriv->card->driver;
if (!vesaEnable (pScreen))
return FALSE;
chipsSetMMIO (chipsc);
return TRUE;
}
#if 0
static Bool
chipsDPMS (ScreenPtr pScreen, int mode)
{
KdScreenPriv(pScreen);
chipsScreenInfo(pScreenPriv);
ErrorF ("seqreg 0x01 0x%x\n", chipsReadSeq (chipss, 0x1));
ErrorF ("dpmsreg XR61 0x%x\n", chipsReadXR (chipss, 0x61));
ErrorF ("dpmsreg XR73 0x%x\n", chipsReadXR (chipss, 0x73));
ErrorF ("flat panel FR05 0x%x\n", chipsReadFR (chipss, 0x5));
ErrorF ("flat panel XR52 0x%x\n", chipsReadXR (chipss, 0x52));
return TRUE;
}
#endif
static void
chipsDisable (ScreenPtr pScreen)
{
vesaDisable (pScreen);
}
static void
chipsRestore (KdCardInfo *card)
{
ChipsCardInfo *chipsc = card->driver;
chipsResetMMIO (chipsc);
vesaRestore (card);
}
static void
chipsScreenFini (KdScreenInfo *screen)
{
ChipsScreenInfo *chipss = (ChipsScreenInfo *) screen->driver;
if (chipss->mmio_base)
{
KdUnmapDevice ((void *) chipss->mmio_base, CHIPS_MMIO_SIZE(chipss));
KdResetMappedMode (CHIPS_MMIO_BASE(chipss),
CHIPS_MMIO_SIZE(chipss),
KD_MAPPED_MODE_REGISTERS);
}
vesaScreenFini (screen);
xfree (chipss);
screen->driver = 0;
}
static void
chipsCardFini (KdCardInfo *card)
{
vesaCardFini (card);
}
#define chipsCursorInit (void *) 0
#define chipsCursorEnable (void *) 0
#define chipsCursorDisable (void *) 0
#define chipsCursorFini (void *) 0
#define chipsRecolorCursor (void *) 0
KdCardFuncs chipsFuncs = {
chipsCardInit, /* cardinit */
chipsScreenInit, /* scrinit */
chipsInitScreen, /* initScreen */
chipsFinishInitScreen, /* finishInitScreen */
chipsCreateResources, /* createRes */
chipsPreserve, /* preserve */
chipsEnable, /* enable */
vesaDPMS, /* dpms */
chipsDisable, /* disable */
chipsRestore, /* restore */
chipsScreenFini, /* scrfini */
chipsCardFini, /* cardfini */
chipsCursorInit, /* initCursor */
chipsCursorEnable, /* enableCursor */
chipsCursorDisable, /* disableCursor */
chipsCursorFini, /* finiCursor */
chipsRecolorCursor, /* recolorCursor */
chipsDrawInit, /* initAccel */
chipsDrawEnable, /* enableAccel */
chipsDrawDisable, /* disableAccel */
chipsDrawFini, /* finiAccel */
vesaGetColors, /* getColors */
vesaPutColors, /* putColors */
};

View File

@ -1,117 +0,0 @@
/*
* Copyright © 1999 Keith Packard
*
* 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 Keith Packard not be used in
* advertising or publicity pertaining to distribution of the software without
* specific, written prior permission. Keith Packard makes no
* representations about the suitability of this software for any purpose. It
* is provided "as is" without express or implied warranty.
*
* KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL KEITH PACKARD 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.
*/
#ifndef _CHIPS_H_
#define _CHIPS_H_
#include <vesa.h>
/*
* offset from ioport beginning
*/
#define HIQV
#ifdef HIQV
#define CHIPS_MMIO_BASE(c) ((c)->vesa.fb_phys + 0x400000)
#else
#define CHIPS_MMIO_BASE(c) ((c)->vesa.fb_phys + 0x200000)
#endif
#define CHIPS_MMIO_SIZE(c) (0x20000)
typedef volatile CARD8 VOL8;
typedef volatile CARD16 VOL16;
typedef volatile CARD32 VOL32;
typedef struct _chipsSave {
int dummy;
} ChipsSave;
typedef struct _chipsCardInfo {
VesaCardPrivRec vesa;
CARD32 *window;
Bool mmio;
ChipsSave save;
} ChipsCardInfo;
#define getChipsCardInfo(kd) ((ChipsCardInfo *) ((kd)->card->driver))
#define chipsCardInfo(kd) ChipsCardInfo *chipsc = getChipsCardInfo(kd)
typedef struct _chipsCursor {
int width, height;
int xhot, yhot;
Bool has_cursor;
CursorPtr pCursor;
Pixel source, mask;
} ChipsCursor;
#define CHIPS_CURSOR_WIDTH 64
#define CHIPS_CURSOR_HEIGHT 64
typedef struct _chipsScreenInfo {
VesaScreenPrivRec vesa;
CARD8 *mmio_base;
CARD8 *cursor_base;
CARD8 *screen;
CARD8 *off_screen;
int off_screen_size;
ChipsCursor cursor;
KaaScreenInfoRec kaa;
} ChipsScreenInfo;
#define getChipsScreenInfo(kd) ((ChipsScreenInfo *) ((kd)->screen->driver))
#define chipsScreenInfo(kd) ChipsScreenInfo *chipss = getChipsScreenInfo(kd)
Bool
chipsDrawInit (ScreenPtr pScreen);
void
chipsDrawEnable (ScreenPtr pScreen);
void
chipsDrawDisable (ScreenPtr pScreen);
void
chipsDrawFini (ScreenPtr pScreen);
CARD8
chipsReadXR (ChipsScreenInfo *chipsc, CARD8 index);
void
chipsWriteXR (ChipsScreenInfo *chipsc, CARD8 index, CARD8 value);
Bool
chipsCursorInit (ScreenPtr pScreen);
void
chipsCursorEnable (ScreenPtr pScreen);
void
chipsCursorDisable (ScreenPtr pScreen);
void
chipsCursorFini (ScreenPtr pScreen);
void
chipsRecolorCursor (ScreenPtr pScreen, int ndef, xColorItem *pdef);
extern KdCardFuncs chipsFuncs;
#endif /* _CHIPS_H_ */

View File

@ -1,491 +0,0 @@
/*
* Copyright © 1999 Keith Packard
*
* 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 Keith Packard not be used in
* advertising or publicity pertaining to distribution of the software without
* specific, written prior permission. Keith Packard makes no
* representations about the suitability of this software for any purpose. It
* is provided "as is" without express or implied warranty.
*
* KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL KEITH PACKARD 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.
*/
#ifdef HAVE_CONFIG_H
#include <kdrive-config.h>
#endif
#include "chips.h"
#include <X11/Xmd.h>
#include "gcstruct.h"
#include "scrnintstr.h"
#include "pixmapstr.h"
#include "regionstr.h"
#include "mistruct.h"
#include "dixfontstr.h"
#include "fb.h"
#include "migc.h"
#include "miline.h"
#include "kaa.h"
CARD8 chipsBltRop[16] = {
/* GXclear */ 0x00, /* 0 */
/* GXand */ 0x88, /* src AND dst */
/* GXandReverse */ 0x44, /* src AND NOT dst */
/* GXcopy */ 0xcc, /* src */
/* GXandInverted*/ 0x22, /* NOT src AND dst */
/* GXnoop */ 0xaa, /* dst */
/* GXxor */ 0x66, /* src XOR dst */
/* GXor */ 0xee, /* src OR dst */
/* GXnor */ 0x11, /* NOT src AND NOT dst */
/* GXequiv */ 0x99, /* NOT src XOR dst */
/* GXinvert */ 0x55, /* NOT dst */
/* GXorReverse */ 0xdd, /* src OR NOT dst */
/* GXcopyInverted*/ 0x33, /* NOT src */
/* GXorInverted */ 0xbb, /* NOT src OR dst */
/* GXnand */ 0x77, /* NOT src OR NOT dst */
/* GXset */ 0xff, /* 1 */
};
CARD8 chipsSolidRop[16] = {
/* GXclear */ 0x00, /* 0 */
/* GXand */ 0xa0, /* src AND dst */
/* GXandReverse */ 0x50, /* src AND NOT dst */
/* GXcopy */ 0xf0, /* src */
/* GXandInverted*/ 0x0a, /* NOT src AND dst */
/* GXnoop */ 0xaa, /* dst */
/* GXxor */ 0x5a, /* src XOR dst */
/* GXor */ 0xfa, /* src OR dst */
/* GXnor */ 0x05, /* NOT src AND NOT dst */
/* GXequiv */ 0xa5, /* NOT src XOR dst */
/* GXinvert */ 0x55, /* NOT dst */
/* GXorReverse */ 0xf5, /* src OR NOT dst */
/* GXcopyInverted*/ 0x0f, /* NOT src */
/* GXorInverted */ 0xaf, /* NOT src OR dst */
/* GXnand */ 0x5f, /* NOT src OR NOT dst */
/* GXset */ 0xff, /* 1 */
};
/* Definitions for the Chips and Technology BitBLT engine communication. */
/* These are done using Memory Mapped IO, of the registers */
/* BitBLT modes for register 93D0. */
#ifdef HIQV
#define ctPATCOPY 0xF0
#define ctLEFT2RIGHT 0x000
#define ctRIGHT2LEFT 0x100
#define ctTOP2BOTTOM 0x000
#define ctBOTTOM2TOP 0x200
#define ctSRCSYSTEM 0x400
#define ctDSTSYSTEM 0x800
#define ctSRCMONO 0x1000
#define ctBGTRANSPARENT 0x22000
#define ctCOLORTRANSENABLE 0x4000
#define ctCOLORTRANSDISABLE 0x0
#define ctCOLORTRANSDST 0x8000
#define ctCOLORTRANSROP 0x0
#define ctCOLORTRANSEQUAL 0x10000L
#define ctCOLORTRANSNEQUAL 0x0
#define ctPATMONO 0x40000L
#define ctPATSOLID 0x80000L
#define ctPATSTART0 0x000000L
#define ctPATSTART1 0x100000L
#define ctPATSTART2 0x200000L
#define ctPATSTART3 0x300000L
#define ctPATSTART4 0x400000L
#define ctPATSTART5 0x500000L
#define ctPATSTART6 0x600000L
#define ctPATSTART7 0x700000L
#define ctSRCFG 0x000000L /* Where is this for the 65550?? */
#else
#define ctPATCOPY 0xF0
#define ctTOP2BOTTOM 0x100
#define ctBOTTOM2TOP 0x000
#define ctLEFT2RIGHT 0x200
#define ctRIGHT2LEFT 0x000
#define ctSRCFG 0x400
#define ctSRCMONO 0x800
#define ctPATMONO 0x1000
#define ctBGTRANSPARENT 0x2000
#define ctSRCSYSTEM 0x4000
#define ctPATSOLID 0x80000L
#define ctPATSTART0 0x00000L
#define ctPATSTART1 0x10000L
#define ctPATSTART2 0x20000L
#define ctPATSTART3 0x30000L
#define ctPATSTART4 0x40000L
#define ctPATSTART5 0x50000L
#define ctPATSTART6 0x60000L
#define ctPATSTART7 0x70000L
#endif
#define chipsFillPix(bpp,pixel) {\
if (bpp == 8) \
{ \
pixel = pixel & 0xff; \
} \
else if (bpp == 16) \
{ \
pixel = pixel & 0xffff; \
} \
}
static VOL8 *mmio;
static CARD32 byteStride;
static CARD32 bytesPerPixel;
static CARD32 pixelStride;
static void
chipsSet (ScreenPtr pScreen)
{
KdScreenPriv(pScreen);
chipsScreenInfo(pScreenPriv);
mmio = chipss->mmio_base;
byteStride = pScreenPriv->screen->fb[0].byteStride;
bytesPerPixel = pScreenPriv->screen->fb[0].bitsPerPixel >> 3;
pixelStride = pScreenPriv->screen->fb[0].pixelStride;
}
#ifdef HIQV
#define CHIPS_BR0 0x00 /* offset */
#define CHIPS_BR1 0x04 /* bg */
#define CHIPS_BR2 0x08 /* fg */
#define CHIPS_BR3 0x0c /* monochrome */
#define CHIPS_BR4 0x10 /* bitblt */
#define CHIPS_BR5 0x14 /* pattern addr */
#define CHIPS_BR6 0x18 /* source addr */
#define CHIPS_BR7 0x1c /* dst addr */
#define CHIPS_BR8 0x20 /* dst w/h */
#else
#define CHIPS_DR0 0x83d0
#define CHIPS_DR1 0x87d0
#define CHIPS_DR2 0x8bd0
#define CHIPS_DR3 0x8fd0
#define CHIPS_DR4 0x93d0
#define CHIPS_DR5 0x97d0
#define CHIPS_DR6 0x9bd0
#define CHIPS_DR7 0x9fd0
#endif
#define DBG(x)
static void
chipsPitch (int src, int dst)
{
CARD32 p;
p = ((dst & 0xffff) << 16) | (src & 0xffff);
DBG(ErrorF ("\tpitch 0x%x\n", p));
#ifdef HIQV
*(VOL32 *) (mmio + CHIPS_BR0) = p;
#else
*(VOL32 *) (mmio + CHIPS_DR0) = p;
#endif
}
static void
chipsBg (Pixel bg)
{
DBG(ErrorF ("\tbg 0x%x\n", bg));
#ifdef HIQV
*(VOL32 *) (mmio + CHIPS_BR1) = bg & 0xffff;
#else
*(VOL32 *) (mmio + CHIPS_DR2) = bg;
#endif
}
static void
chipsFg (Pixel fg)
{
DBG(ErrorF ("\tfg 0x%x\n", fg));
#ifdef HIQV
*(VOL32 *) (mmio + CHIPS_BR2) = fg;
#else
*(VOL32 *) (mmio + CHIPS_DR3) = fg;
#endif
}
static void
chipsOp (CARD32 op)
{
DBG(ErrorF ("\top 0x%x\n", op));
#ifdef HIQV
*(VOL32 *) (mmio + CHIPS_BR4) = op;
#else
*(VOL32 *) (mmio + CHIPS_DR4) = op;
#endif
}
static void
chipsRopSolid (int rop)
{
CARD32 op;
op = chipsSolidRop[rop] | ctTOP2BOTTOM | ctLEFT2RIGHT | ctPATSOLID | ctPATMONO;
chipsOp (op);
}
static void
chipsSrc (int addr)
{
DBG(ErrorF ("\tsrc 0x%x\n", addr));
#ifdef HIQV
*(VOL32 *) (mmio + CHIPS_BR6) = addr;
#else
*(VOL32 *) (mmio + CHIPS_DR5) = addr;
#endif
}
static void
chipsDst (int addr)
{
DBG(ErrorF ("\tdst 0x%x\n", addr));
#ifdef HIQV
*(VOL32 *) (mmio + CHIPS_BR7) = addr;
#else
*(VOL32 *) (mmio + CHIPS_DR6) = addr;
#endif
}
static void
chipsWidthHeightGo (int w, int h)
{
DBG(ErrorF ("\twidth height %d/%d\n", w, h));
#ifdef HIQV
*(VOL32 *) (mmio + CHIPS_BR8) = ((h & 0xffff) << 16) | (w & 0xffff);
#else
*(VOL32 *) (mmio + CHIPS_DR7) = ((h & 0xffff) << 16) | (w & 0xffff);
#endif
}
static void
chipsWaitIdle (void)
{
#ifdef HIQV
int timeout = 0;
CARD8 tmp;
VOL32 *br4 = (VOL32 *) (mmio + CHIPS_BR4);
DBG(ErrorF ("\tBR4 0x%x 0x%x\n", mmio + CHIPS_BR4, *br4));
DBG(ErrorF ("\tXR20 0x%x\n", chipsReadXR (0, 0x20)));
for (;;)
{
if ((*br4 & 0x80000000) == 0)
break;
tmp = chipsReadXR (0, 0x20);
if ((tmp & 1) == 0)
break;
if (++timeout > 1000000)
{
ErrorF ("timeout\n");
tmp = chipsReadXR (0, 0x20);
chipsWriteXR (0, 0x20, tmp | 2);
sleep (1);
chipsWriteXR (0, 0x20, tmp);
sleep (1);
}
}
#else
while (*(VOL32 *) (mmio + CHIPS_DR4) & 0x00100000)
;
#endif
}
static void
chipsWaitMarker (ScreenPtr pScreen, int marker)
{
chipsSet (pScreen);
chipsWaitIdle ();
}
static Bool
chipsPrepareSolid (PixmapPtr pPixmap,
int alu,
Pixel pm,
Pixel fg)
{
FbBits depthMask;
DBG(ErrorF ("PrepareSolid %d 0x%x\n", alu, fg));
depthMask = FbFullMask(pPixmap->drawable.depth);
if ((pm & depthMask) != depthMask)
return FALSE;
else
{
chipsSet (pPixmap->drawable.pScreen);
chipsWaitIdle ();
chipsFillPix(pPixmap->drawable.bitsPerPixel,fg);
chipsFg (fg);
chipsBg (fg);
chipsRopSolid (alu);
chipsPitch (byteStride, byteStride);
return TRUE;
}
}
static void
chipsSolid (int x1, int y1, int x2, int y2)
{
CARD32 dst;
int w, h;
DBG(ErrorF (" Solid %dx%d %dx%d\n", x1, y1, x2, y2));
dst = y1 * byteStride + x1 * bytesPerPixel;
w = (x2 - x1) * bytesPerPixel;
h = (y2 - y1);
chipsWaitIdle ();
chipsDst (dst);
chipsWidthHeightGo (w, h);
}
static void
chipsDoneSolid (void)
{
}
static CARD32 copyOp;
static Bool
chipsPrepareCopy (PixmapPtr pSrcPixmap,
PixmapPtr pDstPixmap,
int dx,
int dy,
int alu,
Pixel pm)
{
FbBits depthMask;
DBG(ErrorF ("PrepareSolid %d 0x%x\n", alu, fg));
depthMask = FbFullMask(pDstPixmap->drawable.depth);
if ((pm & depthMask) != depthMask)
return FALSE;
else
{
copyOp = chipsBltRop[alu];
if (dy >= 0)
copyOp |= ctTOP2BOTTOM;
else
copyOp |= ctBOTTOM2TOP;
if (dx >= 0)
copyOp |= ctLEFT2RIGHT;
else
copyOp |= ctRIGHT2LEFT;
chipsSet (pDstPixmap->drawable.pScreen);
chipsWaitIdle ();
chipsOp (copyOp);
chipsPitch (byteStride, byteStride);
return TRUE;
}
}
static void
chipsCopy (int srcX,
int srcY,
int dstX,
int dstY,
int w,
int h)
{
int src, dst;
if ((copyOp & (ctTOP2BOTTOM|ctBOTTOM2TOP)) == ctBOTTOM2TOP)
{
src = (srcY + h - 1) * byteStride;
dst = (dstY + h - 1) * byteStride;
}
else
{
src = srcY * byteStride;
dst = dstY * byteStride;
}
if ((copyOp & (ctLEFT2RIGHT|ctRIGHT2LEFT)) == ctRIGHT2LEFT)
{
src = src + (srcX + w) * bytesPerPixel - 1;
dst = dst + (dstX + w) * bytesPerPixel - 1;
}
else
{
src = src + srcX * bytesPerPixel;
dst = dst + dstX * bytesPerPixel;
}
chipsWaitIdle ();
chipsSrc (src);
chipsDst (dst);
chipsWidthHeightGo (w * bytesPerPixel, h);
}
static void
chipsDoneCopy (void)
{
}
Bool
chipsDrawInit (ScreenPtr pScreen)
{
KdScreenPriv(pScreen);
chipsScreenInfo(pScreenPriv);
switch (pScreenPriv->screen->fb[0].bitsPerPixel) {
case 8:
case 16:
break;
default:
return FALSE;
}
memset(&chipss->kaa, 0, sizeof(KaaScreenInfoRec));
chipss->kaa.waitMarker = chipsWaitMarker;
chipss->kaa.PrepareSolid = chipsPrepareSolid;
chipss->kaa.Solid = chipsSolid;
chipss->kaa.DoneSolid = chipsDoneSolid;
chipss->kaa.PrepareCopy = chipsPrepareCopy;
chipss->kaa.Copy = chipsCopy;
chipss->kaa.DoneCopy = chipsDoneCopy;
if (!kaaDrawInit (pScreen, &chipss->kaa))
return FALSE;
return TRUE;
}
void
chipsDrawEnable (ScreenPtr pScreen)
{
KdScreenPriv(pScreen);
chipsScreenInfo(pScreenPriv);
CARD8 mode = 0x00;
switch (pScreenPriv->screen->fb[0].bitsPerPixel) {
case 8:
mode = 0x00;
break;
case 16:
mode = 0x10;
break;
}
chipsSet (pScreen);
chipsWaitIdle ();
chipsWriteXR (chipss, 0x20, mode);
kaaMarkSync (pScreen);
}
void
chipsDrawDisable (ScreenPtr pScreen)
{
}
void
chipsDrawFini (ScreenPtr pScreen)
{
}

View File

@ -1,67 +0,0 @@
/*
* Copyright 1999 SuSE, Inc.
*
* 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 SuSE not be used in advertising or
* publicity pertaining to distribution of the software without specific,
* written prior permission. SuSE makes no representations about the
* suitability of this software for any purpose. It is provided "as is"
* without express or implied warranty.
*
* SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
* 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.
*
* Author: Keith Packard, SuSE, Inc.
*/
#ifdef HAVE_CONFIG_H
#include <kdrive-config.h>
#endif
#include "chips.h"
extern int chips_clk, chips_mclk;
void
InitCard (char *name)
{
KdCardAttr attr;
KdCardInfoAdd (&chipsFuncs, &attr, 0);
}
void
InitOutput (ScreenInfo *pScreenInfo, int argc, char **argv)
{
KdInitOutput (pScreenInfo, argc, argv);
}
void
InitInput (int argc, char **argv)
{
KdOsAddInputDrivers ();
KdInitInput ();
}
void
ddxUseMsg (void)
{
KdUseMsg();
vesaUseMsg();
}
int
ddxProcessArgument (int argc, char **argv, int i)
{
int ret;
if (!(ret = vesaProcessArgument (argc, argv, i)))
ret = KdProcessArgument(argc, argv, i);
return ret;
}

View File

@ -150,11 +150,22 @@ ephyrScreenInitialize (KdScreenInfo *screen, EphyrScrPriv *scrpriv)
screen->fb[0].depth = 16;
screen->fb[0].bitsPerPixel = 16;
}
else
else if (screen->fb[0].depth <= 24)
{
screen->fb[0].depth = 24;
screen->fb[0].bitsPerPixel = 32;
}
else if (screen->fb[0].depth <= 30)
{
screen->fb[0].depth = 30;
screen->fb[0].bitsPerPixel = 32;
}
else
{
ErrorF("\nXephyr: Unsupported screen depth %d\n",
screen->fb[0].depth);
return FALSE;
}
hostx_get_visual_masks (screen, &redMask, &greenMask, &blueMask);

View File

@ -1,36 +0,0 @@
INCLUDES = \
@KDRIVE_INCS@ \
@KDRIVE_CFLAGS@
bin_PROGRAMS = Xepson
noinst_LIBRARIES = libepson.a
libepson_a_SOURCES = \
epson13806.c \
epson13806.h \
epson13806draw.c\
epson13806draw.h\
epson13806reg.h
Xepson_SOURCES = \
epson13806stub.c
EPSON_LIBS = \
libepson.a \
@KDRIVE_LIBS@
if GLX
Xepson_LDFLAGS = $(LD_EXPORT_SYMBOLS_FLAG)
endif
Xepson_LDADD = \
$(EPSON_LIBS) \
@KDRIVE_LIBS@
Xepson_DEPENDENCIES = \
libepson.a \
@KDRIVE_LOCAL_LIBS@
relink:
rm -f $(bin_PROGRAMS) && make $(bin_PROGRAMS)

View File

@ -1,26 +0,0 @@
.\" $XFree86: xc/programs/Xserver/hw/kdrive/epson/Xepson.man,v 1.5 2001/02/13 21:15:15 dawes Exp $
.\"
.TH Xepson 1 __vendorversion__
.SH NAME
Xepson \- Epson 13806 accelerated framebuffer device tiny X server
.SH SYNOPSIS
.B Xepson
.RI [ :display ]
.RI [ option ...]
.SH DESCRIPTION
.B Xepson
is a driver for the Epson LCD 13806 framebuffer.
.B Xepson
is heavily based upon the Kdrive Xfbdev driver, and behaves very similarly, except for accelerated operations targetted at the Epson chip.
.SH OPTIONS
.B Xepson
accepts the common options of the Xkdrive family of servers. Please
see Xkdrive(1).
.SH KEYBOARD
To be written.
.SH SEE ALSO
X(__miscmansuffix__), Xserver(1), Xkdrive(1), xdm(1), xinit(1).
.SH AUTHORS
The
.B Xepson
server was written by Costas Stylianou based on the Xfbdev sources with some contributions from Phil Blundell & Peter Naulls.

View File

@ -1,604 +0,0 @@
/*
* Copyright 2004 by Costas Stylianou <costas.stylianou@psion.com> +44(0)7850 394095
*
* 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 Costas Sylianou not be used in
* advertising or publicity pertaining to distribution of the software without
* specific, written prior permission. Costas Stylianou makes no representations
* about the suitability of this software for any purpose. It is provided
* "as is" without express or implied warranty.
*
* COSTAS STYLIANOU DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL COSTAS STYLIANOU 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.
*/
/*
* epson13806.c - Implementation of hardware accelerated functions for
* Epson S1D13806 graphics controller.
*
* History:
* 28-Jan-04 C.Stylianou PRJ NBL: Created from fbdev.c.
* 30-Mar-04 Phil Blundell/Peter Naulls Integration with XFree 4.3
*
*/
#ifdef HAVE_CONFIG_H
#include <kdrive-config.h>
#endif
#include <sys/ioctl.h>
#include "epson13806.h"
#include "epson13806reg.h"
extern int KdTsPhyScreen;
Bool
epsonInitialize (KdCardInfo *card, EpsonPriv *priv)
{
int k;
unsigned long off;
if ((priv->fd = open("/dev/fb0", O_RDWR)) < 0) {
perror("Error opening /dev/fb0\n");
return FALSE;
}
if ((k=ioctl(priv->fd, FBIOGET_FSCREENINFO, &priv->fix)) < 0) {
perror("Error with /dev/fb ioctl FIOGET_FSCREENINFO");
close (priv->fd);
return FALSE;
}
if ((k=ioctl(priv->fd, FBIOGET_VSCREENINFO, &priv->var)) < 0) {
perror("Error with /dev/fb ioctl FIOGET_VSCREENINFO");
close (priv->fd);
return FALSE;
}
priv->fb_base = KdMapDevice (EPSON13806_PHYSICAL_VMEM_ADDR, EPSON13806_VMEM_SIZE);
if (priv->fb_base == (char *)-1) {
perror("ERROR: mmap framebuffer fails!");
close (priv->fd);
return FALSE;
}
off = (unsigned long) priv->fix.smem_start % (unsigned long) getpagesize();
priv->fb = priv->fb_base + off;
return TRUE;
}
Bool
epsonCardInit (KdCardInfo *card)
{
EpsonPriv *priv;
priv = (EpsonPriv *) xalloc (sizeof (EpsonPriv));
if (!priv)
return FALSE;
if (!epsonInitialize (card, priv))
{
xfree (priv);
return FALSE;
}
card->driver = priv;
// Call InitEpson to map onto Epson registers
initEpson13806();
return TRUE;
}
#define FBDEV_KLUDGE_FORMAT
#ifdef FBDEV_KLUDGE_FORMAT
static Pixel
epsonMakeContig (Pixel orig, Pixel others)
{
Pixel low;
low = lowbit (orig) >> 1;
while (low && (others & low) == 0)
{
orig |= low;
low >>= 1;
}
return orig;
}
#endif
Bool
epsonScreenInitialize (KdScreenInfo *screen, EpsonScrPriv *scrpriv)
{
EpsonPriv *priv = screen->card->driver;
Pixel allbits;
int depth;
Bool gray;
depth = priv->var.bits_per_pixel;
gray = priv->var.grayscale;
screen->fb[0].visuals = (1 << TrueColor);
#define Mask(o,l) (((1 << l) - 1) << o)
screen->fb[0].redMask = Mask (priv->var.red.offset, priv->var.red.length);
screen->fb[0].greenMask = Mask (priv->var.green.offset, priv->var.green.length);
screen->fb[0].blueMask = Mask (priv->var.blue.offset, priv->var.blue.length);
#ifdef FBDEV_KLUDGE_FORMAT
/*
* This is a kludge so that Render will work -- fill in the gaps
* in the pixel
*/
screen->fb[0].redMask = epsonMakeContig (screen->fb[0].redMask,
screen->fb[0].greenMask|
screen->fb[0].blueMask);
screen->fb[0].greenMask = epsonMakeContig (screen->fb[0].greenMask,
screen->fb[0].redMask|
screen->fb[0].blueMask);
screen->fb[0].blueMask = epsonMakeContig (screen->fb[0].blueMask,
screen->fb[0].redMask|
screen->fb[0].greenMask);
#endif
allbits = screen->fb[0].redMask | screen->fb[0].greenMask | screen->fb[0].blueMask;
depth = 32;
while (depth && !(allbits & (1 << (depth - 1))))
depth--;
screen->rate = 60;
scrpriv->randr = screen->randr;
{
screen->fb[0].depth = depth;
screen->fb[0].bitsPerPixel = priv->var.bits_per_pixel;
screen->width = priv->var.xres;
screen->height = priv->var.yres;
screen->fb[0].byteStride = priv->fix.line_length;
screen->fb[0].pixelStride = (priv->fix.line_length * 8 /
priv->var.bits_per_pixel);
screen->fb[0].frameBuffer = (CARD8 *) (priv->fb);
screen->off_screen_base = screen->fb[0].byteStride * screen->height;
screen->memory_base = priv->fb;
screen->memory_size = EPSON13806_VMEM_SIZE;
}
return TRUE;
}
Bool
epsonScreenInit (KdScreenInfo *screen)
{
EpsonScrPriv *scrpriv;
scrpriv = xalloc (sizeof (EpsonScrPriv));
if (!scrpriv)
return FALSE;
memset (scrpriv, '\0', sizeof (EpsonScrPriv));
screen->driver = scrpriv;
if (!epsonScreenInitialize (screen, scrpriv)) {
screen->driver = 0;
xfree (scrpriv);
return FALSE;
}
return TRUE;
}
static void *
epsonWindowLinear (ScreenPtr pScreen,
CARD32 row,
CARD32 offset,
int mode,
CARD32 *size,
void *closure)
{
KdScreenPriv(pScreen);
EpsonPriv *priv = pScreenPriv->card->driver;
if (!pScreenPriv->enabled)
return 0;
*size = priv->fix.line_length;
return (CARD8 *) priv->fb + row * priv->fix.line_length + offset;
}
#ifdef RANDR
static Bool
epsonRandRGetInfo (ScreenPtr pScreen, Rotation *rotations)
{
KdScreenPriv(pScreen);
KdScreenInfo *screen = pScreenPriv->screen;
EpsonScrPriv *scrpriv = screen->driver;
#if 0
RRVisualGroupPtr pVisualGroup;
RRGroupOfVisualGroupPtr pGroupOfVisualGroup;
#endif
RRScreenSizePtr pSize;
Rotation randr;
int n;
*rotations = RR_Rotate_0|RR_Rotate_90|RR_Rotate_180|RR_Rotate_270;
for (n = 0; n < pScreen->numDepths; n++)
if (pScreen->allowedDepths[n].numVids)
break;
if (n == pScreen->numDepths)
return FALSE;
#if 0
pVisualGroup = RRCreateVisualGroup (pScreen);
if (!pVisualGroup)
return FALSE;
if (!RRAddDepthToVisualGroup (pScreen, pVisualGroup, &pScreen->allowedDepths[n])) {
RRDestroyVisualGroup (pScreen, pVisualGroup);
return FALSE;
}
pVisualGroup = RRRegisterVisualGroup (pScreen, pVisualGroup);
if (!pVisualGroup)
return FALSE;
pGroupOfVisualGroup = RRCreateGroupOfVisualGroup (pScreen);
if (!RRAddVisualGroupToGroupOfVisualGroup (pScreen,
pGroupOfVisualGroup,
pVisualGroup))
{
RRDestroyGroupOfVisualGroup (pScreen, pGroupOfVisualGroup);
/* pVisualGroup left until screen closed */
return FALSE;
}
pGroupOfVisualGroup = RRRegisterGroupOfVisualGroup (pScreen, pGroupOfVisualGroup);
if (!pGroupOfVisualGroup)
return FALSE;
#endif
pSize = RRRegisterSize (pScreen,
screen->width,
screen->height,
screen->width_mm,
screen->height_mm);
randr = KdSubRotation (scrpriv->randr, screen->randr);
RRSetCurrentConfig (pScreen, randr, RR_Rotate_0, pSize);
return TRUE;
}
static Bool
epsonRandRSetConfig (ScreenPtr pScreen,
Rotation randr,
int rate,
RRScreenSizePtr pSize)
{
KdScreenPriv(pScreen);
KdScreenInfo *screen = pScreenPriv->screen;
EpsonScrPriv *scrpriv = screen->driver;
Bool wasEnabled = pScreenPriv->enabled;
randr = KdAddRotation (randr, screen->randr);
if (scrpriv->randr != randr)
{
if (wasEnabled)
KdDisableScreen (pScreen);
scrpriv->randr = randr;
if (wasEnabled)
KdEnableScreen (pScreen);
}
return TRUE;
}
static Bool
epsonRandRInit (ScreenPtr pScreen)
{
rrScrPrivPtr pScrPriv;
if (!RRScreenInit (pScreen))
return FALSE;
pScrPriv = rrGetScrPriv(pScreen);
pScrPriv->rrGetInfo = epsonRandRGetInfo;
pScrPriv->rrSetConfig = epsonRandRSetConfig;
return TRUE;
}
#endif
static Bool
epsonCreateColormap (ColormapPtr pmap)
{
ScreenPtr pScreen = pmap->pScreen;
KdScreenPriv(pScreen);
EpsonPriv *priv = pScreenPriv->card->driver;
VisualPtr pVisual;
int i;
int nent;
xColorItem *pdefs;
switch (priv->fix.visual) {
case FB_VISUAL_STATIC_PSEUDOCOLOR:
pVisual = pmap->pVisual;
nent = pVisual->ColormapEntries;
pdefs = xalloc (nent * sizeof (xColorItem));
if (!pdefs)
return FALSE;
for (i = 0; i < nent; i++)
pdefs[i].pixel = i;
epsonGetColors (pScreen, 0, nent, pdefs);
for (i = 0; i < nent; i++)
{
pmap->red[i].co.local.red = pdefs[i].red;
pmap->red[i].co.local.green = pdefs[i].green;
pmap->red[i].co.local.blue = pdefs[i].blue;
}
xfree (pdefs);
return TRUE;
default:
return fbInitializeColormap (pmap);
}
}
Bool
epsonInitScreen (ScreenPtr pScreen)
{
#ifdef TOUCHSCREEN
KdTsPhyScreen = pScreen->myNum;
#endif
pScreen->CreateColormap = epsonCreateColormap;
return TRUE;
}
static Bool
epsonFinishInitScreen (ScreenPtr pScreen)
{
if (!shadowSetup (pScreen))
return FALSE;
#ifdef RANDR
if (!epsonRandRInit (pScreen))
return FALSE;
#endif
return TRUE;
}
static Bool
epsonSetShadow (ScreenPtr pScreen)
{
KdScreenPriv(pScreen);
KdScreenInfo *screen = pScreenPriv->screen;
EpsonScrPriv *scrpriv = screen->driver;
ShadowUpdateProc update;
ShadowWindowProc window;
window = epsonWindowLinear;
update = shadowUpdatePacked;
return KdShadowSet (pScreen, scrpriv->randr, update, window);
}
static Bool
epsonCreateResources (ScreenPtr pScreen)
{
return epsonSetShadow (pScreen);
}
void
epsonPreserve (KdCardInfo *card)
{
}
Bool
epsonEnable (ScreenPtr pScreen)
{
KdScreenPriv(pScreen);
EpsonPriv *priv = pScreenPriv->card->driver;
int k;
priv->var.activate = FB_ACTIVATE_NOW|FB_CHANGE_CMAP_VBL;
/* display it on the LCD */
k = ioctl (priv->fd, FBIOPUT_VSCREENINFO, &priv->var);
if (k < 0) {
perror ("FBIOPUT_VSCREENINFO");
return FALSE;
}
k = ioctl (priv->fd, FBIOGET_FSCREENINFO, &priv->fix);
if (k < 0) {
perror ("FBIOGET_FSCREENINFO");
return FALSE;
}
if (priv->fix.visual == FB_VISUAL_DIRECTCOLOR) {
struct fb_cmap cmap;
int i;
for (i = 0;
i < (1 << priv->var.red.length) ||
i < (1 << priv->var.green.length) ||
i < (1 << priv->var.blue.length); i++) {
priv->red[i] = i * 65535 / ((1 << priv->var.red.length) - 1);
priv->green[i] = i * 65535 / ((1 << priv->var.green.length) - 1);
priv->blue[i] = i * 65535 / ((1 << priv->var.blue.length) - 1);
}
cmap.start = 0;
cmap.len = i;
cmap.red = &priv->red[0];
cmap.green = &priv->green[0];
cmap.blue = &priv->blue[0];
cmap.transp = 0;
ioctl (priv->fd, FBIOPUTCMAP, &cmap);
}
return TRUE;
}
Bool
epsonDPMS (ScreenPtr pScreen, int mode)
{
KdScreenPriv(pScreen);
EpsonPriv *priv = pScreenPriv->card->driver;
static int oldmode = -1;
if (mode == oldmode)
return TRUE;
#ifdef FBIOPUT_POWERMODE
if (ioctl (priv->fd, FBIOPUT_POWERMODE, &mode) >= 0) {
oldmode = mode;
return TRUE;
}
#endif
#ifdef FBIOBLANK
if (ioctl (priv->fd, FBIOBLANK, mode ? mode + 1 : 0) >= 0) {
oldmode = mode;
return TRUE;
}
#endif
return FALSE;
}
void
epsonDisable (ScreenPtr pScreen)
{
}
void
epsonRestore (KdCardInfo *card)
{
}
void
epsonScreenFini (KdScreenInfo *screen)
{
}
void
epsonCardFini (KdCardInfo *card)
{
EpsonPriv *priv = card->driver;
munmap (priv->fb_base, priv->fix.smem_len);
close (priv->fd);
xfree (priv);
}
void
epsonGetColors (ScreenPtr pScreen, int fb, int n, xColorItem *pdefs)
{
KdScreenPriv(pScreen);
EpsonPriv *priv = pScreenPriv->card->driver;
struct fb_cmap cmap;
int p;
int k;
int min, max;
min = 256;
max = 0;
for (k = 0; k < n; k++) {
if (pdefs[k].pixel < min)
min = pdefs[k].pixel;
if (pdefs[k].pixel > max)
max = pdefs[k].pixel;
}
cmap.start = min;
cmap.len = max - min + 1;
cmap.red = &priv->red[min];
cmap.green = &priv->green[min];;
cmap.blue = &priv->blue[min];
cmap.transp = 0;
k = ioctl (priv->fd, FBIOGETCMAP, &cmap);
if (k < 0) {
perror ("can't get colormap");
return;
}
while (n--) {
p = pdefs->pixel;
pdefs->red = priv->red[p];
pdefs->green = priv->green[p];
pdefs->blue = priv->blue[p];
pdefs++;
}
}
void
epsonPutColors (ScreenPtr pScreen, int fb, int n, xColorItem *pdefs)
{
KdScreenPriv(pScreen);
EpsonPriv *priv = pScreenPriv->card->driver;
struct fb_cmap cmap;
int p;
int min, max;
min = 256;
max = 0;
while (n--) {
p = pdefs->pixel;
priv->red[p] = pdefs->red;
priv->green[p] = pdefs->green;
priv->blue[p] = pdefs->blue;
if (p < min)
min = p;
if (p > max)
max = p;
pdefs++;
}
cmap.start = min;
cmap.len = max - min + 1;
cmap.red = &priv->red[min];
cmap.green = &priv->green[min];
cmap.blue = &priv->blue[min];
cmap.transp = 0;
ioctl (priv->fd, FBIOPUTCMAP, &cmap);
}
KdCardFuncs epsonFuncs = {
epsonCardInit, /* cardinit */
epsonScreenInit, /* scrinit */
epsonInitScreen, /* initScreen */
epsonFinishInitScreen,
epsonCreateResources,
epsonPreserve, /* preserve */
epsonEnable, /* enable */
epsonDPMS, /* dpms */
epsonDisable, /* disable */
epsonRestore, /* restore */
epsonScreenFini, /* scrfini */
epsonCardFini, /* cardfini */
0, /* initCursor */
0, /* enableCursor */
0, /* disableCursor */
0, /* finiCursor */
0, /* recolorCursor */
/*
* History:
* 28-Jan-04 C.Stylianou NBL: Added the following for h/w accel.
*
*/
epsonDrawInit, /* initAccel */
epsonDrawEnable, /* enableAccel */
epsonDrawDisable, /* disableAccel */
epsonDrawFini, /* finiAccel */
epsonGetColors, /* getColors */
epsonPutColors, /* putColors */
};

View File

@ -1,132 +0,0 @@
/*
* Copyright 2004 by Costas Stylianou <costas.stylianou@psion.com> +44(0)7850 394095
*
* 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 Costas Sylianou not be used in
* advertising or publicity pertaining to distribution of the software without
* specific, written prior permission. Costas Stylianou makes no representations
* about the suitability of this software for any purpose. It is provided
* "as is" without express or implied warranty.
*
* COSTAS STYLIANOU DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL COSTAS STYLIANOU 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.
*/
/*
* epson13806draw.h - Implementation of hard ware accelerated functions for epson S1D13806
* Graphic controller.
*
* History:
* 28-Jan-04 C.Stylianou PRJ NBL: Created from fbdev.h
*
*/
#ifndef _EPSON13806_H_
#define _EPSON13806_H_
#include <stdio.h>
#include <linux/fb.h>
#include <unistd.h>
#include <sys/mman.h>
#include "kdrive.h"
#ifdef RANDR
#include "randrstr.h"
#endif
typedef struct _epsonPriv {
struct fb_var_screeninfo var;
struct fb_fix_screeninfo fix;
__u16 red[256];
__u16 green[256];
__u16 blue[256];
int fd;
char *fb;
char *fb_base;
} EpsonPriv;
typedef struct _epsonScrPriv {
Rotation randr;
Bool shadow;
KaaScreenInfoRec kaa;
} EpsonScrPriv;
extern KdCardFuncs epsonFuncs;
Bool
epsonInitialize (KdCardInfo *card, EpsonPriv *priv);
Bool
epsonCardInit (KdCardInfo *card);
Bool
epsonScreenInit (KdScreenInfo *screen);
Bool
epsonScreenInitialize (KdScreenInfo *screen, EpsonScrPriv *scrpriv);
Bool
epsonInitScreen (ScreenPtr pScreen);
void
epsonPreserve (KdCardInfo *card);
Bool
epsonEnable (ScreenPtr pScreen);
Bool
epsonDPMS (ScreenPtr pScreen, int mode);
void
epsonDisable (ScreenPtr pScreen);
void
epsonRestore (KdCardInfo *card);
void
epsonScreenFini (KdScreenInfo *screen);
void
epsonCardFini (KdCardInfo *card);
void
epsonGetColors (ScreenPtr pScreen, int fb, int n, xColorItem *pdefs);
void
epsonPutColors (ScreenPtr pScreen, int fb, int n, xColorItem *pdefs);
/*
* History:
* 28-Jan-04 C.Stylianou NBL: Added the following prototypes for h/w accel.
*
*/
Bool
epsonDrawInit (ScreenPtr pScreen);
void
epsonDrawEnable (ScreenPtr pScreen);
void
epsonDrawDisable (ScreenPtr pScreen);
void
epsonDrawFini (ScreenPtr pScreen);
/*
* History:
* 28-Jan-04 C.Stylianou NBL: Maps to Epson registers
*
*/
void
initEpson13806(void);
#endif /* __EPSON13806_H_ */

View File

@ -1,649 +0,0 @@
/*
* Copyright 2004 by Costas Stylianou <costas.stylianou@psion.com> +44(0)7850 394095
*
* 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 Costas Sylianou not be used in
* advertising or publicity pertaining to distribution of the software without
* specific, written prior permission. Costas Stylianou makes no representations
* about the suitability of this software for any purpose. It is provided
* "as is" without express or implied warranty.
*
* COSTAS STYLIANOU DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL COSTAS STYLIANOU 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.
*/
/*
* epson13806draw.c - Implementation of hardware accelerated functions for epson S1D13806
* Graphic controller.
*
* History:
* 28-Jan-04 C.Stylianou PRJ NBL: Created from chipsdraw.c
*
*/
#include "epson13806.h"
#include "epson13806draw.h"
#include "epson13806reg.h"
#include "kaa.h"
#include "gcstruct.h"
#include "scrnintstr.h"
#include "pixmapstr.h"
#include "regionstr.h"
#include "mistruct.h"
#include "dixfontstr.h"
#include "fb.h"
#include "migc.h"
#include "miline.h"
// Functionality of BitBLT ROP register for Epson S1D13806 Graphics controller
CARD8 epson13806Rop[16] = {
/* GXclear */ 0x00, /* 0 */
/* GXand */ 0x08, /* src AND dst */
/* GXandReverse */ 0x04, /* src AND NOT dst */
/* GXcopy */ 0x0C, /* src */
/* GXandInverted*/ 0x02, /* NOT src AND dst */
/* GXnoop */ 0x0A, /* dst */
/* GXxor */ 0x06, /* src XOR dst */
/* GXor */ 0x0E, /* src OR dst */
/* GXnor */ 0x01, /* NOT src AND NOT dst */
/* GXequiv */ 0x09, /* NOT src XOR dst */
/* GXinvert */ 0x05, /* NOT dst */
/* GXorReverse */ 0x0D, /* src OR NOT dst */
/* GXcopyInverted*/ 0x03, /* NOT src */
/* GXorInverted */ 0x0B, /* NOT src OR dst */
/* GXnand */ 0x07, /* NOT src OR NOT dst */
/* GXset */ 0x0F, /* 1 */
};
#undef __DEBUG_EPSON__
#undef __DEBUG_EPSON_FBSET__
#undef __DEBUG_EPSON_SOLID__
#undef __DEBUG_EPSON_COPY__
#ifdef __DEBUG_EPSON__
#define EPSON_DEBUG(a) a
#else
#define EPSON_DEBUG(a)
#endif
#ifdef __DEBUG_EPSON_FBSET__
#define EPSON_DEBUG_FBSET(a) a
#else
#define EPSON_DEBUG_FBSET(a)
#endif
#ifdef __DEBUG_EPSON_SOLID__
#define EPSON_DEBUG_SOLID(a) a
#else
#define EPSON_DEBUG_SOLID(a)
#endif
#ifdef __DEBUG_EPSON_COPY__
#define EPSON_DEBUG_COPY(a) a
#else
#define EPSON_DEBUG_COPY(a)
#endif
static unsigned int byteStride; // Distance between lines in the frame buffer (in bytes)
static unsigned int bytesPerPixel;
static unsigned int pixelStride;
static unsigned char *regbase;
/*
* epsonSet
*
* Description: Sets Epson variables
*
* History:
* 11-Feb-04 C.Stylianou NBL: Created.
*
*/
static void
epsonSet (ScreenPtr pScreen)
{
EPSON_DEBUG_FBSET (fprintf(stderr,"+epsonSet\n"));
KdScreenPriv(pScreen);
byteStride = pScreenPriv->screen->fb[0].byteStride;
bytesPerPixel = pScreenPriv->screen->fb[0].bitsPerPixel >> 3;
pixelStride = pScreenPriv->screen->fb[0].pixelStride;
EPSON_DEBUG_FBSET (fprintf(stderr,"byteStride: [%x]\n", pScreenPriv->screen->fb[0].byteStride));
EPSON_DEBUG_FBSET (fprintf(stderr,"bytesPerPixel: [%x]\n", pScreenPriv->screen->fb[0].bitsPerPixel >> 3));
EPSON_DEBUG_FBSET (fprintf(stderr,"pixelStride: [%x]\n", pScreenPriv->screen->fb[0].pixelStride));
EPSON_DEBUG_FBSET (fprintf(stderr,"-epsonSet\n"));
}
/*
* epsonBg
*
* Description: Sets background colour
*
* History:
* 11-Feb-04 C.Stylianou NBL: Created.
*
*/
static void
epsonBg (Pixel bg)
{
EPSON13806_REG16(EPSON13806_BLTBGCOLOR) = bg;
}
/*
* epsonFg
*
* Description: Sets foreground colour
*
* History:
* 11-Feb-04 C.Stylianou NBL: Created.
*
*/
static void
epsonFg (Pixel fg)
{
EPSON13806_REG16(EPSON13806_BLTFGCOLOR) = fg;
}
/*
* epsonWaitForHwBltDone
*
* Description: Wait for previous blt to be done before programming any blt registers
*
* History:
* 11-Feb-04 C.Stylianou NBL: Created.
*
*/
static void
epsonWaitForHwBltDone (void)
{
while (EPSON13806_REG (EPSON13806_BLTCTRL0) & EPSON13806_BLTCTRL0_ACTIVE) {}
}
/*
* epsonDrawSync
*
* Description: Sync hardware acceleration
*
* History:
* 11-Feb-04 C.Stylianou NBL: Created.
*
*/
static void
epsonWaitMarker (ScreenPtr pScreen, int marker)
{
EPSON_DEBUG (fprintf(stderr,"+epsonDrawSync\n"));
epsonWaitForHwBltDone ();
EPSON_DEBUG (fprintf(stderr,"-epsonDrawSync\n"));
}
/*
* epsonPrepareSolid
*
* Description: Prepare Solid Fill i.e, can it be accelerated
*
* History:
* 11-Feb-04 C.Stylianou NBL: Created.
*
*/
static Bool
epsonPrepareSolid (PixmapPtr pPixmap,
int alu,
Pixel pm,
Pixel fg)
{
EPSON_DEBUG_SOLID (fprintf(stderr,"+epsonPrepareSolid\n"));
FbBits depthMask;
depthMask = FbFullMask(pPixmap->drawable.depth);
if ((pm & depthMask) != depthMask)
return FALSE;
epsonSet (pPixmap->drawable.pScreen);
fg &= 0xffff;
epsonFg (fg);
epsonBg (fg);
epsonWaitForHwBltDone ();
EPSON_DEBUG_SOLID (fprintf(stderr,"Solid.alu [0x%x], [%d]\n", alu ,epson13806Rop[alu]));
EPSON13806_REG(EPSON13806_BLTROP) = epson13806Rop[alu];
if (epson13806Rop[alu] == GXnoop)
{
EPSON13806_REG(EPSON13806_BLTOPERATION) = EPSON13806_BLTOPERATION_PATFILLROP;
}
else
{
EPSON13806_REG(EPSON13806_BLTOPERATION) = EPSON13806_BLTOPERATION_SOLIDFILL;
}
EPSON_DEBUG_SOLID (fprintf(stderr,"-epsonPrepareSolid\n"));
return TRUE;
}
/*
* epsonSolid
*
* Description: Executes Solid Fill
*
* History:
* 11-Feb-04 C.Stylianou NBL: Created.
*
*/
static void
epsonSolid (int x1, int y1, int x2, int y2)
{
EPSON_DEBUG_SOLID (fprintf(stderr,"+epsonSolid\n"));
CARD32 dst_addr;
int width, height;
EPSON_DEBUG_SOLID (fprintf(stderr,"Solid X1 [%d] Y1 [%d] X2 [%d] Y2 [%d]\n", x1, y1, x2, y2));
dst_addr = y1 * byteStride + x1 * bytesPerPixel;
width = ((x2 - x1)-1);
height = ((y2 - y1)-1);
// program dst address
EPSON13806_REG16(EPSON13806_BLTDSTSTART01) = dst_addr;
EPSON13806_REG(EPSON13806_BLTDSTSTART2) = dst_addr >> 16;
// program width and height of blit
EPSON13806_REG16(EPSON13806_BLTWIDTH) = width;
EPSON13806_REG16(EPSON13806_BLTHEIGHT) = height;
EPSON13806_REG(EPSON13806_BLTCTRL0) = EPSON13806_BLTCTRL0_ACTIVE;
// Wait for operation to complete
while (EPSON13806_REG(EPSON13806_BLTCTRL0) & EPSON13806_BLTCTRL0_ACTIVE) {}
EPSON_DEBUG_SOLID (fprintf(stderr,"-epsonSolid\n"));
}
/*
* epsonDoneSolid
*
* Description: Done Solid
*
* History:
* 11-Feb-04 C.Stylianou NBL: Created.
*
*/
static void
epsonDoneSolid (void)
{
EPSON_DEBUG_SOLID (fprintf(stderr,"+epsonDoneSolid\n"));
// Read from BitBLT data offset 0 to shut it down
//(void)EPSON13806_REG(EPSON13806_BITBLTDATA);
EPSON_DEBUG_SOLID (fprintf(stderr,"-epsonDoneSolid\n"));
}
/*
* epsonPrepareCopy
*
* Description: Prepares BitBLT, i.e, can it be accelerated
*
* History:
* 11-Feb-04 C.Stylianou NBL: Created.
*
*/
static Bool
epsonPrepareCopy (PixmapPtr pSrcPixmap,
PixmapPtr pDstPixmap,
int dx,
int dy,
int alu,
Pixel pm)
{
EPSON_DEBUG_COPY (fprintf(stderr,"+epsonPrepareCopy dx [0x%x] dy [0x%x]\n", dx, dy));
FbBits depthMask;
depthMask = FbFullMask(pDstPixmap->drawable.depth);
if ((pm & depthMask) != depthMask)
return FALSE;
epsonSet (pDstPixmap->drawable.pScreen);
epsonWaitForHwBltDone ();
EPSON13806_REG(EPSON13806_BLTROP) = epson13806Rop[alu];
EPSON_DEBUG_COPY (fprintf(stderr,"-epsonPrepareCopy\n"));
return TRUE;
}
/*
* epsonCopy
*
* Description: Executes BitBLT
*
* History:
* 11-Feb-04 C.Stylianou NBL: Created.
*
*/
static void
epsonCopy (int srcX,
int srcY,
int dstX,
int dstY,
int width,
int height)
{
EPSON_DEBUG_COPY (fprintf(stderr,"+epsonCopy\n"));
int src_addr, dst_addr;
int neg_dir = FALSE;
if (!width || !height)
return;
src_addr = srcX * bytesPerPixel + srcY * byteStride;
dst_addr = dstX * bytesPerPixel + dstY * byteStride;
/*
* See if regions overlap and dest region is beyond source region.
* If so, we need to do a move BLT in negative direction. Only applies
* if the BLT is not transparent.
*/
if ((srcX + width > dstX) && (srcX < dstX + width) &&
(srcY + height > dstY) && (srcY < dstY + height) &&
(dst_addr > src_addr))
{
neg_dir = TRUE;
// negative direction : get the coords of lower right corner
src_addr += byteStride * (height-1) + bytesPerPixel * (width-1);
dst_addr += byteStride * (height-1) + bytesPerPixel * (width-1);
}
// program BLIT memory offset
EPSON13806_REG16(EPSON13806_BLTSTRIDE) = byteStride/2;
// program src and dst addresses
EPSON13806_REG16(EPSON13806_BLTSRCSTART01) = src_addr;
EPSON13806_REG(EPSON13806_BLTSRCSTART2) = src_addr >> 16;
EPSON13806_REG16(EPSON13806_BLTDSTSTART01) = dst_addr;
EPSON13806_REG(EPSON13806_BLTDSTSTART2) = dst_addr >> 16;
// program width and height of blit
EPSON13806_REG16(EPSON13806_BLTWIDTH) = width-1;
EPSON13806_REG16(EPSON13806_BLTHEIGHT) = height-1;
// select pos/neg move BLIT
EPSON13806_REG(EPSON13806_BLTOPERATION) = neg_dir ?
EPSON13806_BLTOPERATION_MOVENEGROP : EPSON13806_BLTOPERATION_MOVEPOSROP;
EPSON13806_REG(EPSON13806_BLTCTRL0) = EPSON13806_BLTCTRL0_ACTIVE;
// Wait for operation to complete
while (EPSON13806_REG(EPSON13806_BLTCTRL0) & EPSON13806_BLTCTRL0_ACTIVE) {}
EPSON_DEBUG_COPY (fprintf(stderr,"-epsonCopy\n"));
}
/*
* epsonDoneCopy
*
* Description: Done Copy
*
* History:
* 11-Feb-04 C.Stylianou NBL: Created.
*
*/
static void
epsonDoneCopy (void)
{
EPSON_DEBUG_COPY (fprintf(stderr,"+epsonDoneCopy\n"));
// Read from BitBLT data offset 0 to shut it down
//(void)EPSON13806_REG(EPSON13806_BITBLTDATA);
EPSON_DEBUG_COPY (fprintf(stderr,"-epsonDoneCopy\n"));
}
/*
* epsonDrawInit
*
* Description: Configure the Epson S1D13806 for a 800x600 TFT colour display
*
* History:
* 11-Feb-04 C.Stylianou NBL: Created.
*
*/
Bool
epsonDrawInit (ScreenPtr pScreen)
{
KdScreenPriv(pScreen);
KdScreenInfo *screen = pScreenPriv->screen;
EpsonScrPriv *epsons = screen->driver;
EPSON_DEBUG (fprintf(stderr,"+epsonDrawInit\n"));
epsonSet(pScreen);
#if 0
EPSON13806_REG(EPSON13806_MISC) = 0x00;
EPSON13806_REG(EPSON13806_DISPMODE) = 0x00;
EPSON13806_REG16(EPSON13806_GPIOCFG) = 0xffff;
EPSON13806_REG16(EPSON13806_GPIOCTRL) = 0x0001;
EPSON13806_REG(EPSON13806_MEMCLKCFG) = 0x01;
EPSON13806_REG(EPSON13806_LCDPCLKCFG) = 0x00;
EPSON13806_REG(EPSON13806_CRTPCLKCFG) = 0x02;
EPSON13806_REG(EPSON13806_MPCLKCFG) = 0x02;
EPSON13806_REG(EPSON13806_CPUMEMWAITSEL) = 0x01;
EPSON13806_REG(EPSON13806_MEMCFG) = 0x80;
EPSON13806_REG(EPSON13806_DRAMREFRESH) = 0x03;
EPSON13806_REG16(EPSON13806_DRAMTIMINGCTRL) = 0x0100;
// 5ms delay for internal LCD SDRAM to initialize
usleep(5000);
EPSON13806_REG(EPSON13806_PANELTYPE) = 0x25;
EPSON13806_REG(EPSON13806_MODRATE) = 0x00;
EPSON13806_REG(EPSON13806_LCDHDP) = 0x63;
EPSON13806_REG(EPSON13806_LCDHNDP) = 0x1f;
EPSON13806_REG(EPSON13806_TFTFPLINESTART) = 0x01;
EPSON13806_REG(EPSON13806_TFTFPLINEPULSE) = 0x0b;
EPSON13806_REG16(EPSON13806_LCDVDP0) = 0x0257;
EPSON13806_REG(EPSON13806_LCDVNDP) = 0x1b;
EPSON13806_REG(EPSON13806_TFTFPFRAMESTART) = 0x0a;
EPSON13806_REG(EPSON13806_TFTFPFRAMEPULSE) = 0x01;
EPSON13806_REG(EPSON13806_LCDDISPMODE) = 0x85;
EPSON13806_REG(EPSON13806_LCDMISC) = 0x00;
EPSON13806_REG16(EPSON13806_LCDSTART01) = 0x0000;
EPSON13806_REG(EPSON13806_LCDSTART2) = 0x00;
EPSON13806_REG16(EPSON13806_LCDSTRIDE) = byteStride>>1;
EPSON13806_REG(EPSON13806_LCDPIXELPAN) = 0x00;
EPSON13806_REG(EPSON13806_LCDFIFOHIGH) = 0x00;
EPSON13806_REG(EPSON13806_LCDFIFOLOW) = 0x00;
#endif
EPSON13806_REG(EPSON13806_BLTCTRL0) = 0x00;
EPSON13806_REG(EPSON13806_BLTCTRL1) = 0x01; // We're using 16 bpp
EPSON13806_REG16(EPSON13806_BLTSTRIDE) = byteStride>>1; // program BLIT memory offset
#if 0
EPSON13806_REG(EPSON13806_LUTMODE) = 0x00;
EPSON13806_REG(EPSON13806_LUTADDR) = 0x00;
EPSON13806_REG(EPSON13806_PWRSAVECFG) = 0x10;
EPSON13806_REG(EPSON13806_PWRSAVESTATUS) = 0x00;
EPSON13806_REG(EPSON13806_CPUMEMWATCHDOG) = 0x00;
EPSON13806_REG(EPSON13806_DISPMODE) = 0x01;
// Enable backlight voltage
EPSON13806_REG16(EPSON13806_GPIOCTRL) |= 1<<1;
// 10ms delay after turning on LCD.
usleep(10000);
#endif
// Instruct the BitBLT unit to fill the screen with black, i.e clear fb.
static int addr = 0x00000000;
EPSON13806_REG16(EPSON13806_BLTDSTSTART01) = addr;
EPSON13806_REG(EPSON13806_BLTDSTSTART2) = addr >> 16;
EPSON13806_REG16(EPSON13806_BLTFGCOLOR) = 0x0000;
EPSON13806_REG(EPSON13806_BLTOPERATION) = EPSON13806_BLTOPERATION_SOLIDFILL; // solid fill blt
EPSON13806_REG16(EPSON13806_BLTWIDTH) = (0x0320-1);
EPSON13806_REG16(EPSON13806_BLTHEIGHT) = (0x0258-1);
EPSON13806_REG(EPSON13806_BLTCTRL0) = EPSON13806_BLTCTRL0_ACTIVE;
#if 0
// Enable LCD data
EPSON13806_REG(EPSON13806_LCDDISPMODE) &= ~(1<<7);
// Turn on backlight full
EPSON13806_REG16(EPSON13806_GPIOCTRL) |= 0x00fc;
#endif
memset(&epsons->kaa, 0, sizeof(KaaScreenInfoRec));
epsons->kaa.waitMarker = epsonWaitMarker;
epsons->kaa.PrepareSolid = epsonPrepareSolid;
epsons->kaa.Solid = epsonSolid;
epsons->kaa.DoneSolid = epsonDoneSolid;
epsons->kaa.PrepareCopy = epsonPrepareCopy;
epsons->kaa.Copy = epsonCopy;
epsons->kaa.DoneCopy = epsonDoneCopy;
epsons->kaa.flags = KAA_OFFSCREEN_PIXMAPS;
if (!kaaDrawInit (pScreen, &epsons->kaa))
return FALSE;
EPSON_DEBUG (fprintf(stderr,"-epsonDrawInit\n"));
return TRUE;
}
/*
* epsonDrawEnable
*
* Description: Enables hardware acceleration
*
* History:
* 11-Feb-04 C.Stylianou NBL: Created.
*
*/
void
epsonDrawEnable (ScreenPtr pScreen)
{
EPSON_DEBUG (fprintf(stderr,"+epsonDrawEnable\n"));
epsonWaitForHwBltDone ();
kaaMarkSync (pScreen);
EPSON_DEBUG (fprintf(stderr,"-epsonDrawEnable\n"));
}
/*
* epsonDrawDisable
*
* Description: Disables hardware acceleration
*
* History:
* 11-Feb-04 C.Stylianou NBL: Created.
*
*/
void
epsonDrawDisable (ScreenPtr pScreen)
{
EPSON_DEBUG (fprintf(stderr,"+epsonDrawDisable\n"));
}
/*
* epsonDrawFini
*
* Description: Finish hardware acceleration
*
* History:
* 11-Feb-04 C.Stylianou NBL: Created.
*
*/
void
epsonDrawFini (ScreenPtr pScreen)
{
EPSON_DEBUG (fprintf(stderr,"+epsonDrawFini\n"));
}
/*
* initEpson13806
*
* Description: Maps Epson S1D13806 registers
*
* History:
* 11-Feb-04 C.Stylianou NBL: Created.
*
*/
void
initEpson13806(void)
{
EPSON_DEBUG (fprintf(stderr,"+initEpson\n"));
// Map Epson S1D13806 registers
regbase = KdMapDevice (EPSON13806_PHYSICAL_REG_ADDR, EPSON13806_GPIO_REGSIZE);
if (!regbase)
perror("ERROR: regbase\n"); // Sets up register mappings in header files.
#if 0
CARD8 rev_code;
rev_code = EPSON13806_REG (EPSON13806_REVCODE);
if ((rev_code >> 2) != 0x07)
perror("ERROR: EPSON13806 Display Controller NOT FOUND!\n");
#endif
EPSON_DEBUG (fprintf(stderr,"-initEpson\n"));
}

View File

@ -1,119 +0,0 @@
/*
* Copyright 2004 by Costas Stylianou <costas.stylianou@psion.com> +44(0)7850 394095
*
* 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 Costas Sylianou not be used in
* advertising or publicity pertaining to distribution of the software without
* specific, written prior permission. Costas Stylianou makes no representations
* about the suitability of this software for any purpose. It is provided
* "as is" without express or implied warranty.
*
* COSTAS STYLIANOU DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL COSTAS STYLIANOU 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.
*/
/*
* epson13806draw.h - Implementation of hard ware accelerated functions for epson S1D13806
* Graphic controller.
*
* History:
* 28-Jan-04 C.Stylianou PRJ NBL: Created from chipsdraw.h
*
*/
#ifndef _EPSON13806DRAW_H_
#define _EPSON13806DRAW_H_
/*
* offset from ioport beginning
*/
#define SetupEpson(s) KdScreenPriv(s); \
epsonCardInfo(pScreenPriv); \
EpsonPtr epson = epsonc->epson
typedef volatile CARD8 VOL8;
typedef volatile CARD16 VOL16;
typedef volatile CARD32 VOL32;
typedef struct _epsonSave {
int dummy;
} EpsonSave;
typedef struct _epsonCardInfo {
EpsonPriv epson;
CARD32 *window;
Bool mmio;
EpsonSave save;
} epsonCardInfo;
#define getEpsonCardInfo(kd) ((epsonCardInfo *) ((kd)->card->driver))
#define epsonCardInfo(kd) epsonCardInfo *epsonc = getEpsonCardInfo(kd)
typedef struct _epsonCursor {
int width, height;
int xhot, yhot;
Bool has_cursor;
CursorPtr pCursor;
Pixel source, mask;
} EpsonCursor;
#define epson_CURSOR_WIDTH 64
#define epson_CURSOR_HEIGHT 64
typedef struct _epsonScreenInfo {
EpsonScrPriv epson;
CARD8 *cursor_base;
CARD8 *screen;
CARD8 *off_screen;
int off_screen_size;
EpsonCursor cursor;
void *regbase_virt;
} EpsonScreenInfo;
#define getEpsonScreenInfo(kd) ((EpsonScreenInfo *) ((kd)->screen->driver))
#define epsonScreenInfo(kd) EpsonScreenInfo *epsons = getEpsonScreenInfo(kd)
Bool
epsonDrawInit (ScreenPtr pScreen);
void
epsonDrawEnable (ScreenPtr pScreen);
void
epsonDrawSync (ScreenPtr pScreen);
void
epsonDrawDisable (ScreenPtr pScreen);
void
epsonDrawFini (ScreenPtr pScreen);
Bool
epsonCursorInit (ScreenPtr pScreen);
void
epsonCursorEnable (ScreenPtr pScreen);
void
epsonCursorDisable (ScreenPtr pScreen);
void
epsonCursorFini (ScreenPtr pScreen);
void
epsonRecolorCursor (ScreenPtr pScreen, int ndef, xColorItem *pdef);
extern KdCardFuncs epsonFuncs;
#endif

View File

@ -1,183 +0,0 @@
/*
* Copyright 2004 by Costas Stylianou <costas.stylianou@psion.com> +44(0)7850 394095
*
* 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 Costas Sylianou not be used in
* advertising or publicity pertaining to distribution of the software without
* specific, written prior permission. Costas Stylianou makes no representations
* about the suitability of this software for any purpose. It is provided
* "as is" without express or implied warranty.
*
* COSTAS STYLIANOU DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL COSTAS STYLIANOU 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.
*/
/*
* epson13806reg.h Epson S1D13806 LCD controller header file.
*
* History:
* 15-Feb-04 C.Stylianou PRJ NBL: Created.
*
*/
#ifndef EPSON13806REG_H
#define EPSON13806REG_H
#define TT_UNUSED(x) ((void) (x))
#define EPSON13806_PHYSICAL_REG_ADDR 0x14000000
#define EPSON13806_GPIO_REGSIZE 0x001f0000
#define EPSON13806_PHYSICAL_VMEM_ADDR 0x14200000
#define EPSON13806_VMEM_SIZE 0x140000
#define PLATFORM_EPSON13806_BASE (regbase)
#define EPSON13806_REG_BASE (PLATFORM_EPSON13806_BASE + 0x000000) // Register base address
#define EPSON13806_SDRAM_BASE (PLATFORM_EPSON13806_BASE + 0x200000) // SDRAM base address
//////////////////////////////////////////////////////////////////////////////////////////
// Register Offsets
//////////////////////////////////////////////////////////////////////////////////////////
#define EPSON13806_REVCODE (EPSON13806_REG_BASE + 0x0000) // Revision Code Register
#define EPSON13806_MISC (EPSON13806_REG_BASE + 0x0001) // Miscellaneous Register
#define EPSON13806_GPIOCFG (EPSON13806_REG_BASE + 0x0004) // General IO Pins Configuration Register (16 bits)
#define EPSON13806_GPIOCFG0 (EPSON13806_REG_BASE + 0x0004) // General IO Pins Configuration Register 0
#define EPSON13806_GPIOCFG1 (EPSON13806_REG_BASE + 0x0005) // General IO Pins Configuration Register 1
#define EPSON13806_GPIOCTRL (EPSON13806_REG_BASE + 0x0008) // General IO Pins Control Register (16 bits)
#define EPSON13806_GPIOCTRL0 (EPSON13806_REG_BASE + 0x0008) // General IO Pins Control Register 0
#define EPSON13806_GPIOCTRL1 (EPSON13806_REG_BASE + 0x0009) // General IO Pins Control Register 1
#define EPSON13806_MDCFGSTATUS (EPSON13806_REG_BASE + 0x000C) // Configuration Status Register
#define EPSON13806_MEMCLKCFG (EPSON13806_REG_BASE + 0x0010) // Memory Clock Configuration Register
#define EPSON13806_LCDPCLKCFG (EPSON13806_REG_BASE + 0x0014) // LCD Pixel Clock Configuration Register
#define EPSON13806_CRTPCLKCFG (EPSON13806_REG_BASE + 0x0018) // CRT/TV Clock Configuration Register
#define EPSON13806_MPCLKCFG (EPSON13806_REG_BASE + 0x001C) // MediaPlug Clock Configuration Register
#define EPSON13806_CPUMEMWAITSEL (EPSON13806_REG_BASE + 0x001E) // CPU To Memory Wait State Select Register
#define EPSON13806_MEMCFG (EPSON13806_REG_BASE + 0x0020) // Memory Configuration Register
#define EPSON13806_DRAMREFRESH (EPSON13806_REG_BASE + 0x0021) // DRAM Refresh Rate Register
#define EPSON13806_DRAMTIMINGCTRL (EPSON13806_REG_BASE + 0x002A) // DRAM Timings Control Register (16 bits)
#define EPSON13806_DRAMTIMINGCTRL0 (EPSON13806_REG_BASE + 0x002A) // DRAM Timings Control Register 0
#define EPSON13806_DRAMTIMINGCTRL1 (EPSON13806_REG_BASE + 0x002B) // DRAM Timings Control Register 1
#define EPSON13806_PANELTYPE (EPSON13806_REG_BASE + 0x0030) // Panel Type Register
#define EPSON13806_MODRATE (EPSON13806_REG_BASE + 0x0031) // MOD Rate Register
#define EPSON13806_LCDHDP (EPSON13806_REG_BASE + 0x0032) // LCD Horizontal Display Width Register
#define EPSON13806_LCDHNDP (EPSON13806_REG_BASE + 0x0034) // LCD Horizontal Non-Display Period Register
#define EPSON13806_TFTFPLINESTART (EPSON13806_REG_BASE + 0x0035) // TFT FPLINE Start Position Register
#define EPSON13806_TFTFPLINEPULSE (EPSON13806_REG_BASE + 0x0036) // TFT FPLINE Pulse Width Register
#define EPSON13806_LCDVDP (EPSON13806_REG_BASE + 0x0038) // LCD Vertical Display Height Register (16 bits)
#define EPSON13806_LCDVDP0 (EPSON13806_REG_BASE + 0x0038) // LCD Vertical Display Height Register 0
#define EPSON13806_LCDVDP1 (EPSON13806_REG_BASE + 0x0039) // LCD Vertical Display Height Register 1
#define EPSON13806_LCDVNDP (EPSON13806_REG_BASE + 0x003A) // LCD Vertical Non-Display Period Register
#define EPSON13806_TFTFPFRAMESTART (EPSON13806_REG_BASE + 0x003B) // TFT FPFRAME Start Position Register
#define EPSON13806_TFTFPFRAMEPULSE (EPSON13806_REG_BASE + 0x003C) // TFT FPFRAME Pulse Width Register
#define EPSON13806_LCDLINECOUNT (EPSON13806_REG_BASE + 0x003E) // LCD Line Count Register (16 bits)
#define EPSON13806_LCDLINECOUNT0 (EPSON13806_REG_BASE + 0x003E) // LCD Line Count Register 0
#define EPSON13806_LCDLINECOUNT1 (EPSON13806_REG_BASE + 0x003F) // LCD Line Count Register 1
#define EPSON13806_LCDDISPMODE (EPSON13806_REG_BASE + 0x0040) // LCD Display Mode Register
#define EPSON13806_LCDMISC (EPSON13806_REG_BASE + 0x0041) // LCD Miscellaneous Register
#define EPSON13806_LCDSTART01 (EPSON13806_REG_BASE + 0x0042) // LCD Display Start Address Register 0 and 1 (16 bits)
#define EPSON13806_LCDSTART0 (EPSON13806_REG_BASE + 0x0042) // LCD Display Start Address Register 0
#define EPSON13806_LCDSTART1 (EPSON13806_REG_BASE + 0x0043) // LCD Display Start Address Register 1
#define EPSON13806_LCDSTART2 (EPSON13806_REG_BASE + 0x0044) // LCD Display Start Address Register 2
#define EPSON13806_LCDSTRIDE (EPSON13806_REG_BASE + 0x0046) // LCD Memory Address Offset Register (16 bits)
#define EPSON13806_LCDSTRIDE0 (EPSON13806_REG_BASE + 0x0046) // LCD Memory Address Offset Register 0
#define EPSON13806_LCDSTRIDE1 (EPSON13806_REG_BASE + 0x0047) // LCD Memory Address Offset Register 1
#define EPSON13806_LCDPIXELPAN (EPSON13806_REG_BASE + 0x0048) // LCD Pixel Panning Register
#define EPSON13806_LCDFIFOHIGH (EPSON13806_REG_BASE + 0x004A) // LCD Display FIFO High Threshold Control Register
#define EPSON13806_LCDFIFOLOW (EPSON13806_REG_BASE + 0x004B) // LCD Display FIFO Low Threshold Control Register
#define EPSON13806_LCDINKCURSCTRL (EPSON13806_REG_BASE + 0x0070) // LCD INK/Cursor Control Register
#define EPSON13806_LCDINKCURSSTART (EPSON13806_REG_BASE + 0x0071) // LCD INK/Cursor Start Address Register
#define EPSON13806_LCDCURSORXPOS (EPSON13806_REG_BASE + 0x0072) // LCD Cursor X Position Register (16 bits)
#define EPSON13806_LCDCURSORXPOS0 (EPSON13806_REG_BASE + 0x0072) // LCD Cursor X Position Register 0
#define EPSON13806_LCDCURSORXPOS1 (EPSON13806_REG_BASE + 0x0073) // LCD Cursor X Position Register 1
#define EPSON13806_LCDCURSORYPOS (EPSON13806_REG_BASE + 0x0074) // LCD Cursor Y Position Register (16 bits)
#define EPSON13806_LCDCURSORYPOS0 (EPSON13806_REG_BASE + 0x0074) // LCD Cursor Y Position Register 0
#define EPSON13806_LCDCURSORYPOS1 (EPSON13806_REG_BASE + 0x0075) // LCD Cursor Y Position Register 1
#define EPSON13806_LCDINKCURSBLUE0 (EPSON13806_REG_BASE + 0x0076) // LCD INK/Cursor Blue Color 0 Register
#define EPSON13806_LCDINKCURSGREEN0 (EPSON13806_REG_BASE + 0x0077) // LCD INK/Cursor Green Color 0 Register
#define EPSON13806_LCDINKCURSRED0 (EPSON13806_REG_BASE + 0x0078) // LCD INK/Cursor Red Color 0 Register
#define EPSON13806_LCDINKCURSBLUE1 (EPSON13806_REG_BASE + 0x007A) // LCD INK/Cursor Blue Color 1 Register
#define EPSON13806_LCDINKCURSGREEN1 (EPSON13806_REG_BASE + 0x007B) // LCD INK/Cursor Green Colour 1 Register
#define EPSON13806_LCDINKCURSRED1 (EPSON13806_REG_BASE + 0x007C) // LCD INK/Cursor Red Color 1 Register
#define EPSON13806_LCDINKCURSFIFO (EPSON13806_REG_BASE + 0x007E) // LCD INK/Cursor FIFO Threshold Register
#define EPSON13806_BLTCTRL0 (EPSON13806_REG_BASE + 0x0100) // BitBlt Control Register 0
#define EPSON13806_BLTCTRL1 (EPSON13806_REG_BASE + 0x0101) // BitBlt Control Register 1
#define EPSON13806_BLTROP (EPSON13806_REG_BASE + 0x0102) // BitBlt ROP Code/Color Expansion Register
#define EPSON13806_BLTOPERATION (EPSON13806_REG_BASE + 0x0103) // BitBlt Operation Register
#define EPSON13806_BLTSRCSTART01 (EPSON13806_REG_BASE + 0x0104) // BitBlt Source Start Address Register 0 and 1 (16 bits)
#define EPSON13806_BLTSRCSTART0 (EPSON13806_REG_BASE + 0x0104) // BitBlt Source Start Address Register 0
#define EPSON13806_BLTSRCSTART1 (EPSON13806_REG_BASE + 0x0105) // BitBlt Source Start Address Register 1
#define EPSON13806_BLTSRCSTART2 (EPSON13806_REG_BASE + 0x0106) // BitBlt Source Start Address Register 2
#define EPSON13806_BLTDSTSTART01 (EPSON13806_REG_BASE + 0x0108) // BitBlt Destination Start Address Register 0 and 1 (16 bits)
#define EPSON13806_BLTDSTSTART0 (EPSON13806_REG_BASE + 0x0108) // BitBlt Destination Start Address Register 0
#define EPSON13806_BLTDSTSTART1 (EPSON13806_REG_BASE + 0x0109) // BitBlt Destination Start Address Register 1
#define EPSON13806_BLTDSTSTART2 (EPSON13806_REG_BASE + 0x010A) // BitBlt Destination Start Address Register 2
#define EPSON13806_BLTSTRIDE (EPSON13806_REG_BASE + 0x010C) // BitBlt Memory Address Offset Register (16 bits)
#define EPSON13806_BLTSTRIDE0 (EPSON13806_REG_BASE + 0x010C) // BitBlt Memory Address Offset Register 0
#define EPSON13806_BLTSTRIDE1 (EPSON13806_REG_BASE + 0x010D) // BitBlt Memory Address Offset Register 1
#define EPSON13806_BLTWIDTH (EPSON13806_REG_BASE + 0x0110) // BitBlt Width Register (16 bits)
#define EPSON13806_BLTWIDTH0 (EPSON13806_REG_BASE + 0x0110) // BitBlt Width Register 0
#define EPSON13806_BLTWIDTH1 (EPSON13806_REG_BASE + 0x0111) // BitBlt Width Register 1
#define EPSON13806_BLTHEIGHT (EPSON13806_REG_BASE + 0x0112) // BitBlt Height Register (16 bits)
#define EPSON13806_BLTHEIGHT0 (EPSON13806_REG_BASE + 0x0112) // BitBlt Height Register 0
#define EPSON13806_BLTHEIGHT1 (EPSON13806_REG_BASE + 0x0113) // BitBlt Height Register 1
#define EPSON13806_BLTBGCOLOR (EPSON13806_REG_BASE + 0x0114) // BitBlt Background Color Register (16 bits)
#define EPSON13806_BLTBGCOLOR0 (EPSON13806_REG_BASE + 0x0114) // BitBlt Background Color Register 0
#define EPSON13806_BLTBGCOLOR1 (EPSON13806_REG_BASE + 0x0115) // BitBlt Background Color Register 1
#define EPSON13806_BLTFGCOLOR (EPSON13806_REG_BASE + 0x0118) // BitBlt Foreground Color Register (16 bits)
#define EPSON13806_BLTFGCOLOR0 (EPSON13806_REG_BASE + 0x0118) // BitBlt Foreground Color Register 0
#define EPSON13806_BLTFGCOLOR1 (EPSON13806_REG_BASE + 0x0119) // BitBlt Foreground Color Register 0
#define EPSON13806_LUTMODE (EPSON13806_REG_BASE + 0x01E0) // Look-Up Table Mode Register
#define EPSON13806_LUTADDR (EPSON13806_REG_BASE + 0x01E2) // Look-Up Table Address Register
#define EPSON13806_LUTDATA (EPSON13806_REG_BASE + 0x01E4) // Look-Up Table Data Register
#define EPSON13806_PWRSAVECFG (EPSON13806_REG_BASE + 0x01F0) // Power Save Configuration Register
#define EPSON13806_PWRSAVESTATUS (EPSON13806_REG_BASE + 0x01F1) // Power Save Status Register
#define EPSON13806_CPUMEMWATCHDOG (EPSON13806_REG_BASE + 0x01F4) // CPU-to-Memory Access Watchdog Timer Register
#define EPSON13806_DISPMODE (EPSON13806_REG_BASE + 0x01FC) // Display Mode Register
#define EPSON13806_MEDIALCMD (EPSON13806_REG_BASE + 0x1000) // MediaPlug LCMD Register
#define EPSON13806_MEDIARESERVEDLCMD (EPSON13806_REG_BASE + 0x1002) // MediaPlug Reserved LCMD Register
#define EPSON13806_MEDIACMD (EPSON13806_REG_BASE + 0x1004) // MediaPlug CMD Register
#define EPSON13806_MEDIARESERVEDCMD (EPSON13806_REG_BASE + 0x1006) // MediaPlug Reserved CMD Register
#define EPSON13806_MEDIADATA (EPSON13806_REG_BASE + 0x1008) // MediaPlug Data Registers (base)
#define EPSON13806_BITBLTDATA (EPSON13806_REG_BASE + 0x100000) // BitBLT Data Registers (base)
// BLTCTRL0 register defines
#define EPSON13806_BLTCTRL0_ACTIVE (1<<7) // Read: 1=busy, 0=idle / Write: 1=start, 0=no change
// BLTOPERATION register defines
#define EPSON13806_BLTOPERATION_WRITEROP (0x00) // Write BitBLT with ROP
#define EPSON13806_BLTOPERATION_READ (0x01) // Read BitBLT
#define EPSON13806_BLTOPERATION_MOVEPOSROP (0x02) // Move BitBLT in positive direction with ROP
#define EPSON13806_BLTOPERATION_MOVENEGROP (0x03) // Move BitBLT in negative direction with ROP
#define EPSON13806_BLTOPERATION_TRANSWRITE (0x04) // Transparent Write BitBLT
#define EPSON13806_BLTOPERATION_TRANSMOVEPOS (0x05) // Transparent Move BitBLT in positive direction
#define EPSON13806_BLTOPERATION_PATFILLROP (0x06) // Pattern fill with ROP
#define EPSON13806_BLTOPERATION_PATFILLTRANS (0x07) // Pattern fill with transparency
#define EPSON13806_BLTOPERATION_COLOREXP (0x08) // Color expansion
#define EPSON13806_BLTOPERATION_COLOREXPTRANS (0x09) // Color expansion with transparency
#define EPSON13806_BLTOPERATION_MOVECOLOREXP (0x0A) // Move BitBLT with color expansion
#define EPSON13806_BLTOPERATION_MOVECOLOREXPTRANS (0x0B) // Move BitBLT with color expansion and transparency
#define EPSON13806_BLTOPERATION_SOLIDFILL (0x0C) // Solid fill
//////////////////////////////////////////////////////////////////////////////////////////
// Epson register access macros
//////////////////////////////////////////////////////////////////////////////////////////
#define EPSON13806_REG(address) *(VOL8 *)(address)
#define EPSON13806_REG16(address) *(VOL16 *)(address)
#endif // EPSON13806

View File

@ -1,69 +0,0 @@
/*
* Copyright 2004 by Costas Stylianou <costas.stylianou@psion.com> +44(0)7850 394095
*
* 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 Costas Sylianou not be used in
* advertising or publicity pertaining to distribution of the software without
* specific, written prior permission. Costas Stylianou makes no representations
* about the suitability of this software for any purpose. It is provided
* "as is" without express or implied warranty.
*
* COSTAS STYLIANOU DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL COSTAS STYLIANOU 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.
*/
/*
* epson13806stub.c
*
* History:
* 28-Jan-04 C.Stylianou PRJ NBL: Created from fbdevinit.c
*
*/
#ifdef HAVE_CONFIG_H
#include <kdrive-config.h>
#endif
#include <epson13806.h>
void
InitCard (char *name)
{
KdCardAttr attr;
fprintf(stderr, "Epson 13806 Tiny X Driver ver 1.01\n");
KdCardInfoAdd (&epsonFuncs, &attr, 0);
}
void
InitOutput (ScreenInfo *pScreenInfo, int argc, char **argv)
{
KdInitOutput (pScreenInfo, argc, argv);
}
void
InitInput (int argc, char **argv)
{
KdOsAddInputDrivers ();
KdInitInput ();
}
int
ddxProcessArgument (int argc, char **argv, int i)
{
return KdProcessArgument (argc, argv, i);
}
void
ddxUseMsg (void)
{
KdUseMsg();
}

View File

@ -1,39 +0,0 @@
INCLUDES = \
@KDRIVE_INCS@ \
@KDRIVE_CFLAGS@
bin_PROGRAMS = Xi810
noinst_LIBRARIES = libi810.a
libi810_a_SOURCES = \
i810_cursor.c \
i810_video.c \
i810draw.c \
i810draw.h \
i810_reg.h \
i810.c \
i810.h
Xi810_SOURCES = \
i810stub.c
I810_LIBS = \
libi810.a \
@KDRIVE_LIBS@
if GLX
Xi810_LDFLAGS = $(LD_EXPORT_SYMBOLS_FLAG)
endif
Xi810_LDADD = \
$(I810_LIBS) \
@KDRIVE_LIBS@
Xi810_DEPENDENCIES = \
libi810.a \
@KDRIVE_LOCAL_LIBS@
relink:
rm -f $(bin_PROGRAMS) && make $(bin_PROGRAMS)

File diff suppressed because it is too large Load Diff

View File

@ -1,511 +0,0 @@
/* COPYRIGHT AND PERMISSION NOTICE
Copyright (c) 2000, 2001 Nokia Home Communications
All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, and/or sell copies of the Software, and to permit persons
to whom the Software is furnished to do so, provided that the above
copyright notice(s) and this permission notice appear in all copies of
the Software and that both the above copyright notice(s) and this
permission notice appear in supporting documentation.
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
OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR 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.
Except as contained in this notice, the name of a copyright holder
shall not be used in advertising or otherwise to promote the sale, use
or other dealings in this Software without prior written authorization
of the copyright holder.
X Window System is a trademark of The Open Group */
/*
* Author:
* Pontus Lidman <pontus.lidman@nokia.com>
*/
#ifndef _I810_H_
#define _I810_H_
#include "i810_reg.h"
/* Globals */
typedef struct _I810Rec *I810Ptr;
/* Linear region allocated in framebuffer.
*/
typedef struct {
unsigned long Start;
unsigned long End;
unsigned long Size;
} I810MemRange;
typedef struct {
int tail_mask;
I810MemRange mem;
unsigned char *virtual_start;
int head;
int tail;
int space;
} I810RingBuffer;
typedef struct {
unsigned char DisplayControl;
unsigned char PixelPipeCfg0;
unsigned char PixelPipeCfg1;
unsigned char PixelPipeCfg2;
unsigned short VideoClk2_M;
unsigned short VideoClk2_N;
unsigned char VideoClk2_DivisorSel;
unsigned char AddressMapping;
unsigned char IOControl;
unsigned char BitBLTControl;
unsigned char ExtVertTotal;
unsigned char ExtVertDispEnd;
unsigned char ExtVertSyncStart;
unsigned char ExtVertBlankStart;
unsigned char ExtHorizTotal;
unsigned char ExtHorizBlank;
unsigned char ExtOffset;
unsigned char InterlaceControl;
unsigned int LMI_FIFO_Watermark;
unsigned int LprbTail;
unsigned int LprbHead;
unsigned int LprbStart;
unsigned int LprbLen;
unsigned int Fence[8];
unsigned short OverlayActiveStart;
unsigned short OverlayActiveEnd;
} I810RegRec, *I810RegPtr;
#define minb(p) *(volatile CARD8 *)(i810c->MMIOBase + (p))
#define moutb(p,v) *(volatile CARD8 *)(i810c->MMIOBase + (p)) = (v)
#define OUT_RING(n) { \
if (I810_DEBUG & DEBUG_VERBOSE_RING) \
ErrorF( "OUT_RING %x: %x\n", outring, n); \
*(volatile unsigned int *)(virt + outring) = n; \
outring += 4; \
outring &= ringmask; \
}
#define ADVANCE_LP_RING() { \
i810c->LpRing.tail = outring; \
OUTREG(LP_RING + RING_TAIL, outring); \
}
#ifdef __GNUC__
#define LP_RING_MESSAGE(n) \
ErrorF("BEGIN_LP_RING %d in %s\n", n, __FUNCTION__)
#else
#define LP_RING_MESSAGE(n) \
ErrorF("BEGIN_LP_RING %d in %s:%d\n", n, __FILE__, __LINE__)
#endif
#define LP_RING_LOCALS \
unsigned int outring, ringmask; \
volatile unsigned char *virt
#define BEGIN_LP_RING(n) \
if (n>2 && (I810_DEBUG&DEBUG_ALWAYS_SYNC)) \
i810Sync(i810s); \
if (i810c->LpRing.space < n*4) i810WaitLpRing(i810s, n*4, 0); \
i810c->LpRing.space -= n*4; \
if (I810_DEBUG & DEBUG_VERBOSE_RING) \
LP_RING_MESSAGE(n); \
outring = i810c->LpRing.tail; \
ringmask = i810c->LpRing.tail_mask; \
virt = i810c->LpRing.virtual_start;
/* Memory mapped register access macros */
#define INREG8(addr) *(volatile CARD8 *)(i810c->MMIOBase + (addr))
#define INREG16(addr) *(volatile CARD16 *)(i810c->MMIOBase + (addr))
#define INREG(addr) *(volatile CARD32 *)(i810c->MMIOBase + (addr))
#define OUTREG8(addr, val) do { \
*(volatile CARD8 *)(i810c->MMIOBase + (addr)) = (val); \
if (I810_DEBUG&DEBUG_VERBOSE_OUTREG) \
ErrorF( "OUTREG8(%x, %x)\n", addr, val); \
} while (0)
#define OUTREG16(addr, val) do { \
*(volatile CARD16 *)(i810c->MMIOBase + (addr)) = (val); \
if (I810_DEBUG&DEBUG_VERBOSE_OUTREG) \
ErrorF( "OUTREG16(%x, %x)\n", addr, val); \
} while (0)
#define OUTREG(addr, val) do { \
*(volatile CARD32 *)(i810c->MMIOBase + (addr)) = (val); \
if (I810_DEBUG&DEBUG_VERBOSE_OUTREG) \
ErrorF( "OUTREG(%x, %x)\n", addr, val); \
} while (0)
/* To remove all debugging, make sure I810_DEBUG is defined as a
* preprocessor symbol, and equal to zero.
*/
#define I810_DEBUG 0
#ifndef I810_DEBUG
#warning "Debugging enabled - expect reduced performance"
extern int I810_DEBUG;
#endif
#define DEBUG_VERBOSE_ACCEL 0x1
#define DEBUG_VERBOSE_SYNC 0x2
#define DEBUG_VERBOSE_VGA 0x4
#define DEBUG_VERBOSE_RING 0x8
#define DEBUG_VERBOSE_OUTREG 0x10
#define DEBUG_VERBOSE_MEMORY 0x20
#define DEBUG_VERBOSE_CURSOR 0x40
#define DEBUG_ALWAYS_SYNC 0x80
#define DEBUG_VERBOSE_DRI 0x100
/* Size of the mmio region.
*/
#define I810_REG_SIZE 0x80000
/* PCI identifiers */
#ifndef PCI_CHIP_I810
#define PCI_CHIP_I810 0x7121
#define PCI_CHIP_I810_DC100 0x7123
#define PCI_CHIP_I810_E 0x7125
#define PCI_CHIP_I815 0x1132
#define PCI_CHIP_I810_BRIDGE 0x7120
#define PCI_CHIP_I810_DC100_BRIDGE 0x7122
#define PCI_CHIP_I810_E_BRIDGE 0x7124
#define PCI_CHIP_I815_BRIDGE 0x1130
#define PCI_CHIP_I845G 0x2562
#endif
#define IS_I810(i810c) (i810c->PciInfo->chipType == PCI_CHIP_I810 || \
i810c->PciInfo->chipType == PCI_CHIP_I810_DC100 || \
i810c->PciInfo->chipType == PCI_CHIP_I810_E)
#define IS_I815(i810c) (i810c->PciInfo->chipType == PCI_CHIP_I815)
/* default number of VGA registers stored internally */
#define VGA_NUM_CRTC 25 /* 0x19 */
#define VGA_NUM_SEQ 5
#define VGA_NUM_GFX 9
#define VGA_NUM_ATTR 21
/*
* Settings of standard VGA registers.
*/
typedef struct {
unsigned char MiscOutReg; /* */
unsigned char CRTC[VGA_NUM_CRTC]; /* Crtc Controller */
unsigned char Sequencer[VGA_NUM_SEQ]; /* Video Sequencer */
unsigned char Graphics[VGA_NUM_GFX]; /* Video Graphics */
unsigned char Attribute[VGA_NUM_ATTR]; /* Video Atribute */
unsigned char DAC[768]; /* Internal Colorlookuptable */
} vgaRegRec, *vgaRegPtr;
typedef struct _i810VGARec *i810VGAPtr;
/* VGA registers */
typedef struct _i810VGARec {
int IOBase; /* I/O Base address */
CARD8 * MMIOBase; /* Pointer to MMIO start */
vgaRegRec SavedReg; /* saved registers */
vgaRegRec ModeReg; /* register settings for
current mode */
Bool ShowOverscan;
Bool paletteEnabled;
Bool cmapSaved;
} i810VGARec;
typedef struct _i810CardInfo {
int videoRam;
int MaxClock;
long FbMapSize;
int cpp; /* chars per pixel */
unsigned long LinearAddr;
unsigned long MMIOAddr;
unsigned char *MMIOBase;
unsigned char *FbBase;
Bool GttBound;
Bool agpAcquired2d;
int VramKey;
unsigned long VramOffset;
int DcacheKey;
unsigned long DcacheOffset;
int HwcursKey;
unsigned long HwcursOffset;
I810MemRange DcacheMem;
I810MemRange SysMem;
I810MemRange SavedDcacheMem;
I810MemRange SavedSysMem;
unsigned int bufferOffset; /* for I810SelectBuffer */
Bool DoneFrontAlloc;
BoxRec FbMemBox;
I810MemRange FrontBuffer;
I810MemRange Scratch;
I810MemRange XvMem;
int LmFreqSel;
i810VGARec vga;
I810RegRec SavedReg;
I810RegRec ModeReg;
I810RingBuffer LpRing;
unsigned int BR[20];
int CursorOffset;
unsigned long CursorPhysical;
unsigned long CursorStart;
unsigned long OverlayPhysical;
unsigned long OverlayStart;
int colorKey;
int nextColorExpandBuf;
ScreenBlockHandlerProcPtr BlockHandler;
#ifdef XV
KdVideoAdaptorPtr adaptor;
#endif
} i810CardInfo;
typedef struct _i810CardInfo I810CardInfo; /* compatibility */
#define getI810CardInfo(kd) ((I810CardInfo *) ((kd)->card->driver))
#define i810CardInfo(kd) I810CardInfo *i810c = getI810CardInfo(kd)
#define getI810ScreenInfo(kd) ((I810ScreenInfo *) ((kd)->screen->driver))
#define i810ScreenInfo(kd) I810ScreenInfo *i810s = getI810ScreenInfo(kd)
typedef struct _i810Cursor {
int width, height;
int xhot, yhot;
Bool has_cursor;
CursorPtr pCursor;
} i810Cursor, *i810CursorPtr;
typedef struct _i810ScreenInfo {
i810CardInfo *i810c;
i810Cursor cursor;
int pitch;
KaaScreenInfoRec kaa;
} i810ScreenInfo;
typedef struct _i810ScreenInfo I810ScreenInfo; /* compatibility */
#define I810_CURSOR_HEIGHT 64
#define I810_CURSOR_WIDTH 64
/* init functions (i810.c) */
Bool
i810CardInit (KdCardInfo *card);
Bool
i810ScreenInit (KdScreenInfo *screen);
/* The cursor functions (i810_cursor.c) */
Bool
i810CursorInit(ScreenPtr pScreen);
void
i810CursorEnable (ScreenPtr pScreen);
void
i810CursorDisable (ScreenPtr pScreen);
void
i810CursorFini (ScreenPtr pScreen);
/* Accel functions (i810draw.c) */
Bool
i810InitAccel(ScreenPtr);
void
i810EnableAccel (ScreenPtr);
void
i810DisableAccel (ScreenPtr);
void
i810FiniAccel (ScreenPtr);
void
i810FillBoxSolid (KdScreenInfo *screen, int nBox, BoxPtr pBox,
unsigned long pixel, int alu, unsigned long planemask);
extern KdCardFuncs i810Funcs;
/* Standard VGA registers */
#define VGA_ATTR_INDEX 0x3C0
#define VGA_ATTR_DATA_W 0x3C0
#define VGA_ATTR_DATA_R 0x3C1
#define VGA_IN_STAT_0 0x3C2 /* read */
#define VGA_MISC_OUT_W 0x3C2 /* write */
#define VGA_ENABLE 0x3C3
#define VGA_SEQ_INDEX 0x3C4
#define VGA_SEQ_DATA 0x3C5
#define VGA_DAC_MASK 0x3C6
#define VGA_DAC_READ_ADDR 0x3C7
#define VGA_DAC_WRITE_ADDR 0x3C8
#define VGA_DAC_DATA 0x3C9
#define VGA_FEATURE_R 0x3CA /* read */
#define VGA_MISC_OUT_R 0x3CC /* read */
#define VGA_GRAPH_INDEX 0x3CE
#define VGA_GRAPH_DATA 0x3CF
#define VGA_IOBASE_MONO 0x3B0
#define VGA_IOBASE_COLOR 0x3D0
#define VGA_CRTC_INDEX_OFFSET 0x04
#define VGA_CRTC_DATA_OFFSET 0x05
#define VGA_IN_STAT_1_OFFSET 0x0A /* read */
#define VGA_FEATURE_W_OFFSET 0x0A /* write */
/* VGA stuff */
#define BIT_PLANE 3 /* Which plane we write to in mono mode */
/* DAC indices for white and black */
#define WHITE_VALUE 0x3F
#define BLACK_VALUE 0x00
#define OVERSCAN_VALUE 0x01
#define OVERSCAN 0x11 /* Index of OverScan register */
void
i810VGAUnlock(i810VGAPtr vgap);
void
i810VGALock(i810VGAPtr vgap);
Bool
i810VGAInit(KdScreenInfo *scrninfp, const KdMonitorTiming *t);
void
i810VGABlankScreen(KdCardInfo *card, Bool on);
void
i810AdjustFrame(KdScreenInfo *screen, int x, int y, int flags);
Bool
i810VGAMapMem(KdCardInfo *card);
void
i810VGASave(KdCardInfo *card, vgaRegPtr save, int flags);
void
i810PrintErrorState(i810CardInfo *i810c);
void
i810VGAGetIOBase(i810VGAPtr vgap);
Bool
i810InitVideo(ScreenPtr pScreen);
/*
* MMIO versions of the register access functions. These require
* hwp->MemBase to be set in such a way that when the standard VGA port
* address is added the correct memory address results.
*/
#define Vminb(p) ( *(volatile CARD8 *)(vgap->MMIOBase + (p)))
#define Vmoutb(p,v) ( *(volatile CARD8 *)(vgap->MMIOBase + (p)) = (v))
#define mmioWriteCrtc(vgap, index, value) { \
Vmoutb(vgap->IOBase + VGA_CRTC_INDEX_OFFSET, index); \
Vmoutb(vgap->IOBase + VGA_CRTC_DATA_OFFSET, value); \
}
#define mmioReadCrtc(vgap, index) ( \
Vmoutb(vgap->IOBase + VGA_CRTC_INDEX_OFFSET, index), \
Vminb(vgap->IOBase + VGA_CRTC_DATA_OFFSET) \
)
#define mmioWriteGr(vgap, index, value) { \
Vmoutb(VGA_GRAPH_INDEX, index); \
Vmoutb(VGA_GRAPH_DATA, value); \
}
#define mmioReadGr(vgap, index) ( \
Vmoutb(VGA_GRAPH_INDEX, index), \
Vminb(VGA_GRAPH_DATA) \
)
#define mmioWriteSeq(vgap, index, value) {\
Vmoutb(VGA_SEQ_INDEX, index); \
Vmoutb(VGA_SEQ_DATA, value); \
}
#define mmioReadSeq(vgap, index) ( \
Vmoutb(VGA_SEQ_INDEX, index), \
Vminb(VGA_SEQ_DATA) \
)
#define mmioWriteAttr(vgap, index, value) { \
(void) Vminb(vgap->IOBase + VGA_IN_STAT_1_OFFSET); \
Vmoutb(VGA_ATTR_INDEX, index); \
Vmoutb(VGA_ATTR_DATA_W, value); \
}
#define mmioReadAttr(vgap, index) ( \
(void) Vminb(vgap->IOBase + VGA_IN_STAT_1_OFFSET), \
Vmoutb(VGA_ATTR_INDEX, index), \
Vminb(VGA_ATTR_DATA_R) \
)
#define mmioWriteMiscOut(vgap, value) Vmoutb(VGA_MISC_OUT_W, value)
#define mmioReadMiscOut(vgap) Vminb(VGA_MISC_OUT_R)
#define mmioEnablePalette(vgap) { \
(void) Vminb(vgap->IOBase + VGA_IN_STAT_1_OFFSET); \
Vmoutb(VGA_ATTR_INDEX, 0x00); \
vgap->paletteEnabled = TRUE; \
}
#define mmioDisablePalette(vgap) { \
(void) Vminb(vgap->IOBase + VGA_IN_STAT_1_OFFSET); \
Vmoutb(VGA_ATTR_INDEX, 0x20); \
vgap->paletteEnabled = FALSE; \
}
#define mmioWriteDacWriteAddr(vgap, value) Vmoutb(VGA_DAC_WRITE_ADDR, value)
#define mmioWriteDacData(vgap, value) Vmoutb(VGA_DAC_DATA, value)
#endif /* _I810_H_ */

View File

@ -1,436 +0,0 @@
/* COPYRIGHT AND PERMISSION NOTICE
Copyright (c) 2000, 2001 Nokia Home Communications
All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, and/or sell copies of the Software, and to permit persons
to whom the Software is furnished to do so, provided that the above
copyright notice(s) and this permission notice appear in all copies of
the Software and that both the above copyright notice(s) and this
permission notice appear in supporting documentation.
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
OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR 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.
Except as contained in this notice, the name of a copyright holder
shall not be used in advertising or otherwise to promote the sale, use
or other dealings in this Software without prior written authorization
of the copyright holder.
X Window System is a trademark of The Open Group */
/**************************************************************************
Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
All Rights Reserved.
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sub license, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice (including the
next paragraph) 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 NON-INFRINGEMENT.
IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS 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.
**************************************************************************/
/* i810_cursor.c: KDrive hardware cursor routines for the i810 chipset */
/*
* Authors:
* Keith Whitwell <keith@tungstengraphics.com>
* Pontus Lidman <pontus.lidman@nokia.com>
*
*/
#ifdef HAVE_CONFIG_H
#include <kdrive-config.h>
#endif
#include "kdrive.h"
#include "kxv.h"
#include "i810.h"
#include "cursorstr.h"
#include "inputstr.h"
#define SetupCursor(s) KdScreenPriv(pScreen); \
i810CardInfo(pScreenPriv); \
i810ScreenInfo(pScreenPriv); \
i810Cursor *pCurPriv = &i810s->cursor
static void
writeStandardMMIO(I810CardInfo *i810c, int addr, CARD8 val)
{
moutb(addr, val);
}
static void
_i810MoveCursor(ScreenPtr pScreen, int x, int y)
{
KdScreenPriv(pScreen);
i810CardInfo(pScreenPriv);
int flag;
if (I810_DEBUG & DEBUG_VERBOSE_CURSOR)
ErrorF( "I810SetCursorPosition %d %d\n", x, y);
x += i810c->CursorOffset;
if (x >= 0) flag = CURSOR_X_POS;
else {
flag = CURSOR_X_NEG;
x=-x;
}
OUTREG8( CURSOR_X_LO, x&0xFF);
OUTREG8( CURSOR_X_HI, (((x >> 8) & 0x07) | flag));
if (y >= 0) flag = CURSOR_Y_POS;
else {
flag = CURSOR_Y_NEG;
y=-y;
}
OUTREG8( CURSOR_Y_LO, y&0xFF);
OUTREG8( CURSOR_Y_HI, (((y >> 8) & 0x07) | flag));
/* Enable cursor */
OUTREG( CURSOR_BASEADDR, i810c->CursorPhysical);
OUTREG8( CURSOR_CONTROL, CURSOR_ORIGIN_DISPLAY | CURSOR_MODE_64_3C);
}
static void i810LoadCursor(ScreenPtr pScreen, int x, int y);
static void
i810MoveCursor (DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y)
{
KdScreenPriv(pScreen);
i810ScreenInfo(pScreenPriv);
i810Cursor *pCurPriv = &i810s->cursor;
if (!pCurPriv->has_cursor)
return;
if (!pScreenPriv->enabled)
return;
_i810MoveCursor (pScreen, x, y);
i810LoadCursor(pScreen, x, y);
}
static void
_i810SetCursorColors(ScreenPtr pScreen)
{
KdScreenPriv(pScreen);
i810CardInfo(pScreenPriv);
int tmp;
int bg = 0xffffff;
int fg = 0x000000;
tmp=INREG8(PIXPIPE_CONFIG_0);
tmp |= EXTENDED_PALETTE;
OUTREG8( PIXPIPE_CONFIG_0, tmp);
writeStandardMMIO(i810c, DACMASK, 0xFF);
writeStandardMMIO(i810c, DACWX, 0x04);
writeStandardMMIO(i810c, DACDATA, (bg & 0x00FF0000) >> 16);
writeStandardMMIO(i810c, DACDATA, (bg & 0x0000FF00) >> 8);
writeStandardMMIO(i810c, DACDATA, (bg & 0x000000FF));
writeStandardMMIO(i810c, DACDATA, (fg & 0x00FF0000) >> 16);
writeStandardMMIO(i810c, DACDATA, (fg & 0x0000FF00) >> 8);
writeStandardMMIO(i810c, DACDATA, (fg & 0x000000FF));
tmp=INREG8( PIXPIPE_CONFIG_0 );
tmp &= ~EXTENDED_PALETTE;
OUTREG8( PIXPIPE_CONFIG_0, tmp );
}
#define InvertBits32(v) { \
v = ((v & 0x55555555) << 1) | ((v >> 1) & 0x55555555); \
v = ((v & 0x33333333) << 2) | ((v >> 2) & 0x33333333); \
v = ((v & 0x0f0f0f0f) << 4) | ((v >> 4) & 0x0f0f0f0f); \
}
static void i810LoadCursor(ScreenPtr pScreen, int x, int y)
{
SetupCursor(pScreen);
int h;
unsigned int *msk, *mskLine, *src, *srcLine;
int i, j;
int src_stride, src_width;
CursorPtr pCursor = pCurPriv->pCursor;
CursorBitsPtr bits = pCursor->bits;
CARD8 tmp;
unsigned int *ram, *ramLine;
pCurPriv->pCursor = pCursor;
pCurPriv->xhot = pCursor->bits->xhot;
pCurPriv->yhot = pCursor->bits->yhot;
ramLine = (unsigned int *) (i810c->FbBase + i810c->CursorStart);
mskLine = (unsigned int *) (bits->mask);
srcLine = (unsigned int *) (bits->source);
h = bits->height;
if (h > I810_CURSOR_HEIGHT)
h = I810_CURSOR_HEIGHT;
src_stride = BitmapBytePad(bits->width); /* bytes per line */
src_stride = (src_stride +3) >> 2;
src_width = (bits->width + 31) >> 5;
for (i = 0; i < I810_CURSOR_HEIGHT; i++) {
msk = mskLine;
src = srcLine;
ram = ramLine;
mskLine += src_stride;
srcLine += src_stride;
ramLine += I810_CURSOR_WIDTH / 16;
for (j = 0; j < I810_CURSOR_WIDTH / 32; j++) {
unsigned long m, s;
if (i < h && j < src_width)
{
m = *msk++;
s = *src++ & m;
m = ~m;
/* mask off right side */
if (j == src_width - 1 && (bits->width & 31))
{
m |= 0xffffffff << (bits->width & 31);
}
}
else
{
m = 0xffffffff;
s = 0x00000000;
}
InvertBits32(s);
InvertBits32(m);
ram[2+j]=s;
ram[0+j]=m;
}
}
/* Set new color */
_i810SetCursorColors (pScreen);
/* Move to new position */
_i810MoveCursor (pScreen, x, y);
/* Enable cursor */
OUTREG( CURSOR_BASEADDR, i810c->CursorPhysical);
OUTREG8( CURSOR_CONTROL, CURSOR_ORIGIN_DISPLAY | CURSOR_MODE_64_3C);
tmp = INREG8( PIXPIPE_CONFIG_0 );
tmp |= HW_CURSOR_ENABLE;
OUTREG8( PIXPIPE_CONFIG_0, tmp);
}
static void
i810UnloadCursor(ScreenPtr pScreen)
{
KdScreenPriv(pScreen);
i810CardInfo(pScreenPriv);
unsigned char tmp;
tmp=INREG8( PIXPIPE_CONFIG_0 );
tmp &= ~HW_CURSOR_ENABLE;
OUTREG8( PIXPIPE_CONFIG_0, tmp);
}
static Bool
i810RealizeCursor (DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor)
{
KdScreenPriv(pScreen);
i810ScreenInfo(pScreenPriv);
i810Cursor *pCurPriv = &i810s->cursor;
if (!pScreenPriv->enabled)
return TRUE;
/* miRecolorCursor does this */
if (pCurPriv->pCursor == pCursor)
{
if (pCursor)
{
int x, y;
miPointerGetPosition (pDev, &x, &y);
i810LoadCursor (pScreen, x, y);
}
}
return TRUE;
}
static Bool
i810UnrealizeCursor (DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor)
{
return TRUE;
}
static void
i810SetCursor (DeviceIntPtr pDev, ScreenPtr pScreen, CursorPtr pCursor, int x, int y)
{
KdScreenPriv(pScreen);
i810ScreenInfo(pScreenPriv);
i810Cursor *pCurPriv = &i810s->cursor;
pCurPriv->pCursor = pCursor;
if (!pScreenPriv->enabled)
return;
if (pCursor)
i810LoadCursor (pScreen, x, y);
else
i810UnloadCursor (pScreen);
}
miPointerSpriteFuncRec i810PointerSpriteFuncs = {
i810RealizeCursor,
i810UnrealizeCursor,
i810SetCursor,
i810MoveCursor,
};
static void
i810QueryBestSize (int class,
unsigned short *pwidth, unsigned short *pheight,
ScreenPtr pScreen)
{
KdScreenPriv(pScreen);
i810ScreenInfo(pScreenPriv);
i810Cursor *pCurPriv = &i810s->cursor;
switch (class)
{
case CursorShape:
if (*pwidth > pCurPriv->width)
*pwidth = pCurPriv->width;
if (*pheight > pCurPriv->height)
*pheight = pCurPriv->height;
if (*pwidth > pScreen->width)
*pwidth = pScreen->width;
if (*pheight > pScreen->height)
*pheight = pScreen->height;
break;
default:
fbQueryBestSize (class, pwidth, pheight, pScreen);
break;
}
}
Bool
i810CursorInit(ScreenPtr pScreen)
{
KdScreenPriv(pScreen);
i810ScreenInfo(pScreenPriv);
i810CardInfo(pScreenPriv);
i810Cursor *pCurPriv = &i810s->cursor;
if (!i810c->CursorStart) {
pCurPriv->has_cursor = FALSE;
return FALSE;
}
pCurPriv->width = I810_CURSOR_WIDTH;
pCurPriv->height= I810_CURSOR_HEIGHT;
pScreen->QueryBestSize = i810QueryBestSize;
miPointerInitialize (pScreen,
&i810PointerSpriteFuncs,
&kdPointerScreenFuncs,
FALSE);
pCurPriv->has_cursor = TRUE;
pCurPriv->pCursor = NULL;
return TRUE;
}
void
i810CursorEnable (ScreenPtr pScreen)
{
KdScreenPriv(pScreen);
i810ScreenInfo(pScreenPriv);
i810Cursor *pCurPriv = &i810s->cursor;
if (pCurPriv->has_cursor)
{
if (pCurPriv->pCursor)
{
int x, y;
miPointerPosition (&x, &y);
i810LoadCursor (pScreen, x, y);
}
else
i810UnloadCursor (pScreen);
}
}
void
i810CursorDisable (ScreenPtr pScreen)
{
KdScreenPriv(pScreen);
i810ScreenInfo(pScreenPriv);
i810Cursor *pCurPriv = &i810s->cursor;
if (!pScreenPriv->enabled)
return;
if (pCurPriv->has_cursor)
{
if (pCurPriv->pCursor)
{
i810UnloadCursor (pScreen);
}
}
}
void
i810CursorFini (ScreenPtr pScreen)
{
KdScreenPriv(pScreen);
i810ScreenInfo(pScreenPriv);
i810Cursor *pCurPriv = &i810s->cursor;
pCurPriv->pCursor = NULL;
}

View File

@ -1,695 +0,0 @@
/* COPYRIGHT AND PERMISSION NOTICE
Copyright (c) 2000, 2001 Nokia Home Communications
All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, and/or sell copies of the Software, and to permit persons
to whom the Software is furnished to do so, provided that the above
copyright notice(s) and this permission notice appear in all copies of
the Software and that both the above copyright notice(s) and this
permission notice appear in supporting documentation.
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
OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR 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.
Except as contained in this notice, the name of a copyright holder
shall not be used in advertising or otherwise to promote the sale, use
or other dealings in this Software without prior written authorization
of the copyright holder.
X Window System is a trademark of The Open Group */
/**************************************************************************
Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
All Rights Reserved.
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sub license, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice (including the
next paragraph) 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 NON-INFRINGEMENT.
IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS 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.
**************************************************************************/
/*
* Authors:
* Keith Whitwell <keith@tungstengraphics.com>
* Pontus Lidman <pontus.lidman@nokia.com>
*
* based on the i740 driver by
* Kevin E. Martin <kevin@precisioninsight.com>
*
*
*/
/* I/O register offsets
*/
#define SRX 0x3C4 /* p208 */
#define GRX 0x3CE /* p213 */
#define ARX 0x3C0 /* p224 */
/* VGA Color Palette Registers */
#define DACMASK 0x3C6 /* p232 */
#define DACSTATE 0x3C7 /* p232 */
#define DACRX 0x3C7 /* p233 */
#define DACWX 0x3C8 /* p233 */
#define DACDATA 0x3C9 /* p233 */
/* CRT Controller Registers (CRX) */
#define START_ADDR_HI 0x0C /* p246 */
#define START_ADDR_LO 0x0D /* p247 */
#define VERT_SYNC_END 0x11 /* p249 */
#define EXT_VERT_TOTAL 0x30 /* p257 */
#define EXT_VERT_DISPLAY 0x31 /* p258 */
#define EXT_VERT_SYNC_START 0x32 /* p259 */
#define EXT_VERT_BLANK_START 0x33 /* p260 */
#define EXT_HORIZ_TOTAL 0x35 /* p261 */
#define EXT_HORIZ_BLANK 0x39 /* p261 */
#define EXT_START_ADDR 0x40 /* p262 */
#define EXT_START_ADDR_ENABLE 0x80
#define EXT_OFFSET 0x41 /* p263 */
#define EXT_START_ADDR_HI 0x42 /* p263 */
#define INTERLACE_CNTL 0x70 /* p264 */
#define INTERLACE_ENABLE 0x80
#define INTERLACE_DISABLE 0x00
/* Miscellaneous Output Register
*/
#define MSR_R 0x3CC /* p207 */
#define MSR_W 0x3C2 /* p207 */
#define IO_ADDR_SELECT 0x01
#define MDA_BASE 0x3B0 /* p207 */
#define CGA_BASE 0x3D0 /* p207 */
/* CR80 - IO Control, p264
*/
#define IO_CTNL 0x80
#define EXTENDED_ATTR_CNTL 0x02
#define EXTENDED_CRTC_CNTL 0x01
/* GR10 - Address mapping, p221
*/
#define ADDRESS_MAPPING 0x10
#define PAGE_TO_LOCAL_MEM_ENABLE 0x10
#define GTT_MEM_MAP_ENABLE 0x08
#define PACKED_MODE_ENABLE 0x04
#define LINEAR_MODE_ENABLE 0x02
#define PAGE_MAPPING_ENABLE 0x01
/* Blitter control, p378
*/
#define BITBLT_CNTL 0x7000c
#define COLEXP_MODE 0x30
#define COLEXP_8BPP 0x00
#define COLEXP_16BPP 0x10
#define COLEXP_24BPP 0x20
#define COLEXP_RESERVED 0x30
#define BITBLT_STATUS 0x01
/* p375.
*/
#define DISPLAY_CNTL 0x70008
#define VGA_WRAP_MODE 0x02
#define VGA_WRAP_AT_256KB 0x00
#define VGA_NO_WRAP 0x02
#define GUI_MODE 0x01
#define STANDARD_VGA_MODE 0x00
#define HIRES_MODE 0x01
/* p375
*/
#define PIXPIPE_CONFIG_0 0x70009
#define DAC_8_BIT 0x80
#define DAC_6_BIT 0x00
#define HW_CURSOR_ENABLE 0x10
#define EXTENDED_PALETTE 0x01
/* p375
*/
#define PIXPIPE_CONFIG_1 0x7000a
#define DISPLAY_COLOR_MODE 0x0F
#define DISPLAY_VGA_MODE 0x00
#define DISPLAY_8BPP_MODE 0x02
#define DISPLAY_15BPP_MODE 0x04
#define DISPLAY_16BPP_MODE 0x05
#define DISPLAY_24BPP_MODE 0x06
#define DISPLAY_32BPP_MODE 0x07
/* p375
*/
#define PIXPIPE_CONFIG_2 0x7000b
#define DISPLAY_GAMMA_ENABLE 0x08
#define DISPLAY_GAMMA_DISABLE 0x00
#define OVERLAY_GAMMA_ENABLE 0x04
#define OVERLAY_GAMMA_DISABLE 0x00
/* p380
*/
#define DISPLAY_BASE 0x70020
#define DISPLAY_BASE_MASK 0x03fffffc
/* Cursor control registers, pp383-384
*/
#define CURSOR_CONTROL 0x70080
#define CURSOR_ORIGIN_SCREEN 0x00
#define CURSOR_ORIGIN_DISPLAY 0x10
#define CURSOR_MODE 0x07
#define CURSOR_MODE_DISABLE 0x00
#define CURSOR_MODE_32_4C_AX 0x01
#define CURSOR_MODE_64_3C 0x04
#define CURSOR_MODE_64_4C_AX 0x05
#define CURSOR_MODE_64_4C 0x06
#define CURSOR_MODE_RESERVED 0x07
#define CURSOR_BASEADDR 0x70084
#define CURSOR_BASEADDR_MASK 0x1FFFFF00
#define CURSOR_X_LO 0x70088
#define CURSOR_X_HI 0x70089
#define CURSOR_X_POS 0x00
#define CURSOR_X_NEG 0x80
#define CURSOR_Y_LO 0x7008A
#define CURSOR_Y_HI 0x7008B
#define CURSOR_Y_POS 0x00
#define CURSOR_Y_NEG 0x80
/* Similar registers exist in Device 0 on the i810 (pp55-65), but I'm
* not sure they refer to local (graphics) memory.
*
* These details are for the local memory control registers,
* (pp301-310). The test machines are not equiped with local memory,
* so nothing is tested. Only a single row seems to be supported.
*/
#define DRAM_ROW_TYPE 0x3000
#define DRAM_ROW_0 0x01
#define DRAM_ROW_0_SDRAM 0x01
#define DRAM_ROW_0_EMPTY 0x00
#define DRAM_ROW_CNTL_LO 0x3001
#define DRAM_PAGE_MODE_CTRL 0x10
#define DRAM_RAS_TO_CAS_OVRIDE 0x08
#define DRAM_CAS_LATENCY 0x04
#define DRAM_RAS_TIMING 0x02
#define DRAM_RAS_PRECHARGE 0x01
#define DRAM_ROW_CNTL_HI 0x3002
#define DRAM_REFRESH_RATE 0x18
#define DRAM_REFRESH_DISABLE 0x00
#define DRAM_REFRESH_60HZ 0x08
#define DRAM_REFRESH_FAST_TEST 0x10
#define DRAM_REFRESH_RESERVED 0x18
#define DRAM_SMS 0x07
#define DRAM_SMS_NORMAL 0x00
#define DRAM_SMS_NOP_ENABLE 0x01
#define DRAM_SMS_ABPCE 0x02
#define DRAM_SMS_MRCE 0x03
#define DRAM_SMS_CBRCE 0x04
/* p307
*/
#define DPMS_SYNC_SELECT 0x5002
#define VSYNC_CNTL 0x08
#define VSYNC_ON 0x00
#define VSYNC_OFF 0x08
#define HSYNC_CNTL 0x02
#define HSYNC_ON 0x00
#define HSYNC_OFF 0x02
/* p317, 319
*/
#define VCLK2_VCO_M 0x6008 /* treat as 16 bit? (includes msbs) */
#define VCLK2_VCO_N 0x600a
#define VCLK2_VCO_DIV_SEL 0x6012
#define POST_DIV_SELECT 0x70
#define POST_DIV_1 0x00
#define POST_DIV_2 0x10
#define POST_DIV_4 0x20
#define POST_DIV_8 0x30
#define POST_DIV_16 0x40
#define POST_DIV_32 0x50
#define VCO_LOOP_DIV_BY_4M 0x00
#define VCO_LOOP_DIV_BY_16M 0x04
/* Instruction Parser Mode Register
* - p281
* - 2 new bits.
*/
#define INST_PM 0x20c0
#define AGP_SYNC_PACKET_FLUSH_ENABLE 0x20 /* reserved */
#define SYNC_PACKET_FLUSH_ENABLE 0x10
#define TWO_D_INST_DISABLE 0x08
#define THREE_D_INST_DISABLE 0x04
#define STATE_VAR_UPDATE_DISABLE 0x02
#define PAL_STIP_DISABLE 0x01
#define INST_DONE 0x2090
#define INST_PS 0x20c4
#define MEMMODE 0x20dc
/* Instruction parser error register. p279
*/
#define IPEIR 0x2088
#define IPEHR 0x208C
/* General error reporting regs, p296
*/
#define EIR 0x20B0
#define EMR 0x20B4
#define ESR 0x20B8
#define IP_ERR 0x0001
#define ERROR_RESERVED 0xffc6
/* Interrupt Control Registers
* - new bits for i810
* - new register hwstam (mask)
*/
#define HWSTAM 0x2098 /* p290 */
#define IER 0x20a0 /* p291 */
#define IIR 0x20a4 /* p292 */
#define IMR 0x20a8 /* p293 */
#define ISR 0x20ac /* p294 */
#define HW_ERROR 0x8000
#define SYNC_STATUS_TOGGLE 0x1000
#define DPY_0_FLIP_PENDING 0x0800
#define DPY_1_FLIP_PENDING 0x0400 /* not implemented on i810 */
#define OVL_0_FLIP_PENDING 0x0200
#define OVL_1_FLIP_PENDING 0x0100 /* not implemented on i810 */
#define DPY_0_VBLANK 0x0080
#define DPY_0_EVENT 0x0040
#define DPY_1_VBLANK 0x0020 /* not implemented on i810 */
#define DPY_1_EVENT 0x0010 /* not implemented on i810 */
#define HOST_PORT_EVENT 0x0008 /* */
#define CAPTURE_EVENT 0x0004 /* */
#define USER_DEFINED 0x0002
#define BREAKPOINT 0x0001
#define INTR_RESERVED (0x6000 | \
DPY_1_FLIP_PENDING | \
OVL_1_FLIP_PENDING | \
DPY_1_VBLANK | \
DPY_1_EVENT | \
HOST_PORT_EVENT | \
CAPTURE_EVENT )
/* FIFO Watermark and Burst Length Control Register
*
* - different offset and contents on i810 (p299) (fewer bits per field)
* - some overlay fields added
* - what does it all mean?
*/
#define FWATER_BLC 0x20d8
#define MM_BURST_LENGTH 0x00700000
#define MM_FIFO_WATERMARK 0x0001F000
#define LM_BURST_LENGTH 0x00000700
#define LM_FIFO_WATERMARK 0x0000001F
/* Fence/Tiling ranges [0..7]
*/
#define FENCE 0x2000
#define FENCE_NR 8
#define FENCE_START_MASK 0x03F80000
#define FENCE_X_MAJOR 0x00000000
#define FENCE_Y_MAJOR 0x00001000
#define FENCE_SIZE_MASK 0x00000700
#define FENCE_SIZE_512K 0x00000000
#define FENCE_SIZE_1M 0x00000100
#define FENCE_SIZE_2M 0x00000200
#define FENCE_SIZE_4M 0x00000300
#define FENCE_SIZE_8M 0x00000400
#define FENCE_SIZE_16M 0x00000500
#define FENCE_SIZE_32M 0x00000600
#define FENCE_PITCH_MASK 0x00000070
#define FENCE_PITCH_1 0x00000000
#define FENCE_PITCH_2 0x00000010
#define FENCE_PITCH_4 0x00000020
#define FENCE_PITCH_8 0x00000030
#define FENCE_PITCH_16 0x00000040
#define FENCE_PITCH_32 0x00000050
#define FENCE_VALID 0x00000001
/* Registers to control page table, p274
*/
#define PGETBL_CTL 0x2020
#define PGETBL_ADDR_MASK 0xFFFFF000
#define PGETBL_ENABLE_MASK 0x00000001
#define PGETBL_ENABLED 0x00000001
/* Register containing pge table error results, p276
*/
#define PGE_ERR 0x2024
#define PGE_ERR_ADDR_MASK 0xFFFFF000
#define PGE_ERR_ID_MASK 0x00000038
#define PGE_ERR_CAPTURE 0x00000000
#define PGE_ERR_OVERLAY 0x00000008
#define PGE_ERR_DISPLAY 0x00000010
#define PGE_ERR_HOST 0x00000018
#define PGE_ERR_RENDER 0x00000020
#define PGE_ERR_BLITTER 0x00000028
#define PGE_ERR_MAPPING 0x00000030
#define PGE_ERR_CMD_PARSER 0x00000038
#define PGE_ERR_TYPE_MASK 0x00000007
#define PGE_ERR_INV_TABLE 0x00000000
#define PGE_ERR_INV_PTE 0x00000001
#define PGE_ERR_MIXED_TYPES 0x00000002
#define PGE_ERR_PAGE_MISS 0x00000003
#define PGE_ERR_ILLEGAL_TRX 0x00000004
#define PGE_ERR_LOCAL_MEM 0x00000005
#define PGE_ERR_TILED 0x00000006
/* Page table entries loaded via mmio region, p323
*/
#define PTE_BASE 0x10000
#define PTE_ADDR_MASK 0x3FFFF000
#define PTE_TYPE_MASK 0x00000006
#define PTE_LOCAL 0x00000002
#define PTE_MAIN_UNCACHED 0x00000000
#define PTE_MAIN_CACHED 0x00000006
#define PTE_VALID_MASK 0x00000001
#define PTE_VALID 0x00000001
/* Ring buffer registers, p277, overview p19
*/
#define LP_RING 0x2030
#define HP_RING 0x2040
#define RING_TAIL 0x00
#define TAIL_ADDR 0x000FFFF8
#define RING_HEAD 0x04
#define HEAD_WRAP_COUNT 0xFFE00000
#define HEAD_WRAP_ONE 0x00200000
#define HEAD_ADDR 0x001FFFFC
#define RING_START 0x08
#define START_ADDR 0x00FFFFF8
#define RING_LEN 0x0C
#define RING_NR_PAGES 0x000FF000
#define RING_REPORT_MASK 0x00000006
#define RING_REPORT_64K 0x00000002
#define RING_REPORT_128K 0x00000004
#define RING_NO_REPORT 0x00000000
#define RING_VALID_MASK 0x00000001
#define RING_VALID 0x00000001
#define RING_INVALID 0x00000000
/* BitBlt Instructions
*
* There are many more masks & ranges yet to add.
*/
#define BR00_BITBLT_CLIENT 0x40000000
#define BR00_OP_COLOR_BLT 0x10000000
#define BR00_OP_SRC_COPY_BLT 0x10C00000
#define BR00_OP_FULL_BLT 0x11400000
#define BR00_OP_MONO_SRC_BLT 0x11800000
#define BR00_OP_MONO_SRC_COPY_BLT 0x11000000
#define BR00_OP_MONO_PAT_BLT 0x11C00000
#define BR00_OP_MONO_SRC_COPY_IMMEDIATE_BLT (0x61 << 22)
#define BR00_OP_TEXT_IMMEDIATE_BLT 0xc000000
#define BR00_TPCY_DISABLE 0x00000000
#define BR00_TPCY_ENABLE 0x00000010
#define BR00_TPCY_ROP 0x00000000
#define BR00_TPCY_NO_ROP 0x00000020
#define BR00_TPCY_EQ 0x00000000
#define BR00_TPCY_NOT_EQ 0x00000040
#define BR00_PAT_MSB_FIRST 0x00000000 /* ? */
#define BR00_PAT_VERT_ALIGN 0x000000e0
#define BR00_LENGTH 0x0000000F
#define BR09_DEST_ADDR 0x03FFFFFF
#define BR11_SOURCE_PITCH 0x00003FFF
#define BR12_SOURCE_ADDR 0x03FFFFFF
#define BR13_SOLID_PATTERN 0x80000000
#define BR13_RIGHT_TO_LEFT 0x40000000
#define BR13_LEFT_TO_RIGHT 0x00000000
#define BR13_MONO_TRANSPCY 0x20000000
#define BR13_USE_DYN_DEPTH 0x04000000
#define BR13_DYN_8BPP 0x00000000
#define BR13_DYN_16BPP 0x01000000
#define BR13_DYN_24BPP 0x02000000
#define BR13_ROP_MASK 0x00FF0000
#define BR13_DEST_PITCH 0x0000FFFF
#define BR13_PITCH_SIGN_BIT 0x00008000
#define BR14_DEST_HEIGHT 0xFFFF0000
#define BR14_DEST_WIDTH 0x0000FFFF
#define BR15_PATTERN_ADDR 0x03FFFFFF
#define BR16_SOLID_PAT_COLOR 0x00FFFFFF
#define BR16_BACKGND_PAT_CLR 0x00FFFFFF
#define BR17_FGND_PAT_CLR 0x00FFFFFF
#define BR18_SRC_BGND_CLR 0x00FFFFFF
#define BR19_SRC_FGND_CLR 0x00FFFFFF
/* Instruction parser instructions
*/
#define INST_PARSER_CLIENT 0x00000000
#define INST_OP_FLUSH 0x02000000
#define INST_FLUSH_MAP_CACHE 0x00000001
#define INST_DEST_BUFFER_INFO 0x06800000
#define INST_FRONT_BUFFER_INFO 0x06000000
#define FRONT_INFO_ASYNC_FLIP 1<<6
#define FRONT_INFO_PITCH_B 8
#define GFX_OP_USER_INTERRUPT ((0<<29)|(2<<23))
/* Registers in the i810 host-pci bridge pci config space which affect
* the i810 graphics operations.
*/
#define SMRAM_MISCC 0x70
#define GMS 0x000000c0
#define GMS_DISABLE 0x00000000
#define GMS_ENABLE_BARE 0x00000040
#define GMS_ENABLE_512K 0x00000080
#define GMS_ENABLE_1M 0x000000c0
#define USMM 0x00000030
#define USMM_DISABLE 0x00000000
#define USMM_TSEG_ZERO 0x00000010
#define USMM_TSEG_512K 0x00000020
#define USMM_TSEG_1M 0x00000030
#define GFX_MEM_WIN_SIZE 0x00010000
#define GFX_MEM_WIN_32M 0x00010000
#define GFX_MEM_WIN_64M 0x00000000
/* Overkill? I don't know. Need to figure out top of mem to make the
* SMRAM calculations come out. Linux seems to have problems
* detecting it all on its own, so this seems a reasonable double
* check to any user supplied 'mem=...' boot param.
*
* ... unfortunately this reg doesn't work according to spec on the
* test hardware.
*/
#define WHTCFG_PAMR_DRP 0x50
#define SYS_DRAM_ROW_0_SHIFT 16
#define SYS_DRAM_ROW_1_SHIFT 20
#define DRAM_MASK 0x0f
#define DRAM_VALUE_0 0
#define DRAM_VALUE_1 8
/* No 2 value defined */
#define DRAM_VALUE_3 16
#define DRAM_VALUE_4 16
#define DRAM_VALUE_5 24
#define DRAM_VALUE_6 32
#define DRAM_VALUE_7 32
#define DRAM_VALUE_8 48
#define DRAM_VALUE_9 64
#define DRAM_VALUE_A 64
#define DRAM_VALUE_B 96
#define DRAM_VALUE_C 128
#define DRAM_VALUE_D 128
#define DRAM_VALUE_E 192
#define DRAM_VALUE_F 256 /* nice one, geezer */
#define LM_FREQ_MASK 0x10
#define LM_FREQ_133 0x10
#define LM_FREQ_100 0x00
/* These are 3d state registers, but the state is invarient, so we let
* the X server handle it:
*/
/* GFXRENDERSTATE_COLOR_CHROMA_KEY, p135
*/
#define GFX_OP_COLOR_CHROMA_KEY ((0x3<<29)|(0x1d<<24)|(0x2<<16)|0x1)
#define CC1_UPDATE_KILL_WRITE (1<<28)
#define CC1_ENABLE_KILL_WRITE (1<<27)
#define CC1_DISABLE_KILL_WRITE 0
#define CC1_UPDATE_COLOR_IDX (1<<26)
#define CC1_UPDATE_CHROMA_LOW (1<<25)
#define CC1_UPDATE_CHROMA_HI (1<<24)
#define CC1_CHROMA_LOW_MASK ((1<<24)-1)
#define CC2_COLOR_IDX_SHIFT 24
#define CC2_COLOR_IDX_MASK (0xff<<24)
#define CC2_CHROMA_HI_MASK ((1<<24)-1)
#define GFX_CMD_CONTEXT_SEL ((0<<29)|(0x5<<23))
#define CS_UPDATE_LOAD (1<<17)
#define CS_UPDATE_USE (1<<16)
#define CS_UPDATE_LOAD (1<<17)
#define CS_LOAD_CTX0 0
#define CS_LOAD_CTX1 (1<<8)
#define CS_USE_CTX0 0
#define CS_USE_CTX1 (1<<0)
/* 3D Rendering Engine */
#define RENDER_CLIENT 0x60000000
/* Primitive rendering instruction */
#define GFX_PRIMITIVE 0x1f000000
#define PRIMITIVE_TRIANGLE 0 << 18
#define PRIMITIVE_TRI_STRIP 1 << 18
#define PRIMITIVE_TRI_REV_STRIP 2 << 18
#define PRIMITIVE_TRI_FAN 3 << 18
#define PRIMITIVE_POLYGON 4 << 18
#define PRIMITIVE_LINE 5 << 18
#define PRIMITIVE_LINE_STRIP 6 << 18
#define PRIMITIVE_RECTANGLE 7 << 18
/* Vertex format instruction */
#define GFX_VERTEX_FORMAT 0x05000000
#define VERTEX_0_TEXCOORDS 0 << 8
#define VERTEX_1_TEXCOORDS 1 << 8
#define VERTEX_2_TEXCOORDS 2 << 8
#define VERTEX_SPECULAR_FOG 1 << 7
#define VERTEX_DIFFUSE_ALPHA 1 << 6
#define VERTEX_Z_OFFSET 1 << 5
#define VERTEX_POS_XYZ 1 << 1
#define VERTEX_POS_XYZ_RHW 2 << 1
#define VERTEX_POS_XY 3 << 1
#define VERTEX_POS_XY_RHW 4 << 1
/* Drawing Rectangle Info instruction */
#define GFX_DRAWING_RECTANGLE_INFO 0x1d800003
#define GFX_DRAWING_CLIP_DISABLE 1<<31
/* Boolean enable 1 */
#define GFX_BOOLEAN_ENA_1 0x03000000
#define BOOL1_ALPHA_SETUP_MASK 1<<17
#define BOOL1_ALPHA_SETUP_BIT 1<<16
#define BOOL1_FOG_ENABLE_MASK 1<<7
#define BOOL1_FOG_ENABLE_BIT 1<<6
#define BOOL1_ALPHA_TEST_MASK 1<<5
#define BOOL1_ALPHA_TEST_BIT 1<<4
#define BOOL1_BLEND_ENABLE_MASK 1<<3
#define BOOL1_BLEND_ENABLE_BIT 1<<2
#define BOOL1_Z_ENABLE_MASK 1<<1
#define BOOL1_Z_ENABLE_BIT 1<<0
/* Boolean enable 2 */
#define GFX_BOOLEAN_ENA_2 0x04000000
#define BOOL2_MAPPING_CACHE_MASK 1<<17
#define BOOL2_MAPPING_CACHE_BIT 1<<16
#define BOOL2_ALPHA_DITHER_MASK 1<<15
#define BOOL2_ALPHA_DITHER_BIT 1<<14
#define BOOL2_FOG_DITHER_MASK 1<<13
#define BOOL2_FOG_DITHER_BIT 1<<12
#define BOOL2_SPECULAR_DITHER_MASK 1<<11
#define BOOL2_SPECULAR_DITHER_BIT 1<<10
#define BOOL2_COLOR_DITHER_MASK 1<<9
#define BOOL2_COLOR_DITHER_BIT 1<<8
#define BOOL2_FB_WRITE_MASK 1<<3
#define BOOL2_FB_WRITE_BIT 1<<2
#define BOOL2_Z_WRITE_MASK 1<<1
#define BOOL2_Z_WRITE_BIT 1<<0
/* Dest buffer variables */
#define GFX_DEST_BUFFER_VARIABLES 0x1d850000
#define DEST_BUF_VAR_8BIT 0 << 8
#define DEST_BUF_VAR_555 1 << 8
#define DEST_BUF_VAR_565 2 << 8
/* map color blend stages */
#define GFX_MAP_COLOR_BLEND_STAGES 0
#define MAP_BLEND_STAGE_B 20
#define MAP_BLEND_ACC_SEL_MASK 1<<19
#define MAP_BLEND_ACC_SEL_BIT 1<<18
#define MAP_BLEND_ARG1_MASK 1<<17
#define MAP_BLEND_ARG1_B 14
#define MAP_BLEND_REPLICATE_ARG1 1<<13
#define MAP_BLEND_INVERT_ARG1 1<<12
#define MAP_BLEND_ARG2_MASK 1<<11
#define MAP_BLEND_ARG2_B 8
#define MAP_BLEND_REPLICATE_ARG2 1<<7
#define MAP_BLEND_INVERT_ARG2 1<<6
#define MAP_BLEND_COLOR_OP_MASK 1<<5
#define MAP_BLEND_COLOR_OP_B 0
#define GFX_SCISSOR_ENABLE 0x1c800000
#define SCISSOR_ENABLE_MASK 1<<1
#define SCISSOR_ENABLE_BIT 1<<0

File diff suppressed because it is too large Load Diff

View File

@ -1,352 +0,0 @@
/* COPYRIGHT AND PERMISSION NOTICE
Copyright (c) 2000, 2001 Nokia Home Communications
All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, and/or sell copies of the Software, and to permit persons
to whom the Software is furnished to do so, provided that the above
copyright notice(s) and this permission notice appear in all copies of
the Software and that both the above copyright notice(s) and this
permission notice appear in supporting documentation.
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
OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR 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.
Except as contained in this notice, the name of a copyright holder
shall not be used in advertising or otherwise to promote the sale, use
or other dealings in this Software without prior written authorization
of the copyright holder.
X Window System is a trademark of The Open Group */
/* Hardware accelerated drawing for KDrive i810 driver.
Author: Pontus Lidman <pontus.lidman@nokia.com>
*/
#ifdef HAVE_CONFIG_H
#include <kdrive-config.h>
#endif
#include "kdrive.h"
#include "kaa.h"
#ifdef XV
#include "kxv.h"
#endif
#include "i810.h"
#include "i810_reg.h"
//#include "Xmd.h"
#include "gcstruct.h"
#include "scrnintstr.h"
#include "pixmapstr.h"
#include "regionstr.h"
#include "mistruct.h"
#include "dixfontstr.h"
#include "fb.h"
#include "migc.h"
#include "miline.h"
#include "picturestr.h"
#define NUM_STACK_RECTS 1024
i810ScreenInfo *accel_i810s;
static int
i810WaitLpRing(i810ScreenInfo *i810s, int n, int timeout_millis)
{
i810CardInfo *i810c = i810s->i810c;
I810RingBuffer *ring = &(i810c->LpRing);
int iters = 0;
int start = 0;
int now = 0;
int last_head = 0;
int first = 0;
/* If your system hasn't moved the head pointer in 2 seconds, I'm going to
* call it crashed.
*/
if (timeout_millis == 0)
timeout_millis = 2000;
if (I810_DEBUG) {
fprintf(stderr, "i810WaitLpRing %d\n", n);
first = GetTimeInMillis();
}
while (ring->space < n)
{
int i;
ring->head = INREG(LP_RING + RING_HEAD) & HEAD_ADDR;
ring->space = ring->head - (ring->tail+8);
if (ring->space < 0)
ring->space += ring->mem.Size;
iters++;
now = GetTimeInMillis();
if ( start == 0 || now < start || ring->head != last_head) {
if (I810_DEBUG)
if (now > start)
fprintf(stderr, "space: %d wanted %d\n", ring->space, n );
start = now;
last_head = ring->head;
} else if ( now - start > timeout_millis ) {
i810PrintErrorState(i810c);
fprintf(stderr, "space: %d wanted %d\n", ring->space, n );
FatalError("lockup\n");
}
for (i = 0 ; i < 2000 ; i++)
;
}
if (I810_DEBUG)
{
now = GetTimeInMillis();
if (now - first) {
fprintf(stderr,"Elapsed %d ms\n", now - first);
fprintf(stderr, "space: %d wanted %d\n", ring->space, n );
}
}
return iters;
}
static void
i810Sync(i810ScreenInfo *i810s)
{
i810CardInfo *i810c = i810s->i810c;
LP_RING_LOCALS;
if (I810_DEBUG)
fprintf(stderr, "i810Sync\n");
/* Send a flush instruction and then wait till the ring is empty.
* This is stronger than waiting for the blitter to finish as it also
* flushes the internal graphics caches.
*/
BEGIN_LP_RING(2);
OUT_RING( INST_PARSER_CLIENT | INST_OP_FLUSH | INST_FLUSH_MAP_CACHE );
OUT_RING( 0 ); /* pad to quadword */
ADVANCE_LP_RING();
i810WaitLpRing(i810s, i810c->LpRing.mem.Size - 8, 0);
i810c->LpRing.space = i810c->LpRing.mem.Size - 8;
i810c->nextColorExpandBuf = 0;
}
static void
i810WaitMarker(ScreenPtr pScreen, int marker)
{
KdScreenPriv(pScreen);
i810ScreenInfo(pScreenPriv);
i810Sync(i810s);
}
#if 0
static void
i810EmitInvarientState(ScreenPtr pScreen)
{
KdScreenPriv(pScreen);
i810CardInfo(pScreenPriv);
i810ScreenInfo(pScreenPriv);
LP_RING_LOCALS;
BEGIN_LP_RING( 10 );
OUT_RING( INST_PARSER_CLIENT | INST_OP_FLUSH | INST_FLUSH_MAP_CACHE );
OUT_RING( GFX_CMD_CONTEXT_SEL | CS_UPDATE_USE | CS_USE_CTX0 );
OUT_RING( INST_PARSER_CLIENT | INST_OP_FLUSH | INST_FLUSH_MAP_CACHE);
OUT_RING( 0 );
OUT_RING( GFX_OP_COLOR_CHROMA_KEY );
OUT_RING( CC1_UPDATE_KILL_WRITE |
CC1_DISABLE_KILL_WRITE |
CC1_UPDATE_COLOR_IDX |
CC1_UPDATE_CHROMA_LOW |
CC1_UPDATE_CHROMA_HI |
0);
OUT_RING( 0 );
OUT_RING( 0 );
/* No depth buffer in KDrive yet */
/* OUT_RING( CMD_OP_Z_BUFFER_INFO ); */
/* OUT_RING( pI810->DepthBuffer.Start | pI810->auxPitchBits); */
ADVANCE_LP_RING();
}
#endif
static unsigned int i810PatternRop[16] = {
0x00, /* GXclear */
0xA0, /* GXand */
0x50, /* GXandReverse */
0xF0, /* GXcopy */
0x0A, /* GXandInvert */
0xAA, /* GXnoop */
0x5A, /* GXxor */
0xFA, /* GXor */
0x05, /* GXnor */
0xA5, /* GXequiv */
0x55, /* GXinvert */
0xF5, /* GXorReverse */
0x0F, /* GXcopyInvert */
0xAF, /* GXorInverted */
0x5F, /* GXnand */
0xFF /* GXset */
};
static Bool
i810PrepareSolid(PixmapPtr pPix, int alu, Pixel pm, Pixel fg)
{
KdScreenPriv(pPix->drawable.pScreen);
i810ScreenInfo(pScreenPriv);
i810CardInfo(pScreenPriv);
if (I810_DEBUG & DEBUG_VERBOSE_ACCEL)
ErrorF( "i810PrepareSolid color: %x rop: %x mask: %x\n",
fg, alu, pm);
/* Color blit, p166 */
i810c->BR[13] = BR13_SOLID_PATTERN |
(i810PatternRop[alu] << 16) |
(pPix->drawable.pScreen->width * i810c->cpp);
i810c->BR[16] = fg;
accel_i810s = i810s;
return TRUE;
}
static void
i810Solid(int x1, int y1, int x2, int y2)
{
I810ScreenInfo *i810s = accel_i810s;
I810CardInfo *i810c = i810s->i810c;
LP_RING_LOCALS;
if (I810_DEBUG & DEBUG_VERBOSE_ACCEL)
ErrorF( "i810SubsequentFillRectSolid %d,%d %d,%d\n", x1, y1, x2, y2);
BEGIN_LP_RING(6);
OUT_RING( BR00_BITBLT_CLIENT | BR00_OP_COLOR_BLT | 0x3 );
OUT_RING( i810c->BR[13] );
OUT_RING( ((y2 - y1) << 16) | ((x2 - x1) * i810c->cpp));
OUT_RING( i810c->bufferOffset + y1 * i810s->pitch + x1 * i810c->cpp );
OUT_RING( i810c->BR[16]);
OUT_RING( 0 ); /* pad to quadword */
ADVANCE_LP_RING();
}
static void
i810DoneSolid(void)
{
}
static Bool
i810PrepareCopy(PixmapPtr pSrc, PixmapPtr pDst, int dx, int dy, int alu, Pixel pm)
{
return FALSE;
}
static void
i810RefreshRing(i810CardInfo *i810c)
{
i810c->LpRing.head = INREG(LP_RING + RING_HEAD) & HEAD_ADDR;
i810c->LpRing.tail = INREG(LP_RING + RING_TAIL);
i810c->LpRing.space = i810c->LpRing.head - (i810c->LpRing.tail+8);
if (i810c->LpRing.space < 0)
i810c->LpRing.space += i810c->LpRing.mem.Size;
}
static void
i810SetRingRegs(i810CardInfo *i810c)
{
unsigned int itemp;
OUTREG(LP_RING + RING_TAIL, 0 );
OUTREG(LP_RING + RING_HEAD, 0 );
itemp = INREG(LP_RING + RING_START);
itemp &= ~(START_ADDR);
itemp |= i810c->LpRing.mem.Start;
OUTREG(LP_RING + RING_START, itemp );
itemp = INREG(LP_RING + RING_LEN);
itemp &= ~(RING_NR_PAGES | RING_REPORT_MASK | RING_VALID_MASK);
itemp |= ((i810c->LpRing.mem.Size-4096) | RING_NO_REPORT | RING_VALID);
OUTREG(LP_RING + RING_LEN, itemp );
}
Bool
i810InitAccel(ScreenPtr pScreen)
{
KdScreenPriv(pScreen);
i810ScreenInfo(pScreenPriv);
i810CardInfo(pScreenPriv);
memset(&i810s->kaa, 0, sizeof(KaaScreenInfoRec));
i810s->kaa.waitMarker = i810WaitMarker;
i810s->kaa.PrepareSolid = i810PrepareSolid;
i810s->kaa.Solid = i810Solid;
i810s->kaa.DoneSolid = i810DoneSolid;
i810s->kaa.PrepareCopy = i810PrepareCopy;
i810s->kaa.Copy = NULL;
i810s->kaa.DoneCopy = NULL;
i810s->pitch = pScreen->width * i810c->cpp;
return FALSE;
}
void
i810EnableAccel(ScreenPtr pScreen)
{
KdScreenPriv(pScreen);
i810CardInfo(pScreenPriv);
if (i810c->LpRing.mem.Size == 0) {
ErrorF("No memory for LpRing!! Acceleration not functional!!\n");
}
i810SetRingRegs(i810c);
kaaMarkSync (pScreen);
}
void
i810DisableAccel(ScreenPtr pScreen)
{
KdScreenPriv(pScreen);
i810CardInfo(pScreenPriv);
i810ScreenInfo(pScreenPriv);
i810RefreshRing(i810c);
i810Sync(i810s);
}
void
i810FiniAccel(ScreenPtr pScreen)
{
}

View File

@ -1,46 +0,0 @@
/* COPYRIGHT AND PERMISSION NOTICE
Copyright (c) 2000, 2001 Nokia Home Communications
All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, and/or sell copies of the Software, and to permit persons
to whom the Software is furnished to do so, provided that the above
copyright notice(s) and this permission notice appear in all copies of
the Software and that both the above copyright notice(s) and this
permission notice appear in supporting documentation.
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
OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR 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.
Except as contained in this notice, the name of a copyright holder
shall not be used in advertising or otherwise to promote the sale, use
or other dealings in this Software without prior written authorization
of the copyright holder.
X Window System is a trademark of The Open Group */
/* Hardware accelerated drawing for KDrive i810 driver, header file.
Author: Pontus Lidman <pontus.lidman@nokia.com>
*/
#ifndef _I810DRAW_H_
#define _I810DRAW_H_
void i810RefreshRing(KdScreenInfo *screen);
int i810WaitLpRing( KdScreenInfo *screen, int n, int timeout_millis );
void i810Sync( KdScreenInfo *screen );
#endif /* _I810DRAW_H_ */

View File

@ -1,92 +0,0 @@
/* COPYRIGHT AND PERMISSION NOTICE
Copyright (c) 2000, 2001 Nokia Home Communications
All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, and/or sell copies of the Software, and to permit persons
to whom the Software is furnished to do so, provided that the above
copyright notice(s) and this permission notice appear in all copies of
the Software and that both the above copyright notice(s) and this
permission notice appear in supporting documentation.
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
OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR 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.
Except as contained in this notice, the name of a copyright holder
shall not be used in advertising or otherwise to promote the sale, use
or other dealings in this Software without prior written authorization
of the copyright holder.
X Window System is a trademark of The Open Group */
/* Stub functions for the i810 KDrive driver
Author: Pontus Lidman <pontus.lidman@nokia.com>
*/
#ifdef HAVE_CONFIG_H
#include <kdrive-config.h>
#endif
#include "kdrive.h"
#include "kxv.h"
#include "i810.h"
#include "klinux.h"
static const int i810Cards[]={
PCI_CHIP_I810,
PCI_CHIP_I810_DC100,
PCI_CHIP_I810_E
};
#define numI810Cards (sizeof(i810Cards) / sizeof(i810Cards[0]))
void
InitCard (char *name)
{
KdCardAttr attr;
int i;
for (i = 0; i < numI810Cards; i++)
if (LinuxFindPci (0x8086, i810Cards[i], 0, &attr))
KdCardInfoAdd (&i810Funcs, &attr, (void *) i810Cards[i]);
}
void
InitOutput (ScreenInfo *pScreenInfo, int argc, char **argv)
{
KdInitOutput (pScreenInfo, argc, argv);
}
void
InitInput (int argc, char **argv)
{
KdOsAddInputDrivers ();
KdInitInput ();
}
void
ddxUseMsg (void)
{
KdUseMsg();
}
int
ddxProcessArgument (int argc, char **argv, int i)
{
int ret;
ret = KdProcessArgument(argc, argv, i);
return ret;
}

View File

@ -1,667 +0,0 @@
/*
* Copyright © 1999 SuSE, Inc.
*
* 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 SuSE not be used in advertising or
* publicity pertaining to distribution of the software without specific,
* written prior permission. SuSE makes no representations about the
* suitability of this software for any purpose. It is provided "as is"
* without express or implied warranty.
*
* SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
* 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.
*
* Author: Keith Packard, SuSE, Inc.
*/
#ifdef HAVE_CONFIG_H
#include <kdrive-config.h>
#endif
#include "igs.h"
Bool
igsCardInit (KdCardInfo *card)
{
int k;
char *pixels;
IgsCardInfo *igsc;
igsc = (IgsCardInfo *) xalloc (sizeof (IgsCardInfo));
if (!igsc)
return FALSE;
memset (igsc, '\0', sizeof (IgsCardInfo));
igsc->frameBuffer = (CARD8 *) KdMapDevice (card->attr.address[0] +
IGS_FB,
IGS_MEM);
igsc->vga = (VOL8 *) KdMapDevice (card->attr.address[0] +
IGS_VGA,
64 * 1024);
igsc->cop = (Cop5xxx *) KdMapDevice (card->attr.address[0] +
IGS_COP_OFFSET,
sizeof (Cop5xxx));
igsc->copData = (VOL32 *) KdMapDevice (card->attr.address[0] +
IGS_COP_DATA,
IGS_COP_DATA_LEN);
igsRegInit (&igsc->igsvga, igsc->vga);
card->driver = igsc;
return TRUE;
}
Bool
igsModeSupported (KdScreenInfo *screen,
const KdMonitorTiming *t)
{
/* make sure the clock isn't too fast */
if (t->clock > IGS_MAX_CLOCK)
return FALSE;
/* width must be a multiple of 16 */
if (t->horizontal & 0xf)
return FALSE;
return TRUE;
}
Bool
igsModeUsable (KdScreenInfo *screen)
{
KdCardInfo *card = screen->card;
int screen_size;
int pixel_width;
int byte_width;
int fb = 0;
screen_size = 0;
if (screen->fb[fb].depth >= 24)
{
screen->fb[fb].depth = 24;
if (screen->fb[fb].bitsPerPixel != 24)
screen->fb[fb].bitsPerPixel = 32;
}
else if (screen->fb[fb].depth >= 16)
{
screen->fb[fb].depth = 16;
screen->fb[fb].bitsPerPixel = 16;
}
else if (screen->fb[fb].depth >= 15)
{
screen->fb[fb].depth = 15;
screen->fb[fb].bitsPerPixel = 16;
}
else if (screen->fb[fb].depth >= 12)
{
screen->fb[fb].depth = 12;
screen->fb[fb].bitsPerPixel = 16;
}
else
{
screen->fb[fb].depth = 8;
screen->fb[fb].bitsPerPixel = 8;
}
byte_width = screen->width * (screen->fb[fb].bitsPerPixel >> 3);
pixel_width = screen->width;
screen->fb[fb].pixelStride = pixel_width;
screen->fb[fb].byteStride = byte_width;
screen_size += byte_width * screen->height;
return TRUE;
}
Bool
igsScreenInit (KdScreenInfo *screen)
{
IgsCardInfo *igsc = screen->card->driver;
int fb = 0;
IgsScreenInfo *igss;
int screen_size, memory;
int pattern_size;
int tile_size;
int stipple_size;
int poffset, boffset;
const KdMonitorTiming *t;
if (!screen->width || !screen->height)
{
screen->width = 800;
screen->height = 600;
screen->rate = 72;
}
if (!screen->fb[0].depth)
screen->fb[0].depth = 8;
t = KdFindMode (screen, igsModeSupported);
screen->rate = t->rate;
screen->width = t->horizontal;
screen->height = t->vertical;
if (!KdTuneMode (screen, igsModeUsable, igsModeSupported))
{
return FALSE;
}
igss = (IgsScreenInfo *) xalloc (sizeof (IgsScreenInfo));
if (!igss)
return FALSE;
memset (igss, '\0', sizeof (IgsScreenInfo));
screen_size = screen->fb[fb].byteStride * screen->height;
memory = IGS_MEM;
memory -= screen_size;
if (memory >= 1024)
{
igss->cursor_offset = memory - 1024;
#if BITMAP_BIT_ORDER == MSBFirst
igss->cursor_base = (CARD8 *) KdMapDevice (card->attr.address[0] +
igss->cursor_offset,
1024);
#else
igss->cursor_base = igsc->frameBuffer + igss->cursor_offset;
#endif
memory -= 1024;
}
else
igss->cursor_base = 0;
tile_size = IgsTileSize(screen->fb[fb].bitsPerPixel) * IGS_NUM_PATTERN;
stipple_size = IgsStippleSize(screen->fb[fb].bitsPerPixel) * IGS_NUM_PATTERN;
pattern_size = tile_size + stipple_size;
if (memory >= pattern_size)
{
boffset = screen_size;
poffset = boffset * 8 / screen->fb[fb].bitsPerPixel;
igss->tile.offset = poffset;
igss->tile.base = igsc->frameBuffer + boffset;
boffset = screen_size + tile_size;
poffset = boffset * 8 / screen->fb[fb].bitsPerPixel;
igss->stipple.offset = poffset;
igss->stipple.base = igsc->frameBuffer + boffset;
memory -= pattern_size;
}
else
{
igss->tile.base = 0;
igss->stipple.base = 0;
}
switch (screen->fb[fb].depth) {
case 8:
screen->fb[fb].visuals = ((1 << StaticGray) |
(1 << GrayScale) |
(1 << StaticColor) |
(1 << PseudoColor) |
(1 << TrueColor) |
(1 << DirectColor));
screen->fb[fb].blueMask = 0x00;
screen->fb[fb].greenMask = 0x00;
screen->fb[fb].redMask = 0x00;
break;
case 15:
screen->fb[fb].visuals = (1 << TrueColor);
screen->fb[fb].blueMask = 0x001f;
screen->fb[fb].greenMask = 0x03e0;
screen->fb[fb].redMask = 0x7c00;
break;
case 16:
screen->fb[fb].visuals = (1 << TrueColor);
screen->fb[fb].blueMask = 0x001f;
screen->fb[fb].greenMask = 0x07e0;
screen->fb[fb].redMask = 0xf800;
break;
case 24:
screen->fb[fb].visuals = (1 << TrueColor);
screen->fb[fb].blueMask = 0x0000ff;
screen->fb[fb].greenMask = 0x00ff00;
screen->fb[fb].redMask = 0xff0000;
break;
}
screen->fb[fb].pixelStride = screen->width;
screen->fb[fb].byteStride = screen->width * (screen->fb[fb].bitsPerPixel >> 3);
screen->fb[fb].frameBuffer = igsc->frameBuffer;
if (!igsc->cop)
screen->dumb = TRUE;
screen->driver = igss;
return TRUE;
}
Bool
igsInitScreen(ScreenPtr pScreen)
{
return TRUE;
}
void
igsPreserve (KdCardInfo *card)
{
IgsCardInfo *igsc = card->driver;
IgsVga *igsvga = &igsc->igsvga;
igsSave (igsvga);
}
void
igsSetBlank (IgsVga *igsvga, Bool blank)
{
igsSetImm(igsvga, igs_screen_off, blank ? 1 : 0);
}
void
igsSetSync (IgsCardInfo *igsc, int hsync, int vsync)
{
IgsVga *igsvga = &igsc->igsvga;
igsSet (igsvga, igs_mexhsyn, hsync);
igsSet (igsvga, igs_mexvsyn, vsync);
VgaFlush (&igsvga->card);
}
/*
* Clock synthesis:
*
* scale = p ? (2 * p) : 1
* f_out = f_ref * ((M + 1) / ((N + 1) * scale))
*
* Constraints:
*
* 1. 115MHz <= f_ref * ((M + 1) / (N + 1)) <= 260 MHz
* 2. N >= 1
*
* Vertical refresh rate = clock / ((hsize + hblank) * (vsize + vblank))
* Horizontal refresh rate = clock / (hsize + hblank)
*/
/* all in kHz */
void
igsGetClock (int target, int *Mp, int *Np, int *Pp, int maxM, int maxN, int maxP, int minVco)
{
int M, N, P, bestM, bestN;
int f_vco, f_out;
int err, abserr, besterr;
/*
* Compute correct P value to keep VCO in range
*/
for (P = 0; P <= maxP; P++)
{
f_vco = target * IGS_SCALE(P);
if (f_vco >= minVco)
break;
}
/* M = f_out / f_ref * ((N + 1) * IGS_SCALE(P)); */
besterr = target;
for (N = 1; N <= maxN; N++)
{
M = ((target * (N + 1) * IGS_SCALE(P) + (IGS_CLOCK_REF/2)) + IGS_CLOCK_REF/2) / IGS_CLOCK_REF - 1;
if (0 <= M && M <= maxM)
{
f_out = IGS_CLOCK(M,N,P);
err = target - f_out;
if (err < 0)
err = -err;
if (err < besterr)
{
besterr = err;
bestM = M;
bestN = N;
}
}
}
*Mp = bestM;
*Np = bestN;
*Pp = P;
}
Bool
igsEnable (ScreenPtr pScreen)
{
KdScreenPriv(pScreen);
KdCardInfo *card = pScreenPriv->card;
KdScreenInfo *screen = pScreenPriv->screen;
IgsCardInfo *igsc = card->driver;
IgsVga *igsvga = &igsc->igsvga;
const KdMonitorTiming *t;
int hactive, hblank, hfp, hbp;
int vactive, vblank, vfp, vbp;
int hsize;
int fb = 0;
int m, n, r;
int h_total;
int h_display_end;
int h_blank_start;
int h_blank_end;
int h_sync_start;
int h_sync_end;
int h_screen_off;
int v_total;
int v_retrace_start;
int v_retrace_end;
int v_display_end;
int v_blank_start;
int v_blank_end;
int offset;
int num_fetch;
int m_m, m_n, m_r;
igsSetBlank (igsvga, TRUE);
t = KdFindMode (screen, igsModeSupported);
igsGetClock (t->clock, &m, &n, &r, 2047, 255, 7, IGS_MIN_VCO);
/*
* Set the chip so that 0x400000 is a big-endian frame buffer
* with the correct byte swapping enabled
*/
igsSet (igsvga, igs_biga22force, 0);
igsSet (igsvga, igs_biga22en, 1);
igsSet (igsvga, igs_biga24en, 1);
/*
* Enable 8-bit DACs
*/
igsSet (igsvga, igs_rampwdn, 0);
igsSet (igsvga, igs_dac6_8, 1);
igsSet (igsvga, igs_dacpwdn, 0);
/*
* Set overscan to black
*/
igsSet (igsvga, igs_overscan_red, 0x00);
igsSet (igsvga, igs_overscan_green, 0x00);
igsSet (igsvga, igs_overscan_blue, 0x00);
/*
* Enable PCI retries
*/
igsSet (igsvga, igs_iow_retry, 1);
igsSet (igsvga, igs_mw_retry, 1);
igsSet (igsvga, igs_mr_retry, 1);
igsSet (igsvga, igs_pci_burst_write, 1);
igsSet (igsvga, igs_pci_burst_read, 1);
/*
* Set FIFO
*/
igsSet (igsvga, igs_memgopg, 1);
igsSet (igsvga, igs_memr2wpg, 0);
igsSet (igsvga, igs_crtff16, 0);
igsSet (igsvga, igs_fifomust, 0xff);
igsSet (igsvga, igs_fifogen, 0xff);
/*
* Enable CRT reg access
*/
igsSetImm (igsvga, igs_ena_vr_access, 1);
igsSetImm (igsvga, igs_crt_protect, 0);
hfp = t->hfp;
hbp = t->hbp;
hblank = t->hblank;
hactive = t->horizontal;
offset = screen->fb[0].byteStride;
vfp = t->vfp;
vbp = t->vbp;
vblank = t->vblank;
vactive = t->vertical;
/*
* Compute character lengths for horizontal timing values
*/
hactive = screen->width / 8;
hblank /= 8;
hfp /= 8;
hbp /= 8;
offset /= 8;
switch (screen->fb[fb].bitsPerPixel) {
case 8:
igsSet (igsvga, igs_overscan_red, pScreen->blackPixel);
igsSet (igsvga, igs_overscan_green, pScreen->blackPixel);
igsSet (igsvga, igs_overscan_blue, pScreen->blackPixel);
igsSet (igsvga, igs_bigswap, IGS_BIGSWAP_8);
igsSet (igsvga, igs_mode_sel, IGS_MODE_8);
igsSet (igsvga, igs_ramdacbypass, 0);
break;
case 16:
igsSet (igsvga, igs_bigswap, IGS_BIGSWAP_16);
igsSet (igsvga, igs_ramdacbypass, 1);
switch (screen->fb[fb].depth) {
case 12:
igsSet (igsvga, igs_mode_sel, IGS_MODE_4444);
break;
case 15:
igsSet (igsvga, igs_mode_sel, IGS_MODE_5551);
break;
case 16:
igsSet (igsvga, igs_mode_sel, IGS_MODE_565);
break;
}
break;
case 24:
igsSet (igsvga, igs_ramdacbypass, 1);
igsSet (igsvga, igs_bigswap, IGS_BIGSWAP_8);
igsSet (igsvga, igs_mode_sel, IGS_MODE_888);
break;
case 32:
igsSet (igsvga, igs_ramdacbypass, 1);
igsSet (igsvga, igs_bigswap, IGS_BIGSWAP_32);
igsSet (igsvga, igs_mode_sel, IGS_MODE_8888);
break;
}
/*
* Compute horizontal register values from timings
*/
h_total = hactive + hblank - 5;
h_display_end = hactive - 1;
h_sync_start = hactive + hfp;
h_sync_end = hactive + hblank - hbp;
/*
* pad the blank values narrow a bit and use the border_select to
* eliminate the remaining border; don't know why, but it doesn't
* work in the documented fashion
*/
h_blank_start = hactive - 1;
h_blank_end = hactive + hblank - 1 - 1;
num_fetch = (t->horizontal * screen->fb[fb].bitsPerPixel / 64) + 1;
v_total = vactive + vblank - 2;
v_display_end = vactive - 1;
v_blank_start = vactive - 1;
v_blank_end = v_blank_start + vblank - 1;
v_retrace_start = vactive + vfp;
v_retrace_end = vactive + vblank - vbp;
#if 0
#define chk(a,b,c) fprintf (stderr, "%20.20s: BIOS %6d X %6d\n", a, igsGet(igsvga, b), c);
chk("h_total", igs_h_total, h_total);
chk("h_display_end", igs_h_de_end, h_display_end);
chk("h_sync_start", igs_h_rstart, h_sync_start);
chk("h_sync_end", igs_h_rend, h_sync_end&0x1f);
chk("h_blank_start", igs_h_bstart, h_blank_start);
chk("h_blank_end", igs_h_bend, h_blank_end&0x3f);
chk("offset", igs_offset, offset);
chk("num_fetch", igs_num_fetch, num_fetch);
chk("v_total", igs_v_total, v_total);
chk("v_display_end", igs_v_de_end, v_display_end);
chk("v_blank_start", igs_v_bstart, v_blank_start);
chk("v_blank_end", igs_v_bend, v_blank_end&0xf);
chk("v_retrace_start", igs_v_rstart, v_retrace_start);
chk("v_retrace_end", igs_v_rend, v_retrace_end&0xf);
chk("vclk_m", igs_vclk_m, m);
chk("vclk_n", igs_vclk_n, n);
chk("vclk_p", igs_vclk_p, r);
fprintf (stderr, "%20.20s: BIOS %6d X %6d\n", "vclk",
IGS_CLOCK(igsGet(igsvga,igs_vclk_m),
igsGet(igsvga,igs_vclk_n),
igsGet(igsvga,igs_vclk_p)),
IGS_CLOCK(m,n,r));
#endif
igsSet (igsvga, igs_h_total, h_total);
igsSet (igsvga, igs_h_de_end, h_display_end);
igsSet (igsvga, igs_h_rstart, h_sync_start);
igsSet (igsvga, igs_h_rend, h_sync_end);
igsSet (igsvga, igs_h_bstart, h_blank_start);
igsSet (igsvga, igs_h_bend, h_blank_end);
igsSet (igsvga, igs_offset, offset);
igsSet (igsvga, igs_num_fetch, num_fetch);
igsSet (igsvga, igs_v_total, v_total);
igsSet (igsvga, igs_v_de_end, v_display_end);
igsSet (igsvga, igs_v_bstart, v_blank_start);
igsSet (igsvga, igs_v_bend, v_blank_end&0xf);
igsSet (igsvga, igs_v_rstart, v_retrace_start);
igsSet (igsvga, igs_v_rend, v_retrace_end&0xf);
igsSet (igsvga, igs_vclk_m, m);
igsSet (igsvga, igs_vclk_n, n);
igsSet (igsvga, igs_vclk_p, r);
igsSet (igsvga, igs_vfsel, IGS_CLOCK(m, n, 0) >= 180000);
VgaFlush (&igsvga->card);
igsSetImm (igsvga, igs_frqlat, 0);
igsSetImm (igsvga, igs_frqlat, 1);
igsSetImm (igsvga, igs_frqlat, 0);
igsSetBlank (igsvga, FALSE);
#if 0
#define dbg(a,b) fprintf(stderr, "%20.20s = 0x%x\n", a, igsGet(igsvga,b))
#include "reg.dbg"
{
VGA16 reg;
char buf[128];
for (reg = 0; reg < IGS_NREG; reg++)
fprintf(stderr, "%20.20s = 0x%02x\n", igsRegName(buf, reg),
VgaFetch (&igsvga->card, reg));
}
#endif
return TRUE;
}
Bool
igsDPMS (ScreenPtr pScreen, int mode)
{
KdScreenPriv(pScreen);
IgsCardInfo *igsc = pScreenPriv->card->driver;
IgsVga *igsvga = &igsc->igsvga;
switch (mode) {
case KD_DPMS_NORMAL:
igsSetSync (igsc, 0, 0);
igsSetBlank (igsvga, FALSE);
break;
case KD_DPMS_STANDBY:
igsSetBlank (igsvga, TRUE);
igsSetSync (igsc, 1, 0);
break;
case KD_DPMS_SUSPEND:
igsSetBlank (igsvga, TRUE);
igsSetSync (igsc, 0, 1);
break;
case KD_DPMS_POWERDOWN:
igsSetBlank (igsvga, TRUE);
igsSetSync (igsc, 1, 1);
break;
}
return TRUE;
}
void
igsDisable (ScreenPtr pScreen)
{
}
void
igsRestore (KdCardInfo *card)
{
IgsCardInfo *igsc = card->driver;
IgsVga *igsvga = &igsc->igsvga;
igsReset (igsvga);
}
void
igsScreenFini (KdScreenInfo *screen)
{
IgsScreenInfo *igss = (IgsScreenInfo *) screen->driver;
#if BITMAP_BIT_ORDER == MSBFirst
if (igss->cursor_base)
KdUnmapDevice ((void *) igss->cursor_base, 1024);
#endif
xfree (igss);
screen->driver = 0;
}
void
igsCardFini (KdCardInfo *card)
{
IgsCardInfo *igsc = card->driver;
if (igsc->copData)
KdUnmapDevice ((void *) igsc->copData, IGS_COP_DATA_LEN);
if (igsc->cop)
KdUnmapDevice ((void *) igsc->cop, sizeof (Cop5xxx));
if (igsc->vga)
KdUnmapDevice ((void *) igsc->vga, 64 * 1024);
if (igsc->frameBuffer)
KdUnmapDevice (igsc->frameBuffer, IGS_MEM);
xfree (igsc);
card->driver = 0;
}
KdCardFuncs igsFuncs = {
igsCardInit, /* cardinit */
igsScreenInit, /* scrinit */
igsInitScreen,
igsPreserve, /* preserve */
igsEnable, /* enable */
igsDPMS, /* dpms */
igsDisable, /* disable */
igsRestore, /* restore */
igsScreenFini, /* scrfini */
igsCardFini, /* cardfini */
igsCursorInit, /* initCursor */
igsCursorEnable, /* enableCursor */
igsCursorDisable, /* disableCursor */
igsCursorFini, /* finiCursor */
0, /* recolorCursor */
igsDrawInit, /* initAccel */
igsDrawEnable, /* enableAccel */
igsDrawSync, /* drawSync */
igsDrawDisable, /* disableAccel */
igsDrawFini, /* finiAccel */
igsGetColors, /* getColors */
igsPutColors, /* putColors */
};

View File

@ -1,327 +0,0 @@
/*
* Copyright © 1999 SuSE, Inc.
*
* 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 SuSE not be used in advertising or
* publicity pertaining to distribution of the software without specific,
* written prior permission. SuSE makes no representations about the
* suitability of this software for any purpose. It is provided "as is"
* without express or implied warranty.
*
* SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
* 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.
*
* Author: Keith Packard, SuSE, Inc.
*/
#ifndef _IGS_H_
#define _IGS_H_
#include "kdrive.h"
#include "igsreg.h"
extern KdCardFuncs igsFuncs;
/*
* FB 0x00000000
* VGA 0x00800000
* Blt window 0x008a0000
* Coprocessor 0x008bf000
*/
#if BITMAP_BIT_ORDER == MSBFirst
#define IGS_FB 0x00400000
#else
#define IGS_FB 0x00000000
#endif
#define IGS_VGA 0x00800000
#define IGS_COP_DATA 0x008a0000
#define IGS_COP_DATA_LEN 0x00010000
#define IGS_COP_OFFSET 0x008bf000
/* give audio 1/2 meg at end */
#if 1
#define IGS_MEM ((4096-512)*1024)
#else
#define IGS_MEM ((4096)*1024)
#endif
#define IGS_CLOCK_REF 24576 /* KHz */
#define IGS_SCALE(p) ((p) ? (2 * (p)) : 1)
#define IGS_CLOCK(m,n,p) ((IGS_CLOCK_REF * ((m) + 1)) / (((n) + 1) * IGS_SCALE(p)))
#define IGS_MAX_CLOCK 260000
#define IGS_MIN_VCO 115000
typedef volatile CARD8 VOL8;
typedef volatile CARD16 VOL16;
typedef volatile CARD32 VOL32;
typedef struct _Cop5xxx {
VOL8 pad000[0x10]; /* 0x000 */
VOL32 control; /* 0x010 */
#define IGS_CONTROL_HBLTW_RDYZ 0x0100
#define IGS_CONTROL_MALLWBEPTZ 0x0200
#define IGS_CONTROL_CMDFF 0x0400
#define IGS_CONTROL_SOP 0x0800
#define IGS_CONTROL_OPS 0x1000
#define IGS_CONTROL_TER 0x2000
#define IGS_CONTROL_HBACKZ 0x4000
#define IGS_CONTROL_BUSY 0x8000
VOL8 pad014[0x04]; /* 0x014 */
VOL32 src1_stride; /* 0x018 */
VOL32 format; /* 0x01c */
#define IGS_FORMAT_8BPP 0
#define IGS_FORMAT_16BPP 1
#define IGS_FORMAT_24BPP 2
#define IGS_FORMAT_32BPP 3
VOL32 bres_error; /* 0x020 */
VOL32 bres_k1; /* 0x024 */
VOL32 bres_k2; /* 0x028 */
VOL8 pad02c[0x1c]; /* 0x02c */
VOL32 mix; /* 0x048 */
#define IGS_MIX_FG 0x00ff
#define IGS_MIX_BG 0xff00
#define IGS_MAKE_MIX(fg,bg) ((fg) | ((bg) << 8))
#define IGS_MIX_ZERO 0x0
#define IGS_MIX_SRC_AND_DST 0x1
#define IGS_MIX_SRC_AND_NOT_DST 0x2
#define IGS_MIX_SRC 0x3
#define IGS_MIX_NOT_SRC_AND_DST 0x4
#define IGS_MIX_DST 0x5
#define IGS_MIX_SRC_XOR_DST 0x6
#define IGS_MIX_SRC_OR_DST 0x7
#define IGS_MIX_NOT_SRC_AND_NOT_DST 0x8
#define IGS_MIX_SRC_XOR_NOT_DST 0x9
#define IGS_MIX_NOT_DST 0xa
#define IGS_MIX_SRC_OR_NOT_DST 0xb
#define IGS_MIX_NOT_SRC 0xc
#define IGS_MIX_NOT_SRC_OR_DST 0xd
#define IGS_MIX_NOT_SRC_OR_NOT_DST 0xe
#define IGS_MIX_ONE 0xf
VOL32 colorComp; /* 0x04c */
VOL32 planemask; /* 0x050 */
VOL8 pad054[0x4]; /* 0x054 */
VOL32 fg; /* 0x058 */
VOL32 bg; /* 0x05c */
VOL32 dim; /* 0x060 */
#define IGS_MAKE_DIM(w,h) ((w) | ((h) << 16))
VOL8 pad5[0x0c]; /* 0x064 */
VOL32 src1_base_address; /* 0x070 */
VOL8 pad074[0x04]; /* 0x074 */
VOL32 rotate; /* 0x078 */
#define IGS_MAKE_ROTATE(x,y) ((x) | ((y) << 16))
VOL32 operation; /* 0x07c */
/* OCT[2:0] */
#define IGS_DRAW_X_MAJOR 0x00000000
#define IGS_DRAW_Y_MAJOR 0x00000001
#define IGS_DRAW_T_B 0x00000000
#define IGS_DRAW_B_T 0x00000002
#define IGS_DRAW_L_R 0x00000000
#define IGS_DRAW_R_L 0x00000004
/* Draw_Mode[1:0] */
#define IGS_DRAW_ALL 0x00000000
#define IGS_DRAW_NOT_FIRST 0x00000010
#define IGS_DRAW_NOT_LAST 0x00000020
#define IGS_DRAW_NOT_FIRST_LAST 0x00000030
/* TRPS[1:0] */
#define IGS_TRANS_SRC1 0x00000000
#define IGS_TRANS_SRC2 0x00000100
#define IGS_TRANS_DST 0x00000200
/* TRPS2 Transparent Invert */
#define IGS_TRANS_INVERT 0x00000400
/* TRPS3, Transparent Enable */
#define IGS_TRANS_ENABLE 0x00000800
/* PPS[3:0], Pattern Pixel Select */
#define IGS_PIXEL_TEXT_OPAQUE 0x00001000
#define IGS_PIXEL_STIP_OPAQUE 0x00002000
#define IGS_PIXEL_LINE_OPAQUE 0x00003000
#define IGS_PIXEL_TEXT_TRANS 0x00005000
#define IGS_PIXEL_STIP_TRANS 0x00006000
#define IGS_PIXEL_LINE_TRANS 0x00007000
#define IGS_PIXEL_FG 0x00008000
#define IGS_PIXEL_TILE 0x00009000
#define IGS_PIXEL_TILE_OPAQUE 0x0000d000
/* HostBltEnable[1:0] */
#define IGS_HBLT_DISABLE 0x00000000
#define IGS_HBLT_READ 0x00010000
#define IGS_HBLT_WRITE_1 0x00020000
#define IGS_HBLT_WRITE_2 0x00030000
/* Src2MapSelect[2:0], Src2 map select mode */
#define IGS_SRC2_NORMAL 0x00000000
#define IGS_SRC2_MONO_OPAQUE 0x00100000
#define IGS_SRC2_FG 0x00200000
#define IGS_SRC2_MONO_TRANS 0x00500000
/* StepFunction[3:0], Step function select */
#define IGS_STEP_DRAW_AND_STEP 0x04000000
#define IGS_STEP_LINE_DRAW 0x05000000
#define IGS_STEP_PXBLT 0x08000000
#define IGS_STEP_INVERT_PXBLT 0x09000000
#define IGS_STEP_TERNARY_PXBLT 0x0b000000
/* FGS */
#define IGS_FGS_FG 0x00000000
#define IGS_FGS_SRC 0x20000000
/* BGS */
#define IGS_BGS_BG 0x00000000
#define IGS_BGS_SRC 0x80000000
VOL8 pad080[0x90]; /* 0x080 */
VOL32 debug_control; /* 0x110 */
VOL8 pad114[0x04]; /* 0x114 */
VOL32 src2_stride; /* 0x118 */
VOL8 pad11c[0x14]; /* 0x11c */
VOL32 extension; /* 0x130 */
#define IGS_BURST_ENABLE 0x01
#define IGS_STYLE_LINE 0x02
#define IGS_ADDITIONAL_WAIT 0x04
#define IGS_BLOCK_COP_REG 0x08
#define IGS_TURBO_MONO 0x10
#define IGS_SELECT_SAMPLE 0x40
#define IGS_MDSBL_RD_B_WR 0x80
#define IGS_WRMRSTZ 0x100
#define IGS_TEST_MTST 0x200
VOL32 style_line; /* 0x134 */
#define IGS_MAKE_STILE_LINE(roll_over,inc,pattern,accumulator) \
((roll_over) | \
((style_line_inc) << 8) | \
((style_line_patern) << 16) | \
((style_line_accumullator) << 24))
VOL32 style_line_pattern_index; /* 0x138 */
VOL32 mono_burst_total; /* 0x13c */
VOL8 pad140[0x10]; /* 0x140 */
VOL32 pat_x_rotate; /* 0x150 */
VOL8 pad154[0x1c]; /* 0x154 */
VOL32 src1_start; /* 0x170 */
VOL32 src2_start; /* 0x174 */
VOL32 dst_start; /* 0x178 */
VOL8 pad17c[0x9c]; /* 0x17c */
VOL32 dst_stride; /* 0x218 */
} Cop5xxx;
typedef struct _igsCardInfo {
Cop5xxx *cop;
VOL8 *vga;
VOL32 *copData;
CARD8 *frameBuffer;
IgsVga igsvga;
} IgsCardInfo;
#define getIgsCardInfo(kd) ((IgsCardInfo *) ((kd)->card->driver))
#define igsCardInfo(kd) IgsCardInfo *igsc = getIgsCardInfo(kd)
typedef struct _igsCursor {
int width, height;
int xhot, yhot;
Bool has_cursor;
CursorPtr pCursor;
Pixel source, mask;
} IgsCursor;
#define IGS_CURSOR_WIDTH 64
#define IGS_CURSOR_HEIGHT 64
typedef struct _igsPattern {
INT32 xrot, yrot;
CARD32 serial_number;
CARD8 *base;
CARD32 offset;
} IgsPattern;
#define IGS_NUM_PATTERN 8
#define IGS_PATTERN_WIDTH 8
#define IGS_PATTERN_HEIGHT 8
typedef struct _igsPatternCache {
CARD8 *base;
CARD32 offset;
IgsPattern pattern[IGS_NUM_PATTERN];
int next;
} IgsPatternCache;
typedef struct _igsScreenInfo {
CARD8 *cursor_base;
CARD32 cursor_offset;
IgsCursor cursor;
IgsPatternCache tile;
IgsPatternCache stipple;
} IgsScreenInfo;
#define IgsTileSize(bpp) (IGS_PATTERN_WIDTH*(bpp)/8*IGS_PATTERN_HEIGHT)
#define IgsStippleSize(bpp) (IGS_PATTERN_WIDTH/8*IGS_PATTERN_HEIGHT)
#define getIgsScreenInfo(kd) ((IgsScreenInfo *) ((kd)->screen->driver))
#define igsScreenInfo(kd) IgsScreenInfo *igss = getIgsScreenInfo(kd)
Bool
igsDrawInit (ScreenPtr pScreen);
void
igsDrawEnable (ScreenPtr pScreen);
void
igsDrawDisable (ScreenPtr pScreen);
void
igsDrawSync (ScreenPtr pScreen);
void
igsDrawFini (ScreenPtr pScreen);
void
igsGetColors (ScreenPtr pScreen, int fb, int ndef, xColorItem *pdefs);
void
igsPutColors (ScreenPtr pScreen, int fb, int ndef, xColorItem *pdefs);
Bool
igsCursorInit (ScreenPtr pScreen);
void
igsCursorEnable (ScreenPtr pScreen);
void
igsCursorDisable (ScreenPtr pScreen);
void
igsCursorFini (ScreenPtr pScreen);
#endif /* _IGS_H_ */

View File

@ -1,62 +0,0 @@
/*
* Copyright © 2000 Keith Packard
*
* 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 Keith Packard not be used in
* advertising or publicity pertaining to distribution of the software without
* specific, written prior permission. Keith Packard makes no
* representations about the suitability of this software for any purpose. It
* is provided "as is" without express or implied warranty.
*
* KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL KEITH PACKARD 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.
*/
#ifdef HAVE_CONFIG_H
#include <kdrive-config.h>
#endif
#include "igs.h"
#define IGS_DAC_SHIFT 8
void
igsGetColors (ScreenPtr pScreen, int fb, int ndef, xColorItem *pdefs)
{
KdScreenPriv(pScreen);
igsCardInfo(pScreenPriv);
IgsVga *igsvga = &igsc->igsvga;
while (ndef--)
{
igsSetImm (igsvga, igs_dac_read_index, pdefs->pixel);
pdefs->red = igsGetImm (igsvga, igs_dac_data) << IGS_DAC_SHIFT;
pdefs->green = igsGetImm (igsvga, igs_dac_data) << IGS_DAC_SHIFT;
pdefs->blue = igsGetImm (igsvga, igs_dac_data) << IGS_DAC_SHIFT;
pdefs++;
}
}
void
igsPutColors (ScreenPtr pScreen, int fb, int ndef, xColorItem *pdefs)
{
KdScreenPriv(pScreen);
igsCardInfo(pScreenPriv);
IgsVga *igsvga = &igsc->igsvga;
while (ndef--)
{
igsSetImm (igsvga, igs_dac_write_index, pdefs->pixel);
igsSetImm (igsvga, igs_dac_data, pdefs->red >> IGS_DAC_SHIFT);
igsSetImm (igsvga, igs_dac_data, pdefs->green >> IGS_DAC_SHIFT);
igsSetImm (igsvga, igs_dac_data, pdefs->blue >> IGS_DAC_SHIFT);
pdefs++;
}
}

View File

@ -1,345 +0,0 @@
/*
* Copyright © 2000 Keith Packard
*
* 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 Keith Packard not be used in
* advertising or publicity pertaining to distribution of the software without
* specific, written prior permission. Keith Packard makes no
* representations about the suitability of this software for any purpose. It
* is provided "as is" without express or implied warranty.
*
* KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL KEITH PACKARD 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.
*/
#ifdef HAVE_CONFIG_H
#include <kdrive-config.h>
#endif
#include "igs.h"
#include "cursorstr.h"
#define SetupCursor(s) KdScreenPriv(s); \
igsCardInfo(pScreenPriv); \
igsScreenInfo(pScreenPriv); \
IgsCursor *pCurPriv = &igss->cursor; \
IgsVga *igsvga = &igsc->igsvga
static void
_igsMoveCursor (ScreenPtr pScreen, int x, int y)
{
SetupCursor(pScreen);
CARD8 xoff, yoff;
x -= pCurPriv->xhot;
xoff = 0;
if (x < 0)
{
xoff = -x;
x = 0;
}
y -= pCurPriv->yhot;
yoff = 0;
if (y < 0)
{
yoff = -y;
y = 0;
}
igsSet (igsvga, igs_sprite_x, x);
igsSet (igsvga, igs_sprite_preset_x, xoff);
igsSet (igsvga, igs_sprite_y, y);
igsSet (igsvga, igs_sprite_preset_y, yoff);
}
static void
igsMoveCursor (ScreenPtr pScreen, int x, int y)
{
SetupCursor (pScreen);
if (!pCurPriv->has_cursor)
return;
if (!pScreenPriv->enabled)
return;
_igsMoveCursor (pScreen, x, y);
VgaFlush (&igsvga->card);
}
static void
igsSetCursorColors (ScreenPtr pScreen)
{
SetupCursor (pScreen);
CursorPtr pCursor = pCurPriv->pCursor;
igsSetImm (igsvga, igs_cursor_write_index, 0);
igsSetImm (igsvga, igs_cursor_data, pCursor->backRed >> 8);
igsSetImm (igsvga, igs_cursor_data, pCursor->backGreen >> 8);
igsSetImm (igsvga, igs_cursor_data, pCursor->backBlue >> 8);
igsSetImm (igsvga, igs_cursor_write_index, 1);
igsSetImm (igsvga, igs_cursor_data, pCursor->foreRed >> 8);
igsSetImm (igsvga, igs_cursor_data, pCursor->foreGreen >> 8);
igsSetImm (igsvga, igs_cursor_data, pCursor->foreBlue >> 8);
}
#if BITMAP_BIT_ORDER == MSBFirst
#define IgsAdjustCursor(v) { \
v = ((v & 0x55555555) << 1) | ((v >> 1) & 0x55555555); \
v = ((v & 0x33333333) << 2) | ((v >> 2) & 0x33333333); \
v = ((v & 0x0f0f0f0f) << 4) | ((v >> 4) & 0x0f0f0f0f); \
v = ((v & 0x00ff00ff) << 8) | ((v >> 8) & 0x00ff00ff); \
v = ((v & 0x0000ffff) <<16) | ((v >>16) & 0x0000ffff); \
}
#else
#define IgsAdjustCursor(v)
#endif
#define ExplodeBits2(v) (((v) & 1) | (((v) & 2) << 1))
#define ExplodeBits4(v) ((ExplodeBits2((v) >> 2) << 4) | \
(ExplodeBits2((v) & 0x3)))
#define ExplodeBits8(v) ((ExplodeBits4((v) >> 4) << 8) | \
(ExplodeBits4((v) & 0xf)))
#define ExplodeBits16(v) ((ExplodeBits8((v) >> 8) << 16) | \
(ExplodeBits8((v) & 0xff)))
static void
igsLoadCursor (ScreenPtr pScreen, int x, int y)
{
SetupCursor(pScreen);
CursorPtr pCursor = pCurPriv->pCursor;
CursorBitsPtr bits = pCursor->bits;
int w, h;
CARD32 *ram, *msk, *mskLine, *src, *srcLine;
int i, j;
int cursor_address;
int lwsrc;
unsigned char ramdac_control_;
CARD32 offset;
CARD32 b0, b1;
pCurPriv->pCursor = pCursor;
pCurPriv->xhot = pCursor->bits->xhot;
pCurPriv->yhot = pCursor->bits->yhot;
/*
* Stick new image into cursor memory
*/
ram = (CARD32 *) igss->cursor_base;
mskLine = (CARD32 *) bits->mask;
srcLine = (CARD32 *) bits->source;
h = bits->height;
if (h > IGS_CURSOR_HEIGHT)
h = IGS_CURSOR_HEIGHT;
lwsrc = BitmapBytePad(bits->width) / 4; /* words per line */
for (i = 0; i < IGS_CURSOR_HEIGHT; i++) {
msk = mskLine;
src = srcLine;
mskLine += lwsrc;
srcLine += lwsrc;
for (j = 0; j < IGS_CURSOR_WIDTH / 32; j++) {
CARD32 m, s;
if (i < h && j < lwsrc)
{
m = *msk++;
s = *src++;
IgsAdjustCursor(m);
IgsAdjustCursor(s);
}
else
{
m = 0;
s = 0;
}
s &= m;
m = ~m;
b0 = ExplodeBits16(s&0xffff) | (ExplodeBits16(m&0xffff)<<1);
b1 = ExplodeBits16(s>>16) | (ExplodeBits16(m>>16)<<1);
*ram++ = b0;
*ram++ = b1;
}
}
/* Set new color */
igsSetCursorColors (pScreen);
/* Set address for cursor bits */
offset = igss->cursor_offset;
offset >>= 10;
igsSet (igsvga, igs_sprite_addr, offset);
/* Assume TV interpolation off */
igsSet (igsvga, igs_hcshf, 3);
/* Enable the cursor */
igsSet (igsvga, igs_sprite_visible, 1);
igsSet (igsvga, igs_sprite_64x64, 1);
/* Move to new position */
_igsMoveCursor (pScreen, x, y);
VgaFlush (&igsvga->card);
}
static void
igsUnloadCursor (ScreenPtr pScreen)
{
SetupCursor (pScreen);
/* Disable cursor */
igsSet (igsvga, igs_sprite_visible, 0);
VgaFlush (&igsvga->card);
}
static Bool
igsRealizeCursor (ScreenPtr pScreen, CursorPtr pCursor)
{
SetupCursor(pScreen);
if (!pScreenPriv->enabled)
return TRUE;
/* miRecolorCursor does this */
if (pCurPriv->pCursor == pCursor)
{
if (pCursor)
{
int x, y;
miPointerPosition (&x, &y);
igsLoadCursor (pScreen, x, y);
}
}
return TRUE;
}
static Bool
igsUnrealizeCursor (ScreenPtr pScreen, CursorPtr pCursor)
{
return TRUE;
}
static void
igsSetCursor (ScreenPtr pScreen, CursorPtr pCursor, int x, int y)
{
SetupCursor(pScreen);
pCurPriv->pCursor = pCursor;
if (!pScreenPriv->enabled)
return;
if (pCursor)
igsLoadCursor (pScreen, x, y);
else
igsUnloadCursor (pScreen);
}
miPointerSpriteFuncRec igsPointerSpriteFuncs = {
igsRealizeCursor,
igsUnrealizeCursor,
igsSetCursor,
igsMoveCursor,
};
static void
igsQueryBestSize (int class,
unsigned short *pwidth, unsigned short *pheight,
ScreenPtr pScreen)
{
SetupCursor (pScreen);
switch (class)
{
case CursorShape:
if (*pwidth > pCurPriv->width)
*pwidth = pCurPriv->width;
if (*pheight > pCurPriv->height)
*pheight = pCurPriv->height;
if (*pwidth > pScreen->width)
*pwidth = pScreen->width;
if (*pheight > pScreen->height)
*pheight = pScreen->height;
break;
default:
fbQueryBestSize (class, pwidth, pheight, pScreen);
break;
}
}
Bool
igsCursorInit (ScreenPtr pScreen)
{
SetupCursor (pScreen);
if (!igss->cursor_base)
{
pCurPriv->has_cursor = FALSE;
return FALSE;
}
pCurPriv->width = IGS_CURSOR_WIDTH;
pCurPriv->height= IGS_CURSOR_HEIGHT;
pScreen->QueryBestSize = igsQueryBestSize;
miPointerInitialize (pScreen,
&igsPointerSpriteFuncs,
&kdPointerScreenFuncs,
FALSE);
pCurPriv->has_cursor = TRUE;
pCurPriv->pCursor = NULL;
return TRUE;
}
void
igsCursorEnable (ScreenPtr pScreen)
{
SetupCursor (pScreen);
if (pCurPriv->has_cursor)
{
if (pCurPriv->pCursor)
{
int x, y;
miPointerPosition (&x, &y);
igsLoadCursor (pScreen, x, y);
}
else
igsUnloadCursor (pScreen);
}
}
void
igsCursorDisable (ScreenPtr pScreen)
{
SetupCursor (pScreen);
if (!pScreenPriv->enabled)
return;
if (pCurPriv->has_cursor)
{
if (pCurPriv->pCursor)
{
igsUnloadCursor (pScreen);
}
}
}
void
igsCursorFini (ScreenPtr pScreen)
{
SetupCursor (pScreen);
pCurPriv->pCursor = NULL;
}

File diff suppressed because it is too large Load Diff

View File

@ -1,258 +0,0 @@
/*
* Copyright © 2000 Keith Packard
*
* 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 Keith Packard not be used in
* advertising or publicity pertaining to distribution of the software without
* specific, written prior permission. Keith Packard makes no
* representations about the suitability of this software for any purpose. It
* is provided "as is" without express or implied warranty.
*
* KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL KEITH PACKARD 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.
*/
#ifndef _IGSDRAW_H_
#define _IGSDRAW_H_
extern CARD8 igsPatRop[];
#define SetupIgs(s) KdScreenPriv(s); \
igsCardInfo(pScreenPriv); \
Cop5xxx *cop = igsc->cop; \
int cop_stride = pScreenPriv->screen->fb[0].pixelStride
#define _igsWaitLoop(cop,mask,value) { \
int __loop = 1000000; \
while (((cop)->control & (mask)) != (value)) { \
if (--__loop <= 0) { \
FatalError("Warning: igsWaitLoop 0x%x 0x%x failed\n", mask, value); \
} \
} \
}
#define _igsWaitDone(cop) _igsWaitLoop(cop, \
(IGS_CONTROL_BUSY| \
IGS_CONTROL_MALLWBEPTZ), \
0)
#if 1
#define _igsWaitFull(cop) _igsWaitLoop(cop, \
IGS_CONTROL_CMDFF, \
0)
#else
#define _igsWaitFull(cop) _igsWaitDone(cop)
#endif
#define _igsWaitIdleEmpty(cop) _igsWaitDone(cop)
#define _igsWaitHostBltAck(cop) _igsWaitLoop(cop, \
(IGS_CONTROL_HBACKZ| \
IGS_CONTROL_CMDFF), \
0)
#define _igsReset(cop) ((cop)->control = 0)
#define IgsInvertBits32(v) { \
v = ((v & 0x55555555) << 1) | ((v >> 1) & 0x55555555); \
v = ((v & 0x33333333) << 2) | ((v >> 2) & 0x33333333); \
v = ((v & 0x0f0f0f0f) << 4) | ((v >> 4) & 0x0f0f0f0f); \
}
#define IgsInvertBits16(v) { \
v = ((v & 0x5555) << 1) | ((v >> 1) & 0x5555); \
v = ((v & 0x3333) << 2) | ((v >> 2) & 0x3333); \
v = ((v & 0x0f0f) << 4) | ((v >> 4) & 0x0f0f); \
}
#define IgsInvertBits8(v) { \
v = ((v & 0x55) << 1) | ((v >> 1) & 0x55); \
v = ((v & 0x33) << 2) | ((v >> 2) & 0x33); \
v = ((v & 0x0f) << 4) | ((v >> 4) & 0x0f); \
}
#define IgsByteSwap32(x) ((x) = (((x) >> 24) | \
(((x) >> 8) & 0xff00) | \
(((x) << 8) & 0xff0000) | \
((x) << 24)))
#define IgsByteSwap16(x) ((x) = ((x) << 8) | ((x) >> 8))
#define igsPatternDimOk(d) ((d) <= IGS_PATTERN_WIDTH && (((d) & ((d) - 1)) == 0))
#if BITMAP_BIT_ORDER == LSBFirst
#define IgsAdjustBits32(b) IgsInvertBits32(b)
#define IgsAdjustBits16(x) IgsInvertBits16(x)
#else
#define IgsAdjustBits32(x) IgsByteSwap32(x)
#define IgsAdjustBits16(x) IgsByteSwap16(x)
#endif
#define _igsSetSolidRect(cop,alu,pm,pix,cmd) {\
_igsWaitFull(cop); \
(cop)->mix = IGS_MAKE_MIX(alu,alu); \
(cop)->fg = (pix); \
(cmd) = (IGS_DRAW_T_B | \
IGS_DRAW_L_R | \
IGS_DRAW_ALL | \
IGS_PIXEL_FG | \
IGS_HBLT_DISABLE | \
IGS_SRC2_NORMAL | \
IGS_STEP_PXBLT | \
IGS_FGS_FG | \
IGS_BGS_BG); \
}
#define _igsSetTiledRect(cop,alu,pm,base,cmd) {\
_igsWaitFull(cop); \
(cop)->mix = IGS_MAKE_MIX(alu,alu); \
(cop)->src1_stride = IGS_PATTERN_WIDTH - 1; \
(cop)->src1_start = (base); \
(cmd) = (IGS_DRAW_T_B | \
IGS_DRAW_L_R | \
IGS_DRAW_ALL | \
IGS_PIXEL_TILE | \
IGS_HBLT_DISABLE | \
IGS_SRC2_NORMAL | \
IGS_STEP_PXBLT | \
IGS_FGS_SRC | \
IGS_BGS_BG); \
}
#define _igsSetStippledRect(cop,alu,pm,pix,base,cmd) {\
_igsWaitFull(cop); \
(cop)->mix = IGS_MAKE_MIX(alu,alu); \
(cop)->src1_start = (base); \
(cop)->fg = (pix); \
(cmd) = (IGS_DRAW_T_B | \
IGS_DRAW_L_R | \
IGS_DRAW_ALL | \
IGS_PIXEL_STIP_TRANS | \
IGS_HBLT_DISABLE | \
IGS_SRC2_NORMAL | \
IGS_STEP_PXBLT | \
IGS_FGS_FG | \
IGS_BGS_BG); \
}
#define _igsSetOpaqueStippledRect(cop,alu,pm,_fg,_bg,base,cmd) {\
_igsWaitFull(cop); \
(cop)->mix = IGS_MAKE_MIX(alu,alu); \
(cop)->src1_start = (base); \
(cop)->fg = (_fg); \
(cop)->bg = (_bg); \
(cmd) = (IGS_DRAW_T_B | \
IGS_DRAW_L_R | \
IGS_DRAW_ALL | \
IGS_PIXEL_STIP_OPAQUE | \
IGS_HBLT_DISABLE | \
IGS_SRC2_NORMAL | \
IGS_STEP_PXBLT | \
IGS_FGS_FG | \
IGS_BGS_BG); \
}
#define _igsRect(cop,x,y,w,h,cmd) { \
_igsWaitFull(cop); \
(cop)->dst_start = (x) + (y) * (cop_stride); \
(cop)->dim = IGS_MAKE_DIM(w-1,h-1); \
(cop)->operation = (cmd); \
}
#define _igsPatRect(cop,x,y,w,h,cmd) { \
_igsWaitFull(cop); \
(cop)->dst_start = (x) + (y) * (cop_stride); \
(cop)->rotate = IGS_MAKE_ROTATE(x&7,y&7); \
(cop)->dim = IGS_MAKE_DIM(w-1,h-1); \
(cop)->operation = (cmd); \
}
#define _igsSetBlt(cop,alu,pm,backwards,upsidedown,cmd) { \
_igsWaitFull(cop); \
(cop)->mix = IGS_MAKE_MIX(alu,alu); \
(cop)->src1_stride = cop_stride - 1; \
(cmd) = (IGS_DRAW_ALL | \
IGS_PIXEL_FG | \
IGS_HBLT_DISABLE | \
IGS_SRC2_NORMAL | \
IGS_STEP_PXBLT | \
IGS_FGS_SRC | \
IGS_BGS_BG); \
if (backwards) (cmd) |= IGS_DRAW_R_L; \
if (upsidedown) (cmd) |= IGS_DRAW_B_T; \
}
#if 0
#define _igsPreparePlaneBlt(cop) { \
_igsReset(cop); \
(cop)->dst_stride = cop_stride - 1; \
(cop)->src1_stride = cop_stride - 1; \
(cop)->src2_stride = cop_stride - 1; \
(cop)->format = IGS_FORMAT_16BPP; \
(cop)->src1_start = 0; \
(cop)->src2_start = 0; \
}
#else
#define _igsPreparePlaneBlt(cop)
#endif
#define _igsSetTransparentPlaneBlt(cop,alu,pm,fg_pix,cmd) { \
_igsWaitIdleEmpty(cop); \
_igsPreparePlaneBlt(cop); \
(cop)->mix = IGS_MAKE_MIX(igsPatRop[alu],igsPatRop[alu]); \
(cop)->fg = (fg_pix); \
(cmd) = (IGS_DRAW_T_B | \
IGS_DRAW_L_R | \
IGS_DRAW_ALL | \
IGS_PIXEL_FG | \
IGS_HBLT_WRITE_2 | \
IGS_SRC2_MONO_TRANS | \
IGS_STEP_TERNARY_PXBLT | \
IGS_FGS_FG | \
IGS_BGS_BG); \
}
#define _igsSetOpaquePlaneBlt(cop,alu,pm,fg_pix,bg_pix,cmd) { \
_igsWaitIdleEmpty(cop); \
_igsPreparePlaneBlt(cop); \
(cop)->mix = IGS_MAKE_MIX(igsPatRop[alu],igsPatRop[alu]); \
(cop)->fg = (fg_pix); \
(cop)->bg = (bg_pix); \
(cmd) = (IGS_DRAW_T_B | \
IGS_DRAW_L_R | \
IGS_DRAW_ALL | \
IGS_PIXEL_FG | \
IGS_HBLT_WRITE_2 | \
IGS_SRC2_MONO_OPAQUE | \
IGS_STEP_TERNARY_PXBLT | \
IGS_FGS_FG | \
IGS_BGS_BG); \
}
#define _igsPlaneBlt(cop,x,y,w,h,cmd) { \
/* _igsWaitFull(cop); */ \
(cop)->dst_start = (x) + (y) * (cop_stride); \
(cop)->dim = IGS_MAKE_DIM((w)-1,(h)-1); \
(cop)->operation = (cmd); \
/* _igsWaitHostBltAck(cop); */ \
}
#define _igsBlt(cop,sx,sy,dx,dy,w,h,cmd) { \
_igsWaitFull(cop); \
(cop)->dst_start = (dx) + (dy) * cop_stride; \
(cop)->src1_start = (sx) + (sy) * cop_stride; \
(cop)->src1_stride = cop_stride - 1; \
(cop)->dim = IGS_MAKE_DIM(w-1,h-1); \
(cop)->operation = (cmd); \
}
#define sourceInvarient(alu) (((alu) & 3) == (((alu) >> 2) & 3))
#endif

View File

@ -1,969 +0,0 @@
/*
* Copyright © 2000 Keith Packard
*
* 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 Keith Packard not be used in
* advertising or publicity pertaining to distribution of the software without
* specific, written prior permission. Keith Packard makes no
* representations about the suitability of this software for any purpose. It
* is provided "as is" without express or implied warranty.
*
* KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL KEITH PACKARD 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.
*/
#ifdef HAVE_CONFIG_H
#include <kdrive-config.h>
#endif
#include "igsreg.h"
#include <stdio.h>
#define CR00 IGS_CR+0x00
#define CR01 IGS_CR+0x01
#define CR02 IGS_CR+0x02
#define CR03 IGS_CR+0x03
#define CR04 IGS_CR+0x04
#define CR05 IGS_CR+0x05
#define CR06 IGS_CR+0x06
#define CR07 IGS_CR+0x07
#define CR08 IGS_CR+0x08
#define CR09 IGS_CR+0x09
#define CR0A IGS_CR+0x0A
#define CR0B IGS_CR+0x0B
#define CR0C IGS_CR+0x0C
#define CR0D IGS_CR+0x0D
#define CR0E IGS_CR+0x0E
#define CR0F IGS_CR+0x0F
#define CR10 IGS_CR+0x10
#define CR11 IGS_CR+0x11
#define CR12 IGS_CR+0x12
#define CR13 IGS_CR+0x13
#define CR14 IGS_CR+0x14
#define CR15 IGS_CR+0x15
#define CR16 IGS_CR+0x16
#define CR17 IGS_CR+0x17
#define CR18 IGS_CR+0x18
#define CR19 IGS_CR+0x19
#define CR1A IGS_CR+0x1A
#define CR1B IGS_CR+0x1B
#define CR1C IGS_CR+0x1C
#define CR1D IGS_CR+0x1D
#define CR1E IGS_CR+0x1E
#define CR1F IGS_CR+0x1F
#define CR20 IGS_CR+0x20
#define CR21 IGS_CR+0x21
#define CR22 IGS_CR+0x22
#define CR23 IGS_CR+0x23
#define CR24 IGS_CR+0x24
#define CR25 IGS_CR+0x25
#define CR26 IGS_CR+0x26
#define CR27 IGS_CR+0x27
#define CR28 IGS_CR+0x28
#define CR29 IGS_CR+0x29
#define CR2A IGS_CR+0x2A
#define CR2B IGS_CR+0x2B
#define CR2C IGS_CR+0x2C
#define CR2D IGS_CR+0x2D
#define CR2E IGS_CR+0x2E
#define CR2F IGS_CR+0x2F
#define CR30 IGS_CR+0x30
#define CR31 IGS_CR+0x31
#define CR32 IGS_CR+0x32
#define CR33 IGS_CR+0x33
#define CR34 IGS_CR+0x34
#define CR35 IGS_CR+0x35
#define CR36 IGS_CR+0x36
#define CR37 IGS_CR+0x37
#define CR38 IGS_CR+0x38
#define CR39 IGS_CR+0x39
#define CR3A IGS_CR+0x3A
#define CR3B IGS_CR+0x3B
#define CR3C IGS_CR+0x3C
#define CR3D IGS_CR+0x3D
#define CR3E IGS_CR+0x3E
#define CR3F IGS_CR+0x3F
#define CR40 IGS_CR+0x40
#define CR41 IGS_CR+0x41
#define CR42 IGS_CR+0x42
#define CR43 IGS_CR+0x43
#define CR44 IGS_CR+0x44
#define CR45 IGS_CR+0x45
#define CR46 IGS_CR+0x46
#define CR47 IGS_CR+0x47
#define CR48 IGS_CR+0x48
#define CR_FIRST CR00
#define CR_LAST CR48
#define SR00 IGS_SR+0x00
#define SR01 IGS_SR+0x01
#define SR02 IGS_SR+0x02
#define SR03 IGS_SR+0x03
#define SR04 IGS_SR+0x04
#define SR_FIRST SR00
#define SR_LAST SR04
#define AR00 IGS_AR+0x00
#define AR01 IGS_AR+0x01
#define AR02 IGS_AR+0x02
#define AR03 IGS_AR+0x03
#define AR04 IGS_AR+0x04
#define AR05 IGS_AR+0x05
#define AR06 IGS_AR+0x06
#define AR07 IGS_AR+0x07
#define AR08 IGS_AR+0x08
#define AR09 IGS_AR+0x09
#define AR0A IGS_AR+0x0A
#define AR0B IGS_AR+0x0B
#define AR0C IGS_AR+0x0C
#define AR0D IGS_AR+0x0D
#define AR0E IGS_AR+0x0E
#define AR0F IGS_AR+0x0F
#define AR10 IGS_AR+0x10
#define AR11 IGS_AR+0x11
#define AR12 IGS_AR+0x12
#define AR13 IGS_AR+0x13
#define AR14 IGS_AR+0x14
#define AR_FIRST AR00
#define AR_LAST AR14
#define GR00 IGS_GR+0x00
#define GR01 IGS_GR+0x01
#define GR02 IGS_GR+0x02
#define GR03 IGS_GR+0x03
#define GR04 IGS_GR+0x04
#define GR05 IGS_GR+0x05
#define GR06 IGS_GR+0x06
#define GR07 IGS_GR+0x07
#define GR08 IGS_GR+0x08
#define GR09 IGS_GR+0x09
#define GR0A IGS_GR+0x0A
#define GR0B IGS_GR+0x0B
#define GR0C IGS_GR+0x0C
#define GR0D IGS_GR+0x0D
#define GR0E IGS_GR+0x0E
#define GR0F IGS_GR+0x0F
#define GR10 IGS_GR+0x10
#define GR11 IGS_GR+0x11
#define GR12 IGS_GR+0x12
#define GR13 IGS_GR+0x13
#define GR14 IGS_GR+0x14
#define GR15 IGS_GR+0x15
#define GR16 IGS_GR+0x16
#define GR17 IGS_GR+0x17
#define GR18 IGS_GR+0x18
#define GR19 IGS_GR+0x19
#define GR1A IGS_GR+0x1A
#define GR1B IGS_GR+0x1B
#define GR1C IGS_GR+0x1C
#define GR1D IGS_GR+0x1D
#define GR1E IGS_GR+0x1E
#define GR1F IGS_GR+0x1F
#define GR20 IGS_GR+0x20
#define GR21 IGS_GR+0x21
#define GR22 IGS_GR+0x22
#define GR23 IGS_GR+0x23
#define GR24 IGS_GR+0x24
#define GR25 IGS_GR+0x25
#define GR26 IGS_GR+0x26
#define GR27 IGS_GR+0x27
#define GR28 IGS_GR+0x28
#define GR29 IGS_GR+0x29
#define GR2A IGS_GR+0x2A
#define GR2B IGS_GR+0x2B
#define GR2C IGS_GR+0x2C
#define GR2D IGS_GR+0x2D
#define GR2E IGS_GR+0x2E
#define GR2F IGS_GR+0x2F
#define GR30 IGS_GR+0x30
#define GR31 IGS_GR+0x31
#define GR32 IGS_GR+0x32
#define GR33 IGS_GR+0x33
#define GR34 IGS_GR+0x34
#define GR35 IGS_GR+0x35
#define GR36 IGS_GR+0x36
#define GR37 IGS_GR+0x37
#define GR38 IGS_GR+0x38
#define GR39 IGS_GR+0x39
#define GR3A IGS_GR+0x3A
#define GR3B IGS_GR+0x3B
#define GR3C IGS_GR+0x3C
#define GR3D IGS_GR+0x3D
#define GR3E IGS_GR+0x3E
#define GR3F IGS_GR+0x3F
#define GR40 IGS_GR+0x40
#define GR41 IGS_GR+0x41
#define GR42 IGS_GR+0x42
#define GR43 IGS_GR+0x43
#define GR44 IGS_GR+0x44
#define GR45 IGS_GR+0x45
#define GR46 IGS_GR+0x46
#define GR47 IGS_GR+0x47
#define GR48 IGS_GR+0x48
#define GR49 IGS_GR+0x49
#define GR4A IGS_GR+0x4A
#define GR4B IGS_GR+0x4B
#define GR4C IGS_GR+0x4C
#define GR4D IGS_GR+0x4D
#define GR4E IGS_GR+0x4E
#define GR4F IGS_GR+0x4F
#define GR50 IGS_GR+0x50
#define GR51 IGS_GR+0x51
#define GR52 IGS_GR+0x52
#define GR53 IGS_GR+0x53
#define GR54 IGS_GR+0x54
#define GR55 IGS_GR+0x55
#define GR56 IGS_GR+0x56
#define GR57 IGS_GR+0x57
#define GR58 IGS_GR+0x58
#define GR59 IGS_GR+0x59
#define GR5A IGS_GR+0x5A
#define GR5B IGS_GR+0x5B
#define GR5C IGS_GR+0x5C
#define GR5D IGS_GR+0x5D
#define GR5E IGS_GR+0x5E
#define GR5F IGS_GR+0x5F
#define GR60 IGS_GR+0x60
#define GR61 IGS_GR+0x61
#define GR62 IGS_GR+0x62
#define GR63 IGS_GR+0x63
#define GR64 IGS_GR+0x64
#define GR65 IGS_GR+0x65
#define GR66 IGS_GR+0x66
#define GR67 IGS_GR+0x67
#define GR68 IGS_GR+0x68
#define GR69 IGS_GR+0x69
#define GR6A IGS_GR+0x6A
#define GR6B IGS_GR+0x6B
#define GR6C IGS_GR+0x6C
#define GR6D IGS_GR+0x6D
#define GR6E IGS_GR+0x6E
#define GR6F IGS_GR+0x6F
#define GR70 IGS_GR+0x70
#define GR71 IGS_GR+0x71
#define GR72 IGS_GR+0x72
#define GR73 IGS_GR+0x73
#define GR74 IGS_GR+0x74
#define GR75 IGS_GR+0x75
#define GR76 IGS_GR+0x76
#define GR77 IGS_GR+0x77
#define GR78 IGS_GR+0x78
#define GR79 IGS_GR+0x79
#define GR7A IGS_GR+0x7A
#define GR7B IGS_GR+0x7B
#define GR7C IGS_GR+0x7C
#define GR7D IGS_GR+0x7D
#define GR7E IGS_GR+0x7E
#define GR7F IGS_GR+0x7F
#define GR80 IGS_GR+0x80
#define GR81 IGS_GR+0x81
#define GR82 IGS_GR+0x82
#define GR83 IGS_GR+0x83
#define GR84 IGS_GR+0x84
#define GR85 IGS_GR+0x85
#define GR86 IGS_GR+0x86
#define GR87 IGS_GR+0x87
#define GR88 IGS_GR+0x88
#define GR89 IGS_GR+0x89
#define GR8A IGS_GR+0x8A
#define GR8B IGS_GR+0x8B
#define GR8C IGS_GR+0x8C
#define GR8D IGS_GR+0x8D
#define GR8E IGS_GR+0x8E
#define GR8F IGS_GR+0x8F
#define GR90 IGS_GR+0x90
#define GR91 IGS_GR+0x91
#define GR92 IGS_GR+0x92
#define GR93 IGS_GR+0x93
#define GR94 IGS_GR+0x94
#define GR95 IGS_GR+0x95
#define GR96 IGS_GR+0x96
#define GR97 IGS_GR+0x97
#define GR98 IGS_GR+0x98
#define GR99 IGS_GR+0x99
#define GR9A IGS_GR+0x9A
#define GR9B IGS_GR+0x9B
#define GR9C IGS_GR+0x9C
#define GR9D IGS_GR+0x9D
#define GR9E IGS_GR+0x9E
#define GR9F IGS_GR+0x9F
#define GRA0 IGS_GR+0xA0
#define GRA1 IGS_GR+0xA1
#define GRA2 IGS_GR+0xA2
#define GRA3 IGS_GR+0xA3
#define GRA4 IGS_GR+0xA4
#define GRA5 IGS_GR+0xA5
#define GRA6 IGS_GR+0xA6
#define GRA7 IGS_GR+0xA7
#define GRA8 IGS_GR+0xA8
#define GRA9 IGS_GR+0xA9
#define GRAA IGS_GR+0xAA
#define GRAB IGS_GR+0xAB
#define GRAC IGS_GR+0xAC
#define GRAD IGS_GR+0xAD
#define GRAE IGS_GR+0xAE
#define GRAF IGS_GR+0xAF
#define GRB0 IGS_GR+0xB0
#define GRB1 IGS_GR+0xB1
#define GRB2 IGS_GR+0xB2
#define GRB3 IGS_GR+0xB3
#define GRB4 IGS_GR+0xB4
#define GRB5 IGS_GR+0xB5
#define GRB6 IGS_GR+0xB6
#define GRB7 IGS_GR+0xB7
#define GRB8 IGS_GR+0xB8
#define GRB9 IGS_GR+0xB9
#define GRBA IGS_GR+0xBA
#define GRBB IGS_GR+0xBB
#define GRBC IGS_GR+0xBC
#define GRBD IGS_GR+0xBD
#define GRBE IGS_GR+0xBE
#define GRBF IGS_GR+0xBF
#define GR_FIRST GR00
#define GR_LAST GRBF
#define GREX3C IGS_GREX+(0x3c-IGS_GREXBASE)
VgaReg igs_h_total[] = {
CR00, 0, 8,
VGA_REG_END
};
VgaReg igs_h_de_end[] = {
CR01, 0, 8,
VGA_REG_END
};
VgaReg igs_h_bstart[] = {
CR02, 0, 8,
VGA_REG_END
};
VgaReg igs_h_bend[] = {
CR03, 0, 5,
CR05, 7, 1,
VGA_REG_END
};
VgaReg igs_de_skew[] = {
CR03, 5, 2,
VGA_REG_END
};
VgaReg igs_ena_vr_access[] = {
CR03, 7, 1,
VGA_REG_END
};
VgaReg igs_h_rstart[] = {
CR04, 0, 8,
VGA_REG_END
};
VgaReg igs_h_rend[] = {
CR05, 0, 5,
VGA_REG_END
};
VgaReg igs_h_rdelay[] = {
CR05, 5, 2,
VGA_REG_END
};
VgaReg igs_v_total[] = {
CR06, 0, 8,
CR07, 0, 1,
CR07, 5, 1,
GR11, 0, 1,
VGA_REG_END
};
VgaReg igs_v_rstart[] = {
CR10, 0, 8,
CR07, 2, 1,
CR07, 7, 1,
GR11, 2, 1,
VGA_REG_END
};
VgaReg igs_v_rend[] = {
CR11, 0, 4,
VGA_REG_END
};
VgaReg igs_clear_v_int[] = {
CR11, 4, 1,
VGA_REG_END
};
VgaReg igs_disable_v_int[] = {
CR11, 5, 1,
VGA_REG_END
};
VgaReg igs_bandwidth[] = {
CR11, 6, 1,
VGA_REG_END
};
VgaReg igs_crt_protect[] = {
CR11, 7, 1,
VGA_REG_END
};
VgaReg igs_v_de_end[] = {
CR12, 0, 8,
CR07, 1, 1,
CR07, 6, 1,
GR11, 1, 1,
VGA_REG_END
};
VgaReg igs_offset[] = {
CR13, 0, 8,
GR15, 4, 2,
VGA_REG_END
};
VgaReg igs_v_bstart[] = {
CR15, 0, 8,
CR07, 3, 1,
CR09, 5, 1,
GR11, 3, 1,
VGA_REG_END
};
VgaReg igs_v_bend[] = {
CR16, 0, 7,
VGA_REG_END
};
VgaReg igs_linecomp[] = {
CR18, 0, 8,
CR07, 4, 1,
CR09, 6, 1,
GR11, 4, 1,
VGA_REG_END
};
VgaReg igs_ivideo[] = {
GR11, 5, 1,
VGA_REG_END
};
VgaReg igs_num_fetch[] = {
GR14, 0, 8,
GR15, 0, 2,
VGA_REG_END
};
VgaReg igs_wcrt0[] = {
CR1F, 0, 1,
VGA_REG_END
};
VgaReg igs_wcrt1[] = {
CR1F, 1, 1,
VGA_REG_END
};
VgaReg igs_rcrts1[] = {
CR1F, 4, 1,
VGA_REG_END
};
VgaReg igs_selwk[] = {
CR1F, 6, 1,
VGA_REG_END
};
VgaReg igs_dot_clock_8[] = {
SR01, 0, 1,
VGA_REG_END
};
VgaReg igs_screen_off[] = {
SR01, 5, 1,
VGA_REG_END
};
VgaReg igs_enable_write_plane[] = {
SR02, 0, 4,
VGA_REG_END
};
VgaReg igs_mexhsyn[] = {
GR16, 0, 2,
VGA_REG_END
};
VgaReg igs_mexvsyn[] = {
GR16, 2, 2,
VGA_REG_END
};
VgaReg igs_pci_burst_write[] = {
GR30, 5, 1,
VGA_REG_END
};
VgaReg igs_pci_burst_read[] = {
GR30, 7, 1,
VGA_REG_END
};
VgaReg igs_iow_retry[] = {
GREX3C, 0, 1,
VGA_REG_END
};
VgaReg igs_mw_retry[] = {
GREX3C, 1, 1,
VGA_REG_END
};
VgaReg igs_mr_retry[] = {
GREX3C, 2, 1,
VGA_REG_END
};
VgaReg igs_biga22en[] = {
GR3D, 4, 1,
VGA_REG_END
};
VgaReg igs_biga24en[] = {
GR3D, 5, 1,
VGA_REG_END
};
VgaReg igs_biga22force[] = {
GR3D, 6, 1,
VGA_REG_END
};
VgaReg igs_bigswap[] = {
GR3F, 0, 6,
VGA_REG_END
};
/* #define IGS_BIGSWAP_8 0x3f */
/* #define IGS_BIGSWAP_16 0x2a */
/* #define IGS_BIGSWAP_32 0x00 */
VgaReg igs_sprite_x[] = {
GR50, 0, 8,
GR51, 0, 3,
VGA_REG_END
};
VgaReg igs_sprite_preset_x[] = {
GR52, 0, 6,
VGA_REG_END
};
VgaReg igs_sprite_y[] = {
GR53, 0, 8,
GR54, 0, 3,
VGA_REG_END
};
VgaReg igs_sprite_preset_y[] = {
GR55, 0, 6,
VGA_REG_END
};
VgaReg igs_sprite_visible[] = {
GR56, 0, 1,
VGA_REG_END
};
VgaReg igs_sprite_64x64[] = {
GR56, 1, 1,
VGA_REG_END
};
VgaReg igs_mgrext[] = {
GR57, 0, 1,
VGA_REG_END
};
VgaReg igs_hcshf[] = {
GR57, 4, 2,
VGA_REG_END
};
VgaReg igs_mbpfix[] = {
GR57, 6, 2,
VGA_REG_END
};
VgaReg igs_overscan_red[] = {
GR58, 0, 8,
VGA_REG_END
};
VgaReg igs_overscan_green[] = {
GR59, 0, 8,
VGA_REG_END
};
VgaReg igs_overscan_blue[] = {
GR5A, 0, 8,
VGA_REG_END
};
VgaReg igs_memgopg[] = {
GR73, 2, 1,
VGA_REG_END
};
VgaReg igs_memr2wpg[] = {
GR73, 1, 1,
VGA_REG_END
};
VgaReg igs_crtff16[] = {
GR73, 3, 1,
VGA_REG_END
};
VgaReg igs_fifomust[] = {
GR74, 0, 5,
VGA_REG_END
};
VgaReg igs_fifogen[] = {
GR75, 0, 5,
VGA_REG_END
};
VgaReg igs_mode_sel[] = {
GR77, 0, 4,
VGA_REG_END
};
/* #define IGS_MODE_TEXT 0 */
/* #define IGS_MODE_8 1 */
/* #define IGS_MODE_565 2 */
/* #define IGS_MODE_5551 6 */
/* #define IGS_MODE_8888 3 */
/* #define IGS_MODE_888 4 */
/* #define IGS_MODE_332 9 */
/* #define IGS_MODE_4444 10 */
VgaReg igs_sprite_addr[] = {
GR7E, 0, 8,
GR7F, 0, 4,
VGA_REG_END
};
VgaReg igs_fastmpie[] = {
GR9E, 0, 1,
VGA_REG_END
};
VgaReg igs_vclk_m[] = {
GRB0, 0, 8,
GRBA, 0, 3,
VGA_REG_END
};
VgaReg igs_vclk_n[] = {
GRB1, 0, 5,
GRBA, 3, 3,
VGA_REG_END
};
VgaReg igs_vfsel[] = {
GRB1, 5, 1,
VGA_REG_END
};
VgaReg igs_vclk_p[] = {
GRB1, 6, 2,
GRBA, 6, 1,
VGA_REG_END
};
VgaReg igs_frqlat[] = {
GRB9, 7, 1,
VGA_REG_END
};
VgaReg igs_dac_mask[] = {
IGS_DAC + 0, 0, 8,
VGA_REG_END
};
VgaReg igs_dac_read_index[] = {
IGS_DAC + 1, 0, 8,
VGA_REG_END
};
VgaReg igs_dac_write_index[] = {
IGS_DAC + 2, 0, 8,
VGA_REG_END
};
VgaReg igs_dac_data[] = {
IGS_DAC + 3, 0, 8,
VGA_REG_END
};
VgaReg igs_rampwdn[] = {
IGS_DACEX + 0, 0, 1,
VGA_REG_END
};
VgaReg igs_dac6_8[] = {
IGS_DACEX + 0, 1, 1,
VGA_REG_END
};
VgaReg igs_ramdacbypass[] = {
IGS_DACEX + 0, 4, 1,
VGA_REG_END
};
VgaReg igs_dacpwdn[] = {
IGS_DACEX + 0, 6, 1,
VGA_REG_END
};
VgaReg igs_cursor_read_index[] = {
IGS_DACEX + 1, 0, 8,
VGA_REG_END
};
VgaReg igs_cursor_write_index[] = {
IGS_DACEX + 2, 0, 8,
VGA_REG_END
};
VgaReg igs_cursor_data[] = {
IGS_DACEX + 3, 0, 8,
VGA_REG_END
};
VGA8
_igsInb (VgaCard *card, VGA16 port)
{
VGAVOL8 *reg;
if (card->closure)
return VgaReadMemb ((VGA32) card->closure + port);
else
return VgaInb (port);
}
void
_igsOutb (VgaCard *card, VGA8 value, VGA16 port)
{
if (card->closure)
VgaWriteMemb (value, (VGA32) card->closure + port);
else
VgaOutb (value, port);
}
void
_igsRegMap (VgaCard *card, VGA16 reg, VgaMap *map, VGABOOL write)
{
if (reg < IGS_SR + IGS_NSR)
{
map->access = VgaAccessIndIo;
map->port = 0x3c4;
map->addr = 0;
map->value = 1;
map->index = reg - IGS_SR;
}
else if (reg < IGS_GR + IGS_NGR)
{
map->access = VgaAccessIndIo;
map->port = 0x3ce;
map->addr = 0;
map->value = 1;
map->index = reg - IGS_GR;
}
else if (reg < IGS_GREX + IGS_NGREX)
{
VGA8 gr33;
map->access = VgaAccessDone;
_igsOutb (card, 0x33, 0x3ce);
gr33 = _igsInb (card, 0x3cf);
_igsOutb (card, gr33 | 0x40, 0x3cf);
_igsOutb (card, IGS_GREXBASE + reg - IGS_GREX, 0x3ce);
if (write)
_igsOutb (card, map->value, 0x3cf);
else
map->value = _igsInb (card, 0x3cf);
_igsOutb (card, 0x33, 0x3ce);
_igsOutb (card, gr33, 0x3cf);
return;
}
else if (reg < IGS_AR + IGS_NAR)
{
reg -= IGS_AR;
map->access = VgaAccessDone;
/* reset AFF to index */
(void) _igsInb (card, 0x3da);
if (reg >= 16)
reg |= 0x20;
_igsOutb (card, reg, 0x3c0);
if (write)
_igsOutb (card, map->value, 0x3c0);
else
map->value = _igsInb (card, 0x3c1);
if (!(reg & 0x20))
{
/* enable video display again */
(void) _igsInb (card, 0x3da);
_igsOutb (card, 0x20, 0x3c0);
}
return;
}
else if (reg < IGS_CR + IGS_NCR)
{
map->access = VgaAccessIndIo;
map->port = 0x3d4;
map->addr = 0;
map->value = 1;
map->index = reg - IGS_CR;
}
else if (reg < IGS_DAC + IGS_NDAC)
{
map->access = VgaAccessIo;
map->port = 0x3c6 + reg - IGS_DAC;
}
else if (reg < IGS_DACEX + IGS_NDACEX)
{
VGA8 gr56;
reg = 0x3c6 + reg - IGS_DACEX;
map->access = VgaAccessDone;
_igsOutb (card, 0x56, 0x3ce);
gr56 = _igsInb (card, 0x3cf);
_igsOutb (card, gr56 | 4, 0x3cf);
if (write)
_igsOutb (card, map->value, reg);
else
map->value = _igsInb (card, reg);
_igsOutb (card, gr56, 0x3cf);
return;
}
else switch (reg) {
case IGS_MISC_OUT:
map->access = VgaAccessIo;
if (write)
map->port = 0x3c2;
else
map->port = 0x3cc;
break;
case IGS_INPUT_STATUS_1:
map->access = VgaAccessIo;
map->port = 0x3da;
break;
}
if (card->closure)
{
map->port = map->port + (VGA32) card->closure;
if (map->access == VgaAccessIo)
map->access = VgaAccessMem;
if (map->access == VgaAccessIndIo)
map->access = VgaAccessIndMem;
}
}
VgaSave igsSaves[] = {
CR00, CR18,
SR01, SR02,
GR11, GRBA,
IGS_MISC_OUT, IGS_MISC_OUT,
VGA_SAVE_END
};
void
igsRegInit (IgsVga *igsvga, VGAVOL8 *mmio)
{
igsvga->card.map = _igsRegMap;
igsvga->card.closure = (void *) mmio;
igsvga->card.max = IGS_NREG;
igsvga->card.values = igsvga->values;
igsvga->card.saves = igsSaves;
}
void
igsSave (IgsVga *igsvga)
{
igsSetImm (igsvga, igs_wcrt0, 1);
igsSetImm (igsvga, igs_wcrt1, 1);
igsSetImm (igsvga, igs_rcrts1, 1);
igsSetImm (igsvga, igs_selwk, 1);
VgaPreserve (&igsvga->card);
}
void
igsReset (IgsVga *igsvga)
{
VgaRestore (&igsvga->card);
igsSetImm (igsvga, igs_frqlat, 0);
igsSetImm (igsvga, igs_frqlat, 1);
igsSetImm (igsvga, igs_frqlat, 0);
VgaFinish (&igsvga->card);
}
char *
igsRegName(char *buf, VGA16 reg)
{
if (reg < IGS_SR + IGS_NSR)
{
sprintf (buf, " SR%02X", reg - IGS_SR);
}
else if (reg < IGS_GR + IGS_NGR)
{
sprintf (buf, " GR%02X", reg - IGS_GR);
}
else if (reg < IGS_GREX + IGS_NGREX)
{
sprintf (buf, " GRX%02X", reg - IGS_GREX + IGS_GREXBASE);
}
else if (reg < IGS_AR + IGS_NAR)
{
sprintf (buf, " AR%02X", reg - IGS_AR);
}
else if (reg < IGS_CR + IGS_NCR)
{
sprintf (buf, " CR%02X", reg - IGS_CR);
}
else if (reg < IGS_DAC + IGS_NDAC)
{
sprintf (buf, " DAC%02X", reg - IGS_DAC);
}
else if (reg < IGS_DACEX + IGS_NDACEX)
{
sprintf (buf, "DACX%02X", reg - IGS_DACEX);
}
else switch (reg) {
case IGS_MISC_OUT:
sprintf (buf, "MISC_O");
break;
case IGS_INPUT_STATUS_1:
sprintf (buf, "IN_S_1");
break;
}
return buf;
}

View File

@ -1,155 +0,0 @@
/*
* Copyright © 2000 Keith Packard
*
* 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 Keith Packard not be used in
* advertising or publicity pertaining to distribution of the software without
* specific, written prior permission. Keith Packard makes no
* representations about the suitability of this software for any purpose. It
* is provided "as is" without express or implied warranty.
*
* KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL KEITH PACKARD 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.
*/
#ifndef _IGSREG_H_
#define _IGSREG_H_
#include "vga.h"
#define IGS_SR 0
#define IGS_NSR 5
#define IGS_GR (IGS_SR+IGS_NSR)
#define IGS_NGR 0xC0
#define IGS_GREX (IGS_GR+IGS_NGR)
#define IGS_GREXBASE 0x3c
#define IGS_NGREX 1
#define IGS_AR (IGS_GREX+IGS_NGREX)
#define IGS_NAR 0x15
#define IGS_CR (IGS_AR+IGS_NAR)
#define IGS_NCR 0x48
#define IGS_DAC (IGS_CR+IGS_NCR)
#define IGS_NDAC 4
#define IGS_DACEX (IGS_DAC+IGS_NDAC)
#define IGS_NDACEX 4
#define IGS_MISC_OUT (IGS_DACEX + IGS_NDACEX)
#define IGS_INPUT_STATUS_1 (IGS_MISC_OUT+1)
#define IGS_NREG (IGS_INPUT_STATUS_1+1)
extern VgaReg igs_h_total[];
extern VgaReg igs_h_de_end[];
extern VgaReg igs_h_bstart[];
extern VgaReg igs_h_bend[];
extern VgaReg igs_de_skew[];
extern VgaReg igs_ena_vr_access[];
extern VgaReg igs_h_rstart[];
extern VgaReg igs_h_rend[];
extern VgaReg igs_h_rdelay[];
extern VgaReg igs_v_total[];
extern VgaReg igs_v_rstart[];
extern VgaReg igs_v_rend[];
extern VgaReg igs_clear_v_int[];
extern VgaReg igs_disable_v_int[];
extern VgaReg igs_bandwidth[];
extern VgaReg igs_crt_protect[];
extern VgaReg igs_v_de_end[];
extern VgaReg igs_offset[];
extern VgaReg igs_v_bstart[];
extern VgaReg igs_v_bend[];
extern VgaReg igs_linecomp[];
extern VgaReg igs_ivideo[];
extern VgaReg igs_num_fetch[];
extern VgaReg igs_wcrt0[];
extern VgaReg igs_wcrt1[];
extern VgaReg igs_rcrts1[];
extern VgaReg igs_selwk[];
extern VgaReg igs_dot_clock_8[];
extern VgaReg igs_screen_off[];
extern VgaReg igs_enable_write_plane[];
extern VgaReg igs_mexhsyn[];
extern VgaReg igs_mexvsyn[];
extern VgaReg igs_pci_burst_write[];
extern VgaReg igs_pci_burst_read[];
extern VgaReg igs_iow_retry[];
extern VgaReg igs_mw_retry[];
extern VgaReg igs_mr_retry[];
extern VgaReg igs_biga22en[];
extern VgaReg igs_biga24en[];
extern VgaReg igs_biga22force[];
extern VgaReg igs_bigswap[];
#define IGS_BIGSWAP_8 0x3f
#define IGS_BIGSWAP_16 0x2a
#define IGS_BIGSWAP_32 0x00
extern VgaReg igs_sprite_x[];
extern VgaReg igs_sprite_preset_x[];
extern VgaReg igs_sprite_y[];
extern VgaReg igs_sprite_preset_y[];
extern VgaReg igs_sprite_visible[];
extern VgaReg igs_sprite_64x64[];
extern VgaReg igs_mgrext[];
extern VgaReg igs_hcshf[];
extern VgaReg igs_mbpfix[];
extern VgaReg igs_overscan_red[];
extern VgaReg igs_overscan_green[];
extern VgaReg igs_overscan_blue[];
extern VgaReg igs_memgopg[];
extern VgaReg igs_memr2wpg[];
extern VgaReg igs_crtff16[];
extern VgaReg igs_fifomust[];
extern VgaReg igs_fifogen[];
extern VgaReg igs_mode_sel[];
#define IGS_MODE_TEXT 0
#define IGS_MODE_8 1
#define IGS_MODE_565 2
#define IGS_MODE_5551 6
#define IGS_MODE_8888 3
#define IGS_MODE_888 4
#define IGS_MODE_332 9
#define IGS_MODE_4444 10
extern VgaReg igs_sprite_addr[];
extern VgaReg igs_fastmpie[];
extern VgaReg igs_vclk_m[];
extern VgaReg igs_vclk_n[];
extern VgaReg igs_vfsel[];
extern VgaReg igs_vclk_p[];
extern VgaReg igs_frqlat[];
extern VgaReg igs_dac_mask[];
extern VgaReg igs_dac_read_index[];
extern VgaReg igs_dac_write_index[];
extern VgaReg igs_dac_data[];
extern VgaReg igs_rampwdn[];
extern VgaReg igs_dac6_8[];
extern VgaReg igs_ramdacbypass[];
extern VgaReg igs_dacpwdn[];
extern VgaReg igs_cursor_read_index[];
extern VgaReg igs_cursor_write_index[];
extern VgaReg igs_cursor_data[];
#define igsGet(sv,r) VgaGet(&(sv)->card, (r))
#define igsGetImm(sv,r) VgaGetImm(&(sv)->card, (r))
#define igsSet(sv,r,v) VgaSet(&(sv)->card, (r), (v))
#define igsSetImm(sv,r,v) VgaSetImm(&(sv)->card, (r), (v))
typedef struct _igsVga {
VgaCard card;
VgaValue values[IGS_NREG];
} IgsVga;
void
igsRegInit (IgsVga *igsvga, VGAVOL8 *mmio);
void
igsSave (IgsVga *igsvga);
void
igsReset (IgsVga *igsvga);
#endif /* _IGSREG_H_ */

View File

@ -1,71 +0,0 @@
/*
* Copyright © 2000 Keith Packard
*
* 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 Keith Packard not be used in
* advertising or publicity pertaining to distribution of the software without
* specific, written prior permission. Keith Packard makes no
* representations about the suitability of this software for any purpose. It
* is provided "as is" without express or implied warranty.
*
* KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL KEITH PACKARD 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.
*/
#ifdef HAVE_CONFIG_H
#include <kdrive-config.h>
#endif
#include "igs.h"
void
InitCard (char *name)
{
KdCardAttr attr;
CARD32 count;
count = 0;
#ifdef EMBED
attr.address[0] = 0x10000000; /* Adomo Wing video base address */
attr.io = 0;
attr.naddr = 1;
#else
while (LinuxFindPci (0x10ea, 0x5000, count, &attr))
#endif
{
KdCardInfoAdd (&igsFuncs, &attr, 0);
count++;
}
}
void
InitOutput (ScreenInfo *pScreenInfo, int argc, char **argv)
{
KdInitOutput (pScreenInfo, argc, argv);
}
void
InitInput (int argc, char **argv)
{
KdOsAddInputDrivers ();
KdInitInput ();
}
void
ddxUseMsg (void)
{
KdUseMsg ();
}
int
ddxProcessArgument (int argc, char **argv, int i)
{
return KdProcessArgument (argc, argv, i);
}

View File

@ -1,70 +0,0 @@
/*
* Copyright © 1999 Keith Packard
*
* 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 Keith Packard not be used in
* advertising or publicity pertaining to distribution of the software without
* specific, written prior permission. Keith Packard makes no
* representations about the suitability of this software for any purpose. It
* is provided "as is" without express or implied warranty.
*
* KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL KEITH PACKARD 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.
*
* Adapted from ts300.c by Alan Hourihane <alanh@fairlite.demon.co.uk>
* For the Compaq IPAQ handheld, with the HP VGA Out Card (F1252A).
*/
#ifdef HAVE_CONFIG_H
#include <kdrive-config.h>
#endif
#include "pcmcia.h"
extern KdCardFuncs pcmciaFuncs;
void
InitCard (char *name)
{
KdCardAttr attr;
if (name && !strcmp(name, "pcmcia"))
KdCardInfoAdd (&pcmciaFuncs, &attr, 0);
else
KdCardInfoAdd (&fbdevFuncs, &attr, 0);
}
void
InitOutput (ScreenInfo *pScreenInfo, int argc, char **argv)
{
KdInitOutput (pScreenInfo, argc, argv);
}
void
InitInput (int argc, char **argv)
{
KdInitInput (&LinuxMouseFuncs, &LinuxKeyboardFuncs);
#ifdef TOUCHSCREEN
KdAddMouseDriver (&TsFuncs);
#endif
}
extern pcmciaDisplayModeRec pcmciaDefaultModes[];
void
ddxUseMsg (void)
{
KdUseMsg();
}
int
ddxProcessArgument (int argc, char **argv, int i)
{
return KdProcessArgument (argc, argv, i);
}

View File

@ -1,325 +0,0 @@
/*
* Copyright © 1999 Keith Packard
*
* 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 Keith Packard not be used in
* advertising or publicity pertaining to distribution of the software without
* specific, written prior permission. Keith Packard makes no
* representations about the suitability of this software for any purpose. It
* is provided "as is" without express or implied warranty.
*
* KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL KEITH PACKARD 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.
*/
#ifdef HAVE_CONFIG_H
#include <kdrive-config.h>
#endif
#include "itsy.h"
/* struct with LCD characteristics defined in fb_brutus.h */
static struct FbLcdParamsStruct fbLcdParams;
static int fb_d;
static int fbn;
Bool
itsyCardInit (KdCardInfo *card)
{
int k;
char *fb;
char *pixels;
if ((fb_d = open("/dev/fbclone", O_RDWR)) < 0) {
perror("Error opening /dev/fb\n");
return FALSE;
}
if ((k=ioctl(fb_d, FB_LCD_PARAMS, &fbLcdParams)) != 0) {
perror("Error with /dev/fb ioctl FB_LCD_PARAMS call");
return FALSE;
}
fb = (char *) mmap ((caddr_t) NULL, fbLcdParams.frameBufferSize,
PROT_READ|PROT_WRITE, MAP_FILE|MAP_SHARED, fb_d, 0);
fprintf (stderr, "fb mapped at 0x%x\n", fb);
if (fb == (char *)-1) {
perror("ERROR: mmap framebuffer fails!");
return FALSE;
}
card->driver = fb;
return TRUE;
}
Bool
itsyScreenInit (KdScreenInfo *screen)
{
CARD8 *fb = screen->card->driver;
screen->width = fbLcdParams.screenSizeH;
screen->height = fbLcdParams.screenSizeV;
screen->depth = fbLcdParams.bitsPerPixel;
screen->bitsPerPixel = fbLcdParams.bitsPerPixel;
screen->byteStride = fbLcdParams.frameBufferSizeH;
screen->pixelStride = (fbLcdParams.frameBufferSizeH * 8 /
fbLcdParams.bitsPerPixel);
fprintf (stderr, "width %d height %d depth %d pstride %d bstride %d\n",
screen->width, screen->height, screen->depth,
screen->pixelStride, screen->byteStride);
screen->dumb = FALSE;
screen->softCursor = TRUE;
screen->blueMask = 0;
screen->greenMask = 0;
screen->redMask = 0;
screen->visuals = 1 << StaticGray;
screen->rate = 72;
screen->frameBuffer = (CARD8 *) (fb +
fbLcdParams.pixelDataOffset +
(fbLcdParams.reserveTopRows *
screen->byteStride));
fprintf (stderr, "Frame buffer 0x%x\n", screen->frameBuffer);
return TRUE;
}
static unsigned short itsyIntensity[16] = {
0xffff,
0xffff,
0xedb6,
0xdb6d,
0xc924,
0xb6db,
0xa492,
0x9249,
0x8000,
0x6db6,
0x5b6d,
0x4924,
0x36db,
0x2492,
0x1249,
0x0000,
};
Bool
itsyCreateColormap (ColormapPtr pmap)
{
int i;
for (i = 0; i < 16; i++)
{
pmap->red[i].co.local.red = itsyIntensity[i];
pmap->red[i].co.local.green = itsyIntensity[i];
pmap->red[i].co.local.blue = itsyIntensity[i];
}
return TRUE;
}
Bool
itsyInitScreen (ScreenPtr pScreen)
{
pScreen->CreateColormap = itsyCreateColormap;
return TRUE;
}
void
itsyPreserve (KdCardInfo *card)
{
}
void
itsyEnable (ScreenPtr pScreen)
{
KdScreenPriv(pScreen);
fprintf (stderr, "Enabling LCD display\n");
/* display it on the LCD */
ioctl(fb_d, FB_LCD_SHOW, 0);
}
Bool
itsyDPMS (ScreenPtr pScreen, int mode)
{
if (mode)
ioctl (fb_d, FB_LCD_OFF, 0);
else
ioctl (fb_d, FB_LCD_ON, 0);
return TRUE;
}
void
itsyDisable (ScreenPtr pScreen)
{
/* ioctl (fb_d, FB_LCD_SWITCH, 0); */
/* fprintf (stderr, "Disabling LCD display\n");*/
}
void
itsyRestore (KdCardInfo *card)
{
}
void
itsyScreenFini (KdScreenInfo *screen)
{
}
void
itsyCardFini (KdCardInfo *card)
{
int k;
fprintf (stderr, "Unmapping driver at 0x%x\n", card->driver);
munmap (card->driver, fbLcdParams.frameBufferSize);
fprintf (stderr, "Releasing fbn %d\n", fbn);
/* release it */
if (ioctl(fb_d, FB_LCD_FREE, fbn) != 0) {
printf("FB_LCD_FREE of %d fails!\n", fbn);
}
close (fb_d);
fprintf (stderr, "itsyFini done\n");
}
KdCardFuncs itsyFuncs = {
itsyCardInit, /* cardinit */
itsyScreenInit, /* scrinit */
itsyInitScreen, /* initScreen */
itsyPreserve, /* preserve */
itsyEnable, /* enable */
itsyDPMS, /* dpms */
itsyDisable, /* disable */
itsyRestore, /* restore */
itsyScreenFini, /* scrfini */
itsyCardFini, /* cardfini */
0, /* initCursor */
0, /* enableCursor */
0, /* disableCursor */
0, /* finiCursor */
0, /* recolorCursor */
0, /* initAccel */
0, /* enableAccel */
0, /* disableAccel */
0, /* finiAccel */
0, /* getColors */
0, /* putColors */
};
void
InitCard (void)
{
KdCardAttr attr;
KdCardInfoAdd (&itsyFuncs, &attr, 0);
}
void
InitOutput (ScreenInfo *pScreenInfo, int argc, char **argv)
{
KdInitOutput (pScreenInfo, argc, argv);
}
void
InitInput (int argc, char **argv)
{
KdInitInput (&itsyTsMouseFuncs, &itsyKeyboardFuncs);
}
int itsySessionFd = -1;
int
ItsyOsInit (void)
{
pid_t sid;
int i;
itsy_session_info info;
if (itsySessionFd < 0)
{
itsySessionFd = open ("/dev/session", 0);
ErrorF("itsySessionFD %d\n", itsySessionFd);
}
(void) setsid ();
sid = getsid (0);
ErrorF ("Session ID %d PID %d\n", sid, getpid ());
info.sid = sid;
strcpy (info.name, "X");
if (itsySessionFd >= 0)
{
i = ioctl (itsySessionFd, SESSION_SET_INFO, &info);
if (i < 0)
perror ("SESSION_SET_INFO");
}
return 1;
}
void
ItsyOsEnable (void)
{
itsy_session_request req;
int i;
#define MANAGER_SID_TO_FOREGROUND 2
req.operation = MANAGER_SID_TO_FOREGROUND;
req.data = 0;
if (itsySessionFd >= 0)
{
i = ioctl (itsySessionFd, SESSION_MANAGER_REQUEST, &req);
if (i < 0)
perror ("SESSION_MANAGER_REQUEST");
}
}
Bool
ItsyOsSpecialKey (KeySym sym)
{
return FALSE;
}
void
ItsyOsDisable (void)
{
}
void
ItsyOsFini (void)
{
}
KdOsFuncs ItsyOsFuncs = {
ItsyOsInit,
ItsyOsEnable,
ItsyOsSpecialKey,
ItsyOsDisable,
ItsyOsFini,
0
};
void
OsVendorInit (void)
{
KdOsInit (&ItsyOsFuncs);
}
void
ddxUseMsg (void)
{
KdUseMsg();
}
int
ddxProcessArgument (int argc, char **argv, int i)
{
return KdProcessArgument (argc, argv, i);
}

View File

@ -1,39 +0,0 @@
/*
* Copyright © 1999 Keith Packard
*
* 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 Keith Packard not be used in
* advertising or publicity pertaining to distribution of the software without
* specific, written prior permission. Keith Packard makes no
* representations about the suitability of this software for any purpose. It
* is provided "as is" without express or implied warranty.
*
* KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL KEITH PACKARD 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.
*/
#include "kdrive.h"
#include <stdio.h>
#include <sys/ioctl.h>
#include <linux/itsy_fb.h>
#include <linux/itsy_ts.h>
#include <linux/itsy_buttons.h>
#include <linux/itsy_session.h>
#include <unistd.h>
#include <sys/mman.h>
#define FB_HEIGHT 200
#define FB_WIDTH 320
#define FB_DEPTH 4
#define FB_PALETTE_SIZE 16
extern KdMouseFuncs itsyTsMouseFuncs;
extern KdKeyboardFuncs itsyKeyboardFuncs;

View File

@ -1,251 +0,0 @@
/*
* Copyright © 1999 Keith Packard
*
* 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 Keith Packard not be used in
* advertising or publicity pertaining to distribution of the software without
* specific, written prior permission. Keith Packard makes no
* representations about the suitability of this software for any purpose. It
* is provided "as is" without express or implied warranty.
*
* KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL KEITH PACKARD 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.
*/
#ifdef HAVE_CONFIG_H
#include <kdrive-config.h>
#endif
#include "itsy.h"
#include <X11/keysym.h>
#include <linux/itsy_buttons.h>
#define ITSY_WIDTH 2
KeySym ItsyKeymap[] = {
/* 1 8 */ XK_Escape, NoSymbol,
/* 2 9 */ XK_1, XK_exclam,
/* 3 10 */ XK_2, XK_at,
/* 4 11 */ XK_3, XK_numbersign,
/* 5 12 */ XK_4, XK_dollar,
/* 6 13 */ XK_5, XK_percent,
/* 7 14 */ XK_6, XK_asciicircum,
/* 8 15 */ XK_7, XK_ampersand,
/* 9 16 */ XK_8, XK_asterisk,
/* 10 17 */ XK_9, XK_parenleft,
/* 11 18 */ XK_0, XK_parenright,
/* 12 19 */ XK_minus, XK_underscore,
/* 13 20 */ XK_equal, XK_plus,
/* 14 21 */ XK_BackSpace, NoSymbol,
/* 15 22 */ XK_Tab, NoSymbol,
/* 16 23 */ XK_Q, NoSymbol,
/* 17 24 */ XK_W, NoSymbol,
/* 18 25 */ XK_E, NoSymbol,
/* 19 26 */ XK_R, NoSymbol,
/* 20 27 */ XK_T, NoSymbol,
/* 21 28 */ XK_Y, NoSymbol,
/* 22 29 */ XK_U, NoSymbol,
/* 23 30 */ XK_I, NoSymbol,
/* 24 31 */ XK_O, NoSymbol,
/* 25 32 */ XK_P, NoSymbol,
/* 26 33 */ XK_bracketleft, XK_braceleft,
/* 27 34 */ XK_bracketright, XK_braceright,
/* 28 35 */ XK_Return, NoSymbol,
/* 29 36 */ XK_Control_L, NoSymbol,
/* 30 37 */ XK_A, NoSymbol,
/* 31 38 */ XK_S, NoSymbol,
/* 32 39 */ XK_D, NoSymbol,
/* 33 40 */ XK_F, NoSymbol,
/* 34 41 */ XK_G, NoSymbol,
/* 35 42 */ XK_H, NoSymbol,
/* 36 43 */ XK_J, NoSymbol,
/* 37 44 */ XK_K, NoSymbol,
/* 38 45 */ XK_L, NoSymbol,
/* 39 46 */ XK_semicolon, XK_colon,
/* 40 47 */ XK_apostrophe, XK_quotedbl,
/* 41 48 */ XK_grave, XK_asciitilde,
/* 42 49 */ XK_Shift_L, NoSymbol,
/* 43 50 */ XK_backslash, XK_bar,
/* 44 51 */ XK_Z, NoSymbol,
/* 45 52 */ XK_X, NoSymbol,
/* 46 53 */ XK_C, NoSymbol,
/* 47 54 */ XK_V, NoSymbol,
/* 48 55 */ XK_B, NoSymbol,
/* 49 56 */ XK_N, NoSymbol,
/* 50 57 */ XK_M, NoSymbol,
/* 51 58 */ XK_comma, XK_less,
/* 52 59 */ XK_period, XK_greater,
/* 53 60 */ XK_slash, XK_question,
/* 54 61 */ XK_Shift_R, NoSymbol,
/* 55 62 */ XK_KP_Multiply, NoSymbol,
/* 56 63 */ XK_Alt_L, XK_Meta_L,
/* 57 64 */ XK_space, NoSymbol,
/* 58 65 */ XK_Caps_Lock, NoSymbol,
/* 59 66 */ XK_F1, NoSymbol,
/* 60 67 */ XK_F2, NoSymbol,
/* 61 68 */ XK_F3, NoSymbol,
/* 62 69 */ XK_F4, NoSymbol,
/* 63 70 */ XK_F5, NoSymbol,
/* 64 71 */ XK_F6, NoSymbol,
/* 65 72 */ XK_F7, NoSymbol,
/* 66 73 */ XK_F8, NoSymbol,
/* 67 74 */ XK_F9, NoSymbol,
/* 68 75 */ XK_F10, NoSymbol,
/* 69 76 */ XK_Break, XK_Pause,
/* 70 77 */ XK_Scroll_Lock, NoSymbol,
/* 71 78 */ XK_KP_Home, XK_KP_7,
/* 72 79 */ XK_KP_Up, XK_KP_8,
/* 73 80 */ XK_KP_Page_Up, XK_KP_9,
/* 74 81 */ XK_KP_Subtract, NoSymbol,
/* 75 82 */ XK_KP_Left, XK_KP_4,
/* 76 83 */ XK_KP_5, NoSymbol,
/* 77 84 */ XK_KP_Right, XK_KP_6,
/* 78 85 */ XK_KP_Add, NoSymbol,
/* 79 86 */ XK_KP_End, XK_KP_1,
/* 80 87 */ XK_KP_Down, XK_KP_2,
/* 81 88 */ XK_KP_Page_Down, XK_KP_3,
/* 82 89 */ XK_KP_Insert, XK_KP_0,
/* 83 90 */ XK_KP_Delete, XK_KP_Decimal,
/* 84 91 */ NoSymbol, NoSymbol,
/* 85 92 */ NoSymbol, NoSymbol,
/* 86 93 */ NoSymbol, NoSymbol,
/* 87 94 */ XK_F11, NoSymbol,
/* 88 95 */ XK_F12, NoSymbol,
/* These are remapped from the extended set (using ExtendMap) */
/* 89 96 */ XK_Control_R, NoSymbol,
/* 90 97 */ XK_KP_Enter, NoSymbol,
/* 91 98 */ XK_KP_Divide, NoSymbol,
/* 92 99 */ XK_Sys_Req, XK_Print,
/* 93 100 */ XK_Alt_R, XK_Meta_R,
/* 94 101 */ XK_Num_Lock, NoSymbol,
/* 95 102 */ XK_Home, NoSymbol,
/* 96 103 */ XK_Up, NoSymbol,
/* 97 104 */ XK_Page_Up, NoSymbol,
/* 98 105 */ XK_Left, NoSymbol,
/* 99 106 */ XK_Right, NoSymbol,
/* 100 107 */ XK_End, NoSymbol,
/* 101 108 */ XK_Down, NoSymbol,
/* 102 109 */ XK_Page_Down, NoSymbol,
/* 103 110 */ XK_Insert, NoSymbol,
/* 104 111 */ XK_Delete, NoSymbol,
/* 105 112 */ XK_Super_L, NoSymbol,
/* 106 113 */ XK_Super_R, NoSymbol,
/* 107 114 */ XK_Menu, NoSymbol,
/* Itsy hardware buttons */
#define ITSY_BUTTON_FIRST 108
#define ITSY_BUTTON_LAST 116
/* 108 115 */ XK_Next, NoSymbol, /* right button on side */
/* 109 116 */ XK_Prior, NoSymbol, /* left button on side */
/* 110 117 */ XK_Up, NoSymbol, /* joypad */
/* 111 118 */ XK_Down, NoSymbol,
/* 112 119 */ XK_Left, NoSymbol,
/* 113 120 */ XK_Right, NoSymbol,
/* 114 121 */ NoSymbol, NoSymbol, /* left near speaker */
/* 115 122 */ NoSymbol, NoSymbol, /* right near speaker */
/* 116 123 */ NoSymbol, NoSymbol, /* tiny button */
};
static unsigned long itsyButtonState;
void
ItsyKeyboardLoad (void)
{
KeySym *k;
}
static Status
ItsyKeyboardInit (KdKeyboardInfo *ki)
{
if (!ki)
return BadImplementation;
ki->driverPrivate = open ("/dev/buttons", 0);
itsyButtonState = 0;
ki->keySyms.minKeyCode = 1;
ki->keySyms.maxKeyCode = (sizeof (ItsyKeymap) / sizeof (ItsyKeymap[0])) / ITSY_WIDTH;
ki->minScanCode = ki->keySyms.minKeyCode;
ki->maxScanCode = ki->keySyms.maxKeyCode;
ki->keySyms.mapWidth = ITSY_WIDTH;
if (ki->keySyms.map)
xfree(ki->keySyms.map);
ki->keySyms.map = xalloc(sizeof(ItsyKeymap));
if (!ki->keySyms.map)
return BadAlloc;
memcpy (kdKeymap, ItsyKeymap, sizeof (ItsyKeymap));
return Success;
}
static void
ItsyKeyboardDisable (KdKeybdInfo *ki)
{
if (fd >= 0)
close ((int)ki->driverPrivate);
}
static void
ItsyKeyboardFini (KdKeybdInfo *ki)
{
return;
}
void
ItsyKeyboardRead (int fd)
{
itsy_buttons_event event;
int b;
unsigned long bit;
unsigned long change;
unsigned long buttons;
if (read (fd, &event, sizeof (event)) == sizeof (event))
{
buttons = event.state;
change = buttons ^ itsyButtonState;
if (!change)
return;
for (b = ITSY_BUTTON_FIRST; b <= ITSY_BUTTON_LAST; b++)
{
bit = (1 << (b - ITSY_BUTTON_FIRST));
if (change & bit)
KdEnqueueKeyboardEvent (b, (buttons & bit) == 0);
}
itsyButtonState = buttons;
}
}
void
ItsyKeyboardLeds (int leds)
{
}
void
ItsyKeyboardBell (int volume, int frequency, int duration)
{
}
KdKeyboardFuncs itsyKeyboardFuncs = {
"itsy",
ItsyKeyboardInit,
ItsyKeyboardEnable,
ItsyKeyboardRead,
ItsyKeyboardLeds,
ItsyKeyboardBell,
ItsyKeyboardDisable
ItsyKeyboardFini,
NULL,
};

View File

@ -1,210 +0,0 @@
/*
* Copyright © 1999 Keith Packard
*
* 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 Keith Packard not be used in
* advertising or publicity pertaining to distribution of the software without
* specific, written prior permission. Keith Packard makes no
* representations about the suitability of this software for any purpose. It
* is provided "as is" without express or implied warranty.
*
* KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL KEITH PACKARD 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.
*/
#ifdef HAVE_CONFIG_H
#include <kdrive-config.h>
#endif
#define NEED_EVENTS
#include "itsy.h"
#include <X11/Xproto.h>
#include "inputstr.h"
#include "Xpoll.h"
int
itsyTsReadBytes (int fd, char *buf, int len, int min)
{
int n, tot;
fd_set set;
struct timeval tv;
tot = 0;
while (len)
{
n = read (fd, buf, len);
if (n > 0)
{
tot += n;
buf += n;
len -= n;
}
if (tot % min == 0)
break;
FD_ZERO (&set);
FD_SET (fd, &set);
tv.tv_sec = 0;
tv.tv_usec = 100 * 1000;
n = select (fd + 1, &set, 0, 0, &tv);
if (n <= 0)
break;
}
return tot;
}
void
itsyTsRead (KdPointerInfo *pi, int tsPort)
{
ts_event event;
long buf[3];
int n;
long pressure;
long x, y;
unsigned long flags;
unsigned long buttons;
n = itsyTsReadBytes (tsPort, (char *) &event,
sizeof (event), sizeof (event));
if (n == sizeof (event))
{
if (event.pressure)
{
flags = KD_BUTTON_1;
x = event.point.x;
y = event.point.y;
}
else
{
flags = KD_MOUSE_DELTA;
x = 0;
y = 0;
}
KdEnqueuePointerEvent (pi, flags, x, y, 0);
}
}
#if 0
#define ITSY_DEBUG_LOW 1
//
// Touch screen parameters are stored
// in the flash. This code is taken from 'wm1'.
//
void itsySetTouchCalibration (int mou_filedsc,
int xs, int xt, int ys, int yt, int xys)
{
int k, ibuf[10];
ibuf[0] = xs;
ibuf[1] = xt;
ibuf[2] = ys;
ibuf[3] = yt;
ibuf[4] = xys;
if ((k=ioctl(mou_filedsc, TS_SET_CALM, ibuf)) != 0) {
fprintf(stderr, "ERROR: ioctl TS_SET_CALM returns %d\n", k);
}
}
int itsyReadFlashBlock(int location, signed char *data, int dbytes)
{
int offset, bytes;
int flashfd;
flashfd = open("/dev/flash1", O_RDONLY);
if (flashfd < 0) return(0);
offset = lseek(flashfd, location, SEEK_SET);
if (offset != location) {
close(flashfd);
return(0);
}
bytes = read(flashfd, data, dbytes);
if (bytes != dbytes) {
close(flashfd);
return(0);
}
close(flashfd);
return(1);
}
/**********************************************************************/
#define RAMSIZE (0x400000)
#define MONITOR_BLOCKSIZE (32)
/**********************************************************************/
/* code for storing calibration into flash */
#define CALIBRATE_BLOCKSIZE (32)
#define CALIBRATE_OFFSET (RAMSIZE-MONITOR_BLOCKSIZE-CALIBRATE_BLOCKSIZE)
#define CALIBRATE_MAGIC_NUM (0x0babedee)
static int check_if_calibrated_and_set(int mou_filedsc)
{
signed char cal_data[CALIBRATE_BLOCKSIZE];
int *iptr;
if (itsyReadFlashBlock(CALIBRATE_OFFSET,
cal_data, CALIBRATE_BLOCKSIZE) == 0) {
if ( ITSY_DEBUG_LOW ) {
fprintf(stderr,"unable to read calibration data for touch screen\n");
}
return(0);
}
iptr = (int *) cal_data;
if (iptr[0] == CALIBRATE_MAGIC_NUM) {
if ( ITSY_DEBUG_LOW ) {
fprintf(stderr,"Calibrating touch screen using %d, %d, %d, %d, %d\n",
iptr[1], iptr[2], iptr[3], iptr[4], iptr[5]);
}
itsySetTouchCalibration(mou_filedsc, iptr[1], iptr[2], iptr[3], iptr[4], iptr[5]);
return(1);
}
else {
if ( ITSY_DEBUG_LOW ) {
fprintf(stderr,"Couldn't calibrate screen\n");
}
return(0);
}
}
#endif
int
itsyTsInit (void)
{
int tsPort;
tsPort = open ("/dev/ts", 0);
fprintf (stderr, "tsPort %d\n", tsPort);
#if 0
if (tsPort >= 0)
check_if_calibrated_and_set (tsPort);
#endif
return tsPort;
}
void
itsyTsFini (int tsPort)
{
if (tsPort >= 0)
close (tsPort);
}
KdPointerDriver itsyTsMouseDriver = {
"itsyts",
itsyTsInit,
itsyTsRead,
itsyTsFini
};

View File

@ -1,43 +0,0 @@
INCLUDES = \
@KDRIVE_INCS@ \
-I$(top_srcdir)/hw/kdrive/vesa \
@KDRIVE_CFLAGS@
bin_PROGRAMS = Xmach64
if TSLIB
TSLIB_FLAG = -lts
endif
noinst_LIBRARIES = libmach64.a
libmach64_a_SOURCES = \
mach64.c \
mach64draw.c \
mach64video.c \
mach64.h \
mach64draw.h
Xmach64_SOURCES = \
mach64stub.c
MACH64_LIBS = \
libmach64.a \
$(top_builddir)/hw/kdrive/vesa/libvesa.a
if GLX
Xmach64_LDFLAGS = $(LD_EXPORT_SYMBOLS_FLAG)
endif
Xmach64_LDADD = \
$(MACH64_LIBS) \
@KDRIVE_LIBS@
Xmach64_DEPENDENCIES = \
libmach64.a \
@KDRIVE_LOCAL_LIBS@
relink:
rm -f $(bin_PROGRAMS) && make $(bin_PROGRAMS)

View File

@ -1,433 +0,0 @@
/*
* Copyright © 2001 Keith Packard
*
* 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 Keith Packard not be used in
* advertising or publicity pertaining to distribution of the software without
* specific, written prior permission. Keith Packard makes no
* representations about the suitability of this software for any purpose. It
* is provided "as is" without express or implied warranty.
*
* KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL KEITH PACKARD 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.
*/
#ifdef HAVE_CONFIG_H
#include <kdrive-config.h>
#endif
#include "mach64.h"
#include "kaa.h"
static Bool
mach64CardInit (KdCardInfo *card)
{
Mach64CardInfo *mach64c;
mach64c = (Mach64CardInfo *) xalloc (sizeof (Mach64CardInfo));
if (!mach64c)
return FALSE;
(void) mach64MapReg (card, mach64c);
mach64c->lcdEnabled = FALSE;
if (!vesaInitialize (card, &mach64c->vesa))
{
xfree (mach64c);
return FALSE;
}
card->driver = mach64c;
return TRUE;
}
static Bool
mach64ScreenInit (KdScreenInfo *screen)
{
Mach64CardInfo *mach64c = screen->card->driver;
Mach64ScreenInfo *mach64s;
mach64s = (Mach64ScreenInfo *) xalloc (sizeof (Mach64ScreenInfo));
if (!mach64s)
return FALSE;
memset (mach64s, '\0', sizeof (Mach64ScreenInfo));
if (!vesaScreenInitialize (screen, &mach64s->vesa))
{
xfree (mach64s);
return FALSE;
}
if (!mach64c->reg)
screen->dumb = TRUE;
if (mach64s->vesa.mapping != VESA_LINEAR)
screen->dumb = TRUE;
switch (screen->fb[0].depth) {
case 8:
mach64s->colorKey = 0xff;
break;
case 15:
case 16:
mach64s->colorKey = 0x001e;
break;
case 24:
mach64s->colorKey = 0x0000fe;
break;
default:
mach64s->colorKey = 1;
break;
}
screen->driver = mach64s;
return TRUE;
}
static Bool
mach64InitScreen (ScreenPtr pScreen)
{
#ifdef XV
mach64InitVideo(pScreen);
#endif
return vesaInitScreen (pScreen);
}
#ifdef RANDR
static Bool
mach64RandRSetConfig (ScreenPtr pScreen,
Rotation rotation,
int rate,
RRScreenSizePtr pSize)
{
kaaWaitSync (pScreen);
if (!vesaRandRSetConfig (pScreen, rotation, rate, pSize))
return FALSE;
return TRUE;
}
static void
mach64RandRInit (ScreenPtr pScreen)
{
rrScrPriv(pScreen);
pScrPriv->rrSetConfig = mach64RandRSetConfig;
}
#endif
static Bool
mach64FinishInitScreen (ScreenPtr pScreen)
{
Bool ret;
ret = vesaFinishInitScreen (pScreen);
#ifdef RANDR
mach64RandRInit (pScreen);
#endif
return ret;
}
static Bool
mach64CreateResources (ScreenPtr pScreen)
{
return vesaCreateResources (pScreen);
}
CARD32
mach64ReadLCD (Reg *reg, int id)
{
CARD32 LCD_INDEX;
LCD_INDEX = reg->LCD_INDEX & ~(0x3f);
reg->LCD_INDEX = (LCD_INDEX | id);
return reg->LCD_DATA;
}
void
mach64WriteLCD (Reg *reg, int id, CARD32 data)
{
CARD32 LCD_INDEX;
LCD_INDEX = reg->LCD_INDEX & ~(0x3f);
reg->LCD_INDEX = (LCD_INDEX | id);
reg->LCD_DATA = data;
}
void
mach64Preserve (KdCardInfo *card)
{
Mach64CardInfo *mach64c = card->driver;
Reg *reg = mach64c->reg;
vesaPreserve(card);
if (reg)
{
mach64c->save.LCD_GEN_CTRL = mach64ReadLCD (reg, 1);
}
}
Bool
mach64MapReg (KdCardInfo *card, Mach64CardInfo *mach64c)
{
mach64c->reg_base = (CARD8 *) KdMapDevice (MACH64_REG_BASE(card),
MACH64_REG_SIZE(card));
if (!mach64c->reg_base)
{
mach64c->reg = 0;
mach64c->media_reg = 0;
return FALSE;
}
KdSetMappedMode (MACH64_REG_BASE(card),
MACH64_REG_SIZE(card),
KD_MAPPED_MODE_REGISTERS);
mach64c->reg = (Reg *) (mach64c->reg_base + MACH64_REG_OFF(card));
mach64c->media_reg = (MediaReg *) (mach64c->reg_base + MACH64_MEDIA_REG_OFF(card));
return TRUE;
}
void
mach64UnmapReg (KdCardInfo *card, Mach64CardInfo *mach64c)
{
if (mach64c->reg_base)
{
KdResetMappedMode (MACH64_REG_BASE(card),
MACH64_REG_SIZE(card),
KD_MAPPED_MODE_REGISTERS);
KdUnmapDevice ((void *) mach64c->reg_base, MACH64_REG_SIZE(card));
mach64c->reg_base = 0;
mach64c->reg = 0;
mach64c->media_reg = 0;
}
}
void
mach64SetMMIO (KdCardInfo *card, Mach64CardInfo *mach64c)
{
if (!mach64c->reg_base)
mach64MapReg (card, mach64c);
if (mach64c->reg)
{
if (mach64c->reg->GUI_STAT == 0xffffffff)
FatalError ("Mach64 REG not visible\n");
}
}
void
mach64ResetMMIO (KdCardInfo *card, Mach64CardInfo *mach64c)
{
mach64UnmapReg (card, mach64c);
}
Bool
mach64Enable (ScreenPtr pScreen)
{
KdScreenPriv(pScreen);
Mach64CardInfo *mach64c = pScreenPriv->card->driver;
if (!vesaEnable (pScreen))
return FALSE;
mach64SetMMIO (pScreenPriv->card, mach64c);
mach64DPMS (pScreen, KD_DPMS_NORMAL);
#ifdef XV
KdXVEnable (pScreen);
#endif
return TRUE;
}
void
mach64Disable (ScreenPtr pScreen)
{
KdScreenPriv(pScreen);
Mach64CardInfo *mach64c = pScreenPriv->card->driver;
#ifdef XV
KdXVDisable (pScreen);
#endif
mach64ResetMMIO (pScreenPriv->card, mach64c);
vesaDisable (pScreen);
}
const CARD8 mach64DPMSModes[4] = {
0x80, /* KD_DPMS_NORMAL */
0x8c, /* KD_DPMS_STANDBY */
0x8c, /* KD_DPMS_STANDBY */
0x8c, /* KD_DPMS_STANDBY */
/* 0xb0, KD_DPMS_SUSPEND */
/* 0xbc, KD_DPMS_POWERDOWN */
};
#define PWR_MGT_ON (1 << 0)
#define PWR_MGT_MODE (3 << 1)
#define PWR_MGT_MODE_PIN (0 << 1)
#define PWR_MGT_MODE_REG (1 << 1)
#define PWR_MGT_MODE_TIMER (2 << 1)
#define PWR_MGR_MODE_PCI (3 << 1)
#define AUTO_PWRUP_EN (1 << 3)
#define ACTIVITY_PIN_ON (1 << 4)
#define STANDBY_POL (1 << 5)
#define SUSPEND_POL (1 << 6)
#define SELF_REFRESH (1 << 7)
#define ACTIVITY_PIN_EN (1 << 8)
#define KEYBD_SNOOP (1 << 9)
#define DONT_USE_F32KHZ (1 << 10)
#define TRISTATE_MEM_EN (1 << 11)
#define LCDENG_TEST_MODE (0xf << 12)
#define STANDBY_COUNT (0xf << 16)
#define SUSPEND_COUNT (0xf << 20)
#define BIASON (1 << 24)
#define BLON (1 << 25)
#define DIGON (1 << 26)
#define PM_D3_RST_ENB (1 << 27)
#define STANDBY_NOW (1 << 28)
#define SUSPEND_NOW (1 << 29)
#define PWR_MGT_STATUS (3 << 30)
#define PWR_MGT_STATUS_ON (0 << 30)
#define PWR_MGT_STATUS_STANDBY (1 << 30)
#define PWR_MGT_STATUS_SUSPEND (2 << 30)
#define PWR_MGT_STATUS_TRANSITION (3 << 30)
Bool
mach64DPMS (ScreenPtr pScreen, int mode)
{
KdScreenPriv(pScreen);
Mach64CardInfo *mach64c = pScreenPriv->card->driver;
int hsync_off = 0, vsync_off = 0, blank = 0;
CARD32 CRTC_GEN_CNTL;
CARD32 LCD_GEN_CTRL;
Reg *reg = mach64c->reg;
if (!reg)
return FALSE;
CRTC_GEN_CNTL = reg->CRTC_GEN_CNTL;
LCD_GEN_CTRL = mach64ReadLCD (reg, 1);
switch (mode) {
case KD_DPMS_NORMAL:
hsync_off = 0;
vsync_off = 0;
blank = 0;
break;
case KD_DPMS_STANDBY:
hsync_off = 1;
vsync_off = 0;
blank = 1;
break;
case KD_DPMS_SUSPEND:
hsync_off = 0;
vsync_off = 1;
blank = 1;
break;
case KD_DPMS_POWERDOWN:
hsync_off = 1;
vsync_off = 1;
blank = 1;
}
if (hsync_off)
CRTC_GEN_CNTL |= (1 << 2);
else
CRTC_GEN_CNTL &= ~(1 << 2);
if (vsync_off)
CRTC_GEN_CNTL |= (1 << 3);
else
CRTC_GEN_CNTL &= ~(1 << 3);
if (blank)
{
mach64c->lcdEnabled = (LCD_GEN_CTRL & (1 << 1)) != 0;
LCD_GEN_CTRL &= ~(1 << 1);
CRTC_GEN_CNTL |= (1 << 6);
}
else
{
if (!(LCD_GEN_CTRL & 3) || mach64c->lcdEnabled)
LCD_GEN_CTRL |= (1 << 1);
CRTC_GEN_CNTL &= ~(1 << 6);
}
kaaWaitSync (pScreen);
mach64WriteLCD (reg, 1, LCD_GEN_CTRL);
reg->CRTC_GEN_CNTL = CRTC_GEN_CNTL;
return TRUE;
}
static void
mach64Restore (KdCardInfo *card)
{
Mach64CardInfo *mach64c = card->driver;
Reg *reg = mach64c->reg;
if (reg)
{
mach64WriteLCD (reg, 1, mach64c->save.LCD_GEN_CTRL);
}
mach64ResetMMIO (card, mach64c);
vesaRestore (card);
}
static void
mach64ScreenFini (KdScreenInfo *screen)
{
Mach64ScreenInfo *mach64s = (Mach64ScreenInfo *) screen->driver;
#ifdef XV
mach64FiniVideo(screen->pScreen);
#endif
vesaScreenFini (screen);
xfree (mach64s);
screen->driver = 0;
}
static void
mach64CardFini (KdCardInfo *card)
{
Mach64CardInfo *mach64c = card->driver;
mach64UnmapReg (card, mach64c);
vesaCardFini (card);
xfree (mach64c);
}
#define mach64CursorInit 0 /* initCursor */
#define mach64CursorEnable 0 /* enableCursor */
#define mach64CursorDisable 0 /* disableCursor */
#define mach64CursorFini 0 /* finiCursor */
#define mach64RecolorCursor 0 /* recolorCursor */
KdCardFuncs mach64Funcs = {
mach64CardInit, /* cardinit */
mach64ScreenInit, /* scrinit */
mach64InitScreen, /* initScreen */
mach64FinishInitScreen, /* finishInitScreen */
mach64CreateResources, /* createRes */
mach64Preserve, /* preserve */
mach64Enable, /* enable */
mach64DPMS, /* dpms */
mach64Disable, /* disable */
mach64Restore, /* restore */
mach64ScreenFini, /* scrfini */
mach64CardFini, /* cardfini */
mach64CursorInit, /* initCursor */
mach64CursorEnable, /* enableCursor */
mach64CursorDisable, /* disableCursor */
mach64CursorFini, /* finiCursor */
mach64RecolorCursor, /* recolorCursor */
mach64DrawInit, /* initAccel */
mach64DrawEnable, /* enableAccel */
mach64DrawDisable, /* disableAccel */
mach64DrawFini, /* finiAccel */
vesaGetColors, /* getColors */
vesaPutColors, /* putColors */
};

View File

@ -1,653 +0,0 @@
/*
* Copyright © 2001 Keith Packard
*
* 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 Keith Packard not be used in
* advertising or publicity pertaining to distribution of the software without
* specific, written prior permission. Keith Packard makes no
* representations about the suitability of this software for any purpose. It
* is provided "as is" without express or implied warranty.
*
* KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL KEITH PACKARD 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.
*/
#ifndef _MACH64_H_
#define _MACH64_H_
#include <vesa.h>
#include "kxv.h"
/*
* offset from ioport beginning
*/
#define MACH64_REG_BASE(c) ((c)->attr.address[1])
#define MACH64_REG_SIZE(c) (4096)
#define MACH64_REG_OFF(c) (1024)
#define MACH64_MEDIA_REG_OFF(c) (0)
typedef volatile CARD8 VOL8;
typedef volatile CARD16 VOL16;
typedef volatile CARD32 VOL32;
typedef struct _Reg {
VOL32 CRTC_H_TOTAL_DISP; /* 0x00 */
VOL32 CRTC_H_SYNC_STRT_WID; /* 0x01 */
VOL32 CRTC_V_TOTAL_DISP; /* 0x02 */
VOL32 CRTC_V_SYNC_STRT_WID; /* 0x03 */
VOL32 CRTC_VLINE_CRNT_VLINE; /* 0x04 */
VOL32 CRTC_OFF_PITCH; /* 0x05 */
VOL32 CRTC_INT_CNTL; /* 0x06 */
VOL32 CRTC_GEN_CNTL; /* 0x07 */
VOL32 DSP_CONFIG; /* 0x08 */
VOL32 DSP_ON_OFF; /* 0x09 */
VOL32 TIMER_CONFIG; /* 0x0a */
VOL32 MEM_BUF_CNTL; /* 0x0b */
VOL32 unused0; /* 0x0c */
VOL32 MEM_ADDR_CONFIG; /* 0x0d */
VOL32 CRT_TRAP; /* 0x0e */
VOL32 I2C_CNTL_0; /* 0x0f */
VOL32 OVR_CLR; /* 0x10 */
VOL32 OVR_WID_LEFT_RIGHT; /* 0x11 */
VOL32 OVR_WID_TOP_BOTTOM; /* 0x12 */
VOL32 VGA_DSP_CONFIG; /* 0x13 */
VOL32 VGA_DSP_ON_OFF; /* 0x14 */
VOL32 DSP2_CONFIG; /* 0x15 */
VOL32 DSP2_ON_OFF; /* 0x16 */
VOL32 CRTC2_OFF_PITCH; /* 0x17 */
VOL32 CUR_CLR0; /* 0x18 */
VOL32 CUR_CLR1; /* 0x19 */
VOL32 CUR_OFFSET; /* 0x1a */
VOL32 CUR_HORZ_VERT_POSN; /* 0x1b */
VOL32 CUR_HORZ_VERT_OFF; /* 0x1c */
VOL32 TV_OUT_INDEX; /* 0x1d */
VOL32 GP_IO; /* 0x1e */
VOL32 HW_DEBUG; /* 0x1f */
VOL32 SCRATCH_REG0; /* 0x20 */
VOL32 SCRATCH_REG1;
VOL32 SCRATCH_REG2;
VOL32 SCRATCH_REG3;
VOL32 CLOCK_CNTL;
VOL32 CONFIG_STAT1;
VOL32 CONFIG_STAT2;
VOL32 TV_OUT_DATA;
VOL32 BUS_CNTL; /* 0x28 */
VOL32 LCD_INDEX; /* 0x29 */
VOL32 LCD_DATA; /* 0x2a */
VOL32 EXT_MEM_CNTL;
VOL32 MEM_CNTL;
VOL32 MEM_VGA_WP_SEL;
VOL32 MEM_VGA_RP_SEL;
VOL32 I2C_CNTL_1;
VOL32 DAC_REGS; /* 0x30 */
VOL32 DAC_CNTL; /* 0x31 */
VOL32 unused_32;
VOL32 unused_33;
VOL32 GEN_TEST_CNTL; /* 0x34 */
VOL32 CUSTOM_MACRO_CNTL;
VOL32 unused36;
VOL32 CONFIG_CNTL;
VOL32 CONFIG_CHIP_ID;
VOL32 CONFIG_STAT0;
VOL32 CRC_SIG;
VOL32 unused_3b;
VOL32 unused_3c;
VOL32 unused_3d;
VOL32 unused_3e;
VOL32 unused_3f;
VOL32 DST_OFF_PITCH; /* 0x40 */
VOL32 DST_X;
VOL32 DST_Y;
VOL32 DST_Y_X;
VOL32 DST_WIDTH;
VOL32 DST_HEIGHT;
VOL32 DST_HEIGHT_WIDTH;
VOL32 DST_X_WIDTH;
VOL32 DST_BRES_LNTH;
VOL32 DST_BRES_ERR;
VOL32 DST_BRES_INC;
VOL32 DST_BRES_DEC;
VOL32 DST_CNTL;
VOL32 DST_Y_X_ALIAS;
VOL32 TRAIL_BRES_ERR;
VOL32 TRAIL_BRES_INC;
VOL32 TRAIL_BRES_DEC;
VOL32 LEAD_BRES_LNTH;
VOL32 Z_OFF_PITCH;
VOL32 Z_CNTL;
VOL32 ALPHA_TST_CNTL;
VOL32 unused55;
VOL32 SECONDARY_STW_EXP;
VOL32 SECONDARY_S_X_INC;
VOL32 SECONDARY_S_Y_INC;
VOL32 SECONDARY_S_START;
VOL32 SECONDARY_W_X_INC;
VOL32 SECONDARY_W_Y_INC;
VOL32 SECONDARY_W_START;
VOL32 SECONDARY_T_X_INC;
VOL32 SECONDARY_T_Y_INC;
VOL32 SECONDARY_T_START;
VOL32 SRC_OFF_PITCH;
VOL32 SRC_X;
VOL32 SRC_Y;
VOL32 SRC_Y_X;
VOL32 SRC_WIDTH1;
VOL32 SRC_HEIGHT1;
VOL32 SRC_HEIGHT1_WIDTH1;
VOL32 SRC_X_START;
VOL32 SRC_Y_START;
VOL32 SRC_Y_X_START;
VOL32 SRC_WIDTH2;
VOL32 SRC_HEIGHT2;
VOL32 SRC_HEIGHT2_WIDTH2;
VOL32 SRC_CNTL;
VOL32 unused6e;
VOL32 unused6f;
union {
struct {
VOL32 SCALE_OFF; /* 0x70 */
VOL32 unused71;
VOL32 unused72;
VOL32 unused73;
VOL32 unused74;
VOL32 unused75;
VOL32 unused76;
VOL32 SCALE_WIDTH;
VOL32 SCALE_HEIGHT;
VOL32 unused79;
VOL32 unused7a;
VOL32 SCALE_PITCH;
VOL32 SCALE_X_INC;
VOL32 SCALE_Y_INC;
VOL32 SCALE_VACC;
VOL32 SCALE_3D_CNTL; /* 0x7f */
} scaler;
struct {
VOL32 TEX_0_OFF; /* 0x70 */
VOL32 TEX_1_OFF;
VOL32 TEX_2_OFF;
VOL32 TEX_3_OFF;
VOL32 TEX_4_OFF;
VOL32 TEX_5_OFF;
VOL32 TEX_6_OFF;
VOL32 TEX_7_OFF;
VOL32 TEX_8_OFF;
VOL32 TEX_9_OFF;
VOL32 TEX_10_OFF;
VOL32 S_Y_INC;
VOL32 RED_X_INC;
VOL32 GREEN_X_INC; /* 0x7d */
VOL32 unused7e;
VOL32 unused7f;
} texture;
} u;
VOL32 HOST_DATA[16]; /* 0x80 */
VOL32 HOST_CNTL; /* 0x90 */
VOL32 BM_HOSTDATA; /* 0x91 */
VOL32 BM_ADDR; /* 0x92 */
VOL32 BM_GUI_TABLE_CMD; /* 0x93 */
VOL32 unused94; /* 0x94 */
VOL32 unused95; /* 0x95 */
VOL32 unused96; /* 0x96 */
VOL32 FOG_TABLE_INDEX; /* 0x97 */
VOL32 FOG_TABLE_DATA[8]; /* 0x98 */
VOL32 PAT_REG0; /* 0xa0 */
VOL32 PAT_REG1;
VOL32 PAT_CNTL;
VOL32 unused_0a3;
VOL32 unused_0a4;
VOL32 unused_0a5;
VOL32 unused_0a6;
VOL32 unused_0a7;
VOL32 SC_LEFT;
VOL32 SC_RIGHT;
VOL32 SC_LEFT_RIGHT;
VOL32 SC_TOP;
VOL32 SC_BOTTOM;
VOL32 SC_TOP_BOTTOM;
VOL32 USR1_DST_OFF_PITCH;
VOL32 USR2_DST_OFF_PITCH;
VOL32 DP_BKGD_CLR; /* 0xb0 */
VOL32 DP_FRGD_CLR;
VOL32 DP_WRITE_MSK;
VOL32 unused_0b3;
VOL32 DP_PIX_WIDTH;
VOL32 DP_MIX;
VOL32 DP_SRC;
VOL32 DP_FRGD_CLR_MIX;
VOL32 DP_FRGD_BKGD_CLR;
VOL32 unused_0b9;
VOL32 DST_X_Y;
VOL32 DST_WIDTH_HEIGHT;
VOL32 USR_DST_PITCH;
VOL32 unused_0bd;
VOL32 DP_SET_GUI_ENGINE2;
VOL32 DP_SET_GUI_ENGINE;
VOL32 CLR_CMP_CLR; /* 0xc0 */
VOL32 CLR_CMP_MSK;
VOL32 CLR_CMP_CNTL;
VOL32 unused_0c3;
VOL32 FIFO_STAT;
VOL32 unused_0c5;
VOL32 unused_0c6;
VOL32 unused_0c7;
VOL32 unused_0c8;
VOL32 unused_0c9;
VOL32 unused_0ca;
VOL32 unused_0cb;
VOL32 GUI_TRAJ_CNTL;
VOL32 unused_0cd;
VOL32 GUI_STAT;
VOL32 unused_0cf;
VOL32 TEX_PALETTE_INDEX;
VOL32 STW_EXP;
VOL32 LOG_MAX_INC;
VOL32 S_X_INC;
VOL32 S_Y_INC_2_SCALE_PITCH;
VOL32 S_START;
VOL32 W_X_INC;
VOL32 W_Y_INC;
VOL32 W_START;
VOL32 T_X_INC;
VOL32 T_Y_INC_SECONDARY_SCALE_PITCH;
VOL32 T_START;
VOL32 TEX_SIZE_PITCH;
VOL32 TEX_CNTL;
VOL32 SECONDARY_TEX_OFFSET_SECONDARY_SCALE_OFF;
VOL32 TEX_PALETTE;
VOL32 SCALE_PITCH_BOTH; /* 0xe0 */
VOL32 SECONDARY_SCALE_OFF_ACC;
VOL32 SCALE_OFF_ACC;
VOL32 SCALE_DST_Y_X;
VOL32 unused_0e4;
VOL32 unused_0e5;
VOL32 COMPOSITE_SHADOW_ID;
VOL32 SECONDARY_SCALE_X_INC_SPECULAR_RED_X_INC;
VOL32 SPECULAR_RED_Y_INC;
VOL32 SPECULAR_RED_START_SECONDARY_SCALE_HACC;;
VOL32 SPECULAR_GREEN_X_INC;
VOL32 SPECULAR_GREEN_Y_INC;
VOL32 SPECULAR_GREEN_START;
VOL32 SPECULAR_BLUE_X_INC;
VOL32 SPECULAR_BLUE_Y_INC;
VOL32 SPECULAR_BLUE_START;
VOL32 RED_X_INC_SCALE_X_INC;
VOL32 RED_Y_INC;
VOL32 RED_START_SCALE_HACC;
VOL32 GREEN_X_INC_SCALE_Y_INC;
VOL32 GREEN_Y_INC_SECONDARY_SCALE_Y_INC;
VOL32 GREEN_START_SECONDARY_SCALE_VACC;
VOL32 BLUE_X_INC;
VOL32 BLUE_Y_INC;
VOL32 BLUE_START;
VOL32 Z_X_INC;
VOL32 Z_Y_INC;
VOL32 Z_START;
VOL32 ALPHA_X_INC;
VOL32 FOG_X_INC;
VOL32 ALPHA_Y_INC;
VOL32 FOG_Y_INC;
VOL32 ALPHA_START;
VOL32 FOG_START;
VOL32 unused_0ff;
} Reg; /* 0x100 */
#define DST_X_DIR (1 << 0)
#define DST_Y_DIR (1 << 1)
#define DST_Y_MAJOR (1 << 2)
#define DST_X_TILE (1 << 3)
#define DST_Y_TILE (1 << 4)
#define DST_LAST_PEL (1 << 5)
#define DST_POLYGON_EN (1 << 6)
#define DST_24_ROT_EN (1 << 7)
#define DST_24_ROT(n) ((n) << 8)
#define DST_BRES_ZERO (1 << 11)
#define DST_POLYGON_RTEDGE_DIS (1 << 12)
#define TRAIL_X_DIR (1 << 13)
#define TRAP_FILL_DIR (1 << 14)
#define TRAIL_BRES_SIGN (1 << 15)
#define SRC_PATT_EN (1 << 16)
#define SRC_PATT_ROT_EN (1 << 17)
#define SRC_LINEAR_EN (1 << 18)
#define SRC_BYTE_ALIGN (1 << 19)
#define SRC_LINE_X_DIR (1 << 20)
#define SRC_8x8x8_BRUSH (1 << 21)
#define FAST_FILL_EN (1 << 22)
#define SRC_TRACK_DST (1 << 23)
#define PAT_MONO_EN (1 << 24)
#define PAT_CLR_4x2_EN (1 << 25)
#define PAT_CLR_8x1_EN (1 << 26)
#define HOST_BYTE_ALIGN (1 << 28)
#define HOST_BIG_ENDIAN_EN (1 << 29)
/* BUS_CNTL bits */
#define BUS_DBL_RESYNC (1 << 0)
#define BUS_MSTR_RESET (1 << 1)
#define BUS_FLUSH_BUF (1 << 2)
#define BUS_STOP_REQ_DIS (1 << 3)
#define BUS_APER_REG_DIS (1 << 4)
#define BUS_EXTRA_PIPE_DIS (1 << 5)
#define BUS_MASTER_DIS (1 << 6)
#define ROM_WRT_EN (1 << 7)
#define CHIP_HIDDEN_REV (3 << 8)
#define BUS_PCI_READ_RETRY_EN (1 << 13)
#define BUS_PCI_WRT_RETRY_EN (1 << 15)
#define BUS_RETRY_WS (0xf << 16)
#define BUS_MSTR_RD_MULT (1 << 20)
#define BUS_MSTR_RD_LINE (1 << 21)
#define BUS_SUSPEND (1 << 22)
#define LAT16X (1 << 23)
#define BUS_RD_DISCARD_EN (1 << 24)
#define BUS_RD_ABORT_EN (1 << 25)
#define BUS_MSTR_WS (1 << 26)
#define BUS_EXT_REG_EN (1 << 27)
#define BUS_MSTR_DISCONNECT_EN (1 << 28)
#define BUS_WRT_BURST (1 << 29)
#define BUS_READ_BURST (1 << 30)
#define BUS_RDY_READ_DLY (1 << 31)
#define SCALE_PIX_EXPAND (1 << 0)
#define SCALE_Y2R_TEMP (1 << 1)
#define SCALE_HORZ_MODE (1 << 2)
#define SCALE_VERT_MODE (1 << 3)
#define SCALE_SIGNED_UV (1 << 4)
#define SCALE_GAMMA_SEL (3 << 5)
#define SCALE_GAMMA_BRIGHT (0 << 5)
#define SCALE_GAMMA_22 (1 << 5)
#define SCALE_GAMMA_18 (2 << 5)
#define SCALE_GAMMA_14 (3 << 5)
#define SCALE_DISP_SEL (1 << 7)
#define SCALE_BANDWIDTH (1 << 26)
#define SCALE_DIS_LIMIT (1 << 27)
#define SCALE_CLK_FORCE_ON (1 << 29)
#define SCALE_OVERLAY_EN (1 << 30)
#define SCALE_EN (1 << 31)
#define VIDEO_IN_VYUY422 (0xb)
#define VIDEO_IN_YVYU422 (0xc)
#define SCALER_IN_15bpp (0x3 << 16)
#define SCALER_IN_16bpp (0x4 << 16)
#define SCALER_IN_32bpp (0x6 << 16)
#define SCALER_IN_YUV_9 (0x9 << 16)
#define SCALER_IN_YUV_12 (0xa << 16)
#define SCALER_IN_VYUY422 (0xb << 16)
#define SCALER_IN_YVYU422 (0xc << 16)
#define CAP_INPUT_MODE (1 << 0)
#define CAP_BUF_MODE (1 << 2)
#define CAP_START_BUF (1 << 3)
#define CAP_BUF_TYPE_FIELD (0 << 4)
#define CAP_BUF_TYPE_ALTERNATING (1 << 4)
#define CAP_BUF_TYPE_FRAME (2 << 4)
#define OVL_BUF_MODE (1 << 28)
#define OVL_BUF_NEXT (1 << 29)
#define CAP_TRIGGER (3 << 0)
#define OVL_CUR_BUF (1 << 5)
#define OVL_BUF_STATUS (1 << 6)
#define CAP_BUF_STATUS (1 << 7)
#define CAPTURE_EN (1 << 31)
typedef struct _MediaReg {
VOL32 OVERLAY_Y_X_START; /* 0x100 */
VOL32 OVERLAY_Y_X_END;
VOL32 OVERLAY_VIDEO_KEY_CLR;
VOL32 OVERLAY_VIDEO_KEY_MSK;
VOL32 OVERLAY_GRAPHICS_KEY_CLR;
VOL32 OVERLAY_GRAPHICS_KEY_MSK;
VOL32 OVERLAY_KEY_CNTL;
VOL32 unused_107;
VOL32 OVERLAY_SCALE_INC;
VOL32 OVERLAY_SCALE_CNTL;
VOL32 SCALER_HEIGHT_WIDTH;
VOL32 SCALER_TEST;
VOL32 unused_10c;
VOL32 SCALER_BUF0_OFFSET;
VOL32 SCALER_BUF1_OFFSET;
VOL32 SCALER_BUF_PITCH;
VOL32 CAPTURE_START_END; /* 0x110 */
VOL32 CAPTURE_X_WIDTH;
VOL32 VIDEO_FORMAT;
VOL32 VBI_START_END;
VOL32 CAPTURE_CONFIG;
VOL32 TRIG_CNTL;
VOL32 OVERLAY_EXCLUSIVE_HORZ;
VOL32 OVERLAY_EXCLUSIVE_VERT;
VOL32 VBI_WIDTH;
VOL32 CAPTURE_DEBUG;
VOL32 VIDEO_SYNC_TEST;
VOL32 unused_11b;
VOL32 SNAPSHOT_VH_COUNTS;
VOL32 SNAPSHOT_F_COUNT;
VOL32 N_VIF_COUNT;
VOL32 SNAPSHOT_VIF_COUNT;
VOL32 CAPTURE_BUF0_OFFSET; /* 0x120 */
VOL32 CAPTURE_BUF1_OFFSET;
VOL32 ONESHOT_BUF_OFFSET;
VOL32 unused_123;
VOL32 unused_124;
VOL32 unused_125;
VOL32 unused_126;
VOL32 unused_127;
VOL32 unused_128;
VOL32 unused_129;
VOL32 unused_12a;
VOL32 unused_12b;
VOL32 SNAPSHOT2_VH_COUNTS;
VOL32 SNAPSHOT2_F_COUNT;
VOL32 N_VIF2_COUNT;
VOL32 SNAPSHOT2_VIF_COUNT;
VOL32 MPP_CONFIG; /* 0x130 */
VOL32 MPP_STROBE_SEQ;
VOL32 MPP_ADDR;
VOL32 MPP_DATA;
VOL32 unused_134;
VOL32 unused_135;
VOL32 unused_136;
VOL32 unused_137;
VOL32 unused_138;
VOL32 unused_139;
VOL32 unused_13a;
VOL32 unused_13b;
VOL32 unused_13c;
VOL32 unused_13d;
VOL32 unused_13e;
VOL32 unused_13f;
VOL32 TVO_CNTL; /* 0x140 */
VOL32 unused_141[15];
VOL32 unused_150; /* 0x150 */
VOL32 CRT_HORZ_VERT_LOAD; /* 0x151 */
VOL32 AGP_BASE; /* 0x152 */
VOL32 AGP_CNTL; /* 0x153 */
VOL32 SCALER_COLOUR_CNTL; /* 0x154 */
VOL32 SCALER_H_COEFF0; /* 0x155 */
VOL32 SCALER_H_COEFF1; /* 0x156 */
VOL32 SCALER_H_COEFF2; /* 0x157 */
VOL32 SCALER_H_COEFF3; /* 0x158 */
VOL32 SCALER_H_COEFF4; /* 0x159 */
VOL32 unused_15a;
VOL32 unused_15b;
VOL32 GUI_CMDFIFO_DEBUG;
VOL32 GUI_CMDFIFO_DATA;
VOL32 GUI_CNTL;
VOL32 unused_15f;
VOL32 BM_FRAME_BUF_OFFSET; /* 0x160 */
VOL32 BM_SYSTEM_MEM_ADDR;
VOL32 BM_COMMAND;
VOL32 BM_STATUS;
VOL32 unused_164[10];
VOL32 BM_GUI_TABLE;
VOL32 BM_SYSTEM_TABLE;
VOL32 unused_170[5]; /* 0x170 */
VOL32 SCALER_BUF0_OFFSET_U;
VOL32 SCALER_BUF0_OFFSET_V;
VOL32 SCALER_BUF1_OFFSET_U;
VOL32 SCALER_BUF1_OFFSET_V;
VOL32 unused_179[7];
VOL32 unused_180[16]; /* 0x180 */
VOL32 setup_engine[0x40]; /* 0x190 */
VOL32 dvd_subpicture[0x30]; /* 0x1d0 */
} MediaReg;
#define MACH64_XY(x,y) (((x) & 0x7fff) | (((y) & 0x7fff) << 16))
#define MACH64_YX(x,y) (((y) & 0x7fff) | (((x) & 0x7fff) << 16))
typedef struct _mach64Save {
CARD32 LCD_GEN_CTRL;
} Mach64Save;
typedef struct _mach64CardInfo {
VesaCardPrivRec vesa;
CARD8 *reg_base;
Reg *reg;
MediaReg *media_reg;
Mach64Save save;
Bool lcdEnabled;
} Mach64CardInfo;
#define getMach64CardInfo(kd) ((Mach64CardInfo *) ((kd)->card->driver))
#define mach64CardInfo(kd) Mach64CardInfo *mach64c = getMach64CardInfo(kd)
typedef struct _mach64Cursor {
int width, height;
int xhot, yhot;
Bool has_cursor;
CursorPtr pCursor;
Pixel source, mask;
} Mach64Cursor;
#define MACH64_CURSOR_WIDTH 64
#define MACH64_CURSOR_HEIGHT 64
/*
* Xv information, optional
*/
typedef struct _mach64PortPriv {
CARD32 YBuf0Offset;
CARD32 YBuf1Offset;
CARD8 currentBuf;
int brightness;
int saturation;
RegionRec clip;
CARD32 colorKey;
Bool videoOn;
Time offTime;
Time freeTime;
CARD32 size;
CARD32 offset;
KdOffscreenArea *off_screen;
} Mach64PortPrivRec, *Mach64PortPrivPtr;
Bool mach64InitVideo(ScreenPtr pScreen);
void mach64FiniVideo(ScreenPtr pScreen);
/*
* These values are per-format, which is essentially per-depth/per-bpp.
* Because bpp is fixed for the screen by depth, they're computed
* per-screen per-depth.
*/
typedef struct _mach64ScreenInfo {
VesaScreenPrivRec vesa;
Mach64Cursor cursor;
CARD32 colorKey;
KdVideoAdaptorPtr pAdaptor;
KaaScreenInfoRec kaa;
} Mach64ScreenInfo;
#define getMach64ScreenInfo(kd) ((Mach64ScreenInfo *) ((kd)->screen->driver))
#define mach64ScreenInfo(kd) Mach64ScreenInfo *mach64s = getMach64ScreenInfo(kd)
CARD32
mach64ReadLCD (Reg *reg, int id);
void
mach64WriteLCD (Reg *reg, int id, CARD32 data);
void
mach64Preserve (KdCardInfo *card);
Bool
mach64MapReg (KdCardInfo *card, Mach64CardInfo *mach64c);
void
mach64UnmapReg (KdCardInfo *card, Mach64CardInfo *mach64c);
void
mach64SetMMIO (KdCardInfo *card, Mach64CardInfo *mach64c);
void
mach64ResetMMIO (KdCardInfo *card, Mach64CardInfo *mach64c);
Bool
mach64Enable (ScreenPtr pScreen);
void
mach64Disable (ScreenPtr pScreen);
Bool
mach64DPMS (ScreenPtr pScreen, int mode);
void
mach64WaitAvail(Reg *reg, int n);
void
mach64WaitIdle (Reg *reg);
Bool
mach64DrawSetup (ScreenPtr pScreen);
Bool
mach64DrawInit (ScreenPtr pScreen);
void
mach64DrawReinit (ScreenPtr pScreen);
void
mach64DrawEnable (ScreenPtr pScreen);
void
mach64DrawDisable (ScreenPtr pScreen);
void
mach64DrawFini (ScreenPtr pScreen);
CARD8
mach64ReadIndex (Mach64CardInfo *mach64c, CARD16 port, CARD8 index);
void
mach64WriteIndex (Mach64CardInfo *mach64c, CARD16 port, CARD8 index, CARD8 value);
Bool
mach64CursorInit (ScreenPtr pScreen);
void
mach64CursorEnable (ScreenPtr pScreen);
void
mach64CursorDisable (ScreenPtr pScreen);
void
mach64CursorFini (ScreenPtr pScreen);
void
mach64RecolorCursor (ScreenPtr pScreen, int ndef, xColorItem *pdef);
extern KdCardFuncs mach64Funcs;
#endif /* _MACH64_H_ */

View File

@ -1,389 +0,0 @@
/*
* Copyright © 1999 Keith Packard
*
* 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 Keith Packard not be used in
* advertising or publicity pertaining to distribution of the software without
* specific, written prior permission. Keith Packard makes no
* representations about the suitability of this software for any purpose. It
* is provided "as is" without express or implied warranty.
*
* KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL KEITH PACKARD 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.
*/
#ifdef HAVE_CONFIG_H
#include <kdrive-config.h>
#endif
#include "trident.h"
#include "cursorstr.h"
#define SetupCursor(s) KdScreenPriv(s); \
tridentCardInfo(pScreenPriv); \
tridentScreenInfo(pScreenPriv); \
TridentCursor *pCurPriv = &tridents->cursor
static void
_tridentMoveCursor (ScreenPtr pScreen, int x, int y)
{
SetupCursor(pScreen);
CARD8 xlow, xhigh, ylow, yhigh;
CARD8 xoff, yoff;
x -= pCurPriv->xhot;
xoff = 0;
if (x < 0)
{
xoff = -x;
x = 0;
}
y -= pCurPriv->yhot;
yoff = 0;
if (y < 0)
{
yoff = -y;
y = 0;
}
xlow = (CARD8) x;
xhigh = (CARD8) (x >> 8);
ylow = (CARD8) y;
yhigh = (CARD8) (y >> 8);
/* This is the recommended order to move the cursor */
tridentWriteIndex (tridentc, 0x3d4, 0x41, xhigh);
tridentWriteIndex (tridentc, 0x3d4, 0x40, xlow);
tridentWriteIndex (tridentc, 0x3d4, 0x42, ylow);
tridentWriteIndex (tridentc, 0x3d4, 0x46, xoff);
tridentWriteIndex (tridentc, 0x3d4, 0x47, yoff);
tridentWriteIndex (tridentc, 0x3d4, 0x43, yhigh);
}
static void
tridentMoveCursor (ScreenPtr pScreen, int x, int y)
{
SetupCursor (pScreen);
if (!pCurPriv->has_cursor)
return;
if (!pScreenPriv->enabled)
return;
_tridentMoveCursor (pScreen, x, y);
}
static void
tridentAllocCursorColors (ScreenPtr pScreen)
{
SetupCursor (pScreen);
CursorPtr pCursor = pCurPriv->pCursor;
KdAllocateCursorPixels (pScreen, 0, pCursor,
&pCurPriv->source, &pCurPriv->mask);
switch (pScreenPriv->screen->fb[0].bitsPerPixel) {
case 4:
pCurPriv->source |= pCurPriv->source << 4;
pCurPriv->mask |= pCurPriv->mask << 4;
case 8:
pCurPriv->source |= pCurPriv->source << 8;
pCurPriv->mask |= pCurPriv->mask << 8;
case 16:
pCurPriv->source |= pCurPriv->source << 16;
pCurPriv->mask |= pCurPriv->mask << 16;
}
}
static void
tridentSetCursorColors (ScreenPtr pScreen)
{
SetupCursor (pScreen);
CursorPtr pCursor = pCurPriv->pCursor;
CARD32 fg, bg;
fg = pCurPriv->source;
bg = pCurPriv->mask;
tridentWriteIndex (tridentc, 0x3d4, 0x48, fg);
tridentWriteIndex (tridentc, 0x3d4, 0x49, fg >> 8);
tridentWriteIndex (tridentc, 0x3d4, 0x4a, fg >> 16);
tridentWriteIndex (tridentc, 0x3d4, 0x4c, bg);
tridentWriteIndex (tridentc, 0x3d4, 0x4d, bg >> 8);
tridentWriteIndex (tridentc, 0x3d4, 0x4e, bg >> 16);
}
void
tridentRecolorCursor (ScreenPtr pScreen, int ndef, xColorItem *pdef)
{
SetupCursor (pScreen);
CursorPtr pCursor = pCurPriv->pCursor;
xColorItem sourceColor, maskColor;
if (!pCurPriv->has_cursor || !pCursor)
return;
if (!pScreenPriv->enabled)
return;
if (pdef)
{
while (ndef)
{
if (pdef->pixel == pCurPriv->source ||
pdef->pixel == pCurPriv->mask)
break;
ndef--;
}
if (!ndef)
return;
}
tridentAllocCursorColors (pScreen);
tridentSetCursorColors (pScreen);
}
#define InvertBits32(v) { \
v = ((v & 0x55555555) << 1) | ((v >> 1) & 0x55555555); \
v = ((v & 0x33333333) << 2) | ((v >> 2) & 0x33333333); \
v = ((v & 0x0f0f0f0f) << 4) | ((v >> 4) & 0x0f0f0f0f); \
}
static void
tridentLoadCursor (ScreenPtr pScreen, int x, int y)
{
SetupCursor(pScreen);
CursorPtr pCursor = pCurPriv->pCursor;
CursorBitsPtr bits = pCursor->bits;
int w, h;
CARD32 *ram, *msk, *mskLine, *src, *srcLine;
int i, j;
int cursor_address;
int lwsrc;
unsigned char ramdac_control_;
CARD32 offset;
/*
* Allocate new colors
*/
tridentAllocCursorColors (pScreen);
pCurPriv->pCursor = pCursor;
pCurPriv->xhot = pCursor->bits->xhot;
pCurPriv->yhot = pCursor->bits->yhot;
/*
* Stick new image into cursor memory
*/
ram = (CARD32 *) tridents->cursor_base;
mskLine = (CARD32 *) bits->mask;
srcLine = (CARD32 *) bits->source;
h = bits->height;
if (h > TRIDENT_CURSOR_HEIGHT)
h = TRIDENT_CURSOR_HEIGHT;
lwsrc = BitmapBytePad(bits->width) / 4; /* words per line */
for (i = 0; i < TRIDENT_CURSOR_HEIGHT; i++) {
msk = mskLine;
src = srcLine;
mskLine += lwsrc;
srcLine += lwsrc;
for (j = 0; j < TRIDENT_CURSOR_WIDTH / 32; j++) {
CARD32 m, s;
#if 1
if (i < h && j < lwsrc)
{
m = *msk++;
s = *src++;
InvertBits32(m);
InvertBits32(s);
}
else
{
m = 0;
s = 0;
}
#endif
*ram++ = m;
*ram++ = s;
}
}
/* Set address for cursor bits */
offset = tridents->cursor_base - (CARD8 *) tridents->screen;
offset >>= 10;
tridentWriteIndex (tridentc, 0x3d4, 0x44, (CARD8) (offset & 0xff));
tridentWriteIndex (tridentc, 0x3d4, 0x45, (CARD8) (offset >> 8));
/* Set new color */
tridentSetCursorColors (pScreen);
/* Enable the cursor */
tridentWriteIndex (tridentc, 0x3d4, 0x50, 0xc1);
/* Move to new position */
tridentMoveCursor (pScreen, x, y);
}
static void
tridentUnloadCursor (ScreenPtr pScreen)
{
SetupCursor (pScreen);
/* Disable cursor */
tridentWriteIndex (tridentc, 0x3d4, 0x50, 0);
}
static Bool
tridentRealizeCursor (ScreenPtr pScreen, CursorPtr pCursor)
{
SetupCursor(pScreen);
if (!pScreenPriv->enabled)
return TRUE;
/* miRecolorCursor does this */
if (pCurPriv->pCursor == pCursor)
{
if (pCursor)
{
int x, y;
miPointerPosition (&x, &y);
tridentLoadCursor (pScreen, x, y);
}
}
return TRUE;
}
static Bool
tridentUnrealizeCursor (ScreenPtr pScreen, CursorPtr pCursor)
{
return TRUE;
}
static void
tridentSetCursor (ScreenPtr pScreen, CursorPtr pCursor, int x, int y)
{
SetupCursor(pScreen);
pCurPriv->pCursor = pCursor;
if (!pScreenPriv->enabled)
return;
if (pCursor)
tridentLoadCursor (pScreen, x, y);
else
tridentUnloadCursor (pScreen);
}
miPointerSpriteFuncRec tridentPointerSpriteFuncs = {
tridentRealizeCursor,
tridentUnrealizeCursor,
tridentSetCursor,
tridentMoveCursor,
};
static void
tridentQueryBestSize (int class,
unsigned short *pwidth, unsigned short *pheight,
ScreenPtr pScreen)
{
SetupCursor (pScreen);
switch (class)
{
case CursorShape:
if (*pwidth > pCurPriv->width)
*pwidth = pCurPriv->width;
if (*pheight > pCurPriv->height)
*pheight = pCurPriv->height;
if (*pwidth > pScreen->width)
*pwidth = pScreen->width;
if (*pheight > pScreen->height)
*pheight = pScreen->height;
break;
default:
fbQueryBestSize (class, pwidth, pheight, pScreen);
break;
}
}
Bool
tridentCursorInit (ScreenPtr pScreen)
{
SetupCursor (pScreen);
if (!tridents->cursor_base)
{
pCurPriv->has_cursor = FALSE;
return FALSE;
}
pCurPriv->width = TRIDENT_CURSOR_WIDTH;
pCurPriv->height= TRIDENT_CURSOR_HEIGHT;
pScreen->QueryBestSize = tridentQueryBestSize;
miPointerInitialize (pScreen,
&tridentPointerSpriteFuncs,
&kdPointerScreenFuncs,
FALSE);
pCurPriv->has_cursor = TRUE;
pCurPriv->pCursor = NULL;
return TRUE;
}
void
tridentCursorEnable (ScreenPtr pScreen)
{
SetupCursor (pScreen);
if (pCurPriv->has_cursor)
{
if (pCurPriv->pCursor)
{
int x, y;
miPointerPosition (&x, &y);
tridentLoadCursor (pScreen, x, y);
}
else
tridentUnloadCursor (pScreen);
}
}
void
tridentCursorDisable (ScreenPtr pScreen)
{
SetupCursor (pScreen);
if (!pScreenPriv->enabled)
return;
if (pCurPriv->has_cursor)
{
if (pCurPriv->pCursor)
{
tridentUnloadCursor (pScreen);
}
}
}
void
tridentCursorFini (ScreenPtr pScreen)
{
SetupCursor (pScreen);
pCurPriv->pCursor = NULL;
}

View File

@ -1,590 +0,0 @@
/*
* Copyright © 1999 Keith Packard
*
* 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 Keith Packard not be used in
* advertising or publicity pertaining to distribution of the software without
* specific, written prior permission. Keith Packard makes no
* representations about the suitability of this software for any purpose. It
* is provided "as is" without express or implied warranty.
*
* KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL KEITH PACKARD 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.
*/
#ifdef HAVE_CONFIG_H
#include <kdrive-config.h>
#endif
#include "mach64.h"
#include "mach64draw.h"
#include <X11/Xmd.h>
#include "gcstruct.h"
#include "scrnintstr.h"
#include "pixmapstr.h"
#include "regionstr.h"
#include "mistruct.h"
#include "dixfontstr.h"
#include "fb.h"
#include "migc.h"
#include "miline.h"
#include "picturestr.h"
#include "kaa.h"
CARD8 mach64Rop[16] = {
/* GXclear */ 0x01, /* 0 */
/* GXand */ 0x0c, /* src AND dst */
/* GXandReverse */ 0x0d, /* src AND NOT dst */
/* GXcopy */ 0x07, /* src */
/* GXandInverted*/ 0x0e, /* NOT src AND dst */
/* GXnoop */ 0x03, /* dst */
/* GXxor */ 0x05, /* src XOR dst */
/* GXor */ 0x0b, /* src OR dst */
/* GXnor */ 0x0f, /* NOT src AND NOT dst */
/* GXequiv */ 0x06, /* NOT src XOR dst */
/* GXinvert */ 0x00, /* NOT dst */
/* GXorReverse */ 0x0a, /* src OR NOT dst */
/* GXcopyInverted*/ 0x04, /* NOT src */
/* GXorInverted */ 0x09, /* NOT src OR dst */
/* GXnand */ 0x08, /* NOT src OR NOT dst */
/* GXset */ 0x02, /* 1 */
};
#define MACH64_DRAW_COMBO_SOLID 0x1
#define MACH64_DRAW_COMBO_COPY 0x8
#define SYNC_ALWAYS 0
static Reg *reg;
static CARD32 avail;
static CARD32 triple;
#define IDX(reg,n) (&(reg)->n - &(reg)->CRTC_H_TOTAL_DISP)
void
mach64WaitAvail(Reg *reg, int n)
{
if (avail < n)
{
while ((avail = ((reg->GUI_STAT) >> 16) & 0x3ff) < n)
;
}
avail -= n;
}
void
mach64WaitIdle (Reg *reg)
{
while (reg->GUI_STAT & 1)
;
}
#define PIX_FORMAT_MONO 0
#define PIX_FORMAT_PSEUDO_8 2
#define PIX_FORMAT_TRUE_1555 3
#define PIX_FORMAT_TRUE_565 4
#define PIX_FORMAT_TRUE_8888 6
#define PIX_FORMAT_TRUE_332 7
#define PIX_FORMAT_GRAY_8 8
#define PIX_FORMAT_YUV_422 0xb
#define PIX_FORMAT_YUV_444 0xe
#define PIX_FORMAT_TRUE_4444 0xf
typedef struct _mach64AccelReg {
int depth;
int bitsPerPixel;
CARD32 DP_PIX_WIDTH;
CARD32 DP_SET_GUI_ENGINE;
} Mach64AccelReg;
static const Mach64AccelReg mach64AccelReg[] = {
{ 1, 1,
/* DP_PIX_WIDTH */
((PIX_FORMAT_MONO << 0) | /* DP_DST_PIX_WIDTH */
(PIX_FORMAT_MONO << 4) | /* COMPOSITE_PIX_WIDTH */
(PIX_FORMAT_MONO << 8) | /* DP_SRC_PIX_WIDTH */
(0 << 13) | /* DP_HOST_TRIPLE_EN */
(0 << 14) | /* DP_PALETTE_TYPE */
(PIX_FORMAT_MONO << 16) | /* DP_HOST_PIX_WIDTH */
(0 << 20) | /* DP_C14_RGB_INDEX */
(0 << 24) | /* DP_BYTE_PIX_ORDER */
(0 << 25) | /* DP_CONVERSION_TEMP */
(0 << 26) | /* DP_C14_RGB_LOW_NIBBLE */
(0 << 27) | /* DP_C14_RGB_HIGH_NIBBLE */
(PIX_FORMAT_MONO << 28) | /* DP_SCALE_PIX_WIDTH */
0),
/* DP_SET_GUI_ENGINE */
((PIX_FORMAT_MONO << 3) |
(1 << 6) | /* SET_DP_SRC_PIX_WIDTH */
(6 << 7) | /* SET_DST_OFFSET */
(0 << 10) | /* SET_DST_PITCH */
(0 << 14) | /* SET_DST_PITCH_BY_2 */
(0 << 15) | /* SET_SRC_OFFPITCH_COPY */
(0 << 16) | /* SET_SRC_HGTWID1_2 */
(0 << 20) | /* SET_DRAWING_COMBO */
(1 << 24) | /* SET_BUS_MASTER_OP */
(0 << 26) | /* SET_BUS_MASTER_EN */
(0 << 27) | /* SET_BUS_MASTER_SYNC */
(0 << 28) | /* DP_HOST_TRIPLE_EN */
(0 << 29) | /* FAST_FILL_EN */
(0 << 30) | /* BLOCK_WRITE_EN */
0)
},
{ 8, 8,
/* DP_PIX_WIDTH */
((PIX_FORMAT_PSEUDO_8 << 0) | /* DP_DST_PIX_WIDTH */
(PIX_FORMAT_PSEUDO_8 << 4) | /* COMPOSITE_PIX_WIDTH */
(PIX_FORMAT_PSEUDO_8 << 8) | /* DP_SRC_PIX_WIDTH */
(0 << 13) | /* DP_HOST_TRIPLE_EN */
(0 << 14) | /* DP_PALETTE_TYPE */
(PIX_FORMAT_PSEUDO_8 << 16) | /* DP_HOST_PIX_WIDTH */
(0 << 20) | /* DP_C14_RGB_INDEX */
(0 << 24) | /* DP_BYTE_PIX_ORDER */
(0 << 25) | /* DP_CONVERSION_TEMP */
(0 << 26) | /* DP_C14_RGB_LOW_NIBBLE */
(0 << 27) | /* DP_C14_RGB_HIGH_NIBBLE */
(PIX_FORMAT_PSEUDO_8 << 28) | /* DP_SCALE_PIX_WIDTH */
0),
/* DP_SET_GUI_ENGINE */
((PIX_FORMAT_PSEUDO_8 << 3) |
(1 << 6) | /* SET_DP_SRC_PIX_WIDTH */
(6 << 7) | /* SET_DST_OFFSET */
(0 << 10) | /* SET_DST_PITCH */
(0 << 14) | /* SET_DST_PITCH_BY_2 */
(0 << 15) | /* SET_SRC_OFFPITCH_COPY */
(0 << 16) | /* SET_SRC_HGTWID1_2 */
(0 << 20) | /* SET_DRAWING_COMBO */
(1 << 24) | /* SET_BUS_MASTER_OP */
(0 << 26) | /* SET_BUS_MASTER_EN */
(0 << 27) | /* SET_BUS_MASTER_SYNC */
(0 << 28) | /* DP_HOST_TRIPLE_EN */
(0 << 29) | /* FAST_FILL_EN */
(0 << 30) | /* BLOCK_WRITE_EN */
0)
},
{ 15, 16,
/* DP_PIX_WIDTH */
((PIX_FORMAT_TRUE_1555 << 0) | /* DP_DST_PIX_WIDTH */
(PIX_FORMAT_TRUE_1555 << 4) | /* COMPOSITE_PIX_WIDTH */
(PIX_FORMAT_TRUE_1555 << 8) | /* DP_SRC_PIX_WIDTH */
(0 << 13) | /* DP_HOST_TRIPLE_EN */
(0 << 14) | /* DP_PALETTE_TYPE */
(PIX_FORMAT_TRUE_1555 << 16) | /* DP_HOST_PIX_WIDTH */
(0 << 20) | /* DP_C14_RGB_INDEX */
(0 << 24) | /* DP_BYTE_PIX_ORDER */
(0 << 25) | /* DP_CONVERSION_TEMP */
(0 << 26) | /* DP_C14_RGB_LOW_NIBBLE */
(0 << 27) | /* DP_C14_RGB_HIGH_NIBBLE */
(PIX_FORMAT_TRUE_1555 << 28) | /* DP_SCALE_PIX_WIDTH */
0),
/* DP_SET_GUI_ENGINE */
((PIX_FORMAT_TRUE_1555 << 3) |
(1 << 6) | /* SET_DP_SRC_PIX_WIDTH */
(6 << 7) | /* SET_DST_OFFSET */
(0 << 10) | /* SET_DST_PITCH */
(0 << 14) | /* SET_DST_PITCH_BY_2 */
(0 << 15) | /* SET_SRC_OFFPITCH_COPY */
(0 << 16) | /* SET_SRC_HGTWID1_2 */
(0 << 20) | /* SET_DRAWING_COMBO */
(1 << 24) | /* SET_BUS_MASTER_OP */
(0 << 26) | /* SET_BUS_MASTER_EN */
(0 << 27) | /* SET_BUS_MASTER_SYNC */
(0 << 28) | /* DP_HOST_TRIPLE_EN */
(0 << 29) | /* FAST_FILL_EN */
(0 << 30) | /* BLOCK_WRITE_EN */
0)
},
{ 16, 16,
/* DP_PIX_WIDTH */
((PIX_FORMAT_TRUE_565 << 0) | /* DP_DST_PIX_WIDTH */
(PIX_FORMAT_TRUE_565 << 4) | /* COMPOSITE_PIX_WIDTH */
(PIX_FORMAT_TRUE_565 << 8) | /* DP_SRC_PIX_WIDTH */
(0 << 13) | /* DP_HOST_TRIPLE_EN */
(0 << 14) | /* DP_PALETTE_TYPE */
(PIX_FORMAT_TRUE_565 << 16) | /* DP_HOST_PIX_WIDTH */
(0 << 20) | /* DP_C14_RGB_INDEX */
(0 << 24) | /* DP_BYTE_PIX_ORDER */
(0 << 25) | /* DP_CONVERSION_TEMP */
(0 << 26) | /* DP_C14_RGB_LOW_NIBBLE */
(0 << 27) | /* DP_C14_RGB_HIGH_NIBBLE */
(PIX_FORMAT_TRUE_565 << 28) | /* DP_SCALE_PIX_WIDTH */
0),
/* DP_SET_GUI_ENGINE */
((PIX_FORMAT_TRUE_565 << 3) |
(1 << 6) | /* SET_DP_SRC_PIX_WIDTH */
(6 << 7) | /* SET_DST_OFFSET */
(0 << 10) | /* SET_DST_PITCH */
(0 << 14) | /* SET_DST_PITCH_BY_2 */
(0 << 15) | /* SET_SRC_OFFPITCH_COPY */
(0 << 16) | /* SET_SRC_HGTWID1_2 */
(0 << 20) | /* SET_DRAWING_COMBO */
(1 << 24) | /* SET_BUS_MASTER_OP */
(0 << 26) | /* SET_BUS_MASTER_EN */
(0 << 27) | /* SET_BUS_MASTER_SYNC */
(0 << 28) | /* DP_HOST_TRIPLE_EN */
(0 << 29) | /* FAST_FILL_EN */
(0 << 30) | /* BLOCK_WRITE_EN */
0)
},
{ 24, 24,
/* DP_PIX_WIDTH */
((PIX_FORMAT_PSEUDO_8 << 0) | /* DP_DST_PIX_WIDTH */
(PIX_FORMAT_PSEUDO_8 << 4) | /* COMPOSITE_PIX_WIDTH */
(PIX_FORMAT_PSEUDO_8 << 8) | /* DP_SRC_PIX_WIDTH */
(0 << 13) | /* DP_HOST_TRIPLE_EN */
(0 << 14) | /* DP_PALETTE_TYPE */
(PIX_FORMAT_PSEUDO_8 << 16) | /* DP_HOST_PIX_WIDTH */
(0 << 20) | /* DP_C14_RGB_INDEX */
(0 << 24) | /* DP_BYTE_PIX_ORDER */
(0 << 25) | /* DP_CONVERSION_TEMP */
(0 << 26) | /* DP_C14_RGB_LOW_NIBBLE */
(0 << 27) | /* DP_C14_RGB_HIGH_NIBBLE */
(PIX_FORMAT_PSEUDO_8 << 28) | /* DP_SCALE_PIX_WIDTH */
0),
/* DP_SET_GUI_ENGINE */
((PIX_FORMAT_PSEUDO_8 << 3) |
(1 << 6) | /* SET_DP_SRC_PIX_WIDTH */
(6 << 7) | /* SET_DST_OFFSET */
(0 << 10) | /* SET_DST_PITCH */
(0 << 14) | /* SET_DST_PITCH_BY_2 */
(0 << 15) | /* SET_SRC_OFFPITCH_COPY */
(0 << 16) | /* SET_SRC_HGTWID1_2 */
(0 << 20) | /* SET_DRAWING_COMBO */
(1 << 24) | /* SET_BUS_MASTER_OP */
(0 << 26) | /* SET_BUS_MASTER_EN */
(0 << 27) | /* SET_BUS_MASTER_SYNC */
(0 << 28) | /* DP_HOST_TRIPLE_EN */
(0 << 29) | /* FAST_FILL_EN */
(0 << 30) | /* BLOCK_WRITE_EN */
0)
},
{ 24, 32,
/* DP_PIX_WIDTH */
((PIX_FORMAT_TRUE_8888 << 0) | /* DP_DST_PIX_WIDTH */
(PIX_FORMAT_TRUE_8888 << 4) | /* COMPOSITE_PIX_WIDTH */
(PIX_FORMAT_TRUE_8888 << 8) | /* DP_SRC_PIX_WIDTH */
(0 << 13) | /* DP_HOST_TRIPLE_EN */
(0 << 14) | /* DP_PALETTE_TYPE */
(PIX_FORMAT_TRUE_8888 << 16) | /* DP_HOST_PIX_WIDTH */
(0 << 20) | /* DP_C14_RGB_INDEX */
(0 << 24) | /* DP_BYTE_PIX_ORDER */
(0 << 25) | /* DP_CONVERSION_TEMP */
(0 << 26) | /* DP_C14_RGB_LOW_NIBBLE */
(0 << 27) | /* DP_C14_RGB_HIGH_NIBBLE */
(PIX_FORMAT_TRUE_8888 << 28) | /* DP_SCALE_PIX_WIDTH */
0),
/* DP_SET_GUI_ENGINE */
((PIX_FORMAT_TRUE_8888 << 3) |
(1 << 6) | /* SET_DP_SRC_PIX_WIDTH */
(6 << 7) | /* SET_DST_OFFSET */
(0 << 10) | /* SET_DST_PITCH */
(0 << 14) | /* SET_DST_PITCH_BY_2 */
(0 << 15) | /* SET_SRC_OFFPITCH_COPY */
(0 << 16) | /* SET_SRC_HGTWID1_2 */
(0 << 20) | /* SET_DRAWING_COMBO */
(1 << 24) | /* SET_BUS_MASTER_OP */
(0 << 26) | /* SET_BUS_MASTER_EN */
(0 << 27) | /* SET_BUS_MASTER_SYNC */
(0 << 28) | /* DP_HOST_TRIPLE_EN */
(0 << 29) | /* FAST_FILL_EN */
(0 << 30) | /* BLOCK_WRITE_EN */
0)
},
{ 32, 32,
/* DP_PIX_WIDTH */
((PIX_FORMAT_TRUE_8888 << 0) | /* DP_DST_PIX_WIDTH */
(PIX_FORMAT_TRUE_8888 << 4) | /* COMPOSITE_PIX_WIDTH */
(PIX_FORMAT_TRUE_8888 << 8) | /* DP_SRC_PIX_WIDTH */
(0 << 13) | /* DP_HOST_TRIPLE_EN */
(0 << 14) | /* DP_PALETTE_TYPE */
(PIX_FORMAT_TRUE_8888 << 16) | /* DP_HOST_PIX_WIDTH */
(0 << 20) | /* DP_C14_RGB_INDEX */
(0 << 24) | /* DP_BYTE_PIX_ORDER */
(0 << 25) | /* DP_CONVERSION_TEMP */
(0 << 26) | /* DP_C14_RGB_LOW_NIBBLE */
(0 << 27) | /* DP_C14_RGB_HIGH_NIBBLE */
(PIX_FORMAT_TRUE_8888 << 28) | /* DP_SCALE_PIX_WIDTH */
0),
/* DP_SET_GUI_ENGINE */
((PIX_FORMAT_TRUE_8888 << 3) |
(1 << 6) | /* SET_DP_SRC_PIX_WIDTH */
(6 << 7) | /* SET_DST_OFFSET */
(0 << 10) | /* SET_DST_PITCH */
(0 << 14) | /* SET_DST_PITCH_BY_2 */
(0 << 15) | /* SET_SRC_OFFPITCH_COPY */
(0 << 16) | /* SET_SRC_HGTWID1_2 */
(0 << 20) | /* SET_DRAWING_COMBO */
(1 << 24) | /* SET_BUS_MASTER_OP */
(0 << 26) | /* SET_BUS_MASTER_EN */
(0 << 27) | /* SET_BUS_MASTER_SYNC */
(0 << 28) | /* DP_HOST_TRIPLE_EN */
(0 << 29) | /* FAST_FILL_EN */
(0 << 30) | /* BLOCK_WRITE_EN */
0)
}
};
#define NACCELREG (sizeof mach64AccelReg / sizeof mach64AccelReg[0])
static void
mach64WaitMarker (ScreenPtr pScreen, int marker)
{
KdScreenPriv(pScreen);
mach64CardInfo(pScreenPriv);
reg = mach64c->reg;
mach64WaitIdle (reg);
}
static Bool
mach64Setup (PixmapPtr pDst, PixmapPtr pSrc, CARD32 combo, int wait)
{
ScreenPtr pScreen = pDst->drawable.pScreen;
KdScreenPriv(pScreen);
mach64CardInfo(pScreenPriv);
CARD32 DST_PITCH;
CARD32 DST_OFFSET;
CARD32 SRC_PITCH;
CARD32 SRC_OFFSET;
CARD32 DP_PIX_WIDTH;
CARD32 DP_SET_GUI_ENGINE;
int i;
for (i = 0; i < NACCELREG; i++)
if (mach64AccelReg[i].depth == pDst->drawable.depth &&
mach64AccelReg[i].bitsPerPixel == pDst->drawable.bitsPerPixel)
break;
if (i == NACCELREG)
return FALSE;
DP_PIX_WIDTH = mach64AccelReg[i].DP_PIX_WIDTH;
DP_SET_GUI_ENGINE = mach64AccelReg[i].DP_SET_GUI_ENGINE;
reg = mach64c->reg;
if (!reg)
return FALSE;
triple = (pDst->drawable.bitsPerPixel == 24);
if (triple)
{
/* bytes / 8 = bytes >> 3 */
DST_PITCH = pDst->devKind >> 3;
}
else
{
/* pixels / 8 = ((bytes * 8) / bpp) / 8 = bytes / bpp */
DST_PITCH = pDst->devKind / pDst->drawable.bitsPerPixel;
}
/* bytes / 8 */
DST_OFFSET = ((CARD8 *) pDst->devPrivate.ptr - pScreenPriv->screen->memory_base) >> 3;
mach64WaitAvail(reg, wait + (pSrc ? 5 : 4));
reg->DP_SET_GUI_ENGINE = DP_SET_GUI_ENGINE | (combo << 20);
reg->DP_PIX_WIDTH = DP_PIX_WIDTH;
reg->DST_OFF_PITCH = ((DST_OFFSET << 0) | /* USR1_DST_OFFSET */
(DST_PITCH << 22) | /* USR1_DST_PITCH */
0);
if (pSrc)
{
if (triple)
{
SRC_PITCH = pSrc->devKind >> 3;
}
else
{
/* pixels / 8 = ((bytes * 8) / bpp) / 8 = bytes / bpp */
SRC_PITCH = pSrc->devKind / pSrc->drawable.bitsPerPixel;
}
/* bytes / 8 */
SRC_OFFSET = ((CARD8 *) pSrc->devPrivate.ptr - pScreenPriv->screen->memory_base) >> 3;
reg->SRC_OFF_PITCH = ((SRC_OFFSET << 0) |
(SRC_PITCH << 22) |
0);
}
return TRUE;
}
static Bool
mach64PrepareSolid (PixmapPtr pPixmap,
int alu,
Pixel pm,
Pixel fg)
{
if (!mach64Setup (pPixmap, 0, 1, 3))
return FALSE;
reg->DP_MIX = (mach64Rop[alu] << 16) | 0;
reg->DP_WRITE_MSK = pm;
reg->DP_FRGD_CLR = fg;
return TRUE;
}
static void
mach64Solid (int x1, int y1, int x2, int y2)
{
if (triple)
{
CARD32 traj;
x1 *= 3;
x2 *= 3;
traj = (DST_X_DIR |
DST_Y_DIR |
DST_24_ROT_EN |
DST_24_ROT((x1 / 4) % 6));
mach64WaitAvail (reg, 1);
reg->GUI_TRAJ_CNTL = traj;
}
mach64WaitAvail(reg,2);
reg->DST_X_Y = MACH64_XY(x1,y1);
reg->DST_WIDTH_HEIGHT = MACH64_XY(x2-x1,y2-y1);
}
static void
mach64DoneSolid (void)
{
#if SYNC_ALWAYS
mach64WaitIdle (reg);
#endif
}
static int copyDx;
static int copyDy;
static CARD32 copyCombo;
static Bool
mach64PrepareCopy (PixmapPtr pSrcPixmap,
PixmapPtr pDstPixmap,
int dx,
int dy,
int alu,
Pixel pm)
{
copyCombo = 8 | 2 | 1;
copyDx = dx;
copyDy = dy;
/*
* Avoid going backwards when copying pixmaps to the screen.
* This should reduce tearing somewhat
*/
if (pSrcPixmap == pDstPixmap)
{
if (dx <= 0)
copyCombo &= ~1;
if (dy <= 0)
copyCombo &= ~2;
}
if (!mach64Setup (pDstPixmap, pSrcPixmap, copyCombo, 2))
return FALSE;
reg->DP_MIX = (mach64Rop[alu] << 16) | 0;
reg->DP_WRITE_MSK = pm;
return TRUE;
}
static void
mach64Copy (int srcX,
int srcY,
int dstX,
int dstY,
int w,
int h)
{
if (triple)
{
CARD32 traj;
srcX *= 3;
dstX *= 3;
w *= 3;
traj = DST_24_ROT_EN | DST_24_ROT((dstX / 4) % 6);
if (copyCombo & 1)
traj |= 1;
if (copyCombo & 2)
traj |= 2;
mach64WaitAvail (reg, 1);
reg->GUI_TRAJ_CNTL = traj;
}
if ((copyCombo & 1) == 0)
{
srcX += w - 1;
dstX += w - 1;
}
if ((copyCombo & 2) == 0)
{
srcY += h - 1;
dstY += h - 1;
}
mach64WaitAvail (reg, 4);
reg->SRC_Y_X = MACH64_YX(srcX, srcY);
reg->SRC_WIDTH1 = w;
reg->DST_Y_X = MACH64_YX(dstX, dstY);
reg->DST_HEIGHT_WIDTH = MACH64_YX(w,h);
}
static void
mach64DoneCopy (void)
{
#if SYNC_ALWAYS
mach64WaitIdle (reg);
#endif
}
Bool
mach64DrawInit (ScreenPtr pScreen)
{
KdScreenPriv(pScreen);
mach64ScreenInfo(pScreenPriv);
memset(&mach64s->kaa, 0, sizeof(KaaScreenInfoRec));
mach64s->kaa.waitMarker = mach64WaitMarker;
mach64s->kaa.PrepareSolid = mach64PrepareSolid;
mach64s->kaa.Solid = mach64Solid;
mach64s->kaa.DoneSolid = mach64DoneSolid;
mach64s->kaa.PrepareCopy = mach64PrepareCopy;
mach64s->kaa.Copy = mach64Copy;
mach64s->kaa.DoneCopy = mach64DoneCopy;
mach64s->kaa.offsetAlign = 64;
mach64s->kaa.pitchAlign = 64;
mach64s->kaa.flags = KAA_OFFSCREEN_PIXMAPS;
if (pScreenPriv->screen->fb[0].depth == 4)
return FALSE;
if (!kaaDrawInit (pScreen, &mach64s->kaa))
return FALSE;
return TRUE;
}
void
mach64DrawEnable (ScreenPtr pScreen)
{
kaaMarkSync (pScreen);
}
void
mach64DrawDisable (ScreenPtr pScreen)
{
}
void
mach64DrawFini (ScreenPtr pScreen)
{
kaaDrawFini (pScreen);
}

View File

@ -1,69 +0,0 @@
/*
* Copyright © 1999 Keith Packard
*
* 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 Keith Packard not be used in
* advertising or publicity pertaining to distribution of the software without
* specific, written prior permission. Keith Packard makes no
* representations about the suitability of this software for any purpose. It
* is provided "as is" without express or implied warranty.
*
* KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL KEITH PACKARD 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.
*/
#ifndef _TRIDENTDRAW_H_
#define _TRIDENTDRAW_H_
#define SetupTrident(s) KdScreenPriv(s); \
tridentCardInfo(pScreenPriv); \
Cop *cop = tridentc->cop
#define TridentAlpha (COP_MULTI_ALPHA|COP_ALPHA_WRITE_ENABLE)
#define _tridentInit(cop,tridentc) { \
if ((cop)->status == 0xffffffff) tridentSetMMIO(tridentc); \
(cop)->multi = (tridentc)->cop_depth; \
(cop)->multi = (tridentc)->cop_stride; \
(cop)->multi = TridentAlpha; \
} \
#define _tridentSetSolidRect(cop,pix,alu,cmd) {\
cop->multi = COP_MULTI_PATTERN; \
cop->multi = COP_MULTI_ROP | tridentRop[alu]; \
cop->fg = (pix); \
cmd = COP_OP_BLT | COP_SCL_OPAQUE | COP_OP_ROP | COP_OP_FG; \
}
#define _tridentRect(cop,x1,y1,x2,y2,cmd) { \
(cop)->dst_start_xy = TRI_XY (x1,y1); \
(cop)->dst_end_xy = TRI_XY(x2,y2); \
_tridentWaitDone(cop); \
(cop)->command = (cmd); \
}
#define COP_STATUS_BUSY (COP_STATUS_BE_BUSY | \
COP_STATUS_DPE_BUSY | \
COP_STATUS_MI_BUSY)
#define _tridentWaitDone(cop) { \
int __q__ = 500000; \
while (__q__-- && (cop)->status & COP_STATUS_BUSY) \
; \
if (!__q__) \
(cop)->status = 0; \
}
#define _tridentWaitIdleEmpty(cop) _tridentWaitDone(cop)
#define sourceInvarient(alu) (((alu) & 3) == (((alu) >> 2) & 3))
#endif

View File

@ -1,75 +0,0 @@
/*
* Copyright 1999 SuSE, Inc.
*
* 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 SuSE not be used in advertising or
* publicity pertaining to distribution of the software without specific,
* written prior permission. SuSE makes no representations about the
* suitability of this software for any purpose. It is provided "as is"
* without express or implied warranty.
*
* SuSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL SuSE
* 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.
*
* Author: Keith Packard, SuSE, Inc.
*/
#ifdef HAVE_CONFIG_H
#include <kdrive-config.h>
#endif
#include "mach64.h"
#include <klinux.h>
void
InitCard (char *name)
{
KdCardAttr attr;
if (LinuxFindPci (0x1002, 0x4750, 0, &attr))
KdCardInfoAdd (&mach64Funcs, &attr, 0);
else if (LinuxFindPci (0x1002, 0x4c42, 0, &attr))
KdCardInfoAdd (&mach64Funcs, &attr, 0);
else if (LinuxFindPci (0x1002, 0x4c46, 0, &attr))
KdCardInfoAdd (&mach64Funcs, &attr, 0);
else if (LinuxFindPci (0x1002, 0x4c49, 0, &attr))
KdCardInfoAdd (&mach64Funcs, &attr, 0);
else if (LinuxFindPci (0x1002, 0x4c4d, 0, &attr))
KdCardInfoAdd (&mach64Funcs, &attr, 0);
}
void
InitOutput (ScreenInfo *pScreenInfo, int argc, char **argv)
{
KdInitOutput (pScreenInfo, argc, argv);
}
void
InitInput (int argc, char **argv)
{
KdOsAddInputDrivers ();
KdInitInput ();
}
void
ddxUseMsg (void)
{
KdUseMsg();
vesaUseMsg();
}
int
ddxProcessArgument (int argc, char **argv, int i)
{
int ret;
if (!(ret = vesaProcessArgument (argc, argv, i)))
ret = KdProcessArgument(argc, argv, i);
return ret;
}

View File

@ -1,994 +0,0 @@
/*
* Copyright © 2001 Keith Packard
*
* 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 Keith Packard not be used in
* advertising or publicity pertaining to distribution of the software without
* specific, written prior permission. Keith Packard makes no
* representations about the suitability of this software for any purpose. It
* is provided "as is" without express or implied warranty.
*
* KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL KEITH PACKARD 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.
*/
#ifdef HAVE_CONFIG_H
#include <kdrive-config.h>
#endif
#include "mach64.h"
#include <X11/extensions/Xv.h>
#include "fourcc.h"
#define MAKE_ATOM(a) MakeAtom(a, sizeof(a) - 1, TRUE)
static Atom xvBrightness, xvSaturation, xvColorKey;
#define IMAGE_MAX_WIDTH 720
#define IMAGE_MAX_HEIGHT 576
static void
mach64StopVideo(KdScreenInfo *screen, pointer data, Bool exit)
{
ScreenPtr pScreen = screen->pScreen;
KdScreenPriv(pScreen);
KdCardInfo *card = pScreenPriv->card;
Mach64ScreenInfo *mach64s = (Mach64ScreenInfo *) screen->driver;
Mach64CardInfo *mach64c = (Mach64CardInfo *) card->driver;
Mach64PortPrivPtr pPortPriv = mach64s->pAdaptor->pPortPrivates[0].ptr;
Reg *reg = mach64c->reg;
MediaReg *media = mach64c->media_reg;
REGION_EMPTY(screen->pScreen, &pPortPriv->clip);
if (!media)
return;
if(pPortPriv->videoOn)
{
mach64WaitIdle (reg);
/* wait for buffer to be displayed */
while (((media->TRIG_CNTL >> 5) & 1) != pPortPriv->currentBuf)
;
/* wait for buffer to be finished */
while (((media->TRIG_CNTL >> 6) & 1) != 0)
;
mach64WaitAvail (reg, 1);
media->OVERLAY_SCALE_CNTL = 0;
pPortPriv->videoOn = FALSE;
mach64WaitIdle (reg);
}
if (pPortPriv->off_screen)
{
KdOffscreenFree (pScreen, pPortPriv->off_screen);
pPortPriv->off_screen = 0;
}
}
static int
mach64SetPortAttribute(KdScreenInfo *screen,
Atom attribute,
int value,
pointer data)
{
Mach64ScreenInfo *mach64s = (Mach64ScreenInfo *) screen->driver;
Mach64PortPrivPtr pPortPriv = mach64s->pAdaptor->pPortPrivates[0].ptr;
if(attribute == xvBrightness)
{
if(value < -1000)
value = -1000;
if (value > 1000)
value = 1000;
pPortPriv->brightness = value;
}
else if(attribute == xvSaturation)
{
if (value < -1000)
value = -1000;
if (value > 1000)
value = 1000;
pPortPriv->saturation = value;
}
else if(attribute == xvColorKey)
{
if (pPortPriv->colorKey != value)
{
pPortPriv->colorKey = value;
REGION_EMPTY(screen->pScreen, &pPortPriv->clip);
}
}
else
return BadMatch;
return Success;
}
static int
mach64GetPortAttribute(KdScreenInfo *screen,
Atom attribute,
int *value,
pointer data)
{
Mach64PortPrivPtr pPortPriv = (Mach64PortPrivPtr)data;
if(attribute == xvBrightness)
*value = pPortPriv->brightness;
else if(attribute == xvSaturation)
*value = pPortPriv->saturation;
else if(attribute == xvColorKey)
*value = pPortPriv->colorKey;
else
return BadMatch;
return Success;
}
static void
mach64QueryBestSize(KdScreenInfo *screen,
Bool motion,
short vid_w,
short vid_h,
short drw_w,
short drw_h,
unsigned int *p_w,
unsigned int *p_h,
pointer data)
{
*p_w = drw_w;
*p_h = drw_h;
}
static void
mach64CopyPackedData(KdScreenInfo *screen,
unsigned char *buf,
int randr,
int srcPitch,
int dstPitch,
int srcW,
int srcH,
int top,
int left,
int h,
int w)
{
Mach64ScreenInfo *mach64s = (Mach64ScreenInfo *) screen->driver;
Mach64PortPrivPtr pPortPriv = mach64s->pAdaptor->pPortPrivates[0].ptr;
CARD8 *src = buf, *dst;
int srcDown = srcPitch, srcRight = 2, srcNext;
int p;
switch (randr & RR_Rotate_All) {
case RR_Rotate_0:
src = buf;
srcDown = srcPitch;
srcRight = 2;
break;
case RR_Rotate_90:
src = buf + (srcH - 1) * 2;
srcDown = -2;
srcRight = srcPitch;
break;
case RR_Rotate_180:
src = buf + srcPitch * (srcH - 1) + (srcW - 1) * 2;
srcDown = -srcPitch;
srcRight = -2;
break;
case RR_Rotate_270:
src = buf + srcPitch * (srcW - 1);
srcDown = 2;
srcRight = -srcPitch;
break;
}
src = src + top*srcDown + left*srcRight;
if (pPortPriv->currentBuf == 0)
dst = (CARD8 *) mach64s->vesa.fb + pPortPriv->YBuf0Offset;
else
dst = (CARD8 *) mach64s->vesa.fb + pPortPriv->YBuf1Offset;
w >>= 1;
srcRight >>= 1;
srcNext = srcRight >> 1;
while(h--)
{
CARD16 *s = (CARD16 *) src;
CARD32 *d = (CARD32 *) dst;
p = w;
while (p--)
{
*d++ = s[0] | (s[srcNext] << 16);
s += srcRight;
}
src += srcPitch;
dst += dstPitch;
}
}
static void
mach64CopyPlanarData(KdScreenInfo *screen,
unsigned char *buf,
int randr,
int srcPitch,
int srcPitch2,
int dstPitch, /* of chroma */
int srcW,
int srcH,
int height,
int top,
int left,
int h,
int w,
int id)
{
Mach64ScreenInfo *mach64s = (Mach64ScreenInfo *) screen->driver;
Mach64PortPrivPtr pPortPriv = mach64s->pAdaptor->pPortPrivates[0].ptr;
int i, j;
CARD8 *src1, *src2, *src3, *dst1;
int srcDown = srcPitch, srcDown2 = srcPitch2;
int srcRight = 2, srcRight2 = 1, srcNext = 1;
/* compute source data pointers */
src1 = buf;
src2 = src1 + height * srcPitch;
src3 = src2 + (height >> 1) * srcPitch2;
switch (randr & RR_Rotate_All) {
case RR_Rotate_0:
srcDown = srcPitch;
srcDown2 = srcPitch2;
srcRight = 2;
srcRight2 = 1;
srcNext = 1;
break;
case RR_Rotate_90:
src1 = src1 + srcH - 1;
src2 = src2 + (srcH >> 1) - 1;
src3 = src3 + (srcH >> 1) - 1;
srcDown = -1;
srcDown2 = -1;
srcRight = srcPitch * 2;
srcRight2 = srcPitch2;
srcNext = srcPitch;
break;
case RR_Rotate_180:
src1 = src1 + srcPitch * (srcH - 1) + (srcW - 1);
src2 = src2 + srcPitch2 * ((srcH >> 1) - 1) + ((srcW >> 1) - 1);
src3 = src3 + srcPitch2 * ((srcH >> 1) - 1) + ((srcW >> 1) - 1);
srcDown = -srcPitch;
srcDown2 = -srcPitch2;
srcRight = -2;
srcRight2 = -1;
srcNext = -1;
break;
case RR_Rotate_270:
src1 = src1 + srcPitch * (srcW - 1);
src2 = src2 + srcPitch2 * ((srcW >> 1) - 1);
src3 = src3 + srcPitch2 * ((srcW >> 1) - 1);
srcDown = 1;
srcDown2 = 1;
srcRight = -srcPitch * 2;
srcRight2 = -srcPitch2;
srcNext = -srcPitch;
break;
}
/* adjust for origin */
src1 += top * srcDown + left * srcNext;
src2 += (top >> 1) * srcDown2 + (left >> 1) * srcRight2;
src3 += (top >> 1) * srcDown2 + (left >> 1) * srcRight2;
if (id == FOURCC_I420)
{
CARD8 *srct = src2;
src2 = src3;
src3 = srct;
}
if (pPortPriv->currentBuf == 0)
dst1 = (CARD8 *) mach64s->vesa.fb + pPortPriv->YBuf0Offset;
else
dst1 = (CARD8 *) mach64s->vesa.fb + pPortPriv->YBuf1Offset;
w >>= 1;
for (j = 0; j < h; j++)
{
CARD32 *dst = (CARD32 *) dst1;
CARD8 *s1l = src1;
CARD8 *s1r = src1 + srcNext;
CARD8 *s2 = src2;
CARD8 *s3 = src3;
for (i = 0; i < w; i++)
{
*dst++ = *s1l | (*s1r << 16) | (*s3 << 8) | (*s2 << 24);
s1l += srcRight;
s1r += srcRight;
s2 += srcRight2;
s3 += srcRight2;
}
src1 += srcDown;
dst1 += dstPitch;
if (j & 1)
{
src2 += srcDown2;
src3 += srcDown2;
}
}
}
/* Mach64ClipVideo -
Takes the dst box in standard X BoxRec form (top and left
edges inclusive, bottom and right exclusive). The new dst
box is returned. The source boundaries are given (x1, y1
inclusive, x2, y2 exclusive) and returned are the new source
boundaries in 16.16 fixed point.
*/
static void
Mach64ClipVideo(BoxPtr dst,
INT32 *x1,
INT32 *x2,
INT32 *y1,
INT32 *y2,
BoxPtr extents, /* extents of the clip region */
INT32 width,
INT32 height)
{
INT32 vscale, hscale, delta;
int diff;
hscale = ((*x2 - *x1) << 16) / (dst->x2 - dst->x1);
vscale = ((*y2 - *y1) << 16) / (dst->y2 - dst->y1);
*x1 <<= 16; *x2 <<= 16;
*y1 <<= 16; *y2 <<= 16;
diff = extents->x1 - dst->x1;
if(diff > 0) {
dst->x1 = extents->x1;
*x1 += diff * hscale;
}
diff = dst->x2 - extents->x2;
if(diff > 0) {
dst->x2 = extents->x2;
*x2 -= diff * hscale;
}
diff = extents->y1 - dst->y1;
if(diff > 0) {
dst->y1 = extents->y1;
*y1 += diff * vscale;
}
diff = dst->y2 - extents->y2;
if(diff > 0) {
dst->y2 = extents->y2;
*y2 -= diff * vscale;
}
if(*x1 < 0) {
diff = (- *x1 + hscale - 1)/ hscale;
dst->x1 += diff;
*x1 += diff * hscale;
}
delta = *x2 - (width << 16);
if(delta > 0) {
diff = (delta + hscale - 1)/ hscale;
dst->x2 -= diff;
*x2 -= diff * hscale;
}
if(*y1 < 0) {
diff = (- *y1 + vscale - 1)/ vscale;
dst->y1 += diff;
*y1 += diff * vscale;
}
delta = *y2 - (height << 16);
if(delta > 0) {
diff = (delta + vscale - 1)/ vscale;
dst->y2 -= diff;
*y2 -= diff * vscale;
}
}
static void
mach64DisplayVideo(KdScreenInfo *screen,
int id,
int dstPitch, /* of chroma for 4:2:0 */
int x1,
int y1,
int x2,
int y2,
int dst_x1,
int dst_y1,
int dst_x2,
int dst_y2,
short src_w,
short src_h,
short drw_w,
short drw_h)
{
ScreenPtr pScreen = screen->pScreen;
KdScreenPriv(pScreen);
KdCardInfo *card = pScreenPriv->card;
Mach64ScreenInfo *mach64s = (Mach64ScreenInfo *) screen->driver;
Mach64CardInfo *mach64c = (Mach64CardInfo *) card->driver;
Mach64PortPrivPtr pPortPriv = mach64s->pAdaptor->pPortPrivates[0].ptr;
Reg *reg = mach64c->reg;
MediaReg *media = mach64c->media_reg;
int HORZ_INC, VERT_INC;
CARD32 SCALER_IN;
int bright;
int sat;
if (id == FOURCC_UYVY)
SCALER_IN = SCALER_IN_YVYU422;
else
SCALER_IN = SCALER_IN_VYUY422;
mach64WaitAvail (reg, 4);
media->VIDEO_FORMAT = SCALER_IN | VIDEO_IN_VYUY422;
/* color key */
media->OVERLAY_GRAPHICS_KEY_MSK = (1 << screen->fb[0].depth) - 1;
media->OVERLAY_GRAPHICS_KEY_CLR = pPortPriv->colorKey;
/* set key control to obey only graphics color key */
media->OVERLAY_KEY_CNTL = 0x50;
mach64WaitAvail (reg, 9);
media->CAPTURE_DEBUG = 0;
/* no exclusive video region */
media->OVERLAY_EXCLUSIVE_HORZ = 0;
media->OVERLAY_EXCLUSIVE_VERT = 0;
/* scaling coefficients */
media->SCALER_H_COEFF0 = 0x00002000;
media->SCALER_H_COEFF1 = 0x0D06200D;
media->SCALER_H_COEFF2 = 0x0D0A1C0D;
media->SCALER_H_COEFF3 = 0x0C0E1A0C;
media->SCALER_H_COEFF4 = 0x0C14140C;
media->SCALER_TEST = 0;
mach64WaitAvail (reg, 2);
media->OVERLAY_SCALE_CNTL = (SCALE_PIX_EXPAND |
SCALE_GAMMA_BRIGHT |
SCALE_BANDWIDTH |
SCALE_OVERLAY_EN |
SCALE_EN);
bright = (pPortPriv->brightness * 64 / 1000);
if (bright < -0x40)
bright = -0x40;
if (bright > 0x3f)
bright = 0x3f;
bright = bright & 0x7f;
sat = ((pPortPriv->saturation * 31 + 31000) / 2000);
if (sat > 0x1f)
sat = 0x1f;
if (sat < 0)
sat = 0;
media->SCALER_COLOUR_CNTL = ((bright << 0) | /* BRIGHTNESS */
(sat << 8) | /* SATURATION_U */
(sat << 16) | /* SATURATION_V */
(0 << 21) | /* SCALER_VERT_ADJ_UV */
(0 << 28)); /* SCALER_HORZ_ADJ_UV */
VERT_INC = (src_h << 12) / drw_h;
HORZ_INC = (src_w << 12) / drw_w;
mach64WaitAvail (reg, 13);
/* lock registers to prevent non-atomic update */
media->OVERLAY_Y_X_START = 0x80000000 | MACH64_YX (dst_x1, dst_y1);
/* ending screen coordinate */
media->OVERLAY_Y_X_END = 0x80000000 | MACH64_YX (dst_x2, dst_y2);
media->OVERLAY_SCALE_INC = MACH64_YX(HORZ_INC, VERT_INC);
media->SCALER_BUF0_OFFSET = pPortPriv->YBuf0Offset;
media->SCALER_BUF1_OFFSET = pPortPriv->YBuf1Offset;
media->SCALER_BUF0_OFFSET_U = pPortPriv->YBuf0Offset;
media->SCALER_BUF1_OFFSET_U = pPortPriv->YBuf1Offset;
media->SCALER_BUF0_OFFSET_V = pPortPriv->YBuf0Offset;
media->SCALER_BUF1_OFFSET_V = pPortPriv->YBuf1Offset;
media->SCALER_BUF_PITCH = dstPitch >> 1;
media->SCALER_HEIGHT_WIDTH = MACH64_YX(src_w - (x1 >> 16), src_h - (y1 >> 16));
media->CAPTURE_CONFIG = pPortPriv->currentBuf << 28;
/* set XY location and unlock */
media->OVERLAY_Y_X_START = MACH64_YX (dst_x1, dst_y1);
}
static void
mach64VideoSave (ScreenPtr pScreen, KdOffscreenArea *area)
{
KdScreenPriv(pScreen);
KdScreenInfo *screen = pScreenPriv->screen;
Mach64ScreenInfo *mach64s = (Mach64ScreenInfo *) screen->driver;
Mach64PortPrivPtr pPortPriv = mach64s->pAdaptor->pPortPrivates[0].ptr;
if (pPortPriv->off_screen == area)
pPortPriv->off_screen = 0;
}
static int
mach64PutImage(KdScreenInfo *screen,
DrawablePtr pDraw,
short src_x,
short src_y,
short drw_x,
short drw_y,
short src_w,
short src_h,
short drw_w,
short drw_h,
int id,
unsigned char *buf,
short width,
short height,
Bool sync,
RegionPtr clipBoxes,
pointer data)
{
KdCardInfo *card = screen->card;
Mach64ScreenInfo *mach64s = (Mach64ScreenInfo *) screen->driver;
Mach64CardInfo *mach64c = (Mach64CardInfo *) card->driver;
Mach64PortPrivPtr pPortPriv = (Mach64PortPrivPtr)data;
MediaReg *media = mach64c->media_reg;
INT32 x1, x2, y1, y2;
int randr = mach64s->vesa.randr;
int srcPitch, srcPitch2, dstPitch;
int top, left, npixels, nlines, size;
BoxRec dstBox;
int dst_width = width, dst_height = height;
int rot_x1, rot_y1, rot_x2, rot_y2;
int dst_x1, dst_y1, dst_x2, dst_y2;
int rot_src_w, rot_src_h, rot_drw_w, rot_drw_h;
/* Clip */
x1 = src_x;
x2 = src_x + src_w;
y1 = src_y;
y2 = src_y + src_h;
dstBox.x1 = drw_x;
dstBox.x2 = drw_x + drw_w;
dstBox.y1 = drw_y;
dstBox.y2 = drw_y + drw_h;
Mach64ClipVideo(&dstBox, &x1, &x2, &y1, &y2,
REGION_EXTENTS(pScreen, clipBoxes), width, height);
if((x1 >= x2) || (y1 >= y2))
return Success;
if (!media)
return BadAlloc;
if (randr & (RR_Rotate_0|RR_Rotate_180))
{
dst_width = width;
dst_height = height;
rot_src_w = src_w;
rot_src_h = src_h;
rot_drw_w = drw_w;
rot_drw_h = drw_h;
}
else
{
dst_width = height;
dst_height = width;
rot_src_w = src_h;
rot_src_h = src_w;
rot_drw_w = drw_h;
rot_drw_h = drw_w;
}
switch (randr & RR_Rotate_All) {
case RR_Rotate_0:
default:
dst_x1 = dstBox.x1;
dst_y1 = dstBox.y1;
dst_x2 = dstBox.x2;
dst_y2 = dstBox.y2;
rot_x1 = x1;
rot_y1 = y1;
rot_x2 = x2;
rot_y2 = y2;
break;
case RR_Rotate_90:
dst_x1 = dstBox.y1;
dst_y1 = screen->height - dstBox.x2;
dst_x2 = dstBox.y2;
dst_y2 = screen->height - dstBox.x1;
rot_x1 = y1;
rot_y1 = (src_w << 16) - x2;
rot_x2 = y2;
rot_y2 = (src_w << 16) - x1;
break;
case RR_Rotate_180:
dst_x1 = screen->width - dstBox.x2;
dst_y1 = screen->height - dstBox.y2;
dst_x2 = screen->width - dstBox.x1;
dst_y2 = screen->height - dstBox.y1;
rot_x1 = (src_w << 16) - x2;
rot_y1 = (src_h << 16) - y2;
rot_x2 = (src_w << 16) - x1;
rot_y2 = (src_h << 16) - y1;
break;
case RR_Rotate_270:
dst_x1 = screen->width - dstBox.y2;
dst_y1 = dstBox.x1;
dst_x2 = screen->width - dstBox.y1;
dst_y2 = dstBox.x2;
rot_x1 = (src_h << 16) - y2;
rot_y1 = x1;
rot_x2 = (src_h << 16) - y1;
rot_y2 = x2;
break;
}
switch(id) {
case FOURCC_YV12:
case FOURCC_I420:
dstPitch = ((dst_width << 1) + 15) & ~15;
srcPitch = (width + 3) & ~3;
srcPitch2 = ((width >> 1) + 3) & ~3;
size = dstPitch * (int) dst_height;
break;
case FOURCC_UYVY:
case FOURCC_YUY2:
default:
dstPitch = ((dst_width << 1) + 15) & ~15;
srcPitch = (width << 1);
srcPitch2 = 0;
size = dstPitch * (int) dst_height;
break;
}
if (pPortPriv->off_screen && size != pPortPriv->size)
{
KdOffscreenFree (screen->pScreen, pPortPriv->off_screen);
pPortPriv->off_screen = 0;
}
if (!pPortPriv->off_screen)
{
pPortPriv->off_screen = KdOffscreenAlloc (screen->pScreen, size * 2, 64,
TRUE, mach64VideoSave,
pPortPriv);
if (!pPortPriv->off_screen)
return BadAlloc;
}
pPortPriv->offset = pPortPriv->off_screen->offset;
pPortPriv->size = size;
/* fixup pointers */
pPortPriv->YBuf0Offset = pPortPriv->offset;
pPortPriv->YBuf1Offset = pPortPriv->offset + size;
#if 0
mach64WaitIdle (reg);
if (pPortPriv->videoOn)
{
/* wait for buffer to be displayed */
while (((media->TRIG_CNTL >> 5) & 1) != pPortPriv->currentBuf)
;
}
#endif
/*
* Use the other buffer
*/
pPortPriv->currentBuf = 1 - pPortPriv->currentBuf;
/* copy data */
top = rot_y1 >> 16;
left = (rot_x1 >> 16) & ~1;
npixels = ((((rot_x2 + 0xffff) >> 16) + 1) & ~1) - left;
switch(id) {
case FOURCC_YV12:
case FOURCC_I420:
top &= ~1;
nlines = ((((rot_y2 + 0xffff) >> 16) + 1) & ~1) - top;
mach64CopyPlanarData(screen, buf, randr,
srcPitch, srcPitch2, dstPitch,
rot_src_w, rot_src_h, height,
top, left, nlines, npixels, id);
break;
case FOURCC_UYVY:
case FOURCC_YUY2:
default:
nlines = ((rot_y2 + 0xffff) >> 16) - top;
mach64CopyPackedData(screen, buf, randr,
srcPitch, dstPitch,
rot_src_w, rot_src_h,
top, left, nlines,
npixels);
break;
}
mach64DisplayVideo(screen, id, dstPitch,
rot_x1, rot_y1, rot_x2, rot_y2,
dst_x1, dst_y1,
dst_x2, dst_y2,
rot_src_w, rot_src_h, rot_drw_w, rot_drw_h);
/* update cliplist */
if (!REGION_EQUAL (screen->pScreen, &pPortPriv->clip, clipBoxes))
{
REGION_COPY (screen->pScreen, &pPortPriv->clip, clipBoxes);
KXVPaintRegion (pDraw, &pPortPriv->clip, pPortPriv->colorKey);
}
pPortPriv->videoOn = TRUE;
return Success;
}
static int
mach64QueryImageAttributes(KdScreenInfo *screen,
int id,
unsigned short *w,
unsigned short *h,
int *pitches,
int *offsets)
{
int size, tmp;
if(*w > IMAGE_MAX_WIDTH)
*w = IMAGE_MAX_WIDTH;
if(*h > IMAGE_MAX_HEIGHT)
*h = IMAGE_MAX_HEIGHT;
*w = (*w + 1) & ~1;
if(offsets) offsets[0] = 0;
switch(id) {
case FOURCC_YV12:
case FOURCC_I420:
*h = (*h + 1) & ~1;
size = (*w + 3) & ~3;
if(pitches)
pitches[0] = size;
size *= *h;
if(offsets)
offsets[1] = size;
tmp = ((*w >> 1) + 3) & ~3;
if(pitches)
pitches[1] = pitches[2] = tmp;
tmp *= (*h >> 1);
size += tmp;
if(offsets)
offsets[2] = size;
size += tmp;
break;
case FOURCC_UYVY:
case FOURCC_YUY2:
default:
size = *w << 1;
if(pitches)
pitches[0] = size;
size *= *h;
break;
}
return size;
}
/* client libraries expect an encoding */
static KdVideoEncodingRec DummyEncoding[1] =
{
{
0,
"XV_IMAGE",
IMAGE_MAX_WIDTH, IMAGE_MAX_HEIGHT,
{1, 1}
}
};
#define NUM_FORMATS 3
static KdVideoFormatRec Formats[NUM_FORMATS] =
{
{15, TrueColor}, {16, TrueColor}, {24, TrueColor}
};
#define NUM_ATTRIBUTES 3
static KdAttributeRec Attributes[NUM_ATTRIBUTES] =
{
{XvSettable | XvGettable, 0, ~0, "XV_COLORKEY"},
{XvSettable | XvGettable, -1000, 1000, "XV_BRIGHTNESS"},
{XvSettable | XvGettable, -1000, 1000, "XV_SATURATION"}
};
#define NUM_IMAGES 4
static KdImageRec Images[NUM_IMAGES] =
{
XVIMAGE_YUY2,
XVIMAGE_YV12,
XVIMAGE_I420,
XVIMAGE_UYVY
};
static void mach64ResetVideo(KdScreenInfo *screen)
{
}
static int
mach64ReputImage (KdScreenInfo *screen,
DrawablePtr pDraw,
short drw_x,
short drw_y,
RegionPtr clipBoxes,
pointer data)
{
Mach64PortPrivPtr pPortPriv = (Mach64PortPrivPtr)data;
BoxPtr pOldExtents = REGION_EXTENTS (screen->pScreen, &pPortPriv->clip);
BoxPtr pNewExtents = REGION_EXTENTS (screen->pScreen, clipBoxes);
if (pOldExtents->x1 == pNewExtents->x1 &&
pOldExtents->x2 == pNewExtents->x2 &&
pOldExtents->y1 == pNewExtents->y1 &&
pOldExtents->y2 == pNewExtents->y2)
{
/* update cliplist */
if (!REGION_EQUAL (screen->pScreen, &pPortPriv->clip, clipBoxes))
{
REGION_COPY (screen->pScreen, &pPortPriv->clip, clipBoxes);
KXVPaintRegion (pDraw, &pPortPriv->clip, pPortPriv->colorKey);
}
return Success;
}
return BadMatch;
}
static KdVideoAdaptorPtr
mach64SetupImageVideo(ScreenPtr pScreen)
{
KdScreenPriv(pScreen);
mach64ScreenInfo(pScreenPriv);
KdScreenInfo *screen = pScreenPriv->screen;
KdVideoAdaptorPtr adapt;
Mach64PortPrivPtr pPortPriv;
if(!(adapt = xcalloc(1, sizeof(KdVideoAdaptorRec) +
sizeof(Mach64PortPrivRec) +
sizeof(DevUnion))))
return NULL;
adapt->type = XvWindowMask | XvInputMask | XvImageMask;
adapt->flags = VIDEO_OVERLAID_IMAGES | VIDEO_CLIP_TO_VIEWPORT;
adapt->name = "Mach64 Video Overlay";
adapt->nEncodings = 1;
adapt->pEncodings = DummyEncoding;
adapt->nFormats = NUM_FORMATS;
adapt->pFormats = Formats;
adapt->nPorts = 1;
adapt->pPortPrivates = (DevUnion*)(&adapt[1]);
pPortPriv = (Mach64PortPrivPtr)(&adapt->pPortPrivates[1]);
adapt->pPortPrivates[0].ptr = (pointer)(pPortPriv);
adapt->pAttributes = Attributes;
adapt->nImages = NUM_IMAGES;
adapt->nAttributes = NUM_ATTRIBUTES;
adapt->pImages = Images;
adapt->PutVideo = NULL;
adapt->PutStill = NULL;
adapt->GetVideo = NULL;
adapt->GetStill = NULL;
adapt->StopVideo = mach64StopVideo;
adapt->SetPortAttribute = mach64SetPortAttribute;
adapt->GetPortAttribute = mach64GetPortAttribute;
adapt->QueryBestSize = mach64QueryBestSize;
adapt->PutImage = mach64PutImage;
adapt->ReputImage = mach64ReputImage;
adapt->QueryImageAttributes = mach64QueryImageAttributes;
pPortPriv->colorKey = mach64s->colorKey;
pPortPriv->videoOn = FALSE;
pPortPriv->brightness = 0;
pPortPriv->saturation = 0;
pPortPriv->currentBuf = 0;
pPortPriv->off_screen = 0;
pPortPriv->size = 0;
pPortPriv->offset = 0;
/* gotta uninit this someplace */
REGION_INIT(pScreen, &pPortPriv->clip, NullBox, 0);
mach64s->pAdaptor = adapt;
xvBrightness = MAKE_ATOM("XV_BRIGHTNESS");
xvSaturation = MAKE_ATOM("XV_SATURATION");
xvColorKey = MAKE_ATOM("XV_COLORKEY");
mach64ResetVideo(screen);
return adapt;
}
Bool mach64InitVideo(ScreenPtr pScreen)
{
KdScreenPriv(pScreen);
KdScreenInfo *screen = pScreenPriv->screen;
KdVideoAdaptorPtr *adaptors, *newAdaptors = NULL;
KdVideoAdaptorPtr newAdaptor = NULL;
int num_adaptors;
KdCardInfo *card = pScreenPriv->card;
Mach64CardInfo *mach64c = (Mach64CardInfo *) card->driver;
Mach64ScreenInfo *mach64s = (Mach64ScreenInfo *) screen->driver;
mach64s->pAdaptor = NULL;
if (!mach64c->media_reg)
return FALSE;
newAdaptor = mach64SetupImageVideo(pScreen);
num_adaptors = KdXVListGenericAdaptors(screen, &adaptors);
if(newAdaptor)
{
if(!num_adaptors)
{
num_adaptors = 1;
adaptors = &newAdaptor;
}
else
{
newAdaptors = xalloc((num_adaptors + 1) *
sizeof(KdVideoAdaptorPtr*));
if(newAdaptors)
{
memcpy(newAdaptors, adaptors,
num_adaptors * sizeof(KdVideoAdaptorPtr));
newAdaptors[num_adaptors] = newAdaptor;
adaptors = newAdaptors;
num_adaptors++;
}
}
}
if(num_adaptors)
KdXVScreenInit(pScreen, adaptors, num_adaptors);
if(newAdaptors)
xfree(newAdaptors);
return TRUE;
}
void
mach64FiniVideo (ScreenPtr pScreen)
{
KdScreenPriv(pScreen);
mach64ScreenInfo(pScreenPriv);
KdVideoAdaptorPtr adapt = mach64s->pAdaptor;
if (adapt)
{
Mach64PortPrivPtr pPortPriv = (Mach64PortPrivPtr)(&adapt->pPortPrivates[1]);
REGION_UNINIT (pScreen, &pPortPriv->clip);
xfree (adapt);
}
}

View File

@ -1,38 +0,0 @@
INCLUDES = \
@KDRIVE_INCS@ \
-I$(top_srcdir)/hw/kdrive/vesa \
@KDRIVE_CFLAGS@
bin_PROGRAMS = Xmga
noinst_LIBRARIES = libmga.a
libmga_a_SOURCES = \
mgadraw.c \
g400_composite.c \
g400_common.h \
mga.c \
mga.h
Xmga_SOURCES = \
mgastub.c
MGA_LIBS = \
libmga.a \
$(top_builddir)/hw/kdrive/vesa/libvesa.a \
@KDRIVE_LIBS@
if GLX
Xmga_LDFLAGS = $(LD_EXPORT_SYMBOLS_FLAG)
endif
Xmga_LDADD = \
$(MGA_LIBS) \
@KDRIVE_LIBS@
Xmga_DEPENDENCIES = \
libmga.a \
@KDRIVE_LOCAL_LIBS@
relink:
rm -f $(bin_PROGRAMS) && make $(bin_PROGRAMS)

View File

@ -1,185 +0,0 @@
/*
* Copyright © 2004 Damien Ciabrini
*
* 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 Anders Carlsson not be used in
* advertising or publicity pertaining to distribution of the software without
* specific, written prior permission. Anders Carlsson makes no
* representations about the suitability of this software for any purpose. It
* is provided "as is" without express or implied warranty.
*
* DAMIEN CIABRINI DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL ANDERS CARLSSON 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.
*/
#ifndef __G400_COMMON_H__
#define __G400_COMMON_H__
/* Color registers */
#define MGA_REG_DR4 (0x1CD0)
#define MGA_REG_DR6 (0x1CD8)
#define MGA_REG_DR7 (0x1CDC)
#define MGA_REG_DR8 (0x1CE0)
#define MGA_REG_DR10 (0x1CE8)
#define MGA_REG_DR11 (0x1CEC)
#define MGA_REG_DR12 (0x1CF0)
#define MGA_REG_DR14 (0x1CF8)
#define MGA_REG_DR15 (0x1CFC)
/* Alpha registers */
#define MGA_REG_ALPHASTART (0x2C70)
#define MGA_REG_ALPHAXINC (0x2C74)
#define MGA_REG_ALPHAYINC (0x2C78)
#define MGA_REG_ALPHACTRL (0x2C7C)
# define MGA_SRC_ZERO (0x00000000)
# define MGA_SRC_ONE (0x00000001)
# define MGA_SRC_DST_COLOR (0x00000002)
# define MGA_SRC_ONE_MINUS_DST_COLOR (0x00000003)
# define MGA_SRC_ALPHA (0x00000004)
# define MGA_SRC_ONE_MINUS_SRC_ALPHA (0x00000005)
# define MGA_SRC_DST_ALPHA (0x00000006)
# define MGA_SRC_ONE_MINUS_DST_ALPHA (0x00000007)
# define MGA_SRC_SRC_ALPHA_SATURATE (0x00000008)
# define MGA_SRC_BLEND_MASK (0x0000000f)
# define MGA_DST_ZERO (0x00000000)
# define MGA_DST_ONE (0x00000010)
# define MGA_DST_SRC_COLOR (0x00000020)
# define MGA_DST_ONE_MINUS_SRC_COLOR (0x00000030)
# define MGA_DST_SRC_ALPHA (0x00000040)
# define MGA_DST_ONE_MINUS_SRC_ALPHA (0x00000050)
# define MGA_DST_DST_ALPHA (0x00000060)
# define MGA_DST_ONE_MINUS_DST_ALPHA (0x00000070)
# define MGA_DST_BLEND_MASK (0x00000070)
# define MGA_ALPHACHANNEL (0x00000100)
# define MGA_VIDEOALPHA (0x00000200)
# define MGA_DIFFUSEDALPHA (0x01000000)
# define MGA_MODULATEDALPHA (0x02000000)
/* Textures registers */
#define MGA_REG_TEXORG (0x2c24)
#define MGA_REG_TEXORG1 (0x2ca4)
#define MGA_REG_TEXWIDTH (0x2C28)
#define MGA_REG_TEXHEIGHT (0x2C2C)
#define MGA_REG_TMR0 (0x2C00)
#define MGA_REG_TMR1 (0x2C04)
#define MGA_REG_TMR2 (0x2C08)
#define MGA_REG_TMR3 (0x2C0C)
#define MGA_REG_TMR4 (0x2C10)
#define MGA_REG_TMR5 (0x2C14)
#define MGA_REG_TMR6 (0x2C18)
#define MGA_REG_TMR7 (0x2C1C)
#define MGA_REG_TMR8 (0x2C20)
/* Texture Control Registers */
#define MGA_REG_TEXCTL (0x2C30)
# define MGA_TW4 (0x00000000)
# define MGA_TW8 (0x00000001)
# define MGA_TW15 (0x00000002)
# define MGA_TW16 (0x00000003)
# define MGA_TW12 (0x00000004)
# define MGA_TW32 (0x00000006)
# define MGA_TW8A (0x00000007)
# define MGA_TW8AL (0x00000008)
# define MGA_TW422 (0x0000000A)
# define MGA_TW422UYVY (0x0000000B)
# define MGA_PITCHLIN (0x00000100)
# define MGA_NOPERSPECTIVE (0x00200000)
# define MGA_TAKEY (0x02000000)
# define MGA_TAMASK (0x04000000)
# define MGA_CLAMPUV (0x18000000)
#define MGA_REG_TEXCTL2 (0x2C3C)
# define MGA_G400_TC2_MAGIC (0x00008000)
# define MGA_TC2_DECALBLEND (0x00000001)
# define MGA_TC2_IDECAL (0x00000002)
# define MGA_TC2_DECALDIS (0x00000004)
# define MGA_TC2_CKSTRANSDIS (0x00000010)
# define MGA_TC2_BORDEREN (0x00000020)
# define MGA_TC2_SPECEN (0x00000040)
# define MGA_TC2_DUALTEX (0x00000080)
# define MGA_TC2_TABLEFOG (0x00000100)
# define MGA_TC2_BUMPMAP (0x00000200)
# define MGA_TC2_SELECT_TMU1 (0x80000000)
#define MGA_REG_TEXFILTER (0x2C58)
# define MGA_MIN_NRST (0x00000000)
# define MGA_MIN_BILIN (0x00000002)
# define MGA_MIN_ANISO (0x0000000D)
# define MGA_MAG_NRST (0x00000000)
# define MGA_MAG_BILIN (0x00000020)
/* Multi-Textures Control Registers */
#define MGA_REG_TDUALSTAGE0 (0x2CF8)
#define MGA_REG_TDUALSTAGE1 (0x2CFC)
# define MGA_TDS_COLOR_ARG2_DIFFUSE (0x00000000)
# define MGA_TDS_COLOR_ARG2_SPECULAR (0x00000001)
# define MGA_TDS_COLOR_ARG2_FCOL (0x00000002)
# define MGA_TDS_COLOR_ARG2_PREVSTAGE (0x00000003)
# define MGA_TDS_COLOR_ALPHA_DIFFUSE (0x00000000)
# define MGA_TDS_COLOR_ALPHA_FCOL (0x00000004)
# define MGA_TDS_COLOR_ALPHA_CURRTEX (0x00000008)
# define MGA_TDS_COLOR_ALPHA_PREVTEX (0x0000000c)
# define MGA_TDS_COLOR_ALPHA_PREVSTAGE (0x00000010)
# define MGA_TDS_COLOR_ARG1_REPLICATEALPHA (0x00000020)
# define MGA_TDS_COLOR_ARG1_INV (0x00000040)
# define MGA_TDS_COLOR_ARG2_REPLICATEALPHA (0x00000080)
# define MGA_TDS_COLOR_ARG2_INV (0x00000100)
# define MGA_TDS_COLOR_ALPHA1INV (0x00000200)
# define MGA_TDS_COLOR_ALPHA2INV (0x00000400)
# define MGA_TDS_COLOR_ARG1MUL_ALPHA1 (0x00000800)
# define MGA_TDS_COLOR_ARG2MUL_ALPHA2 (0x00001000)
# define MGA_TDS_COLOR_ARG1ADD_MULOUT (0x00002000)
# define MGA_TDS_COLOR_ARG2ADD_MULOUT (0x00004000)
# define MGA_TDS_COLOR_MODBRIGHT_2X (0x00008000)
# define MGA_TDS_COLOR_MODBRIGHT_4X (0x00010000)
# define MGA_TDS_COLOR_ADD_SUB (0x00000000)
# define MGA_TDS_COLOR_ADD_ADD (0x00020000)
# define MGA_TDS_COLOR_ADD2X (0x00040000)
# define MGA_TDS_COLOR_ADDBIAS (0x00080000)
# define MGA_TDS_COLOR_BLEND (0x00100000)
# define MGA_TDS_COLOR_SEL_ARG1 (0x00000000)
# define MGA_TDS_COLOR_SEL_ARG2 (0x00200000)
# define MGA_TDS_COLOR_SEL_ADD (0x00400000)
# define MGA_TDS_COLOR_SEL_MUL (0x00600000)
# define MGA_TDS_ALPHA_ARG1_INV (0x00800000)
# define MGA_TDS_ALPHA_ARG2_DIFFUSE (0x00000000)
# define MGA_TDS_ALPHA_ARG2_FCOL (0x01000000)
# define MGA_TDS_ALPHA_ARG2_PREVTEX (0x02000000)
# define MGA_TDS_ALPHA_ARG2_PREVSTAGE (0x03000000)
# define MGA_TDS_ALPHA_ARG2_INV (0x04000000)
# define MGA_TDS_ALPHA_ADD (0x08000000)
# define MGA_TDS_ALPHA_ADDBIAS (0x10000000)
# define MGA_TDS_ALPHA_ADD2X (0x20000000)
# define MGA_TDS_ALPHA_SEL_ARG1 (0x00000000)
# define MGA_TDS_ALPHA_SEL_ARG2 (0x40000000)
# define MGA_TDS_ALPHA_SEL_ADD (0x80000000)
# define MGA_TDS_ALPHA_SEL_MUL (0xc0000000)
/* Composition Prototypes. MMIO Access */
Bool
mgaCheckComposite(int op, PicturePtr pSrcPicture, PicturePtr pMaskPicture,
PicturePtr pDstPicture);
Bool
mgaPrepareComposite(int op, PicturePtr pSrcPicture, PicturePtr pMaskPicture,
PicturePtr pDstPicture, PixmapPtr pSrc,
PixmapPtr pMask, PixmapPtr pDst);
void
mgaComposite(int srcX, int srcY, int maskX, int maskY,
int dstX, int dstY, int w, int h);
void
mgaDoneComposite(void);
#endif

View File

@ -1,510 +0,0 @@
/*
* Copyright © 2004 Damien Ciabrini
*
* 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 Anders Carlsson not be used in
* advertising or publicity pertaining to distribution of the software without
* specific, written prior permission. Anders Carlsson makes no
* representations about the suitability of this software for any purpose. It
* is provided "as is" without express or implied warranty.
*
* DAMIEN CIABRINI DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL ANDERS CARLSSON 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.
*/
#ifdef HAVE_CONFIG_H
#include <kdrive-config.h>
#endif
#include "mga.h"
#include "g400_common.h"
static PicturePtr currentSrcPicture;
static PicturePtr currentMaskPicture;
static PixmapPtr currentSrc;
static PixmapPtr currentMask;
static int src_w2;
static int src_h2;
static int mask_w2;
static int mask_h2;
struct blendinfo {
Bool dst_alpha;
Bool src_alpha;
CARD32 blend_cntl;
};
static struct blendinfo mgaBlendOP[] = {
/* Clear */
{0, 0, MGA_SRC_ZERO | MGA_DST_ZERO},
/* Src */
{0, 0, MGA_SRC_ONE | MGA_DST_ZERO},
/* Dst */
{0, 0, MGA_SRC_ZERO | MGA_DST_ONE},
/* Over */
{0, 1, MGA_SRC_ONE | MGA_DST_ONE_MINUS_SRC_ALPHA},
/* OverReverse */
{1, 0, MGA_SRC_ONE_MINUS_DST_ALPHA | MGA_DST_ONE},
/* In */
{1, 0, MGA_SRC_DST_ALPHA | MGA_DST_ZERO},
/* InReverse */
{0, 1, MGA_SRC_ZERO | MGA_DST_SRC_ALPHA},
/* Out */
{1, 0, MGA_SRC_ONE_MINUS_DST_ALPHA | MGA_DST_ZERO},
/* OutReverse */
{0, 1, MGA_SRC_ZERO | MGA_DST_ONE_MINUS_SRC_ALPHA},
/* Atop */
{1, 1, MGA_SRC_DST_ALPHA | MGA_DST_ONE_MINUS_SRC_ALPHA},
/* AtopReverse */
{1, 1, MGA_SRC_ONE_MINUS_DST_ALPHA | MGA_DST_SRC_ALPHA},
/* Xor */
{1, 1, MGA_SRC_ONE_MINUS_DST_ALPHA | MGA_DST_ONE_MINUS_SRC_ALPHA},
/* Add */
{0, 0, MGA_SRC_ONE | MGA_DST_ONE},
};
struct formatinfo {
int fmt;
CARD32 card_fmt;
};
static struct formatinfo texformats[] = {
{PICT_a8r8g8b8, MGA_TW32},
{PICT_x8r8g8b8, MGA_TW32},
{PICT_r5g6b5, MGA_TW16},
{PICT_a1r5g5b5, MGA_TW15},
{PICT_x1r5g5b5, MGA_TW15},
{PICT_a4r4g4b4, MGA_TW12},
{PICT_x4r4g4b4, MGA_TW12},
{PICT_a8, MGA_TW8A},
};
static int
MGA_LOG2( int val )
{
int ret = 0;
if (val==1) return 0;
while (val >> ret)
ret++;
return ((1 << (ret-1)) == val) ? (ret-1) : ret;
}
static Bool
mgaCheckSourceTexture (int tmu,
PicturePtr pPict)
{
int w = pPict->pDrawable->width;
int h = pPict->pDrawable->height;
int i;
CARD32 texctl = 0;
if ((w > 2047) || (h > 2047))
MGA_FALLBACK(("Picture w/h too large (%dx%d)\n", w, h));
for (i = 0; i < sizeof(texformats) / sizeof(texformats[0]); i++) {
if (texformats[i].fmt == pPict->format) {
texctl = texformats[i].card_fmt;
break;
}
}
if (texctl == 0) {
MGA_FALLBACK(("Unsupported picture format 0x%x\n", pPict->format));
}
if (pPict->repeat && ((w & (w - 1)) != 0 || (h & (h - 1)) != 0))
MGA_FALLBACK(("NPOT repeat unsupported (%dx%d)\n", w, h));
if (pPict->filter != PictFilterNearest &&
pPict->filter != PictFilterBilinear)
MGA_FALLBACK(("Unsupported filter 0x%x\n", pPict->filter));
return TRUE;
}
static Bool
PrepareSourceTexture (int tmu,
PicturePtr pSrcPicture,
PixmapPtr pSrc)
{
KdScreenPriv (pSrc->drawable.pScreen);
int mem_base=(int)pScreenPriv->screen->memory_base;
int pitch = pSrc->devKind / (pSrc->drawable.bitsPerPixel >> 3);
int i;
int w = pSrc->drawable.width;
int h = pSrc->drawable.height;
int w_log2 = MGA_LOG2(w);
int h_log2 = MGA_LOG2(h);
int texctl = MGA_PITCHLIN | ((pitch & (2048 - 1)) << 9) |
MGA_CLAMPUV | MGA_NOPERSPECTIVE;
int flags = 0;
int texctl2 = MGA_G400_TC2_MAGIC | flags;
for (i = 0; i < sizeof(texformats) / sizeof(texformats[0]); i++) {
if (texformats[i].fmt == pSrcPicture->format) {
texctl |= texformats[i].card_fmt;
break;
}
}
if (PICT_FORMAT_A(pSrcPicture->format) != 0) {
texctl |= MGA_TAKEY;
} else {
texctl |= MGA_TAMASK | MGA_TAKEY;
}
if (pSrcPicture->repeat) {
texctl &= ~MGA_CLAMPUV;
}
if (tmu == 1)
texctl2 |= MGA_TC2_DUALTEX | MGA_TC2_SELECT_TMU1 | flags;
mgaWaitAvail (6);
MGA_OUT32 (mmio, MGA_REG_TEXCTL2, texctl2);
MGA_OUT32 (mmio, MGA_REG_TEXCTL, texctl);
/* Source (texture) address + pitch */
MGA_OUT32 (mmio, MGA_REG_TEXORG, ((int)pSrc->devPrivate.ptr - mem_base));
MGA_OUT32 (mmio, MGA_REG_TEXWIDTH, (w-1)<<18 | ((8-w_log2)&63)<<9 | w_log2);
MGA_OUT32 (mmio, MGA_REG_TEXHEIGHT, (h-1)<<18 | ((8-h_log2)&63)<<9 | h_log2);
/* Set blit filtering flags */
if (pSrcPicture->filter == PictFilterBilinear) {
MGA_OUT32 (mmio, MGA_REG_TEXFILTER,
(0x10<<21) | MGA_MAG_BILIN | MGA_MIN_BILIN);
} else {
MGA_OUT32 (mmio, MGA_REG_TEXFILTER,
(0x10<<21) | MGA_MAG_NRST | MGA_MIN_NRST);
}
if (tmu == 1) {
mgaWaitAvail (1);
MGA_OUT32 (mmio, MGA_REG_TEXCTL2, MGA_G400_TC2_MAGIC | MGA_TC2_DUALTEX | flags);
}
return TRUE;
}
/*
* The formals params are the elements of the following matrix:
*
* Dest Transform Src
* coords coords
* / Xdst \ / X_incx X_incy X_init \ / Xsrc \
* | Ydst | = | Y_incx Y_incy Y_init | x | Ysrc |
* \ 1 / \ H_incx H_incy H_init / \ 1 /
*
* matrix elements are 32bits fixed points (16.16)
* mga_fx_* is the size of the fixed point for the TMU
*/
static void
setTMIncrementsRegs(int X_incx,
int X_incy,
int X_init,
int Y_incx,
int Y_incy,
int Y_init,
int H_incx,
int H_incy,
int H_init,
int mga_fx_width_size,
int mga_fx_height_size) {
int decalw = mga_fx_width_size - 16;
int decalh = mga_fx_height_size - 16;
/* Convert 16 bits fixpoint -> MGA variable size fixpoint */
if (decalw >= 0) {
X_incx = X_incx << decalw;
X_incy = X_incy << decalw;
X_init = X_init << decalw;
} else {
decalw =- decalw;
X_incx = X_incx >> decalw;
X_incy = X_incy >> decalw;
X_init = X_init >> decalw;
}
/* Convert 16 bits fixpoint -> MGA variable size fixpoint */
if (decalh >= 0) {
Y_incx = Y_incx << decalh;
Y_incy = Y_incy << decalh;
Y_init = Y_init << decalh;
} else {
decalh =- decalh;
Y_incx = Y_incx >> decalh;
Y_incy = Y_incy >> decalh;
Y_init = Y_init >> decalh;
}
/* Set TM registers */
mgaWaitAvail (9);
MGA_OUT32 (mmio, MGA_REG_TMR0, X_incx);
MGA_OUT32 (mmio, MGA_REG_TMR1, Y_incx);
MGA_OUT32 (mmio, MGA_REG_TMR2, X_incy);
MGA_OUT32 (mmio, MGA_REG_TMR3, Y_incy);
MGA_OUT32 (mmio, MGA_REG_TMR4, H_incx);
MGA_OUT32 (mmio, MGA_REG_TMR5, H_incy);
MGA_OUT32 (mmio, MGA_REG_TMR6, X_init);
MGA_OUT32 (mmio, MGA_REG_TMR7, Y_init);
MGA_OUT32 (mmio, MGA_REG_TMR8, H_init);
}
Bool
mgaCheckComposite(int op, PicturePtr pSrcPicture, PicturePtr pMaskPicture,
PicturePtr pDstPicture)
{
if (op >= sizeof(mgaBlendOP) / sizeof(mgaBlendOP[0]))
MGA_FALLBACK(("unsupported op %x", op));
if (!mgaCheckSourceTexture (0, pSrcPicture))
return FALSE;
if (pMaskPicture != NULL) {
if (PICT_FORMAT_A(pMaskPicture->format) == 0)
MGA_FALLBACK(("Mask without alpha unsupported"));
if (!mgaCheckSourceTexture (1, pMaskPicture))
return FALSE;
}
if (pMaskPicture->componentAlpha)
MGA_FALLBACK(("Component alpha unsupported"));
if (pDstPicture->format == PICT_a8)
MGA_FALLBACK(("render to A8 unsupported"));
return TRUE;
}
#define C_ARG1_CUR 0x0
#define C_ARG1_ALPHA MGA_TDS_COLOR_ARG1_REPLICATEALPHA
#define C_ARG2_DIFFUSE MGA_TDS_COLOR_ARG2_DIFFUSE
#define C_ARG2_FCOL MGA_TDS_COLOR_ARG2_FCOL
#define C_ARG2_PREV MGA_TDS_COLOR_ARG2_PREVSTAGE
#define C_ARG1_INV MGA_TDS_COLOR_ARG1_INV
#define C_ARG2_INV MGA_TDS_COLOR_ARG2_INV
#define COLOR_MUL MGA_TDS_COLOR_SEL_MUL
#define COLOR_ARG1 MGA_TDS_COLOR_SEL_ARG1
#define COLOR_ARG2 MGA_TDS_COLOR_SEL_ARG2
#define A_ARG1_CUR 0x0
#define A_ARG2_IGN A_ARG2_DIFFUSE
#define A_ARG2_FCOL MGA_TDS_ALPHA_ARG2_FCOL
#define A_ARG2_DIFFUSE MGA_TDS_ALPHA_ARG2_DIFFUSE
#define A_ARG2_PREV MGA_TDS_ALPHA_ARG2_PREVSTAGE
#define ALPHA_MUL MGA_TDS_ALPHA_SEL_MUL
#define ALPHA_ARG1 MGA_TDS_ALPHA_SEL_ARG1
#define ALPHA_ARG2 MGA_TDS_ALPHA_SEL_ARG2
Bool
mgaPrepareComposite (int op,
PicturePtr pSrcPicture,
PicturePtr pMaskPicture,
PicturePtr pDstPicture,
PixmapPtr pSrc,
PixmapPtr pMask,
PixmapPtr pDst)
{
KdScreenPriv (pSrc->drawable.pScreen);
int mem_base=(int)pScreenPriv->screen->memory_base;
int cmd, blendcntl;
int ds0, ds1;
/* Init MGA (clipping) */
mgaSetup (pSrc->drawable.pScreen, pDst->drawable.bitsPerPixel, 1);
/* Initialize fg color to 0, used in the src = A8 case */
MGA_OUT32 (mmio, MGA_REG_FCOL, 0xff000000);
/* Destination flags */
mgaWaitAvail (2);
MGA_OUT32 (mmio, MGA_REG_DSTORG, ((int)pDst->devPrivate.ptr - mem_base));
MGA_OUT32 (mmio, MGA_REG_PITCH,
pDst->devKind / (pDst->drawable.bitsPerPixel >> 3));
/* Source(s) flags */
if (!PrepareSourceTexture (0, pSrcPicture, pSrc)) return FALSE;
if (pMask != NULL) {
if (!PrepareSourceTexture (1, pMaskPicture, pMask)) return FALSE;
}
/* Prepare multi-texture registers */
ds0=ds1=0;
if (pSrcPicture->format == PICT_a8) {
/* C = 0 A = As */
/* MGA HW: A8 format makes RGB white. We use FCOL for the black
* If FCOL was not 0, it would have been be premultiplied (RENDER)
* color component would have been:
* C_ARG1_ALPHA | C_ARG2_FCOL | COLOR_MUL
*/
ds0=C_ARG2_FCOL | COLOR_ARG2 |
A_ARG1_CUR | ALPHA_ARG1;
/* MGA HW: TMU1 must be enabled when DUALSTAGE0 contains something */
if (pMask == NULL) {
if (!PrepareSourceTexture (1, pSrcPicture, pSrc)) return FALSE;
ds1=C_ARG2_PREV | COLOR_ARG2 |
A_ARG2_PREV | ALPHA_ARG2;
}
} else {
/* C = Cs A = As */
ds0=C_ARG1_CUR | COLOR_ARG1 |
A_ARG1_CUR | ALPHA_ARG1;
}
if (pMask != NULL) {
/* As or Am might be NULL. in this case we don't multiply because,
* the alpha component holds garbage.
*/
int color,alpha;
if (PICT_FORMAT_A (pMaskPicture->format) == 0) {
/* C = Cs */
color = C_ARG2_PREV | COLOR_ARG2;
} else {
/* C = Am * Cs */
color = C_ARG1_ALPHA | C_ARG2_PREV | COLOR_MUL;
}
if (PICT_FORMAT_A (pMaskPicture->format) == 0) {
/* A = As */
alpha = A_ARG2_PREV | ALPHA_ARG2;
} else if (PICT_FORMAT_A (pSrcPicture->format) == 0) {
/* A = Am */
alpha = A_ARG1_CUR | ALPHA_ARG1;
} else {
/* A = Am * As */
alpha = A_ARG1_CUR | A_ARG2_PREV | ALPHA_MUL;
}
ds1 = color | alpha;
}
/* MultiTexture modulation */
mgaWaitAvail (2);
MGA_OUT32 (mmio, MGA_REG_TDUALSTAGE0, ds0);
MGA_OUT32 (mmio, MGA_REG_TDUALSTAGE1, ds1);
cmd = MGA_OPCOD_TEXTURE_TRAP | MGA_ATYPE_RSTR | 0x000c0000 |
MGA_DWGCTL_SHIFTZERO | MGA_DWGCTL_SGNZERO | MGA_DWGCTL_ARZERO |
MGA_ATYPE_I;
blendcntl = mgaBlendOP[op].blend_cntl;
if (PICT_FORMAT_A(pDstPicture->format) == 0 && mgaBlendOP[op].dst_alpha) {
if ((blendcntl & MGA_SRC_BLEND_MASK) == MGA_SRC_DST_ALPHA)
blendcntl = (blendcntl & ~MGA_SRC_BLEND_MASK) | MGA_SRC_ONE;
else if ((blendcntl & MGA_SRC_BLEND_MASK) == MGA_SRC_ONE_MINUS_DST_ALPHA)
blendcntl = (blendcntl & ~MGA_SRC_BLEND_MASK) | MGA_SRC_ZERO;
}
mgaWaitAvail (2);
MGA_OUT32 (mmio, MGA_REG_DWGCTL, cmd);
MGA_OUT32 (mmio, MGA_REG_ALPHACTRL, MGA_ALPHACHANNEL | blendcntl);
currentSrcPicture = pSrcPicture;
currentMaskPicture = pMaskPicture;
currentSrc = pSrc;
currentMask = pMask;
src_w2 = MGA_LOG2 (currentSrc->drawable.width);
src_h2 = MGA_LOG2 (currentSrc->drawable.height);
mask_w2 = MGA_LOG2 (currentMask->drawable.width);
mask_h2 = MGA_LOG2 (currentMask->drawable.height);
return TRUE;
}
void
mgaComposite (int srcX,
int srcY,
int maskX,
int maskY,
int dstX,
int dstY,
int width,
int height)
{
/* Source positions can be outside source textures' boundaries.
* We clamp the values here to avoid rendering glitches.
*/
srcX=srcX % currentSrc->drawable.width;
srcY=srcY % currentSrc->drawable.height;
maskX=maskX % currentMask->drawable.width;
maskY=maskY % currentMask->drawable.height;
if (currentSrcPicture->transform) {
setTMIncrementsRegs (currentSrcPicture->transform->matrix[0][0],
currentSrcPicture->transform->matrix[0][1],
currentSrcPicture->transform->matrix[0][2] +
(srcX << 16),
currentSrcPicture->transform->matrix[1][0],
currentSrcPicture->transform->matrix[1][1],
currentSrcPicture->transform->matrix[1][2] +
(srcY << 16),
currentSrcPicture->transform->matrix[2][0],
currentSrcPicture->transform->matrix[2][1],
currentSrcPicture->transform->matrix[2][2],
20-src_w2, 20-src_h2);
} else {
setTMIncrementsRegs (1 << 16, 0, srcX << 16,
0, 1 << 16, srcY << 16,
0, 0, 0x10000,
20-src_w2, 20-src_h2);
}
if (currentMask != NULL) {
mgaWaitAvail (1);
MGA_OUT32 (mmio, MGA_REG_TEXCTL2,
MGA_G400_TC2_MAGIC | MGA_TC2_DUALTEX | MGA_TC2_SELECT_TMU1);
if (currentMaskPicture->transform) {
setTMIncrementsRegs (currentMaskPicture->transform->matrix[0][0],
currentMaskPicture->transform->matrix[0][1],
currentMaskPicture->transform->matrix[0][2] +
(maskX << 16),
currentMaskPicture->transform->matrix[1][0],
currentMaskPicture->transform->matrix[1][1],
currentMaskPicture->transform->matrix[1][2] +
(maskY << 16),
currentMaskPicture->transform->matrix[2][0],
currentMaskPicture->transform->matrix[2][1],
currentMaskPicture->transform->matrix[2][2],
20-mask_w2, 20-mask_h2);
} else {
setTMIncrementsRegs (1 << 16, 0, maskX << 16,
0, 1 << 16, maskY << 16,
0, 0, 0x10000,
20-mask_w2, 20-mask_h2);
}
mgaWaitAvail (1);
MGA_OUT32 (mmio, MGA_REG_TEXCTL2, MGA_G400_TC2_MAGIC | MGA_TC2_DUALTEX);
}
/* Destination Bounding Box
* (Boundary Right | Boundary Left, Y dest | Height)
*/
mgaWaitAvail (2);
MGA_OUT32 (mmio, MGA_REG_FXBNDRY,
((dstX + width) << 16) | (dstX & 0xffff));
MGA_OUT32 (mmio, MGA_REG_YDSTLEN | MGA_REG_EXEC,
(dstY << 16) | (height & 0xffff));
}
void
mgaDoneComposite (void)
{
}

View File

@ -1,240 +0,0 @@
/*
* Copyright © 2003 Anders Carlsson
*
* 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 Anders Carlsson not be used in
* advertising or publicity pertaining to distribution of the software without
* specific, written prior permission. Anders Carlsson makes no
* representations about the suitability of this software for any purpose. It
* is provided "as is" without express or implied warranty.
*
* ANDERS CARLSSON DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL ANDERS CARLSSON 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.
*/
#ifdef HAVE_CONFIG_H
#include <kdrive-config.h>
#endif
#include "mga.h"
static Bool
mgaCardInit (KdCardInfo *card)
{
MgaCardInfo *mgac;
mgac = (MgaCardInfo *) xalloc (sizeof (MgaCardInfo));
if (!mgac)
return FALSE;
mgaMapReg (card, mgac);
if (!vesaInitialize (card, &mgac->vesa))
{
xfree (mgac);
return FALSE;
}
mgac->fifo_size = 0;
card->driver = mgac;
return TRUE;
}
static Bool
mgaScreenInit (KdScreenInfo *screen)
{
MgaScreenInfo *mgas;
mgas = (MgaScreenInfo *) xalloc (sizeof (MgaScreenInfo));
if (!mgas)
return FALSE;
memset (mgas, '\0', sizeof (MgaScreenInfo));
if (!vesaScreenInitialize (screen, &mgas->vesa))
{
xfree (mgas);
return FALSE;
}
#if 0
/* if (!mgac->reg)
screen->dumb = TRUE; */
if (mgas->vesa.mapping != VESA_LINEAR)
screen->dumb = TRUE;
fprintf (stderr, "vesa mapping is %d\n", mgas->vesa.mapping);
#endif
screen->driver = mgas;
return TRUE;
}
static Bool
mgaInitScreen (ScreenPtr pScreen)
{
return vesaInitScreen (pScreen);
}
static Bool
mgaFinishInitScreen (ScreenPtr pScreen)
{
Bool ret;
ret = vesaFinishInitScreen (pScreen);
return ret;
}
static Bool
mgaCreateResources (ScreenPtr pScreen)
{
return vesaCreateResources (pScreen);
}
static void
mgaPreserve (KdCardInfo *card)
{
vesaPreserve (card);
}
Bool
mgaMapReg (KdCardInfo *card, MgaCardInfo *mgac)
{
mgac->reg_base = (CARD8 *) KdMapDevice (MGA_REG_BASE (card),
MGA_REG_SIZE (card));
if (!mgac->reg_base)
{
return FALSE;
}
KdSetMappedMode (MGA_REG_BASE (card),
MGA_REG_SIZE (card),
KD_MAPPED_MODE_REGISTERS);
return TRUE;
}
void
mgaUnmapReg (KdCardInfo *card, MgaCardInfo *mgac)
{
if (mgac->reg_base)
{
KdResetMappedMode (MGA_REG_BASE (card),
MGA_REG_SIZE (card),
KD_MAPPED_MODE_REGISTERS);
KdUnmapDevice ((void *) mgac->reg_base, MGA_REG_SIZE (card));
mgac->reg_base = 0;
/* mgac->reg = 0; */
}
}
void
mgaSetMMIO (KdCardInfo *card, MgaCardInfo *mgac)
{
if (!mgac->reg_base)
mgaMapReg (card, mgac);
}
void
mgaResetMMIO (KdCardInfo *card, MgaCardInfo *mgac)
{
mgaUnmapReg (card, mgac);
}
static Bool
mgaDPMS (ScreenPtr pScreen, int mode)
{
/* XXX */
return TRUE;
}
static Bool
mgaEnable (ScreenPtr pScreen)
{
KdScreenPriv (pScreen);
MgaCardInfo *mgac = pScreenPriv->card->driver;
if (!vesaEnable (pScreen))
return FALSE;
mgaSetMMIO (pScreenPriv->card, mgac);
mgaDPMS (pScreen, KD_DPMS_NORMAL);
return TRUE;
}
static void
mgaDisable (ScreenPtr pScreen)
{
KdScreenPriv (pScreen);
MgaCardInfo *mgac = pScreenPriv->card->driver;
mgaResetMMIO (pScreenPriv->card, mgac);
vesaDisable (pScreen);
}
static void
mgaRestore (KdCardInfo *card)
{
MgaCardInfo *mgac = card->driver;
mgaResetMMIO (card, mgac);
vesaRestore (card);
}
static void
mgaScreenFini (KdScreenInfo *screen)
{
MgaScreenInfo *mgas = (MgaScreenInfo *) screen->driver;
vesaScreenFini (screen);
xfree (mgas);
screen->driver = 0;
}
static void
mgaCardFini (KdCardInfo *card)
{
MgaCardInfo *mgac = (MgaCardInfo *)card->driver;
mgaUnmapReg (card, mgac);
vesaCardFini (card);
}
KdCardFuncs mgaFuncs = {
mgaCardInit, /* cardinit */
mgaScreenInit, /* scrinit */
mgaInitScreen, /* initScreen */
mgaFinishInitScreen, /* finishInitScreen */
mgaCreateResources, /* createRes */
mgaPreserve, /* preserve */
mgaEnable, /* enable */
mgaDPMS, /* dpms */
mgaDisable, /* disable */
mgaRestore, /* restore */
mgaScreenFini, /* scrfini */
mgaCardFini, /* cardfini */
0, /* initCursor */
0, /* enableCursor */
0, /* disableCursor */
0, /* finiCursor */
0, /* recolorCursor */
mgaDrawInit, /* initAccel */
mgaDrawEnable, /* enableAccel */
mgaDrawDisable, /* disableAccel */
mgaDrawFini, /* finiAccel */
vesaGetColors, /* getColors */
vesaPutColors, /* putColors */
};

View File

@ -1,164 +0,0 @@
/*
* Copyright © 2003-2004 Anders Carlsson
*
* 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 Anders Carlsson not be used in
* advertising or publicity pertaining to distribution of the software without
* specific, written prior permission. Anders Carlsson makes no
* representations about the suitability of this software for any purpose. It
* is provided "as is" without express or implied warranty.
*
* ANDERS CARLSSON DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL ANDERS CARLSSON 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.
*/
#ifndef _MGA_H_
#define _MGA_H_
#include <vesa.h>
#include <klinux.h>
#define MGA_REG_BASE(c) ((c)->attr.address[1])
#define MGA_REG_SIZE(c) (0x4000)
#define MGA_OUT32(mmio, a, v) (*(VOL32 *) ((mmio) + (a)) = (v))
#define MGA_IN32(mmio, a) (*(VOL32 *) ((mmio) + (a)))
#define MGA_REG_EXEC (0x0100)
#define MGA_REG_DWGCTL (0x1c00)
#define MGA_REG_PLNWT (0x1c1c)
#define MGA_REG_FCOL (0x1c24)
#define MGA_REG_MACCESS (0x1c04)
#define MGA_REG_SGN (0x1c58)
#define MGA_REG_AR0 (0x1c60)
#define MGA_REG_AR1 (0x1c64)
#define MGA_REG_AR2 (0x1c68)
#define MGA_REG_AR3 (0x1c6C)
#define MGA_REG_AR4 (0x1c70)
#define MGA_REG_AR5 (0x1c74)
#define MGA_REG_AR6 (0x1c78)
#define MGA_REG_CXBNDRY (0x1c80)
#define MGA_REG_FXBNDRY (0x1c84)
#define MGA_REG_YDSTLEN (0x1c88)
#define MGA_REG_PITCH (0x1c8c)
#define MGA_REG_YTOP (0x1c98)
#define MGA_REG_YBOT (0x1c9c)
#define MGA_REG_FIFOSTATUS (0x1e10)
#define MGA_REG_STATUS (0x1e14)
#define MGA_REG_CACHEFLUSH (0x1fff)
#define MGA_REG_SRCORG (0x2cb4)
#define MGA_REG_DSTORG (0x2cb8)
#define MGA_G4XX_DEVICE_ID (0x0525)
#define MGA_PW8 (0)
#define MGA_PW16 (1)
#define MGA_PW24 (2)
#define MGA_PW32 (3)
/* Drawing opcodes */
#define MGA_OPCOD_TRAP (4)
#define MGA_OPCOD_TEXTURE_TRAP (6)
#define MGA_OPCOD_BITBLT (8)
#define MGA_DWGCTL_SOLID (1 << 11)
#define MGA_DWGCTL_ARZERO (1 << 12)
#define MGA_DWGCTL_SGNZERO (1 << 13)
#define MGA_DWGCTL_SHIFTZERO (1 << 14)
#define MGA_DWGCTL_BFCOL (2 << 25)
#define MGA_ATYPE_RPL (0 << 4)
#define MGA_ATYPE_RSTR (1 << 4)
#define MGA_ATYPE_ZI (3 << 4)
#define MGA_ATYPE_BLK (4 << 4)
#define MGA_ATYPE_I (7 << 4)
typedef volatile CARD8 VOL8;
typedef volatile CARD16 VOL16;
typedef volatile CARD32 VOL32;
typedef struct _mgaCardInfo {
VesaCardPrivRec vesa;
CARD8 *reg_base;
int fifo_size;
} MgaCardInfo;
#define getMgaCardInfo(kd) ((MgaCardInfo *) ((kd)->card->driver))
#define mgaCardInfo(kd) MgaCardInfo *mgac = getMgaCardInfo(kd)
typedef struct _mgaScreenInfo {
VesaScreenPrivRec vesa;
KaaScreenInfoRec kaa;
int pitch;
int pw;
} MgaScreenInfo;
#define getMgaScreenInfo(kd) ((MgaScreenInfo *) ((kd)->screen->driver))
#define mgaScreenInfo(kd) MgaScreenInfo *mgas = getMgaScreenInfo(kd)
VOL8 *mmio;
Bool
mgaMapReg (KdCardInfo *card, MgaCardInfo *mgac);
void
mgaUnmapReg (KdCardInfo *card, MgaCardInfo *mgac);
void
mgaSetMMIO (KdCardInfo *card, MgaCardInfo *mgac);
void
mgaResetMMIO (KdCardInfo *card, MgaCardInfo *mgac);
Bool
mgaDrawSetup (ScreenPtr pScreen);
Bool
mgaDrawInit (ScreenPtr pScreen);
void
mgaDrawEnable (ScreenPtr pScreen);
void
mgaDrawDisable (ScreenPtr pScreen);
void
mgaDrawFini (ScreenPtr pScreen);
extern KdCardFuncs mgaFuncs;
void
mgaWaitAvail (int n);
void
mgaWaitIdle (void);
Bool
mgaSetup (ScreenPtr pScreen, int dest_bpp, int wait);
#if 0
#define MGA_FALLBACK(x) \
do { \
ErrorF x; \
return FALSE; \
} while (0);
#else
#define MGA_FALLBACK(x) return FALSE;
#endif
#endif /* _MGA_H_ */

View File

@ -1,324 +0,0 @@
/*
* Copyright © 2003-2004 Anders Carlsson
*
* 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 Anders Carlsson not be used in
* advertising or publicity pertaining to distribution of the software without
* specific, written prior permission. Anders Carlsson makes no
* representations about the suitability of this software for any purpose. It
* is provided "as is" without express or implied warranty.
*
* ANDERS CARLSSON DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL ANDERS CARLSSON 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.
*/
#ifdef HAVE_CONFIG_H
#include <kdrive-config.h>
#endif
#include "mga.h"
#include "g400_common.h"
#include "kaa.h"
#include <unistd.h>
CARD32 mgaRop[16] = {
/* GXclear */ MGA_ATYPE_RPL | 0x00000000, /* 0 */
/* GXand */ MGA_ATYPE_RSTR | 0x00080000, /* src AND dst */
/* GXandReverse */ MGA_ATYPE_RSTR | 0x00040000, /* src AND NOT dst */
/* GXcopy */ MGA_ATYPE_RSTR | 0x000c0000, /* src */
/* GXandInverted */ MGA_ATYPE_RSTR | 0x00020000, /* NOT src AND dst */
/* GXnoop */ MGA_ATYPE_RSTR | 0x000a0000, /* dst */
/* GXxor */ MGA_ATYPE_RSTR | 0x00060000, /* src XOR dst */
/* GXor */ MGA_ATYPE_RSTR | 0x000e0000, /* src OR dst */
/* GXnor */ MGA_ATYPE_RSTR | 0x00010000, /* NOT src AND NOT dst */
/* GXequiv */ MGA_ATYPE_RSTR | 0x00090000, /* NOT src XOR dst */
/* GXinvert */ MGA_ATYPE_RSTR | 0x00050000, /* NOT dst */
/* GXorReverse */ MGA_ATYPE_RSTR | 0x000d0000, /* src OR NOT dst */
/* GXcopyInverted */ MGA_ATYPE_RPL | 0x00030000, /* NOT src */
/* GXorInverted */ MGA_ATYPE_RSTR | 0x000b0000, /* NOT src OR dst */
/* GXnand */ MGA_ATYPE_RSTR | 0x00070000, /* NOT src OR NOT dst */
/* GXset */ MGA_ATYPE_RPL | 0x000f0000 /* 1 */
};
VOL8 *mmio;
int fifo_size;
int pitch, src_pitch;
int dir;
void
mgaWaitAvail (int n)
{
if (fifo_size < n) {
while ((fifo_size = MGA_IN32 (mmio, MGA_REG_FIFOSTATUS) & 0xff) < n)
;
}
fifo_size -= n;
}
#define MGA_OUT8(mmio, a, v) (*(VOL8 *) ((mmio) + (a)) = (v))
#define MGA_REG_CRTC_INDEX (0x1fd4)
void
mgaWaitIdle (void)
{
mgaWaitAvail (2);
MGA_OUT32(mmio, MGA_REG_CACHEFLUSH, 0);
/* MGA_OUT8 (mmio, MGA_REG_CRTC_INDEX, 0); */
while (MGA_IN32 (mmio, MGA_REG_STATUS) & 0x10000)
;
}
static void
mgaWaitMarker (ScreenPtr pScreen, int marker)
{
KdScreenPriv (pScreen);
mgaCardInfo (pScreenPriv);
mmio = mgac->reg_base;
mgaWaitIdle ();
}
Bool
mgaSetup (ScreenPtr pScreen, int dest_bpp, int wait)
{
KdScreenPriv (pScreen);
mgaScreenInfo (pScreenPriv);
mgaCardInfo (pScreenPriv);
fifo_size = 0;
mmio = mgac->reg_base;
pitch = mgas->pitch;
if (!mmio)
return FALSE;
mgaWaitAvail (wait + 4);
/* Set the format of the destination pixmap */
switch (dest_bpp) {
case 8:
MGA_OUT32 (mmio, MGA_REG_MACCESS, MGA_PW8);
break;
case 16:
MGA_OUT32 (mmio, MGA_REG_MACCESS, MGA_PW16);
break;
case 24:
case 32:
MGA_OUT32 (mmio, MGA_REG_MACCESS, MGA_PW24);
break;
}
MGA_OUT32 (mmio, MGA_REG_CXBNDRY, 0xffff0000);
MGA_OUT32 (mmio, MGA_REG_YTOP, 0x00000000);
MGA_OUT32 (mmio, MGA_REG_YBOT, 0x007fffff);
return TRUE;
}
static Bool
mgaPrepareSolid (PixmapPtr pPixmap, int alu, Pixel pm, Pixel fg)
{
KdScreenPriv(pPixmap->drawable.pScreen);
int cmd;
int dst_org;
/* We must pad pm and fg depending on the format of the
* destination pixmap
*/
switch (pPixmap->drawable.bitsPerPixel) {
case 16:
fg |= fg << 16;
pm |= pm << 16;
break;
case 8:
fg |= (fg << 8) | (fg << 16) | (fg << 24);
pm |= (pm << 8) | (pm << 16) | (pm << 24);
break;
}
cmd = MGA_OPCOD_TRAP | MGA_DWGCTL_SOLID | MGA_DWGCTL_ARZERO | MGA_DWGCTL_SGNZERO |
MGA_DWGCTL_SHIFTZERO | mgaRop[alu];
dst_org = (int)pPixmap->devPrivate.ptr - (int)pScreenPriv->screen->memory_base;
mgaSetup (pPixmap->drawable.pScreen, pPixmap->drawable.bitsPerPixel, 5);
MGA_OUT32 (mmio, MGA_REG_DSTORG, dst_org);
MGA_OUT32 (mmio, MGA_REG_PITCH, pPixmap->devKind / (pPixmap->drawable.bitsPerPixel >> 3));
MGA_OUT32 (mmio, MGA_REG_DWGCTL, cmd);
MGA_OUT32 (mmio, MGA_REG_FCOL, fg);
MGA_OUT32 (mmio, MGA_REG_PLNWT, pm);
return TRUE;
}
static void
mgaSolid (int x1, int y1, int x2, int y2)
{
mgaWaitAvail (2);
MGA_OUT32 (mmio, MGA_REG_FXBNDRY, (x2 << 16) | (x1 & 0xffff));
MGA_OUT32 (mmio, MGA_REG_YDSTLEN | MGA_REG_EXEC, (y1 << 16) | (y2 - y1));
}
static void
mgaDoneSolid (void)
{
}
#define BLIT_LEFT 1
#define BLIT_UP 4
static Bool
mgaPrepareCopy (PixmapPtr pSrcPixmap, PixmapPtr pDstPixmap,
int dx, int dy, int alu, Pixel pm)
{
KdScreenPriv(pSrcPixmap->drawable.pScreen);
int cmd;
cmd = MGA_OPCOD_BITBLT | MGA_DWGCTL_BFCOL | MGA_DWGCTL_SHIFTZERO | mgaRop[alu];
dir = 0;
if (dy < 0)
dir |= BLIT_UP;
if (dx < 0)
dir |= BLIT_LEFT;
mgaSetup (pSrcPixmap->drawable.pScreen,
pDstPixmap->drawable.bitsPerPixel, 7);
MGA_OUT32 (mmio, MGA_REG_SRCORG, ((int)pSrcPixmap->devPrivate.ptr -
(int)pScreenPriv->screen->memory_base));
MGA_OUT32 (mmio, MGA_REG_DSTORG, ((int)pDstPixmap->devPrivate.ptr -
(int)pScreenPriv->screen->memory_base));
MGA_OUT32 (mmio, MGA_REG_PITCH, (pDstPixmap->devKind /
(pDstPixmap->drawable.bitsPerPixel >> 3)));
src_pitch = pSrcPixmap->devKind / (pSrcPixmap->drawable.bitsPerPixel >> 3);
MGA_OUT32 (mmio, MGA_REG_DWGCTL, cmd);
MGA_OUT32 (mmio, MGA_REG_SGN, dir);
MGA_OUT32 (mmio, MGA_REG_PLNWT, pm);
MGA_OUT32 (mmio, MGA_REG_AR5, src_pitch * (dy < 0 ? -1 : 1) );
return TRUE;
}
static void
mgaCopy (int srcX, int srcY, int dstX, int dstY, int w, int h)
{
int start, end;
if (dir & BLIT_UP)
{
srcY += h - 1;
dstY += h - 1;
}
w--;
start = end = srcY * src_pitch + srcX;
if (dir & BLIT_LEFT)
start += w;
else
end += w;
mgaWaitAvail (4);
MGA_OUT32 (mmio, MGA_REG_AR0, end);
MGA_OUT32 (mmio, MGA_REG_AR3, start);
MGA_OUT32 (mmio, MGA_REG_FXBNDRY, ((dstX + w) << 16) | (dstX & 0xffff));
MGA_OUT32 (mmio, MGA_REG_YDSTLEN | MGA_REG_EXEC, (dstY << 16) | h);
}
static void
mgaDoneCopy (void)
{
}
#if 0
static Bool
mgaUploadToScreen(PixmapPtr pDst, char *src, int src_pitch) {
/*fprintf(stderr,"Upload to Screen %p [%d]\n",src,src_pitch);*/
return TRUE;
}
#endif
Bool
mgaDrawInit (ScreenPtr pScreen)
{
KdScreenPriv(pScreen);
mgaScreenInfo (pScreenPriv);
KdCardInfo *card = pScreenPriv->card;
memset(&mgas->kaa, 0, sizeof(KaaScreenInfoRec));
mgas->kaa.waitMarker = mgaWaitMarker;
mgas->kaa.PrepareSolid = mgaPrepareSolid;
mgas->kaa.Solid = mgaSolid;
mgas->kaa.DoneSolid = mgaDoneSolid;
mgas->kaa.PrepareCopy = mgaPrepareCopy;
mgas->kaa.Copy = mgaCopy;
mgas->kaa.DoneCopy = mgaDoneCopy;
/* In PW24 mode, we need to align to "3 64-bytes" */
mgas->kaa.offsetAlign = 192;
/* Pitch alignment is in sets of 32 pixels, and we need to cover 32bpp, so
* 128 bytes
*/
mgas->kaa.pitchAlign = 128;
mgas->kaa.flags = KAA_OFFSCREEN_PIXMAPS;
if (card->attr.deviceID == MGA_G4XX_DEVICE_ID) {
mgas->kaa.CheckComposite = mgaCheckComposite;
mgas->kaa.PrepareComposite = mgaPrepareComposite;
mgas->kaa.Composite = mgaComposite;
mgas->kaa.DoneComposite = mgaDoneComposite;
}
/*mgas->kaa.UploadToScreen=mgaUploadToScreen;*/
if (!kaaDrawInit (pScreen, &mgas->kaa))
return FALSE;
return TRUE;
}
void
mgaDrawEnable (ScreenPtr pScreen)
{
KdScreenPriv (pScreen);
mgaScreenInfo (pScreenPriv);
mgas->pitch = pScreenPriv->screen->width;
switch (pScreenPriv->screen->fb[0].depth) {
case 8:
mgas->pw = MGA_PW8;
break;
case 16:
mgas->pw = MGA_PW16;
break;
case 24:
case 32:
mgas->pw = MGA_PW24;
break;
default:
FatalError ("unsupported pixel format");
}
kaaMarkSync (pScreen);
}
void
mgaDrawDisable (ScreenPtr pScreen)
{
kaaWaitSync(pScreen);
}
void
mgaDrawFini (ScreenPtr pScreen)
{
}

View File

@ -1,64 +0,0 @@
/*
* Copyright © 2003 Anders Carlsson
*
* 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 Anders Carlsson not be used in
* advertising or publicity pertaining to distribution of the software without
* specific, written prior permission. Anders Carlsson makes no
* representations about the suitability of this software for any purpose. It
* is provided "as is" without express or implied warranty.
*
* ANDERS CARLSSON DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
* EVENT SHALL ANDERS CARLSSON 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.
*/
#ifdef HAVE_CONFIG_H
#include <kdrive-config.h>
#endif
#include "mga.h"
void
InitCard (char *name)
{
KdCardAttr attr;
if (LinuxFindPci (0x102b, 0x0525, 0, &attr))
KdCardInfoAdd (&mgaFuncs, &attr, 0);
}
void
InitOutput (ScreenInfo *pScreenInfo, int argc, char **argv)
{
KdInitOutput (pScreenInfo, argc, argv);
}
void
InitInput (int argc, char **argv)
{
KdOsAddInputDrivers ();
KdInitInput ();
}
void
ddxUseMsg (void)
{
KdUseMsg();
vesaUseMsg();
}
int
ddxProcessArgument (int argc, char **argv, int i)
{
int ret;
if (!(ret = vesaProcessArgument (argc, argv, i)))
ret = KdProcessArgument(argc, argv, i);
return ret;
}

View File

@ -1,49 +0,0 @@
if KDRIVEFBDEV
FBDEV_INCLUDES =-I$(top_srcdir)/hw/kdrive/fbdev
FBDEV_LIBS = $(top_builddir)/hw/kdrive/fbdev/libfbdev.a
endif
if KDRIVEVESA
VESA_INCLUDES = -I$(top_srcdir)/hw/kdrive/vesa
VESA_LIBS = $(top_builddir)/hw/kdrive/vesa/libvesa.a
endif
INCLUDES = \
@KDRIVE_INCS@ \
$(FBDEV_INCLUDES) \
$(VESA_INCLUDES) \
@KDRIVE_CFLAGS@
bin_PROGRAMS = Xneomagic
noinst_LIBRARIES = libneomagic.a
libneomagic_a_SOURCES = \
neomagic.c \
neomagic.h \
neo_draw.c
Xneomagic_SOURCES = \
neomagicstub.c
NEOMAGIC_LIBS = \
libneomagic.a \
${FBDEV_LIBS} \
${VESA_LIBS} \
@KDRIVE_LIBS@
if GLX
Xneomagic_LDFLAGS = $(LD_EXPORT_SYMBOLS_FLAG)
endif
Xneomagic_LDADD = \
$(NEOMAGIC_LIBS) \
@KDRIVE_LIBS@ \
@XSERVER_LIBS@
Xneomagic_DEPENDENCIES = \
libneomagic.a \
@KDRIVE_LOCAL_LIBS@
relink:
rm -f $(bin_PROGRAMS) && make $(bin_PROGRAMS)

View File

@ -1,15 +0,0 @@
Neomagic KDrive driver for xserver
This is a very simple implementation for Neomagic based cards.
Almost all functions are handled by the VESA driver, and
only solid drawing and bitblt are done with acceleration,
This driver has been tested in MagicGraph 256AV+(NM2230) card
but it should work on other cards as well.
The only warning is to choose a working mode. You can ask
for supported modes using -listmodes. I use -mode 0x117.
--
Franco Catrin L.
fcatrin@tuxpan.com

Some files were not shown because too many files have changed in this diff Show More