Add files for Xmuu and i810 driver

This commit is contained in:
Keith Packard 2001-03-30 02:18:41 +00:00
parent f39a62d122
commit eb3da37564
13 changed files with 8123 additions and 0 deletions

21
hw/kdrive/i810/Imakefile Normal file
View File

@ -0,0 +1,21 @@
XCOMM $XConsortium: Imakefile /main/10 1996/12/02 10:20:33 lehors $
XCOMM $XFree86: xc/programs/Xserver/hw/kdrive/i810/Imakefile,v 1.6 2000/10/20 00:19:51 keithp Exp $
KDRIVE=..
#include "../Kdrive.tmpl"
#if BuildXvExt
XVSRCS = i810_video.c
XVOBJS = i810_video.o
#endif
SRCS = i810.c i810stub.c i810draw.c i810_cursor.c $(XVSRCS)
OBJS = i810.o i810stub.o i810draw.o i810_cursor.o $(XVOBJS)
DEFINES = XvExtensionDefines /* -DI810CFG_SHOW_OVERSCAN */
INCLUDES = -I. $(KDINCS)
NormalLibraryObjectRule()
NormalLibraryTarget(i810,$(OBJS))
DependTarget()

2096
hw/kdrive/i810/i810.c Normal file

File diff suppressed because it is too large Load Diff

503
hw/kdrive/i810/i810.h Normal file
View File

@ -0,0 +1,503 @@
/* 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 */
/* $XFree86$ */
/*
* 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 BEGIN_LP_RING(n) \
unsigned int outring, ringmask; \
volatile unsigned char *virt; \
if (n>2 && (I810_DEBUG&DEBUG_ALWAYS_SYNC)) i810Sync( screen ); \
if (i810c->LpRing.space < n*4) i810WaitLpRing( screen, 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
#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;
Bool NeedToSync; /* Need to sync accel stuff */
int nextColorExpandBuf;
ScreenBlockHandlerProcPtr BlockHandler;
#ifdef XV
KdVideoAdaptorPtr adaptor;
#endif
} I810CardInfo;
#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 {
i810Cursor cursor;
} I810ScreenInfo;
#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
i810SyncAccel (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(KdCardInfo *card);
void
i810VGAGetIOBase(i810VGAPtr vgap);
/*
* 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

@ -0,0 +1,409 @@
/* 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.
**************************************************************************/
/* $XFree86$ */
/* i810_cursor.c: KDrive hardware cursor routines for the i810 chipset */
/*
* Authors:
* Keith Whitwell <keithw@precisioninsight.com>
* Pontus Lidman <pontus.lidman@nokia.com>
*
*/
#include "kdrive.h"
#include "kxv.h"
#include "i810.h"
#include "cursorstr.h"
#define SetupCursor(s) KdScreenPriv(s); \
i810CardInfo(pScreenPriv); \
i810ScreenInfo(pScreenPriv); \
i810Cursor *pCurPriv = &i810s->cursor
static void
writeStandardMMIO(I810CardInfo *i810c, int addr, CARD8 val) {
moutb(addr, val);
}
void
_i810MoveCursor(ScreenPtr pScreen, int x, int y) {
SetupCursor(pScreen);
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 (ScreenPtr pScreen, int x, int y)
{
SetupCursor (pScreen);
if (!pCurPriv->has_cursor)
return;
if (!pScreenPriv->enabled)
return;
_i810MoveCursor (pScreen, x, y);
i810LoadCursor(pScreen, x, y);
}
static void
_i810SetCursorColors(ScreenPtr pScreen) { /* int bg, int fg */
SetupCursor(pScreen);
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 );
}
static void i810LoadCursor(ScreenPtr pScreen, int x, int y) {
SetupCursor(pScreen);
int w, h;
unsigned short r;
unsigned char *msk, *mskLine, *src, *srcLine;
int i, j;
int src_stride, src_width;
CursorPtr pCursor = pCurPriv->pCursor;
CursorBitsPtr bits = pCursor->bits;
CARD8 tmp;
unsigned char *ram, *ramLine;
pCurPriv->pCursor = pCursor;
pCurPriv->xhot = pCursor->bits->xhot;
pCurPriv->yhot = pCursor->bits->yhot;
ramLine = (unsigned char *)(i810c->FbBase + i810c->CursorStart);
mskLine = (unsigned char *) bits->mask;
srcLine = (unsigned char *) bits->source;
h = bits->height;
if (h > I810_CURSOR_HEIGHT)
h = I810_CURSOR_HEIGHT;
src_stride = BitmapBytePad(bits->width); /* bytes per line */
src_width = (bits->width + 7) >> 3;
for (i = 0; i < I810_CURSOR_HEIGHT; i++) {
msk = mskLine;
src = srcLine;
ram = ramLine;
mskLine += src_stride;
srcLine += src_stride;
ramLine += I810_CURSOR_WIDTH / 4;
for (j = 0; j < I810_CURSOR_WIDTH / 8; j++) {
unsigned short m, s, b1, b2;
if (i < h && j < src_width)
{
m = *msk++;
s = *src++ & m;
m = ~m;
/* mask off right side */
if (j == src_width - 1 && (bits->width & 7))
{
m |= 0xff << (bits->width & 7);
}
}
else
{
m = 0xff;
s = 0x00;
}
/* The i810 stores the cursor in an interleaved bitmap format,
in reverse byte order */
/* Not tested with cursors bigger than 16x16 !!! */
ram[8+(j ^ 1)] = s; /* b2 */
ram[0+(j ^ 1)] = m; /* b1 */
}
}
/* 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) {
SetupCursor(pScreen);
unsigned char tmp;
tmp=INREG8( PIXPIPE_CONFIG_0 );
tmp &= ~HW_CURSOR_ENABLE;
OUTREG8( PIXPIPE_CONFIG_0, tmp);
}
static Bool
i810RealizeCursor (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);
i810LoadCursor (pScreen, x, y);
}
}
return TRUE;
}
static Bool
i810UnrealizeCursor (ScreenPtr pScreen, CursorPtr pCursor)
{
return TRUE;
}
static void
i810SetCursor (ScreenPtr pScreen, CursorPtr pCursor, int x, int y)
{
SetupCursor(pScreen);
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)
{
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
i810CursorInit(ScreenPtr pScreen)
{
SetupCursor(pScreen);
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)
{
SetupCursor (pScreen);
if (pCurPriv->has_cursor)
{
if (pCurPriv->pCursor)
{
int x, y;
miPointerPosition (&x, &y);
i810LoadCursor (pScreen, x, y);
}
else
i810UnloadCursor (pScreen);
}
}
void
i810CursorDisable (ScreenPtr pScreen)
{
SetupCursor (pScreen);
if (!pScreenPriv->enabled)
return;
if (pCurPriv->has_cursor)
{
if (pCurPriv->pCursor)
{
i810UnloadCursor (pScreen);
}
}
}
void
i810CursorFini (ScreenPtr pScreen)
{
SetupCursor (pScreen);
pCurPriv->pCursor = NULL;
}

696
hw/kdrive/i810/i810_reg.h Normal file
View File

@ -0,0 +1,696 @@
/* 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.
**************************************************************************/
/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/i810/i810_reg.h,v 1.4 2000/09/26 15:57:12 tsi Exp $ */
/*
* Authors:
* Keith Whitwell <keithw@precisioninsight.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

1165
hw/kdrive/i810/i810_video.c Normal file

File diff suppressed because it is too large Load Diff

603
hw/kdrive/i810/i810draw.c Normal file
View File

@ -0,0 +1,603 @@
/* 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>
*/
#include "kdrive.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 "fontstruct.h"
#include "dixfontstr.h"
#include "fb.h"
#include "migc.h"
#include "miline.h"
#include "picturestr.h"
#define NUM_STACK_RECTS 1024
void
i810Sync( KdScreenInfo *screen );
int
i810WaitLpRing( KdScreenInfo *screen, int n, int timeout_millis );
void
i810EmitInvarientState(KdScreenInfo *screen)
{
KdCardInfo *card = screen->card;
I810CardInfo *i810c = (I810CardInfo *) card->driver;
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();
}
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 */
};
void
i810SetupForSolidFill(KdScreenInfo *screen, int color, int rop,
unsigned int planemask)
{
KdCardInfo *card = screen->card;
I810CardInfo *i810c = (I810CardInfo *) card->driver;
if (I810_DEBUG & DEBUG_VERBOSE_ACCEL)
ErrorF( "i810SetupForFillRectSolid color: %x rop: %x mask: %x\n",
color, rop, planemask);
/* Color blit, p166 */
i810c->BR[13] = (BR13_SOLID_PATTERN |
(i810PatternRop[rop] << 16) |
(screen->width * i810c->cpp));
i810c->BR[16] = color;
}
void
i810SubsequentSolidFillRect(KdScreenInfo *screen, int x, int y, int w, int h)
{
KdCardInfo *card = screen->card;
I810CardInfo *i810c = (I810CardInfo *) card->driver;
if (I810_DEBUG & DEBUG_VERBOSE_ACCEL)
ErrorF( "i810SubsequentFillRectSolid %d,%d %dx%d\n",
x,y,w,h);
{
BEGIN_LP_RING(6);
OUT_RING( BR00_BITBLT_CLIENT | BR00_OP_COLOR_BLT | 0x3 );
OUT_RING( i810c->BR[13] );
OUT_RING( (h << 16) | (w * i810c->cpp));
OUT_RING( i810c->bufferOffset +
(y * screen->width + x) * i810c->cpp);
OUT_RING( i810c->BR[16]);
OUT_RING( 0 ); /* pad to quadword */
ADVANCE_LP_RING();
}
}
BOOL
i810FillOk (GCPtr pGC)
{
FbBits depthMask;
switch (pGC->fillStyle) {
case FillSolid:
return TRUE;
/* More cases later... */
}
return FALSE;
}
void
i810FillBoxSolid (KdScreenInfo *screen, int nBox, BoxPtr pBox,
unsigned long pixel, int alu, unsigned long planemask)
{
i810SetupForSolidFill(screen, pixel, alu, planemask);
while (nBox--)
{
i810SubsequentSolidFillRect(screen, pBox->x1, pBox->y1,
pBox->x2-pBox->x1, pBox->y2-pBox->y1);
pBox++;
}
KdMarkSync(screen->pScreen);
}
void
i810PolyFillRect (DrawablePtr pDrawable, GCPtr pGC,
int nrectFill, xRectangle *prectInit)
{
xRectangle *prect;
RegionPtr prgnClip;
register BoxPtr pbox;
register BoxPtr pboxClipped;
BoxPtr pboxClippedBase;
BoxPtr pextent;
BoxRec stackRects[NUM_STACK_RECTS];
FbGCPrivPtr fbPriv = fbGetGCPrivate (pGC);
int numRects;
int n;
int xorg, yorg;
int x, y;
KdScreenPriv(pDrawable->pScreen);
KdScreenInfo *screen = pScreenPriv->screen;
if (!i810FillOk (pGC))
{
KdCheckPolyFillRect (pDrawable, pGC, nrectFill, prectInit);
return;
}
prgnClip = fbGetCompositeClip(pGC);
xorg = pDrawable->x;
yorg = pDrawable->y;
if (xorg || yorg)
{
prect = prectInit;
n = nrectFill;
while(n--)
{
prect->x += xorg;
prect->y += yorg;
prect++;
}
}
prect = prectInit;
numRects = REGION_NUM_RECTS(prgnClip) * nrectFill;
if (numRects > NUM_STACK_RECTS)
{
pboxClippedBase = (BoxPtr)xalloc(numRects * sizeof(BoxRec));
if (!pboxClippedBase)
return;
}
else
pboxClippedBase = stackRects;
pboxClipped = pboxClippedBase;
if (REGION_NUM_RECTS(prgnClip) == 1)
{
int x1, y1, x2, y2, bx2, by2;
pextent = REGION_RECTS(prgnClip);
x1 = pextent->x1;
y1 = pextent->y1;
x2 = pextent->x2;
y2 = pextent->y2;
while (nrectFill--)
{
if ((pboxClipped->x1 = prect->x) < x1)
pboxClipped->x1 = x1;
if ((pboxClipped->y1 = prect->y) < y1)
pboxClipped->y1 = y1;
bx2 = (int) prect->x + (int) prect->width;
if (bx2 > x2)
bx2 = x2;
pboxClipped->x2 = bx2;
by2 = (int) prect->y + (int) prect->height;
if (by2 > y2)
by2 = y2;
pboxClipped->y2 = by2;
prect++;
if ((pboxClipped->x1 < pboxClipped->x2) &&
(pboxClipped->y1 < pboxClipped->y2))
{
pboxClipped++;
}
}
}
else
{
int x1, y1, x2, y2, bx2, by2;
pextent = REGION_EXTENTS(pGC->pScreen, prgnClip);
x1 = pextent->x1;
y1 = pextent->y1;
x2 = pextent->x2;
y2 = pextent->y2;
while (nrectFill--)
{
BoxRec box;
if ((box.x1 = prect->x) < x1)
box.x1 = x1;
if ((box.y1 = prect->y) < y1)
box.y1 = y1;
bx2 = (int) prect->x + (int) prect->width;
if (bx2 > x2)
bx2 = x2;
box.x2 = bx2;
by2 = (int) prect->y + (int) prect->height;
if (by2 > y2)
by2 = y2;
box.y2 = by2;
prect++;
if ((box.x1 >= box.x2) || (box.y1 >= box.y2))
continue;
n = REGION_NUM_RECTS (prgnClip);
pbox = REGION_RECTS(prgnClip);
/* clip the rectangle to each box in the clip region
this is logically equivalent to calling Intersect()
*/
while(n--)
{
pboxClipped->x1 = max(box.x1, pbox->x1);
pboxClipped->y1 = max(box.y1, pbox->y1);
pboxClipped->x2 = min(box.x2, pbox->x2);
pboxClipped->y2 = min(box.y2, pbox->y2);
pbox++;
/* see if clipping left anything */
if(pboxClipped->x1 < pboxClipped->x2 &&
pboxClipped->y1 < pboxClipped->y2)
{
pboxClipped++;
}
}
}
}
if (pboxClipped != pboxClippedBase)
{
switch (pGC->fillStyle) {
case FillSolid:
i810FillBoxSolid(screen,
pboxClipped-pboxClippedBase, pboxClippedBase,
pGC->fgPixel, pGC->alu, pGC->planemask);
break;
/* More cases later... */
}
}
if (pboxClippedBase != stackRects)
xfree(pboxClippedBase);
}
void
i810RefreshRing(KdScreenInfo *screen)
{
KdCardInfo *card = screen->card;
I810CardInfo *i810c = (I810CardInfo *) card->driver;
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;
i810c->NeedToSync = TRUE;
}
int
i810WaitLpRing( KdScreenInfo *screen, int n, int timeout_millis )
{
KdCardInfo *card = screen->card;
I810CardInfo *i810c = (I810CardInfo *) card->driver;
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( screen->card );
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;
}
void
i810Sync( KdScreenInfo *screen )
{
KdCardInfo *card = screen->card;
I810CardInfo *i810c = card->driver;
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(screen, i810c->LpRing.mem.Size - 8, 0 );
i810c->LpRing.space = i810c->LpRing.mem.Size - 8;
i810c->nextColorExpandBuf = 0;
}
static const GCOps i810Ops = {
KdCheckFillSpans,
KdCheckSetSpans,
KdCheckPutImage,
KdCheckCopyArea,
KdCheckCopyPlane,
KdCheckPolyPoint,
KdCheckPolylines,
KdCheckPolySegment,
miPolyRectangle,
KdCheckPolyArc,
miFillPolygon,
i810PolyFillRect,
miPolyFillArc,
miPolyText8,
miPolyText16,
miImageText8,
miImageText16,
KdCheckImageGlyphBlt,
KdCheckPolyGlyphBlt,
KdCheckPushPixels,
#ifdef NEED_LINEHELPER
,NULL
#endif
};
void
i810ValidateGC (GCPtr pGC, Mask changes, DrawablePtr pDrawable)
{
FbGCPrivPtr fbPriv = fbGetGCPrivate(pGC);
fbValidateGC (pGC, changes, pDrawable);
if (pDrawable->type == DRAWABLE_WINDOW)
pGC->ops = (GCOps *) &i810Ops;
else
pGC->ops = (GCOps *) &kdAsyncPixmapGCOps;
}
GCFuncs i810GCFuncs = {
i810ValidateGC,
miChangeGC,
miCopyGC,
miDestroyGC,
miChangeClip,
miDestroyClip,
miCopyClip
};
int
i810CreateGC (GCPtr pGC)
{
if (!fbCreateGC (pGC))
return FALSE;
if (pGC->depth != 1)
pGC->funcs = &i810GCFuncs;
return TRUE;
}
static void
i810SetRingRegs( KdScreenInfo *screen ) {
unsigned int itemp;
KdCardInfo *card = screen->card;
I810CardInfo *i810c = (I810CardInfo *) card->driver;
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)
{
/* fprintf(stderr,"i810InitAccel\n"); */
/*
* Hook up asynchronous drawing
*/
KdScreenInitAsync (pScreen);
/*
* Replace various fb screen functions
*/
pScreen->CreateGC = i810CreateGC;
return TRUE;
}
void
i810EnableAccel(ScreenPtr pScreen)
{
KdScreenPriv(pScreen);
KdScreenInfo *screen = pScreenPriv->screen;
KdCardInfo *card = screen->card;
I810CardInfo *i810c = (I810CardInfo *) card->driver;
/* fprintf(stderr,"i810EnableAccel\n"); */
if (i810c->LpRing.mem.Size == 0) {
ErrorF("No memory for LpRing!! Acceleration not functional!!\n");
}
i810SetRingRegs( screen );
KdMarkSync (pScreen);
}
void
i810SyncAccel(ScreenPtr pScreen)
{
KdScreenPriv(pScreen);
KdScreenInfo *screen = pScreenPriv->screen;
i810Sync(screen);
}
void
i810DisableAccel(ScreenPtr pScreen)
{
KdScreenPriv(pScreen);
KdScreenInfo *screen = pScreenPriv->screen;
/* fprintf(stderr,"i810DisableAccel\n"); */
i810RefreshRing( screen );
i810Sync( screen );
}
void
i810FiniAccel(ScreenPtr pScreen)
{
/* fprintf(stderr,"i810FiniAccel\n"); */
}

46
hw/kdrive/i810/i810draw.h Normal file
View File

@ -0,0 +1,46 @@
/* 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_ */

80
hw/kdrive/i810/i810stub.c Normal file
View File

@ -0,0 +1,80 @@
/* 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>
*/
#include "kdrive.h"
#include "kxv.h"
#include "i810.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;
Bool LinuxFindPci(CARD16, CARD16, CARD32, KdCardAttr *);
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)
{
KdInitInput (&Ps2MouseFuncs, &LinuxKeyboardFuncs);
}
int
ddxProcessArgument (int argc, char **argv, int i)
{
int ret;
int KdProcessArgument(int, char **, int);
ret = KdProcessArgument(argc, argv, i);
return ret;
}

348
hw/kdrive/linux/agp.c Normal file
View File

@ -0,0 +1,348 @@
/*
* Abstraction of the AGP GART interface.
*
* This version is for both Linux and FreeBSD.
*
* Copyright © 2000-2001 Nokia Home Communications
* Copyright © 2000 VA Linux Systems, Inc.
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.
*/
/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_agp.c,v 3.4 2000/08/28 18:12:56 dawes Exp $ */
/*
* Author: Pontus Lidman <pontus.lidman@nokia.com> (adaption to KDrive) and others
*/
#include "X.h"
#include "Xdefs.h"
#include "Xmd.h"
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <stdlib.h>
#include "agp.h"
#if defined(linux)
#include <asm/ioctl.h>
#include "../../xfree86/os-support/linux/agpgart.h"
#elif defined(__FreeBSD__)
#include <sys/ioctl.h>
#include <sys/agpio.h>
#endif
#ifndef AGP_DEVICE
#define AGP_DEVICE "/dev/agpgart"
#endif
/* AGP page size is independent of the host page size. */
#ifndef AGP_PAGE_SIZE
#define AGP_PAGE_SIZE 4096
#endif
#define AGPGART_MAJOR_VERSION 0
#define AGPGART_MINOR_VERSION 99
static int gartFd = -1;
static int acquiredScreen = -1;
/*
* Open /dev/agpgart. Keep it open until server exit.
*/
static Bool
GARTInit()
{
static Bool initDone = FALSE;
struct _agp_info agpinf;
if (initDone)
return (gartFd != -1);
initDone = TRUE;
if (gartFd == -1)
gartFd = open(AGP_DEVICE, O_RDWR, 0);
else
return FALSE;
if (gartFd == -1) {
fprintf(stderr, "Unable to open " AGP_DEVICE " (%s)\n",
strerror(errno));
return FALSE;
}
KdAcquireGART(-1);
/* Check the kernel driver version. */
if (ioctl(gartFd, AGPIOC_INFO, &agpinf) != 0) {
fprintf(stderr, "GARTInit: AGPIOC_INFO failed (%s)\n",
strerror(errno));
close(gartFd);
gartFd = -1;
return FALSE;
}
KdReleaseGART(-1);
#if defined(linux)
/* Should this look for version >= rather than version == ? */
if (agpinf.version.major != AGPGART_MAJOR_VERSION &&
agpinf.version.minor != AGPGART_MINOR_VERSION) {
fprintf(stderr,
"Kernel agpgart driver version is not current"
" (%d.%d vs %d.%d)\n",
agpinf.version.major, agpinf.version.minor,
AGPGART_MAJOR_VERSION, AGPGART_MINOR_VERSION);
close(gartFd);
gartFd = -1;
return FALSE;
}
#endif
return TRUE;
}
Bool
KdAgpGARTSupported()
{
return GARTInit();
}
AgpInfoPtr
KdGetAGPInfo(int screenNum)
{
struct _agp_info agpinf;
AgpInfoPtr info;
if (!GARTInit())
return NULL;
if ((info = calloc(sizeof(AgpInfo), 1)) == NULL) {
fprintf(stderr, "Failed to allocate AgpInfo\n");
return NULL;
}
if (ioctl(gartFd, AGPIOC_INFO, &agpinf) != 0) {
fprintf(stderr,
"xf86GetAGPInfo: AGPIOC_INFO failed (%s)\n",
strerror(errno));
return NULL;
}
info->bridgeId = agpinf.bridge_id;
info->agpMode = agpinf.agp_mode;
info->base = agpinf.aper_base;
info->size = agpinf.aper_size;
info->totalPages = agpinf.pg_total;
info->systemPages = agpinf.pg_system;
info->usedPages = agpinf.pg_used;
return info;
}
/*
* XXX If multiple screens can acquire the GART, should we have a reference
* count instead of using acquiredScreen?
*/
Bool
KdAcquireGART(int screenNum)
{
if (screenNum != -1 && !GARTInit())
return FALSE;
if (screenNum == -1 || acquiredScreen != screenNum) {
if (ioctl(gartFd, AGPIOC_ACQUIRE, 0) != 0) {
fprintf(stderr,
"AGPIOC_ACQUIRE failed (%s)\n",
strerror(errno));
return FALSE;
}
acquiredScreen = screenNum;
}
return TRUE;
}
Bool
KdReleaseGART(int screenNum)
{
if (screenNum != -1 && !GARTInit())
return FALSE;
if (acquiredScreen == screenNum) {
if (ioctl(gartFd, AGPIOC_RELEASE, 0) != 0) {
fprintf(stderr,
"AGPIOC_RELEASE failed (%s)\n",
strerror(errno));
return FALSE;
}
acquiredScreen = -1;
return TRUE;
}
return FALSE;
}
int
KdAllocateGARTMemory(int screenNum, unsigned long size, int type,
unsigned long *physical)
{
struct _agp_allocate alloc;
int pages;
/*
* Allocates "size" bytes of GART memory (rounds up to the next
* page multiple) or type "type". A handle (key) for the allocated
* memory is returned. On error, the return value is -1.
*/
if (!GARTInit() || acquiredScreen != screenNum)
return -1;
pages = (size / AGP_PAGE_SIZE);
if (size % AGP_PAGE_SIZE != 0)
pages++;
/* XXX check for pages == 0? */
alloc.pg_count = pages;
alloc.type = type;
if (ioctl(gartFd, AGPIOC_ALLOCATE, &alloc) != 0) {
fprintf(stderr, "KdAllocateGARTMemory: "
"allocation of %d pages failed\n\t(%s)\n", pages,
strerror(errno));
return -1;
}
if (physical)
*physical = alloc.physical;
return alloc.key;
}
/* Bind GART memory with "key" at "offset" */
Bool
KdBindGARTMemory(int screenNum, int key, unsigned long offset)
{
struct _agp_bind bind;
int pageOffset;
if (!GARTInit() || acquiredScreen != screenNum)
return FALSE;
if (acquiredScreen != screenNum) {
fprintf(stderr,
"AGP not acquired by this screen\n");
return FALSE;
}
if (offset % AGP_PAGE_SIZE != 0) {
fprintf(stderr, "KdBindGARTMemory: "
"offset (0x%lx) is not page-aligned (%d)\n",
offset, AGP_PAGE_SIZE);
return FALSE;
}
pageOffset = offset / AGP_PAGE_SIZE;
bind.pg_start = pageOffset;
bind.key = key;
if (ioctl(gartFd, AGPIOC_BIND, &bind) != 0) {
fprintf(stderr, "KdBindGARTMemory: "
"binding of gart memory with key %d\n"
"\tat offset 0x%lx failed (%s)\n",
key, offset, strerror(errno));
return FALSE;
}
return TRUE;
}
/* Unbind GART memory with "key" */
Bool
KdUnbindGARTMemory(int screenNum, int key)
{
struct _agp_unbind unbind;
if (!GARTInit() || acquiredScreen != screenNum)
return FALSE;
if (acquiredScreen != screenNum) {
fprintf(stderr,
"AGP not acquired by this screen\n");
return FALSE;
}
unbind.priority = 0;
unbind.key = key;
if (ioctl(gartFd, AGPIOC_UNBIND, &unbind) != 0) {
fprintf(stderr, "KdUnbindGARTMemory: "
"unbinding of gart memory with key %d "
"failed (%s)\n", key, strerror(errno));
return FALSE;
}
return TRUE;
}
/* XXX Interface may change. */
Bool
KdEnableAGP(int screenNum, CARD32 mode)
{
agp_setup setup;
if (!GARTInit() || acquiredScreen != screenNum)
return FALSE;
setup.agp_mode = mode;
if (ioctl(gartFd, AGPIOC_SETUP, &setup) != 0) {
fprintf(stderr, "KdEnableAGP: "
"AGPIOC_SETUP with mode %ld failed (%s)\n",
mode, strerror(errno));
return FALSE;
}
return TRUE;
}

70
hw/kdrive/linux/agp.h Normal file
View File

@ -0,0 +1,70 @@
/* 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 */
/* agp.h - header file for KDrive AGP GART interface
*
* Author: Pontus Lidman <pontus.lidman@nokia.com>
*
*/
#ifndef _AGP_H_
#define _AGP_H_
#include "Xdefs.h"
/* These two definitions must be consistent with the kernel's,
but using 1 or 2 in driver code is even uglier */
#define AGP_DCACHE_MEMORY 1
#define AGP_PHYS_MEMORY 2
typedef struct _AgpInfo {
CARD32 bridgeId;
CARD32 agpMode;
unsigned long base;
unsigned long size;
unsigned long totalPages;
unsigned long systemPages;
unsigned long usedPages;
} AgpInfo, *AgpInfoPtr;
extern Bool KdAgpGARTSupported(void);
extern AgpInfoPtr KdGetAGPInfo(int screenNum);
extern Bool KdAcquireGART(int screenNum);
extern Bool KdReleaseGART(int screenNum);
extern int KdAllocateGARTMemory(int screenNum, unsigned long size, int type,
unsigned long *physical);
extern Bool KdBindGARTMemory(int screenNum, int key, unsigned long offset);
extern Bool KdUnbindGARTMemory(int screenNum, int key);
extern Bool KdEnableAGP(int screenNum, CARD32 mode);
#endif /* _AGP_H_ */

1784
hw/kdrive/src/kxv.c Normal file

File diff suppressed because it is too large Load Diff

302
hw/kdrive/src/kxv.h Normal file
View File

@ -0,0 +1,302 @@
/*
XFree86 Xv DDX written by Mark Vojkovich (markv@valinux.com)
Adapted for KDrive by Pontus Lidman <pontus.lidman@nokia.com>
Copyright (C) 2000, 2001 - Nokia Home Communications
Copyright (C) 1998, 1999 - The XFree86 Project Inc.
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.
*/
/* $XFree86$ */
#ifndef _XVDIX_H_
#define _XVDIX_H_
#include "scrnintstr.h"
#include "regionstr.h"
#include "windowstr.h"
#include "pixmapstr.h"
#include "mivalidate.h"
#include "validate.h"
#include "resource.h"
#include "gcstruct.h"
#include "dixstruct.h"
#include "../../Xext/xvdix.h"
#define VIDEO_NO_CLIPPING 0x00000001
#define VIDEO_INVERT_CLIPLIST 0x00000002
#define VIDEO_OVERLAID_IMAGES 0x00000004
#define VIDEO_OVERLAID_STILLS 0x00000008
#define VIDEO_CLIP_TO_VIEWPORT 0x00000010
typedef struct {
int id;
int type;
int byte_order;
unsigned char guid[16];
int bits_per_pixel;
int format;
int num_planes;
/* for RGB formats only */
int depth;
unsigned int red_mask;
unsigned int green_mask;
unsigned int blue_mask;
/* for YUV formats only */
unsigned int y_sample_bits;
unsigned int u_sample_bits;
unsigned int v_sample_bits;
unsigned int horz_y_period;
unsigned int horz_u_period;
unsigned int horz_v_period;
unsigned int vert_y_period;
unsigned int vert_u_period;
unsigned int vert_v_period;
char component_order[32];
int scanline_order;
} KdImageRec, *KdImagePtr;
typedef struct {
KdScreenInfo * screen;
int id;
unsigned short width, height;
int *pitches; /* bytes */
int *offsets; /* in bytes from start of framebuffer */
DevUnion devPrivate;
} KdSurfaceRec, *KdSurfacePtr;
typedef int (* PutVideoFuncPtr)( KdScreenInfo * screen,
short vid_x, short vid_y, short drw_x, short drw_y,
short vid_w, short vid_h, short drw_w, short drw_h,
RegionPtr clipBoxes, pointer data );
typedef int (* PutStillFuncPtr)( KdScreenInfo * screen,
short vid_x, short vid_y, short drw_x, short drw_y,
short vid_w, short vid_h, short drw_w, short drw_h,
RegionPtr clipBoxes, pointer data );
typedef int (* GetVideoFuncPtr)( KdScreenInfo * screen,
short vid_x, short vid_y, short drw_x, short drw_y,
short vid_w, short vid_h, short drw_w, short drw_h,
RegionPtr clipBoxes, pointer data );
typedef int (* GetStillFuncPtr)( KdScreenInfo * screen,
short vid_x, short vid_y, short drw_x, short drw_y,
short vid_w, short vid_h, short drw_w, short drw_h,
RegionPtr clipBoxes, pointer data );
typedef void (* StopVideoFuncPtr)(KdScreenInfo * screen, pointer data, Bool Exit);
typedef int (* SetPortAttributeFuncPtr)(KdScreenInfo * screen, Atom attribute,
int value, pointer data);
typedef int (* GetPortAttributeFuncPtr)(KdScreenInfo * screen, Atom attribute,
int *value, pointer data);
typedef void (* QueryBestSizeFuncPtr)(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);
typedef int (* PutImageFuncPtr)( KdScreenInfo * screen,
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 image, unsigned char* buf, short width, short height, Bool Sync,
RegionPtr clipBoxes, pointer data );
typedef int (* ReputImageFuncPtr)( KdScreenInfo * screen, short drw_x, short drw_y,
RegionPtr clipBoxes, pointer data );
typedef int (*QueryImageAttributesFuncPtr)(KdScreenInfo * screen,
int image, unsigned short *width, unsigned short *height,
int *pitches, int *offsets);
typedef enum {
XV_OFF,
XV_PENDING,
XV_ON
} XvStatus;
/*** this is what the driver needs to fill out ***/
typedef struct {
int id;
char *name;
unsigned short width, height;
XvRationalRec rate;
} KdVideoEncodingRec, *KdVideoEncodingPtr;
typedef struct {
char depth;
short class;
} KdVideoFormatRec, *KdVideoFormatPtr;
typedef struct {
int flags;
int min_value;
int max_value;
char *name;
} KdAttributeRec, *KdAttributePtr;
typedef struct {
unsigned int type;
int flags;
char *name;
int nEncodings;
KdVideoEncodingPtr pEncodings;
int nFormats;
KdVideoFormatPtr pFormats;
int nPorts;
DevUnion *pPortPrivates;
int nAttributes;
KdAttributePtr pAttributes;
int nImages;
KdImagePtr pImages;
PutVideoFuncPtr PutVideo;
PutStillFuncPtr PutStill;
GetVideoFuncPtr GetVideo;
GetStillFuncPtr GetStill;
StopVideoFuncPtr StopVideo;
SetPortAttributeFuncPtr SetPortAttribute;
GetPortAttributeFuncPtr GetPortAttribute;
QueryBestSizeFuncPtr QueryBestSize;
PutImageFuncPtr PutImage;
ReputImageFuncPtr ReputImage;
QueryImageAttributesFuncPtr QueryImageAttributes;
} KdVideoAdaptorRec, *KdVideoAdaptorPtr;
typedef struct {
KdImagePtr image;
int flags;
int (*alloc_surface)(KdScreenInfo * screen,
int id,
unsigned short width,
unsigned short height,
KdSurfacePtr surface);
int (*free_surface)(KdSurfacePtr surface);
int (*display) (KdSurfacePtr surface,
short vid_x, short vid_y,
short drw_x, short drw_y,
short vid_w, short vid_h,
short drw_w, short drw_h,
RegionPtr clipBoxes);
int (*stop) (KdSurfacePtr surface);
int (*getAttribute) (KdScreenInfo * screen, Atom attr, INT32 *value);
int (*setAttribute) (KdScreenInfo * screen, Atom attr, INT32 value);
int max_width;
int max_height;
int num_attributes;
KdAttributePtr attributes;
} KdOffscreenImageRec, *KdOffscreenImagePtr;
Bool
KdXVScreenInit(
ScreenPtr pScreen,
KdVideoAdaptorPtr *Adaptors,
int num
);
typedef int (* KdXVInitGenericAdaptorPtr)(KdScreenInfo * screen,
KdVideoAdaptorPtr **Adaptors);
int
KdXVRegisterGenericAdaptorDriver(
KdXVInitGenericAdaptorPtr InitFunc
);
int
KdXVListGenericAdaptors(
KdScreenInfo * screen,
KdVideoAdaptorPtr **Adaptors
);
Bool
KdXVRegisterOffscreenImages(
ScreenPtr pScreen,
KdOffscreenImagePtr images,
int num
);
KdOffscreenImagePtr
KdXVQueryOffscreenImages(
ScreenPtr pScreen,
int *num
);
KdVideoAdaptorPtr KdXVAllocateVideoAdaptorRec(KdScreenInfo * screen);
void KdXVFreeVideoAdaptorRec(KdVideoAdaptorPtr ptr);
/*** These are DDX layer privates ***/
typedef struct {
CreateWindowProcPtr CreateWindow;
DestroyWindowProcPtr DestroyWindow;
ClipNotifyProcPtr ClipNotify;
WindowExposuresProcPtr WindowExposures;
void (*disable) (ScreenPtr); /* turn off rendering */
Bool (*enable) (ScreenPtr); /* set up for rendering */
} KdXVScreenRec, *KdXVScreenPtr;
typedef struct {
int flags;
PutVideoFuncPtr PutVideo;
PutStillFuncPtr PutStill;
GetVideoFuncPtr GetVideo;
GetStillFuncPtr GetStill;
StopVideoFuncPtr StopVideo;
SetPortAttributeFuncPtr SetPortAttribute;
GetPortAttributeFuncPtr GetPortAttribute;
QueryBestSizeFuncPtr QueryBestSize;
PutImageFuncPtr PutImage;
ReputImageFuncPtr ReputImage;
QueryImageAttributesFuncPtr QueryImageAttributes;
} XvAdaptorRecPrivate, *XvAdaptorRecPrivatePtr;
typedef struct {
KdScreenInfo * screen;
DrawablePtr pDraw;
unsigned char type;
unsigned int subWindowMode;
DDXPointRec clipOrg;
RegionPtr clientClip;
RegionPtr pCompositeClip;
Bool FreeCompositeClip;
XvAdaptorRecPrivatePtr AdaptorRec;
XvStatus isOn;
Bool moved;
int vid_x, vid_y, vid_w, vid_h;
int drw_x, drw_y, drw_w, drw_h;
DevUnion DevPriv;
} XvPortRecPrivate, *XvPortRecPrivatePtr;
typedef struct _KdXVWindowRec{
XvPortRecPrivatePtr PortRec;
struct _KdXVWindowRec *next;
} KdXVWindowRec, *KdXVWindowPtr;
#endif /* _XVDIX_H_ */