2010-07-27 13:02:24 -06:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2009 Tiago Vignatti
|
|
|
|
*
|
|
|
|
* 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 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 THE AUTHORS OR COPYRIGHT
|
|
|
|
* HOLDERS 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.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_XORG_CONFIG_H
|
|
|
|
#include <xorg-config.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "misc.h"
|
|
|
|
#include "xf86.h"
|
|
|
|
#include "xf86_OSproc.h"
|
|
|
|
#include <X11/X.h>
|
|
|
|
#include "colormapst.h"
|
|
|
|
#include "scrnintstr.h"
|
|
|
|
#include "screenint.h"
|
|
|
|
#include "gcstruct.h"
|
|
|
|
#include "pixmapstr.h"
|
|
|
|
#include "pixmap.h"
|
|
|
|
#include "windowstr.h"
|
|
|
|
#include "window.h"
|
|
|
|
#include "xf86str.h"
|
|
|
|
#include "mipointer.h"
|
|
|
|
#include "mipointrst.h"
|
2012-06-10 07:21:05 -06:00
|
|
|
#include "picturestr.h"
|
2010-07-27 13:02:24 -06:00
|
|
|
|
|
|
|
#define WRAP_SCREEN(x,y) {pScreenPriv->x = pScreen->x; pScreen->x = y;}
|
|
|
|
|
|
|
|
#define UNWRAP_SCREEN(x) pScreen->x = pScreenPriv->x
|
|
|
|
|
|
|
|
#define SCREEN_PROLOG(x) pScreen->x = ((VGAarbiterScreenPtr) \
|
|
|
|
dixLookupPrivate(&(pScreen)->devPrivates, VGAarbiterScreenKey))->x
|
|
|
|
|
2010-12-05 08:36:02 -07:00
|
|
|
#define SCREEN_EPILOG(x,y) pScreen->x = y;
|
2010-07-27 13:02:24 -06:00
|
|
|
|
|
|
|
#define WRAP_PICT(x,y) if (ps) {pScreenPriv->x = ps->x;\
|
|
|
|
ps->x = y;}
|
|
|
|
|
|
|
|
#define UNWRAP_PICT(x) if (ps) {ps->x = pScreenPriv->x;}
|
|
|
|
|
|
|
|
#define PICTURE_PROLOGUE(field) ps->field = \
|
|
|
|
((VGAarbiterScreenPtr)dixLookupPrivate(&(pScreen)->devPrivates, \
|
|
|
|
VGAarbiterScreenKey))->field
|
|
|
|
|
|
|
|
#define PICTURE_EPILOGUE(field, wrap) ps->field = wrap
|
|
|
|
|
|
|
|
#define WRAP_SCREEN_INFO(x,y) do {pScreenPriv->x = pScrn->x; pScrn->x = y;} while(0)
|
|
|
|
|
|
|
|
#define UNWRAP_SCREEN_INFO(x) pScrn->x = pScreenPriv->x
|
|
|
|
|
|
|
|
#define SPRITE_PROLOG miPointerScreenPtr PointPriv = \
|
|
|
|
(miPointerScreenPtr)dixLookupPrivate(&pScreen->devPrivates, \
|
|
|
|
miPointerScreenKey); VGAarbiterScreenPtr pScreenPriv = \
|
|
|
|
((VGAarbiterScreenPtr)dixLookupPrivate(&(pScreen)->devPrivates, \
|
2010-12-05 08:36:02 -07:00
|
|
|
VGAarbiterScreenKey)); PointPriv->spriteFuncs = pScreenPriv->miSprite;
|
2010-07-27 13:02:24 -06:00
|
|
|
|
|
|
|
#define SPRITE_EPILOG pScreenPriv->miSprite = PointPriv->spriteFuncs;\
|
2010-12-05 08:36:02 -07:00
|
|
|
PointPriv->spriteFuncs = &VGAarbiterSpriteFuncs;
|
2010-07-27 13:02:24 -06:00
|
|
|
|
|
|
|
#define WRAP_SPRITE do { pScreenPriv->miSprite = PointPriv->spriteFuncs;\
|
|
|
|
PointPriv->spriteFuncs = &VGAarbiterSpriteFuncs; \
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
#define UNWRAP_SPRITE PointPriv->spriteFuncs = pScreenPriv->miSprite
|
|
|
|
|
|
|
|
#define GC_WRAP(x) pGCPriv->wrapOps = (x)->ops;\
|
|
|
|
pGCPriv->wrapFuncs = (x)->funcs; (x)->ops = &VGAarbiterGCOps;\
|
2010-12-05 08:36:02 -07:00
|
|
|
(x)->funcs = &VGAarbiterGCFuncs;
|
2010-07-27 13:02:24 -06:00
|
|
|
|
|
|
|
#define GC_UNWRAP(x) VGAarbiterGCPtr pGCPriv = \
|
|
|
|
(VGAarbiterGCPtr)dixLookupPrivate(&(x)->devPrivates, VGAarbiterGCKey);\
|
2010-12-05 08:36:02 -07:00
|
|
|
(x)->ops = pGCPriv->wrapOps; (x)->funcs = pGCPriv->wrapFuncs;
|
2010-07-27 13:02:24 -06:00
|
|
|
|
2011-11-05 07:32:40 -06:00
|
|
|
static inline void
|
2012-06-10 07:21:05 -06:00
|
|
|
VGAGet(ScreenPtr pScreen)
|
|
|
|
{
|
2011-11-05 07:32:40 -06:00
|
|
|
pci_device_vgaarb_set_target(xf86Screens[pScreen->myNum]->vgaDev);
|
|
|
|
pci_device_vgaarb_lock();
|
|
|
|
}
|
2010-07-27 13:02:24 -06:00
|
|
|
|
2011-11-05 07:32:40 -06:00
|
|
|
static inline void
|
2012-06-10 07:21:05 -06:00
|
|
|
VGAPut(void)
|
|
|
|
{
|
2011-11-05 07:32:40 -06:00
|
|
|
pci_device_vgaarb_unlock();
|
|
|
|
}
|
2010-07-27 13:02:24 -06:00
|
|
|
|
|
|
|
typedef struct _VGAarbiterScreen {
|
2012-06-10 07:21:05 -06:00
|
|
|
CreateGCProcPtr CreateGC;
|
|
|
|
CloseScreenProcPtr CloseScreen;
|
|
|
|
ScreenBlockHandlerProcPtr BlockHandler;
|
|
|
|
ScreenWakeupHandlerProcPtr WakeupHandler;
|
|
|
|
GetImageProcPtr GetImage;
|
|
|
|
GetSpansProcPtr GetSpans;
|
|
|
|
SourceValidateProcPtr SourceValidate;
|
|
|
|
CopyWindowProcPtr CopyWindow;
|
|
|
|
ClearToBackgroundProcPtr ClearToBackground;
|
|
|
|
CreatePixmapProcPtr CreatePixmap;
|
|
|
|
SaveScreenProcPtr SaveScreen;
|
2010-07-27 13:02:24 -06:00
|
|
|
/* Colormap */
|
2012-06-10 07:21:05 -06:00
|
|
|
StoreColorsProcPtr StoreColors;
|
2010-07-27 13:02:24 -06:00
|
|
|
/* Cursor */
|
2012-06-10 07:21:05 -06:00
|
|
|
DisplayCursorProcPtr DisplayCursor;
|
|
|
|
RealizeCursorProcPtr RealizeCursor;
|
|
|
|
UnrealizeCursorProcPtr UnrealizeCursor;
|
|
|
|
RecolorCursorProcPtr RecolorCursor;
|
|
|
|
SetCursorPositionProcPtr SetCursorPosition;
|
|
|
|
void (*AdjustFrame) (int, int, int, int);
|
|
|
|
Bool (*SwitchMode) (int, DisplayModePtr, int);
|
|
|
|
Bool (*EnterVT) (int, int);
|
|
|
|
void (*LeaveVT) (int, int);
|
|
|
|
void (*FreeScreen) (int, int);
|
|
|
|
miPointerSpriteFuncPtr miSprite;
|
|
|
|
CompositeProcPtr Composite;
|
|
|
|
GlyphsProcPtr Glyphs;
|
|
|
|
CompositeRectsProcPtr CompositeRects;
|
2010-07-27 13:02:24 -06:00
|
|
|
} VGAarbiterScreenRec, *VGAarbiterScreenPtr;
|
|
|
|
|
|
|
|
typedef struct _VGAarbiterGC {
|
2012-06-10 07:21:05 -06:00
|
|
|
GCOps *wrapOps;
|
|
|
|
GCFuncs *wrapFuncs;
|
2010-07-27 13:02:24 -06:00
|
|
|
} VGAarbiterGCRec, *VGAarbiterGCPtr;
|
|
|
|
|
|
|
|
/* Screen funcs */
|
2012-06-10 07:21:05 -06:00
|
|
|
static void VGAarbiterBlockHandler(int i, pointer blockData, pointer pTimeout,
|
|
|
|
pointer pReadmask);
|
|
|
|
static void VGAarbiterWakeupHandler(int i, pointer blockData,
|
|
|
|
unsigned long result, pointer pReadmask);
|
|
|
|
static Bool VGAarbiterCloseScreen(int i, ScreenPtr pScreen);
|
|
|
|
static void VGAarbiterGetImage(DrawablePtr pDrawable, int sx, int sy, int w,
|
|
|
|
int h, unsigned int format,
|
|
|
|
unsigned long planemask, char *pdstLine);
|
|
|
|
static void VGAarbiterGetSpans(DrawablePtr pDrawable, int wMax, DDXPointPtr ppt,
|
|
|
|
int *pwidth, int nspans, char *pdstStart);
|
|
|
|
static void VGAarbiterSourceValidate(DrawablePtr pDrawable, int x, int y,
|
|
|
|
int width, int height,
|
|
|
|
unsigned int subWindowMode);
|
2010-07-27 13:02:24 -06:00
|
|
|
static void VGAarbiterCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg,
|
2012-06-10 07:21:05 -06:00
|
|
|
RegionPtr prgnSrc);
|
|
|
|
static void VGAarbiterClearToBackground(WindowPtr pWin, int x, int y, int w,
|
|
|
|
int h, Bool generateExposures);
|
2010-07-27 13:02:24 -06:00
|
|
|
static PixmapPtr VGAarbiterCreatePixmap(ScreenPtr pScreen, int w, int h,
|
2012-06-10 07:21:05 -06:00
|
|
|
int depth, unsigned int usage_hint);
|
|
|
|
static Bool VGAarbiterCreateGC(GCPtr pGC);
|
2010-07-27 13:02:24 -06:00
|
|
|
static Bool VGAarbiterSaveScreen(ScreenPtr pScreen, Bool unblank);
|
2012-06-10 07:21:05 -06:00
|
|
|
static void VGAarbiterStoreColors(ColormapPtr pmap, int ndef, xColorItem
|
|
|
|
* pdefs);
|
|
|
|
static void VGAarbiterRecolorCursor(DeviceIntPtr pDev, ScreenPtr pScreen,
|
|
|
|
CursorPtr pCurs, Bool displayed);
|
|
|
|
static Bool VGAarbiterRealizeCursor(DeviceIntPtr pDev, ScreenPtr pScreen,
|
|
|
|
CursorPtr pCursor);
|
|
|
|
static Bool VGAarbiterUnrealizeCursor(DeviceIntPtr pDev, ScreenPtr pScreen,
|
|
|
|
CursorPtr pCursor);
|
|
|
|
static Bool VGAarbiterDisplayCursor(DeviceIntPtr pDev, ScreenPtr pScreen,
|
|
|
|
CursorPtr pCursor);
|
|
|
|
static Bool VGAarbiterSetCursorPosition(DeviceIntPtr pDev, ScreenPtr
|
|
|
|
pScreen, int x, int y,
|
|
|
|
Bool generateEvent);
|
2010-07-27 13:02:24 -06:00
|
|
|
static void VGAarbiterAdjustFrame(int index, int x, int y, int flags);
|
|
|
|
static Bool VGAarbiterSwitchMode(int index, DisplayModePtr mode, int flags);
|
|
|
|
static Bool VGAarbiterEnterVT(int index, int flags);
|
|
|
|
static void VGAarbiterLeaveVT(int index, int flags);
|
|
|
|
static void VGAarbiterFreeScreen(int index, int flags);
|
|
|
|
|
|
|
|
/* GC funcs */
|
|
|
|
static void VGAarbiterValidateGC(GCPtr pGC, unsigned long changes,
|
2012-06-10 07:21:05 -06:00
|
|
|
DrawablePtr pDraw);
|
2010-07-27 13:02:24 -06:00
|
|
|
static void VGAarbiterChangeGC(GCPtr pGC, unsigned long mask);
|
|
|
|
static void VGAarbiterCopyGC(GCPtr pGCSrc, unsigned long mask, GCPtr pGCDst);
|
|
|
|
static void VGAarbiterDestroyGC(GCPtr pGC);
|
|
|
|
static void VGAarbiterChangeClip(GCPtr pGC, int type, pointer pvalue,
|
2012-06-10 07:21:05 -06:00
|
|
|
int nrects);
|
2010-07-27 13:02:24 -06:00
|
|
|
static void VGAarbiterDestroyClip(GCPtr pGC);
|
|
|
|
static void VGAarbiterCopyClip(GCPtr pgcDst, GCPtr pgcSrc);
|
|
|
|
|
|
|
|
/* GC ops */
|
2012-06-10 07:21:05 -06:00
|
|
|
static void VGAarbiterFillSpans(DrawablePtr pDraw, GC * pGC, int nInit,
|
|
|
|
DDXPointPtr pptInit, int *pwidthInit,
|
|
|
|
int fSorted);
|
2010-07-27 13:02:24 -06:00
|
|
|
static void VGAarbiterSetSpans(DrawablePtr pDraw, GCPtr pGC, char *pcharsrc,
|
2012-06-10 07:21:05 -06:00
|
|
|
register DDXPointPtr ppt, int *pwidth,
|
|
|
|
int nspans, int fSorted);
|
|
|
|
static void VGAarbiterPutImage(DrawablePtr pDraw, GCPtr pGC, int depth, int x,
|
|
|
|
int y, int w, int h, int leftPad, int format,
|
|
|
|
char *pImage);
|
2010-07-27 13:02:24 -06:00
|
|
|
static RegionPtr VGAarbiterCopyArea(DrawablePtr pSrc, DrawablePtr pDst,
|
2012-06-10 07:21:05 -06:00
|
|
|
GC * pGC, int srcx, int srcy, int width,
|
|
|
|
int height, int dstx, int dsty);
|
2010-07-27 13:02:24 -06:00
|
|
|
static RegionPtr VGAarbiterCopyPlane(DrawablePtr pSrc, DrawablePtr pDst,
|
2012-06-10 07:21:05 -06:00
|
|
|
GCPtr pGC, int srcx, int srcy, int width,
|
|
|
|
int height, int dstx, int dsty,
|
|
|
|
unsigned long bitPlane);
|
|
|
|
static void VGAarbiterPolyPoint(DrawablePtr pDraw, GCPtr pGC, int mode, int npt,
|
|
|
|
xPoint * pptInit);
|
|
|
|
static void VGAarbiterPolylines(DrawablePtr pDraw, GCPtr pGC, int mode, int npt,
|
|
|
|
DDXPointPtr pptInit);
|
2010-07-27 13:02:24 -06:00
|
|
|
static void VGAarbiterPolySegment(DrawablePtr pDraw, GCPtr pGC, int nseg,
|
2012-06-10 07:21:05 -06:00
|
|
|
xSegment * pSeg);
|
2010-07-27 13:02:24 -06:00
|
|
|
static void VGAarbiterPolyRectangle(DrawablePtr pDraw, GCPtr pGC,
|
2012-06-10 07:21:05 -06:00
|
|
|
int nRectsInit, xRectangle *pRectsInit);
|
2010-07-27 13:02:24 -06:00
|
|
|
static void VGAarbiterPolyArc(DrawablePtr pDraw, GCPtr pGC, int narcs,
|
2012-06-10 07:21:05 -06:00
|
|
|
xArc * parcs);
|
2010-07-27 13:02:24 -06:00
|
|
|
static void VGAarbiterFillPolygon(DrawablePtr pDraw, GCPtr pGC, int shape,
|
2012-06-10 07:21:05 -06:00
|
|
|
int mode, int count, DDXPointPtr ptsIn);
|
|
|
|
static void VGAarbiterPolyFillRect(DrawablePtr pDraw, GCPtr pGC, int nrectFill,
|
|
|
|
xRectangle *prectInit);
|
2010-07-27 13:02:24 -06:00
|
|
|
static void VGAarbiterPolyFillArc(DrawablePtr pDraw, GCPtr pGC, int narcs,
|
2012-06-10 07:21:05 -06:00
|
|
|
xArc * parcs);
|
2010-07-27 13:02:24 -06:00
|
|
|
static int VGAarbiterPolyText8(DrawablePtr pDraw, GCPtr pGC, int x, int y,
|
2012-06-10 07:21:05 -06:00
|
|
|
int count, char *chars);
|
2010-07-27 13:02:24 -06:00
|
|
|
static int VGAarbiterPolyText16(DrawablePtr pDraw, GCPtr pGC, int x, int y,
|
2012-06-10 07:21:05 -06:00
|
|
|
int count, unsigned short *chars);
|
2010-07-27 13:02:24 -06:00
|
|
|
static void VGAarbiterImageText8(DrawablePtr pDraw, GCPtr pGC, int x, int y,
|
2012-06-10 07:21:05 -06:00
|
|
|
int count, char *chars);
|
2010-07-27 13:02:24 -06:00
|
|
|
static void VGAarbiterImageText16(DrawablePtr pDraw, GCPtr pGC, int x, int y,
|
2012-06-10 07:21:05 -06:00
|
|
|
int count, unsigned short *chars);
|
2010-07-27 13:02:24 -06:00
|
|
|
static void VGAarbiterImageGlyphBlt(DrawablePtr pDraw, GCPtr pGC, int xInit,
|
2012-06-10 07:21:05 -06:00
|
|
|
int yInit, unsigned int nglyph,
|
|
|
|
CharInfoPtr * ppci, pointer pglyphBase);
|
2010-07-27 13:02:24 -06:00
|
|
|
static void VGAarbiterPolyGlyphBlt(DrawablePtr pDraw, GCPtr pGC, int xInit,
|
2012-06-10 07:21:05 -06:00
|
|
|
int yInit, unsigned int nglyph,
|
|
|
|
CharInfoPtr * ppci, pointer pglyphBase);
|
2010-07-27 13:02:24 -06:00
|
|
|
static void VGAarbiterPushPixels(GCPtr pGC, PixmapPtr pBitMap, DrawablePtr
|
2012-06-10 07:21:05 -06:00
|
|
|
pDraw, int dx, int dy, int xOrg, int yOrg);
|
2010-07-27 13:02:24 -06:00
|
|
|
|
|
|
|
/* miSpriteFuncs */
|
|
|
|
static Bool VGAarbiterSpriteRealizeCursor(DeviceIntPtr pDev, ScreenPtr
|
2012-06-10 07:21:05 -06:00
|
|
|
pScreen, CursorPtr pCur);
|
2010-07-27 13:02:24 -06:00
|
|
|
static Bool VGAarbiterSpriteUnrealizeCursor(DeviceIntPtr pDev, ScreenPtr
|
2012-06-10 07:21:05 -06:00
|
|
|
pScreen, CursorPtr pCur);
|
2010-07-27 13:02:24 -06:00
|
|
|
static void VGAarbiterSpriteSetCursor(DeviceIntPtr pDev, ScreenPtr pScreen,
|
2012-06-10 07:21:05 -06:00
|
|
|
CursorPtr pCur, int x, int y);
|
2010-07-27 13:02:24 -06:00
|
|
|
static void VGAarbiterSpriteMoveCursor(DeviceIntPtr pDev, ScreenPtr pScreen,
|
2012-06-10 07:21:05 -06:00
|
|
|
int x, int y);
|
|
|
|
static Bool VGAarbiterDeviceCursorInitialize(DeviceIntPtr pDev,
|
|
|
|
ScreenPtr pScreen);
|
2010-07-27 13:02:24 -06:00
|
|
|
static void VGAarbiterDeviceCursorCleanup(DeviceIntPtr pDev, ScreenPtr pScreen);
|
|
|
|
|
|
|
|
static void VGAarbiterComposite(CARD8 op, PicturePtr pSrc, PicturePtr pMask,
|
2012-06-10 07:21:05 -06:00
|
|
|
PicturePtr pDst, INT16 xSrc, INT16 ySrc,
|
|
|
|
INT16 xMask, INT16 yMask, INT16 xDst,
|
|
|
|
INT16 yDst, CARD16 width, CARD16 height);
|
2010-07-27 13:02:24 -06:00
|
|
|
static void VGAarbiterGlyphs(CARD8 op, PicturePtr pSrc, PicturePtr pDst,
|
2012-06-10 07:21:05 -06:00
|
|
|
PictFormatPtr maskFormat, INT16 xSrc, INT16 ySrc,
|
|
|
|
int nlist, GlyphListPtr list, GlyphPtr * glyphs);
|
|
|
|
static void VGAarbiterCompositeRects(CARD8 op, PicturePtr pDst,
|
|
|
|
xRenderColor * color, int nRect,
|
|
|
|
xRectangle *rects);
|