diff options
author | Kaleb Keithley <kaleb@freedesktop.org> | 2003-11-25 19:28:39 +0000 |
---|---|---|
committer | Kaleb Keithley <kaleb@freedesktop.org> | 2003-11-25 19:28:39 +0000 |
commit | 14cd4af100e1deb1c7b63e9f19587e38ce1f08f2 (patch) | |
tree | e8af016d0a4e5289a95542db236ec18f86925171 /src | |
parent | 1684aa7a21a194b6e7dd518f3895c9b2dfce229a (diff) |
XFree86 4.3.99.16 Bring the tree up to date for the Cygwin folksxf86-4_3_99_901xf86-4_3_99_16
Diffstat (limited to 'src')
-rw-r--r-- | src/regsmi.h | 67 | ||||
-rw-r--r-- | src/smi.h | 17 | ||||
-rw-r--r-- | src/smi_accel.c | 13 | ||||
-rw-r--r-- | src/smi_driver.c | 420 | ||||
-rw-r--r-- | src/smi_hwcurs.c | 74 | ||||
-rw-r--r-- | src/smi_shadow.c | 158 | ||||
-rw-r--r-- | src/smi_video.c | 358 |
7 files changed, 849 insertions, 258 deletions
diff --git a/src/regsmi.h b/src/regsmi.h index c134bed..da0f659 100644 --- a/src/regsmi.h +++ b/src/regsmi.h @@ -26,13 +26,14 @@ Silicon Motion shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization from the XFree86 Project and SIlicon Motion. */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/siliconmotion/regsmi.h,v 1.2 2002/01/25 21:56:09 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/siliconmotion/regsmi.h,v 1.3 2003/10/08 11:13:01 eich Exp $ */ #ifndef _REGSMI_H #define _REGSMI_H #define SMI_LYNX_SERIES(chip) ((chip & 0xF0F0) == 0x0010) #define SMI_LYNX3D_SERIES(chip) ((chip & 0xF0F0) == 0x0020) +#define SMI_COUGAR_SERIES(chip) ((chip & 0xF0F0) == 0x0030) #define SMI_LYNXEM_SERIES(chip) ((chip & 0xFFF0) == 0x0710) #define SMI_LYNXM_SERIES(chip) ((chip & 0xFF00) == 0x0700) @@ -45,6 +46,7 @@ authorization from the XFree86 Project and SIlicon Motion. #define SMI_LYNXEM PCI_CHIP_SMI710 #define SMI_LYNXEMplus PCI_CHIP_SMI712 #define SMI_LYNX3DM PCI_CHIP_SMI720 +#define SMI_COUGAR3DR PCI_CHIP_SMI731 /* I/O Functions */ static __inline__ CARD8 @@ -114,6 +116,8 @@ VGAOUT8(SMIPtr pSmi, int port, CARD8 data) #define READ_VPR(pSmi, vpr) MMIO_IN32(pSmi->VPRBase, vpr) #define WRITE_CPR(pSmi, cpr, data) MMIO_OUT32(pSmi->CPRBase, cpr, data); DEBUG((VERBLEV, "CPR%02X = %08X\n", cpr, data)) #define READ_CPR(pSmi, cpr) MMIO_IN32(pSmi->CPRBase, cpr) +#define WRITE_FPR(pSmi, fpr, data) MMIO_OUT32(pSmi->FPRBase, fpr, data); DEBUG((VERBLEV, "FPR%02X = %08X\n", fpr, data)) +#define READ_FPR(pSmi, fpr) MMIO_IN32(pSmi->FPRBase, fpr) /* 2D Engine commands */ #define SMI_TRANSPARENT_SRC 0x00000100 @@ -204,4 +208,65 @@ VGAOUT8(SMIPtr pSmi, int port, CARD8 data) #define RGB16_555 1 #define RGB32_888 2 +/* register defines so we're not hardcoding numbers */ + +#define FPR00 0x0000 + +/* video window formats - I=indexed, P=packed */ +#define FPR00_FMT_8I 0x0 +#define FPR00_FMT_15P 0x1 +#define FPR00_FMT_16P 0x2 +#define FPR00_FMT_32P 0x3 +#define FPR00_FMT_24P 0x4 +#define FPR00_FMT_8P 0x5 +#define FPR00_FMT_YUV422 0x6 +#define FPR00_FMT_YUV420 0x7 + +/* possible bit definitions for FPR00 - VWI = Video Window 1 */ +#define FPR00_VWIENABLE 0x00000008 +#define FPR00_VWITILE 0x00000010 +#define FPR00_VWIFILTER2 0x00000020 +#define FPR00_VWIFILTER4 0x00000040 +#define FPR00_VWIKEYENABLE 0x00000080 +#define FPR00_VWIGDF_SHIFT 16 +#define FPR00_VWIGDENABLE 0x00080000 +#define FPR00_VWIGDTILE 0x00100000 + +#define FPR00_MASKBITS 0x0000FFFF + +#define FPR04 0x0004 +#define FPR08 0x0008 +#define FPR0C 0x000C +#define FPR10 0x0010 +#define FPR14 0x0014 +#define FPR18 0x0018 +#define FPR1C 0x001C +#define FPR20 0x0020 +#define FPR24 0x0024 +#define FPR58 0x0058 +#define FPR5C 0x005C +#define FPR68 0x0068 +#define FPRB0 0x00B0 +#define FPRB4 0x00B4 +#define FPRC4 0x00C4 +#define FPRCC 0x00CC + +#define FPR158 0x0158 +#define FPR158_MASK_MAXBITS 0x07FF +#define FPR158_MASK_BOUNDARY 0x0800 +#define FPR15C 0x015C +#define FPR15C_MASK_HWCCOLORS 0x0000FFFF +#define FPR15C_MASK_HWCADDREN 0xFFFF0000 +#define FPR15C_MASK_HWCENABLE 0x80000000 + +/* panel sizes returned by the bios */ + +#define PANEL_640x480 0x00 +#define PANEL_800x600 0x01 +#define PANEL_1024x768 0x02 +#define PANEL_1280x1024 0x03 +#define PANEL_1600x1200 0x04 +#define PANEL_1400x1050 0x0A + + #endif /* _REGSMI_H */ @@ -26,7 +26,7 @@ Silicon Motion shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization from the XFree86 Project and Silicon Motion. */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/siliconmotion/smi.h,v 1.12 2003/01/12 03:55:49 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/siliconmotion/smi.h,v 1.14 2003/10/08 11:13:01 eich Exp $ */ #ifndef _SMI_H #define _SMI_H @@ -64,10 +64,8 @@ authorization from the XFree86 Project and Silicon Motion. #include "xf86int10.h" #include "vbe.h" -#ifdef XvExtension -# include "xf86xv.h" -# include "Xv.h" -#endif +#include "xf86xv.h" +#include "Xv.h" /******************************************************************************/ /* D E F I N I T I O N S */ @@ -104,6 +102,7 @@ typedef struct DPR44; CARD32 VPR00, VPR0C, VPR10; CARD32 CPR00; + CARD32 FPR00_, FPR0C_, FPR10_; } SMIRegRec, *SMIRegPtr; @@ -147,6 +146,7 @@ typedef struct CARD8 * DPRBase; /* Base of DPR registers */ CARD8 * VPRBase; /* Base of VPR registers */ CARD8 * CPRBase; /* Base of CPR registers */ + CARD8 * FPRBase; /* Base of FPR registers - for 0730 chipset */ CARD8 * DataPortBase; /* Base of data port */ int DataPortSize; /* Size of data port */ CARD8 * IOBase; /* Base of MMIO VGA ports */ @@ -241,17 +241,15 @@ typedef struct void (*PointerMoved)(int index, int x, int y); -#ifdef XvExtension int videoKey; /* Video chroma key */ Bool ByteSwap; /* Byte swap for ZV port */ - Bool interlaced; /* True: Interlaced Video */ + Bool interlaced; /* True: Interlaced Video */ /* XvExtension */ XF86VideoAdaptorPtr ptrAdaptor; /* Pointer to VideoAdapter structure */ void (*BlockHandler)(int i, pointer blockData, pointer pTimeout, pointer pReadMask); - GCPtr videoGC; -#endif + GCPtr videoGC; OptionInfoPtr Options; CARD8 DACmask; } SMIRec, *SMIPtr; @@ -355,6 +353,7 @@ Bool SMI_DGAInit(ScreenPtr pScrn); /* smi_shadow.c */ void SMI_PointerMoved(int index, int x, int y); void SMI_RefreshArea(ScrnInfoPtr pScrn, int num, BoxPtr pbox); +void SMI_RefreshArea730(ScrnInfoPtr pScrn, int num, BoxPtr pbox); /* smi_video.c */ void SMI_InitVideo(ScreenPtr pScreen); diff --git a/src/smi_accel.c b/src/smi_accel.c index 1c53060..70e369b 100644 --- a/src/smi_accel.c +++ b/src/smi_accel.c @@ -26,7 +26,7 @@ Silicon Motion shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization from the XFree86 Project and silicon Motion. */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/siliconmotion/smi_accel.c,v 1.7 2003/01/12 03:55:49 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/siliconmotion/smi_accel.c,v 1.9 2003/10/08 11:13:01 eich Exp $ */ #include "smi.h" @@ -207,7 +207,7 @@ SMI_AccelInit(ScreenPtr pScreen) } else { -#if defined(XvExtension) && SMI_USE_VIDEO +#if SMI_USE_VIDEO numLines = ((pSmi->FBReserved - pSmi->width * pSmi->Bpp * pSmi->height) * 25 / 100 + pSmi->width * pSmi->Bpp - 1) / (pSmi->width * pSmi->Bpp); @@ -1096,7 +1096,14 @@ SMI_Polylines(DrawablePtr pDraw, GCPtr pGC, int mode, int npt, if (box) { /* Refresh all polyline segments now. */ - SMI_RefreshArea(pScrn, box, pBox); + if (pSmi->Chipset == SMI_COUGAR3DR) + { + SMI_RefreshArea730(pScrn, box, pBox); + } + else + { + SMI_RefreshArea(pScrn, box, pBox); + } } /* Free the temporary buffer. */ diff --git a/src/smi_driver.c b/src/smi_driver.c index ffd946e..1d25f80 100644 --- a/src/smi_driver.c +++ b/src/smi_driver.c @@ -26,7 +26,7 @@ Silicon Motion shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization from The XFree86 Project or Silicon Motion. */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/siliconmotion/smi_driver.c,v 1.28.2.1 2003/05/09 02:22:00 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/siliconmotion/smi_driver.c,v 1.37 2003/11/06 18:38:08 tsi Exp $ */ #include "xf86Resources.h" #include "xf86RAC.h" @@ -120,6 +120,7 @@ static SymTabRec SMIChipsets[] = { PCI_CHIP_SMI710, "LynxEM" }, { PCI_CHIP_SMI712, "LynxEM+" }, { PCI_CHIP_SMI720, "Lynx3DM" }, + { PCI_CHIP_SMI731, "Cougar3DR" }, { -1, NULL } }; @@ -132,6 +133,7 @@ static PciChipsets SMIPciChipsets[] = { PCI_CHIP_SMI710, PCI_CHIP_SMI710, RES_SHARED_VGA }, { PCI_CHIP_SMI712, PCI_CHIP_SMI712, RES_SHARED_VGA }, { PCI_CHIP_SMI720, PCI_CHIP_SMI720, RES_SHARED_VGA }, + { PCI_CHIP_SMI731, PCI_CHIP_SMI731, RES_SHARED_VGA }, { -1, -1, RES_UNDEFINED } }; @@ -149,13 +151,11 @@ typedef enum OPTION_HWCURSOR, OPTION_SHADOW_FB, OPTION_ROTATE, -#ifdef XvExtension OPTION_VIDEOKEY, OPTION_BYTESWAP, - /* CZ 26.10.2001: interlaced video */ - OPTION_INTERLACED, - /* end CZ */ -#endif + /* CZ 26.10.2001: interlaced video */ + OPTION_INTERLACED, + /* end CZ */ OPTION_USEBIOS, OPTION_ZOOMONLCD, NUMBER_OF_OPTIONS @@ -164,28 +164,26 @@ typedef enum static const OptionInfoRec SMIOptions[] = { - { OPTION_PCI_BURST, "pci_burst", OPTV_BOOLEAN, {0}, FALSE }, - { OPTION_FIFO_CONSERV, "fifo_conservative", OPTV_BOOLEAN, {0}, FALSE }, - { OPTION_FIFO_MODERATE, "fifo_moderate", OPTV_BOOLEAN, {0}, FALSE }, + { OPTION_PCI_BURST, "pci_burst", OPTV_BOOLEAN, {0}, FALSE }, + { OPTION_FIFO_CONSERV, "fifo_conservative", OPTV_BOOLEAN, {0}, FALSE }, + { OPTION_FIFO_MODERATE, "fifo_moderate", OPTV_BOOLEAN, {0}, FALSE }, { OPTION_FIFO_AGGRESSIVE, "fifo_aggressive", OPTV_BOOLEAN, {0}, FALSE }, - { OPTION_PCI_RETRY, "pci_retry", OPTV_BOOLEAN, {0}, FALSE }, - { OPTION_NOACCEL, "NoAccel", OPTV_BOOLEAN, {0}, FALSE }, - { OPTION_MCLK, "set_mclk", OPTV_FREQ, {0}, FALSE }, - { OPTION_SHOWCACHE, "show_cache", OPTV_BOOLEAN, {0}, FALSE }, - { OPTION_HWCURSOR, "HWCursor", OPTV_BOOLEAN, {0}, FALSE }, - { OPTION_SWCURSOR, "SWCursor", OPTV_BOOLEAN, {0}, FALSE }, - { OPTION_SHADOW_FB, "ShadowFB", OPTV_BOOLEAN, {0}, FALSE }, - { OPTION_ROTATE, "Rotate", OPTV_ANYSTR, {0}, FALSE }, -#ifdef XvExtension - { OPTION_VIDEOKEY, "VideoKey", OPTV_INTEGER, {0}, FALSE }, - { OPTION_BYTESWAP, "ByteSwap", OPTV_BOOLEAN, {0}, FALSE }, + { OPTION_PCI_RETRY, "pci_retry", OPTV_BOOLEAN, {0}, FALSE }, + { OPTION_NOACCEL, "NoAccel", OPTV_BOOLEAN, {0}, FALSE }, + { OPTION_MCLK, "set_mclk", OPTV_FREQ, {0}, FALSE }, + { OPTION_SHOWCACHE, "show_cache", OPTV_BOOLEAN, {0}, FALSE }, + { OPTION_HWCURSOR, "HWCursor", OPTV_BOOLEAN, {0}, FALSE }, + { OPTION_SWCURSOR, "SWCursor", OPTV_BOOLEAN, {0}, FALSE }, + { OPTION_SHADOW_FB, "ShadowFB", OPTV_BOOLEAN, {0}, FALSE }, + { OPTION_ROTATE, "Rotate", OPTV_ANYSTR, {0}, FALSE }, + { OPTION_VIDEOKEY, "VideoKey", OPTV_INTEGER, {0}, FALSE }, + { OPTION_BYTESWAP, "ByteSwap", OPTV_BOOLEAN, {0}, FALSE }, /* CZ 26.10.2001: interlaced video */ - { OPTION_INTERLACED, "Interlaced", OPTV_BOOLEAN, {0}, FALSE }, + { OPTION_INTERLACED, "Interlaced", OPTV_BOOLEAN, {0}, FALSE }, /* end CZ */ -#endif - { OPTION_USEBIOS, "UseBIOS", OPTV_BOOLEAN, {0}, FALSE }, - { OPTION_ZOOMONLCD, "ZoomOnLCD", OPTV_BOOLEAN, {0}, FALSE }, - { -1, NULL, OPTV_NONE, {0}, FALSE } + { OPTION_USEBIOS, "UseBIOS", OPTV_BOOLEAN, {0}, FALSE }, + { OPTION_ZOOMONLCD, "ZoomOnLCD", OPTV_BOOLEAN, {0}, FALSE }, + { -1, NULL, OPTV_NONE, {0}, FALSE } }; /* @@ -223,10 +221,8 @@ static const char *xaaSymbols[] = "XAACreateInfoRec", "XAADestroyInfoRec", "XAAFallbackOps", - "XAAFillSolidRects", "XAAInit", "XAAPatternROP", - "XAAScreenIndex", NULL }; @@ -516,7 +512,7 @@ SMI_PreInit(ScrnInfoPtr pScrn, int flags) unsigned char config, m, n, shift; int mclk; vgaHWPtr hwp; - int vgaCRIndex, vgaCRReg, vgaIOBase; + int vgaCRIndex, vgaIOBase; vbeInfoPtr pVbe = NULL; ENTER_PROC("SMI_PreInit"); @@ -567,11 +563,10 @@ SMI_PreInit(ScrnInfoPtr pScrn, int flags) pScrn->monitor = pScrn->confScreen->monitor; /* - * The first thing we should figure out is the depth, bpp, etc. Our - * default depth is 8, so pass it to the helper function. We support - * only 24bpp layouts, so indicate that. + * The first thing we should figure out is the depth, bpp, etc. + * We support only 24bpp layouts, so indicate that. */ - if (!xf86SetDepthBpp(pScrn, 8, 8, 8, Support24bppFb)) + if (!xf86SetDepthBpp(pScrn, 0, 0, 0, Support24bppFb)) { LEAVE_PROC("SMI_PreInit"); return(FALSE); @@ -792,7 +787,12 @@ SMI_PreInit(ScrnInfoPtr pScrn, int flags) } } -#ifdef XvExtension + if (pSmi->rotate) + { + /* Disable the RandR extension, it messes up the internal rotation stuff */ + xf86DisableRandR(); + } + if (xf86GetOptValInteger(pSmi->Options, OPTION_VIDEOKEY, &pSmi->videoKey)) { xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "Option: Video key set to " @@ -815,18 +815,17 @@ SMI_PreInit(ScrnInfoPtr pScrn, int flags) pSmi->ByteSwap = FALSE; } - /* CZ 26.10.2001: interlaced video */ - if (xf86ReturnOptValBool(pSmi->Options, OPTION_INTERLACED, FALSE)) - { - pSmi->interlaced = TRUE; - xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "Option: Interlaced enabled.\n"); - } - else - { - pSmi->interlaced = FALSE; - } - /* end CZ */ -#endif + /* CZ 26.10.2001: interlaced video */ + if (xf86ReturnOptValBool(pSmi->Options, OPTION_INTERLACED, FALSE)) + { + pSmi->interlaced = TRUE; + xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "Option: Interlaced enabled.\n"); + } + else + { + pSmi->interlaced = FALSE; + } + /* end CZ */ if (xf86GetOptValBool(pSmi->Options, OPTION_USEBIOS, &pSmi->useBIOS)) { @@ -943,11 +942,10 @@ SMI_PreInit(ScrnInfoPtr pScrn, int flags) hwp = VGAHWPTR(pScrn); vgaIOBase = hwp->IOBase; vgaCRIndex = vgaIOBase + VGA_CRTC_INDEX_OFFSET; - vgaCRReg = vgaIOBase + VGA_CRTC_DATA_OFFSET; pSmi->PIOBase = hwp->PIOOffset; xf86ErrorFVerb(VERBLEV, "\tSMI_PreInit vgaCRIndex=%x, vgaIOBase=%x, " - "MMIOBase=%x\n", vgaCRIndex, vgaIOBase, hwp->MMIOBase); + "MMIOBase=%p\n", vgaCRIndex, vgaIOBase, hwp->MMIOBase); /* Next go on to detect amount of installed ram */ config = VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x71); @@ -1053,6 +1051,14 @@ SMI_PreInit(ScrnInfoPtr pScrn, int flags) pSmi->videoRAMKBytes = mem_table[(config >> 6)] * 1024; break; } + + case SMI_COUGAR3DR: + { + /* DANGER - Cougar3DR BIOS is broken - hardcode video ram size */ + /* per instructions from Silicon Motion engineers */ + pSmi->videoRAMKBytes = 16 * 1024; + break; + } } pSmi->videoRAMBytes = pSmi->videoRAMKBytes * 1024; pScrn->videoRam = pSmi->videoRAMKBytes; @@ -1077,7 +1083,7 @@ SMI_PreInit(ScrnInfoPtr pScrn, int flags) pScrn->clock[3] = pScrn->clock[2]; } - if (pSmi->Chipset == SMI_LYNX3DM) + if ((pSmi->Chipset == SMI_LYNX3DM) || (pSmi->Chipset == SMI_COUGAR3DR)) { if (pScrn->clock[0] <= 0) pScrn->clock[0] = 200000; if (pScrn->clock[1] <= 0) pScrn->clock[1] = 200000; @@ -1322,7 +1328,14 @@ SMI_EnterVT(int scrnIndex, int flags) box.y1 = 0; box.x2 = pScrn->virtualY; box.y2 = pScrn->virtualX; - SMI_RefreshArea(pScrn, 1, &box); + if (pSmi->Chipset == SMI_COUGAR3DR) + { + SMI_RefreshArea730(pScrn, 1, &box); + } + else + { + SMI_RefreshArea(pScrn, 1, &box); + } } /* Reset the grapics engine */ @@ -1482,11 +1495,11 @@ SMI_Save(ScrnInfoPtr pScrn) } } - /* CZ 2.11.2001: for gamma correction (TODO: other chipsets?) */ - if (pSmi->Chipset == SMI_LYNX3DM) { - save->CCR66 = VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x66); - } - /* end CZ */ + /* CZ 2.11.2001: for gamma correction (TODO: other chipsets?) */ + if ((pSmi->Chipset == SMI_LYNX3DM) || (pSmi->Chipset == SMI_COUGAR3DR)) { + save->CCR66 = VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x66); + } + /* end CZ */ save->DPR10 = READ_DPR(pSmi, 0x10); save->DPR1C = READ_DPR(pSmi, 0x1C); @@ -1503,6 +1516,13 @@ SMI_Save(ScrnInfoPtr pScrn) save->VPR0C = READ_VPR(pSmi, 0x0C); save->VPR10 = READ_VPR(pSmi, 0x10); + if (pSmi->Chipset == SMI_COUGAR3DR) + { + save->FPR00_ = READ_FPR(pSmi, FPR00); + save->FPR0C_ = READ_FPR(pSmi, FPR0C); + save->FPR10_ = READ_FPR(pSmi, FPR10); + } + save->CPR00 = READ_CPR(pSmi, 0x00); if (!pSmi->ModeStructInit) @@ -1686,11 +1706,11 @@ SMI_WriteMode(ScrnInfoPtr pScrn, vgaRegPtr vgaSavePtr, SMIRegPtr restore) } } - /* CZ 2.11.2001: for gamma correction (TODO: other chipsets?) */ - if (pSmi->Chipset == SMI_LYNX3DM) { - VGAOUT8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x66, restore->CCR66); - } - /* end CZ */ + /* CZ 2.11.2001: for gamma correction (TODO: other chipsets?) */ + if ((pSmi->Chipset == SMI_LYNX3DM) || (pSmi->Chipset == SMI_COUGAR3DR)) { + VGAOUT8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x66, restore->CCR66); + } + /* end CZ */ VGAOUT8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x81, 0x00); @@ -1709,6 +1729,13 @@ SMI_WriteMode(ScrnInfoPtr pScrn, vgaRegPtr vgaSavePtr, SMIRegPtr restore) WRITE_VPR(pSmi, 0x0C, restore->VPR0C); WRITE_VPR(pSmi, 0x10, restore->VPR10); + if(pSmi->Chipset == SMI_COUGAR3DR) + { + WRITE_FPR(pSmi, FPR00, restore->FPR00_); + WRITE_FPR(pSmi, FPR0C, restore->FPR0C_); + WRITE_FPR(pSmi, FPR10, restore->FPR10_); + } + WRITE_CPR(pSmi, 0x00, restore->CPR00); if (xf86GetVerbosity() > 1) @@ -1740,6 +1767,11 @@ SMI_MapMem(ScrnInfoPtr pScrn) pSmi->MapSize = 0x10000; break; + case SMI_COUGAR3DR: + memBase = pSmi->PciInfo->memBase[1]; + pSmi->MapSize = 0x200000; + break; + case SMI_LYNX3D: memBase = pSmi->PciInfo->memBase[0] + 0x680000; pSmi->MapSize = 0x180000; @@ -1778,6 +1810,16 @@ SMI_MapMem(ScrnInfoPtr pScrn) pSmi->DataPortSize = 0x8000; break; + case SMI_COUGAR3DR: + pSmi->DPRBase = pSmi->MapBase + 0x000000; + pSmi->VPRBase = pSmi->MapBase + 0x000800; + pSmi->CPRBase = pSmi->MapBase + 0x001000; + pSmi->FPRBase = pSmi->MapBase + 0x005800; + pSmi->IOBase = pSmi->MapBase + 0x0C0000; + pSmi->DataPortBase = pSmi->MapBase + 0x100000; + pSmi->DataPortSize = 0x100000; + break; + case SMI_LYNX3D: pSmi->DPRBase = pSmi->MapBase + 0x000000; pSmi->VPRBase = pSmi->MapBase + 0x000800; @@ -1807,15 +1849,15 @@ SMI_MapMem(ScrnInfoPtr pScrn) break; } xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, VERBLEV, - "Physical MMIO at 0x%08X\n", memBase); + "Physical MMIO at 0x%08lX\n", (unsigned long)memBase); xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, VERBLEV, - "Logical MMIO at 0x%08X - 0x%08X\n", pSmi->MapBase, + "Logical MMIO at %p - %p\n", pSmi->MapBase, pSmi->MapBase + pSmi->MapSize - 1); xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, VERBLEV, - "DPR=0x%08X, VPR=0x%08X, IOBase=0x%08X\n", pSmi->DPRBase, - pSmi->VPRBase, pSmi->IOBase); + "DPR=%p, VPR=%p, IOBase=%p\n", + pSmi->DPRBase, pSmi->VPRBase, pSmi->IOBase); xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, VERBLEV, - "DataPort=0x%08X - 0x%08X\n", pSmi->DataPortBase, + "DataPort=%p - %p\n", pSmi->DataPortBase, pSmi->DataPortBase + pSmi->DataPortSize - 1); /* Map the frame buffer */ @@ -1842,9 +1884,9 @@ SMI_MapMem(ScrnInfoPtr pScrn) } pSmi->FBOffset = pScrn->fbOffset = 0; xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, VERBLEV, - "Physical frame buffer at 0x%08X\n", pScrn->memPhysBase); + "Physical frame buffer at 0x%08lX\n", pScrn->memPhysBase); xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, VERBLEV, - "Logical frame buffer at 0x%08X - 0x%08X\n", pSmi->FBBase, + "Logical frame buffer at %p - %p\n", pSmi->FBBase, pSmi->FBBase + pSmi->videoRAMBytes - 1); SMI_EnableMmio(pScrn); @@ -1868,44 +1910,122 @@ SMI_MapMem(ScrnInfoPtr pScrn) { pSmi->FBReserved = pSmi->videoRAMBytes - 2048; } - xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Cursor Offset: %08X Reserved: %08X\n", - pSmi->FBCursorOffset, pSmi->FBReserved); - - pSmi->lcd = VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x31) & 0x01; - if (VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x30) & 0x01) - { - pSmi->lcd <<= 1; - } - switch (VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x30) & 0x0C) - { - case 0x00: - pSmi->lcdWidth = 640; - pSmi->lcdHeight = 480; - break; - - case 0x04: - pSmi->lcdWidth = 800; - pSmi->lcdHeight = 600; - break; - - case 0x08: - if (VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x74) & 0x02) + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Cursor Offset: %08lX Reserved: %08lX\n", + (unsigned long)pSmi->FBCursorOffset, + (unsigned long)pSmi->FBReserved); + /* panel size detection ... requires BIOS call on 730 hardware */ + if (pSmi->Chipset == SMI_COUGAR3DR) + { + if (pSmi->pInt10 != NULL) + { + pSmi->pInt10->num = 0x10; + pSmi->pInt10->ax = 0x5F00; + pSmi->pInt10->bx = 0; + pSmi->pInt10->cx = 0; + pSmi->pInt10->dx = 0; + xf86ExecX86int10(pSmi->pInt10); + if (pSmi->pInt10->ax == 0x005F) { - pSmi->lcdWidth = 1024; - pSmi->lcdHeight = 600; + switch (pSmi->pInt10->cx & 0x0F) + { + case PANEL_640x480: + pSmi->lcdWidth = 640; + pSmi->lcdHeight = 480; + break; + + case PANEL_800x600: + pSmi->lcdWidth = 800; + pSmi->lcdHeight = 600; + break; + + case PANEL_1024x768: + pSmi->lcdWidth = 1024; + pSmi->lcdHeight = 768; + break; + + case PANEL_1280x1024: + pSmi->lcdWidth = 1280; + pSmi->lcdHeight = 1024; + break; + + case PANEL_1600x1200: + pSmi->lcdWidth = 1600; + pSmi->lcdHeight = 1200; + break; + + case PANEL_1400x1050: + pSmi->lcdWidth = 1400; + pSmi->lcdHeight = 1050; + break; + } + + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Detected panel size via BIOS: %d x %d\n", + pSmi->lcdWidth, pSmi->lcdHeight); } else { - pSmi->lcdWidth = 1024; - pSmi->lcdHeight = 768; + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "BIOS error during 730 panel detection!\n"); + pSmi->lcdWidth = pScrn->virtualX; + pSmi->lcdHeight = pScrn->virtualY; } - break; + } + else + { + /* int10 support isn't setup on the second call to this function, + so if this is the second call, don't do detection again */ + if (pSmi->lcd == 0) + { + /* If we get here, int10 support is not loaded or not working */ + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "No BIOS support for 730 panel detection!\n"); + pSmi->lcdWidth = pScrn->virtualX; + pSmi->lcdHeight = pScrn->virtualY; + } + } - case 0x0C: - pSmi->lcdWidth = 1280; - pSmi->lcdHeight = 1024; - break; + /* Set this to indicate that we've done the detection */ + pSmi->lcd = 1; + } + else /* panel size detection for hardware other than 730 */ + { + pSmi->lcd = VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x31) & 0x01; + + if (VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x30) & 0x01) + { + pSmi->lcd <<= 1; + } + switch (VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x30) & 0x0C) + { + case 0x00: + pSmi->lcdWidth = 640; + pSmi->lcdHeight = 480; + break; + + case 0x04: + pSmi->lcdWidth = 800; + pSmi->lcdHeight = 600; + break; + + case 0x08: + if (VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x74) & 0x02) + { + pSmi->lcdWidth = 1024; + pSmi->lcdHeight = 600; + } + else + { + pSmi->lcdWidth = 1024; + pSmi->lcdHeight = 768; + } + break; + + case 0x0C: + pSmi->lcdWidth = 1280; + pSmi->lcdHeight = 1024; + break; + } } + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "%s Panel Size = %dx%d\n", (pSmi->lcd == 0) ? "OFF" : (pSmi->lcd == 1) ? "TFT" : "DSTN", pSmi->lcdWidth, pSmi->lcdHeight); @@ -2093,7 +2213,7 @@ SMI_ScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) numLines = maxLines; } else { /* CZ 3.11.2001: What does the following code? see also smi_video.c aaa line 1226 */ -/*#if defined(XvExtension) && SMI_USE_VIDEO */ +/*#if SMI_USE_VIDEO */ #if 0 numLines = ((pSmi->FBReserved - pSmi->width * pSmi->Bpp * pSmi->height) * 25 / 100 + pSmi->width @@ -2147,7 +2267,16 @@ SMI_ScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) if (pSmi->shadowFB) { - RefreshAreaFuncPtr refreshArea = SMI_RefreshArea; + RefreshAreaFuncPtr refreshArea; + + if (pSmi->Chipset == SMI_COUGAR3DR) + { + refreshArea = SMI_RefreshArea730; + } + else + { + refreshArea = SMI_RefreshArea; + } if (pSmi->rotate) { @@ -2251,10 +2380,17 @@ SMI_InternalScreenInit(int scrnIndex, ScreenPtr pScreen) pSmi->FBReserved -= pSmi->saveBufferSize; pSmi->FBReserved &= ~0x15; WRITE_VPR(pSmi, 0x0C, (pSmi->FBOffset = pSmi->FBReserved) >> 3); + if(pSmi->Chipset == SMI_COUGAR3DR) + { + WRITE_FPR(pSmi, FPR0C, (pSmi->FBOffset = pSmi->FBReserved) >> 3); + } - xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Shadow: width=%d height=%d " - "offset=0x%08X pitch=0x%08X\n", pSmi->ShadowWidth, - pSmi->ShadowHeight, pSmi->FBOffset, pSmi->ShadowPitch); + xf86DrvMsg(pScrn->scrnIndex, X_INFO, + "Shadow: width=%d height=%d " + "offset=0x%08lX pitch=0x%08X\n", + pSmi->ShadowWidth, pSmi->ShadowHeight, + (unsigned long)pSmi->FBOffset, + pSmi->ShadowPitch); } else { @@ -2435,14 +2571,18 @@ SMI_ModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode) outb(pSmi->PIOBase + VGA_SEQ_INDEX, 0x21); new->SR21 = inb(pSmi->PIOBase + VGA_SEQ_DATA) & ~0x03; - outb(pSmi->PIOBase + VGA_SEQ_INDEX, 0x31); - new->SR31 = inb(pSmi->PIOBase + VGA_SEQ_DATA) & ~0xC0; - - outb(pSmi->PIOBase + VGA_SEQ_INDEX, 0x32); - new->SR32 = inb(pSmi->PIOBase + VGA_SEQ_DATA) & ~0x07; - if (SMI_LYNXM_SERIES(pSmi->Chipset)) + if (pSmi->Chipset != SMI_COUGAR3DR) { - new->SR32 |= 0x04; + outb(pSmi->PIOBase + VGA_SEQ_INDEX, 0x31); + new->SR31 = inb(pSmi->PIOBase + VGA_SEQ_DATA) & ~0xC0; + + outb(pSmi->PIOBase + VGA_SEQ_INDEX, 0x32); + new->SR32 = inb(pSmi->PIOBase + VGA_SEQ_DATA) & ~0x07; + + if (SMI_LYNXM_SERIES(pSmi->Chipset)) + { + new->SR32 |= 0x04; + } } new->SRA0 = new->CR33 = new->CR3A = 0x00; @@ -2547,7 +2687,7 @@ SMI_ModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode) /* CZ 2.11.2001: for gamma correction (TODO: other chipsets?) */ new->CCR66 = VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x66); - if (pSmi->Chipset == SMI_LYNX3DM) { + if ((pSmi->Chipset == SMI_LYNX3DM) || (pSmi->Chipset == SMI_COUGAR3DR)){ switch (pScrn->bitsPerPixel) { case 8: new->CCR66 = (new->CCR66 & 0xF3) | 0x00; /* 6 bits-RAM */ @@ -2566,15 +2706,18 @@ SMI_ModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode) } } - outb(pSmi->PIOBase + VGA_SEQ_INDEX, 0x30); - if (inb(pSmi->PIOBase + VGA_SEQ_DATA) & 0x01) + if (pSmi->Chipset != SMI_COUGAR3DR) { - new->SR21 = 0x00; + outb(pSmi->PIOBase + VGA_SEQ_INDEX, 0x30); + if (inb(pSmi->PIOBase + VGA_SEQ_DATA) & 0x01) + { + new->SR21 = 0x00; + } } if (pSmi->MCLK > 0) { - SMI_CommonCalcClock(pScrn->scrnIndex,pSmi->MCLK, + SMI_CommonCalcClock(pScrn->scrnIndex, pSmi->MCLK, 1, 1, 31, 0, 2, pSmi->minClock, pSmi->maxClock, &new->SR6A, &new->SR6B); } @@ -2653,37 +2796,44 @@ SMI_ModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode) new->DPR40 = 0; new->DPR44 = 0; - /* Set VPR registers */ + /* Set VPR registers (and FPR registers for SM731) */ switch (pScrn->bitsPerPixel) { case 8: new->VPR00 = 0x00000000; + new->FPR00_= 0x00080000; break; case 16: new->VPR00 = 0x00020000; + new->FPR00_= 0x000A0000; break; case 24: new->VPR00 = 0x00040000; + new->FPR00_= 0x000C0000; break; case 32: new->VPR00 = 0x00030000; + new->FPR00_= 0x000B0000; break; } new->VPR0C = pSmi->FBOffset >> 3; if (pSmi->rotate) { - new->VPR10 = ((((min(pSmi->lcdWidth, pSmi->height) * pSmi->Bpp) >> 3) + new->VPR10 = (((( pSmi->height * pSmi->Bpp) >> 3) + 2) << 16) | ((pSmi->height * pSmi->Bpp) >> 3); } else { - new->VPR10 = ((((min(pSmi->lcdWidth, pSmi->width) * pSmi->Bpp) >> 3) + new->VPR10 = ((((pSmi->width * pSmi->Bpp) >> 3) + 2) << 16) | ((pSmi->width * pSmi->Bpp) >> 3); } + new->FPR0C_ = new->VPR0C; + new->FPR10_ = new->VPR10; + /* Set CPR registers */ new->CPR00 = 0x00000000; @@ -2786,7 +2936,6 @@ SMI_CloseScreen(int scrnIndex, ScreenPtr pScreen) xf86FreeInt10(pSmi->pInt10); pSmi->pInt10 = NULL; } -#ifdef XvExtension if (pSmi->ptrAdaptor != NULL) { xfree(pSmi->ptrAdaptor); @@ -2795,13 +2944,6 @@ SMI_CloseScreen(int scrnIndex, ScreenPtr pScreen) { pScreen->BlockHandler = pSmi->BlockHandler; } -#endif - if (pSmi->I2C != NULL) - { - xf86DestroyI2CBusRec(pSmi->I2C, FALSE, TRUE); - xfree(pSmi->I2C); - pSmi->I2C = NULL; - } /* #670 */ if (pSmi->pSaveBuffer) { @@ -2855,7 +2997,7 @@ SMI_AdjustFrame(int scrnIndex, int x, int y, int flags) } Base = pSmi->FBOffset + (x + y * pScrn->virtualX) * pSmi->Bpp; - if (SMI_LYNX3D_SERIES(pSmi->Chipset)) + if (SMI_LYNX3D_SERIES(pSmi->Chipset) || SMI_COUGAR_SERIES(pSmi->Chipset)) { Base = (Base + 15) & ~15; #if 1 /* PDR#1058 */ @@ -2877,6 +3019,10 @@ SMI_AdjustFrame(int scrnIndex, int x, int y, int flags) } WRITE_VPR(pSmi, 0x0C, Base >> 3); + if(pSmi->Chipset == SMI_COUGAR3DR) + { + WRITE_FPR(pSmi, FPR0C, Base >> 3); + } LEAVE_PROC("SMI_AdjustFrame"); } @@ -2903,6 +3049,16 @@ SMI_LoadPalette(ScrnInfoPtr pScrn, int numColors, int *indicies, LOCO *colors, ENTER_PROC("SMI_LoadPalette"); + /* Enable both the CRT and LCD DAC RAM paths, so both palettes are updated */ + if ((pSmi->Chipset == SMI_LYNX3DM) || (pSmi->Chipset == SMI_COUGAR3DR)) + { + CARD8 ccr66; + + ccr66 = VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x66); + ccr66 &= 0x0f; + VGAOUT8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x66, ccr66); + } + for(i = 0; i < numColors; i++) { DEBUG((VERBLEV, "pal[%d] = %d %d %d\n", indicies[i], @@ -2992,7 +3148,7 @@ SMI_DisableMmio(ScrnInfoPtr pScrn) static void SMI_PrintRegs(ScrnInfoPtr pScrn) { - unsigned char i, tmp; + unsigned char i; vgaHWPtr hwp = VGAHWPTR(pScrn); SMIPtr pSmi = SMIPTR(pScrn); int vgaCRIndex = hwp->IOBase + VGA_CRTC_INDEX_OFFSET; @@ -3041,34 +3197,34 @@ SMI_PrintRegs(ScrnInfoPtr pScrn) " x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 xA xB xC xD xE xF"); for (i = 0x00; i <= 0x14; i++) { - tmp = VGAIN8(pSmi, vgaStatus); + (void) VGAIN8(pSmi, vgaStatus); if ((i & 0xF) == 0x0) xf86ErrorFVerb(VERBLEV, "\n%02X|", i); if ((i & 0x3) == 0x0) xf86ErrorFVerb(VERBLEV, " "); xf86ErrorFVerb(VERBLEV, "%02X ", VGAIN8_INDEX(pSmi, VGA_ATTR_INDEX, VGA_ATTR_DATA_R, i)); } - tmp = VGAIN8(pSmi, vgaStatus); + (void) VGAIN8(pSmi, vgaStatus); VGAOUT8(pSmi, VGA_ATTR_INDEX, 0x20); xf86ErrorFVerb(VERBLEV, "\n\nDPR x0 x4 x8 xC"); for (i = 0x00; i <= 0x44; i += 4) { if ((i & 0xF) == 0x0) xf86ErrorFVerb(VERBLEV, "\n%02X|", i); - xf86ErrorFVerb(VERBLEV, " %08X", READ_DPR(pSmi, i)); + xf86ErrorFVerb(VERBLEV, " %08lX", (unsigned long)READ_DPR(pSmi, i)); } xf86ErrorFVerb(VERBLEV, "\n\nVPR x0 x4 x8 xC"); for (i = 0x00; i <= 0x60; i += 4) { if ((i & 0xF) == 0x0) xf86ErrorFVerb(VERBLEV, "\n%02X|", i); - xf86ErrorFVerb(VERBLEV, " %08X", READ_VPR(pSmi, i)); + xf86ErrorFVerb(VERBLEV, " %08lX", (unsigned long)READ_VPR(pSmi, i)); } xf86ErrorFVerb(VERBLEV, "\n\nCPR x0 x4 x8 xC"); for (i = 0x00; i <= 0x18; i += 4) { if ((i & 0xF) == 0x0) xf86ErrorFVerb(VERBLEV, "\n%02X|", i); - xf86ErrorFVerb(VERBLEV, " %08X", READ_CPR(pSmi, i)); + xf86ErrorFVerb(VERBLEV, " %08lX", (unsigned long)READ_CPR(pSmi, i)); } xf86ErrorFVerb(VERBLEV, "\n\n"); diff --git a/src/smi_hwcurs.c b/src/smi_hwcurs.c index b2f8d69..2c8c63f 100644 --- a/src/smi_hwcurs.c +++ b/src/smi_hwcurs.c @@ -26,7 +26,7 @@ Silicon Motion shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization from the XFree86 Project and Silicon Motion. */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/siliconmotion/smi_hwcurs.c,v 1.2 2001/03/03 22:26:13 tsi Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/siliconmotion/smi_hwcurs.c,v 1.3 2003/10/08 11:13:01 eich Exp $ */ #include "cursorstr.h" #include "smi.h" @@ -211,6 +211,17 @@ SMI_LoadCursorImage(ScrnInfoPtr pScrn, unsigned char *src) VGAOUT8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x81, tmp | ((pSmi->FBCursorOffset / 2048) >> 8)); + /* Program FPR copy when on the 730 */ + if (pSmi->Chipset == SMI_COUGAR3DR) + { + CARD32 fpr15c; + + /* put address in upper word, and disable the cursor */ + fpr15c = READ_FPR(pSmi, FPR15C) & FPR15C_MASK_HWCCOLORS; + fpr15c |= (pSmi->FBCursorOffset / 2048) << 16; + WRITE_FPR(pSmi, FPR15C, fpr15c); + } + /* Copy cursor image to framebuffer storage */ memcpy(pSmi->FBBase + pSmi->FBCursorOffset, src, 1024); @@ -229,6 +240,17 @@ SMI_ShowCursor(ScrnInfoPtr pScrn) tmp = VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x81); VGAOUT8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x81, tmp | 0x80); + /* Program FPR copy when on the 730 */ + if (pSmi->Chipset == SMI_COUGAR3DR) + { + CARD32 fpr15c; + + /* turn on the top bit */ + fpr15c = READ_FPR(pSmi, FPR15C); + fpr15c |= FPR15C_MASK_HWCENABLE; + WRITE_FPR(pSmi, FPR15C, fpr15c); + } + LEAVE_PROC("SMI_ShowCursor"); } @@ -244,6 +266,17 @@ SMI_HideCursor(ScrnInfoPtr pScrn) tmp = VGAIN8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x81); VGAOUT8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x81, tmp & ~0x80); + /* Program FPR copy when on the 730 */ + if (pSmi->Chipset == SMI_COUGAR3DR) + { + CARD32 fpr15c; + + /* turn off the top bit */ + fpr15c = READ_FPR(pSmi, FPR15C); + fpr15c &= ~FPR15C_MASK_HWCENABLE; + WRITE_FPR(pSmi, FPR15C, fpr15c); + } + LEAVE_PROC("SMI_HideCursor"); } @@ -301,6 +334,34 @@ SMI_SetCursorPosition(ScrnInfoPtr pScrn, int x, int y) VGAOUT8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x8B, 0x08); } + /* Program FPR copy when on the 730 */ + if (pSmi->Chipset == SMI_COUGAR3DR) + { + CARD32 fpr158; + + if (xoff >= 0) + { + fpr158 = (xoff & FPR158_MASK_MAXBITS)<<16; + } + else + { + fpr158 = (((-xoff) & FPR158_MASK_MAXBITS) | FPR158_MASK_BOUNDARY)<<16; + } + + if (yoff >= 0) + { + fpr158 |= (yoff & FPR158_MASK_MAXBITS); + } + else + { + fpr158 |= (((-yoff) & FPR158_MASK_MAXBITS) | FPR158_MASK_BOUNDARY); + } + + /* Program combined coordinates */ + WRITE_FPR(pSmi, FPR158, fpr158); + + } + LEAVE_PROC("SMI_SetCursorPosition"); } @@ -326,6 +387,17 @@ SMI_SetCursorColors(ScrnInfoPtr pScrn, int bg, int fg) VGAOUT8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x8C, packedFG); VGAOUT8_INDEX(pSmi, VGA_SEQ_INDEX, VGA_SEQ_DATA, 0x8D, packedBG); + /* Program FPR copy when on the 730 */ + if (pSmi->Chipset == SMI_COUGAR3DR) + { + CARD32 fpr15c; + + fpr15c = READ_FPR(pSmi, FPR15C) & FPR15C_MASK_HWCADDREN; + fpr15c |= packedFG; + fpr15c |= packedBG<<8; + WRITE_FPR(pSmi, FPR15C, fpr15c); + } + LEAVE_PROC("SMI_SetCursorColors"); } diff --git a/src/smi_shadow.c b/src/smi_shadow.c index 5ef9ba5..ed7372b 100644 --- a/src/smi_shadow.c +++ b/src/smi_shadow.c @@ -26,7 +26,7 @@ Silicon Motion shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization from the XFree86 Project and Silicon Motion. */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/siliconmotion/smi_shadow.c,v 1.2 2000/12/05 21:18:37 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/siliconmotion/smi_shadow.c,v 1.3 2003/10/08 11:13:01 eich Exp $ */ #include "xf86.h" #include "xf86_OSproc.h" @@ -181,6 +181,162 @@ void SMI_RefreshArea(ScrnInfoPtr pScrn, int num, BoxPtr pbox) LEAVE_PROC("SMI_RefreshArea"); } +/* Custom version for the 730 series (Cougar3DR). + This chipset has problems with large rotate-blts. */ + +void SMI_RefreshArea730(ScrnInfoPtr pScrn, int num, BoxPtr pbox) +{ + SMIPtr pSmi = SMIPTR(pScrn); + int width, height, srcX, srcY, destX, destY; + int maxPixels, tempWidth; + + ENTER_PROC("SMI_RefreshArea730"); + + /* #671 */ + if (pSmi->polyLines) + { + pSmi->polyLines = FALSE; + return; + } + + if (pSmi->rotate) + { + /* IF we need to do rotation, setup the hardware here. */ + WaitIdleEmpty(); + WRITE_DPR(pSmi, 0x10, pSmi->ShadowPitch); + WRITE_DPR(pSmi, 0x3C, pSmi->ShadowPitch); + WRITE_DPR(pSmi, 0x44, pSmi->FBOffset >> 3); + } + + /* #672 */ + if (pSmi->ClipTurnedOn) + { + WaitQueue(1); + WRITE_DPR(pSmi, 0x2C, pSmi->ScissorsLeft); + pSmi->ClipTurnedOn = FALSE; + } + + /* SM731 cannot rotate-blt more than a certain number of pixels + (based on a calculation from the Windows driver source */ + maxPixels = 1280 / pScrn->bitsPerPixel; + + while (num--) + { + /* Get coordinates of the box to refresh. */ + srcX = pbox->x1; + srcY = pbox->y1; + width = pbox->x2 - srcX; + height = pbox->y2 - srcY; + + DEBUG((VERBLEV, "x=%d y=%d w=%d h=%d\n", srcX, srcY, width, height)); + + if ((width > 0) && (height > 0)) + { + switch (pSmi->rotate) + { + case SMI_ROTATE_CW: + /* 90 degrees CW rotation. Calculate destination + coordinates: + + *---+ + | | +-----* + | | | | destX = shadowHeight - srcY - 1 + | | --> | | destY = srcX + | | | | + | | +-----+ + +---+ + */ + destX = pSmi->ShadowHeight - srcY - 1; + destY = srcX; + + for (tempWidth=width; tempWidth>0;) + { + if (width>maxPixels) + width = maxPixels; + WaitQueue(4); + WRITE_DPR(pSmi, 0x00, (srcX << 16) + srcY); + WRITE_DPR(pSmi, 0x04, (destX << 16) + destY); + WRITE_DPR(pSmi, 0x08, (width << 16) + height); + WRITE_DPR(pSmi, 0x0C, 0xCC | SMI_ROTATE_BLT | + SMI_ROTATE_CW | SMI_START_ENGINE); + destY += maxPixels; + srcX += maxPixels; + tempWidth -= maxPixels; + width = tempWidth; + } + + break; + + case SMI_ROTATE_CCW: + /* 90 degrees CCW rotatation. Calculate destination + coordinates: + + *---+ + | | +-----+ + | | | | destX = srcY + | | --> | | destY = shadowWidth - srcX - 1 + | | | | + | | *-----+ + +---+ + */ + destX = srcY; + destY = pSmi->ShadowWidth - srcX - 1; + + for (tempWidth=width; tempWidth>0;) + { + if (width>maxPixels) + width = maxPixels; + WaitQueue(4); + WRITE_DPR(pSmi, 0x00, (srcX << 16) + srcY); + WRITE_DPR(pSmi, 0x04, (destX << 16) + destY); + WRITE_DPR(pSmi, 0x08, (width << 16) + height); + WRITE_DPR(pSmi, 0x0C, 0xCC | SMI_ROTATE_BLT | + SMI_ROTATE_CCW | SMI_START_ENGINE); + destY -= maxPixels; + srcX += maxPixels; + tempWidth -= maxPixels; + width = tempWidth; + } + + break; + + default: + /* No rotation, perform a normal copy. */ + if (pScrn->bitsPerPixel == 24) + { + srcX *= 3; + width *= 3; + + if (pSmi->Chipset == SMI_LYNX) + { + srcY *= 3; + } + } + + WaitQueue(4); + WRITE_DPR(pSmi, 0x00, (srcX << 16) + srcY); + WRITE_DPR(pSmi, 0x04, (srcX << 16) + srcY); + WRITE_DPR(pSmi, 0x08, (width << 16) + height); + WRITE_DPR(pSmi, 0x0C, SMI_BITBLT + SMI_START_ENGINE + 0xCC); + break; + } + } + + pbox++; + } + + if (pSmi->rotate) + { + /* If we did a rotation, we need to restore the hardware state here. */ + WaitIdleEmpty(); + WRITE_DPR(pSmi, 0x10, (pSmi->Stride << 16) | pSmi->Stride); + WRITE_DPR(pSmi, 0x3C, (pSmi->Stride << 16) | pSmi->Stride); + WRITE_DPR(pSmi, 0x44, 0); + } + + LEAVE_PROC("SMI_RefreshArea730"); +} + /******************************************************************************\ |* SMI_PointerMoved |*============================================================================= diff --git a/src/smi_video.c b/src/smi_video.c index 7ec571e..06dcc3a 100644 --- a/src/smi_video.c +++ b/src/smi_video.c @@ -34,14 +34,14 @@ this is a heavy modified version of the V1.2.2 original siliconmotion driver. XV_SATURATION, XV_HUE, XV_COLORKEY, XV_INTERLACED XV_CAPTURE_BRIGHTNESS can be used to set brightness in the capture device - bug fixes -- tries not to use acceleration functions (if USE_XAA = 0) +- tries not to use acceleration functions - interlaced video for double vertical resolution Author of changes: Corvin Zahn <zahn@zac.de> Date: 2.11.2001 */ -/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/siliconmotion/smi_video.c,v 1.9.2.1 2003/05/09 02:22:00 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/siliconmotion/smi_video.c,v 1.13 2003/11/10 18:22:26 tsi Exp $ */ #include "smi.h" #include "smi_video.h" @@ -79,20 +79,8 @@ The default value can be set with the driver option Interlaced #define MAKE_ATOM(a) MakeAtom(a, sizeof(a) - 1, TRUE) -#if defined(XvExtension) && SMI_USE_VIDEO - -/* USE_XAA = 1: use XAA functions for color key rectangle fill, - USE_XAA = 0: use xf86XVFillKeyHelper for color key rectangle fill, - needs common/xf86xv.c >= 1.30, - common/xf86xv.h >= 1.22, - loader/xf86sym.c >= 1.194 */ -#define USE_XAA 1 - +#if SMI_USE_VIDEO #include "dixstruct.h" -#if USE_XAA -#include "xaa.h" -#include "xaalocal.h" -#endif static int SMI_AddEncoding(XF86VideoEncodingPtr enc, int i, @@ -125,13 +113,15 @@ static int SMI_QueryImageAttributes(ScrnInfoPtr pScrn, int id, unsigned short *width, unsigned short *height, int *picthes, int *offsets); -static Bool RegionsEqual(RegionPtr A, RegionPtr B); static Bool SMI_ClipVideo(ScrnInfoPtr pScrn, BoxPtr dst, INT32 *x1, INT32 *y1, INT32 *x2, INT32 *y2, RegionPtr reg, INT32 width, INT32 height); static void SMI_DisplayVideo(ScrnInfoPtr pScrn, int id, int offset, short width, short height, int pitch, int x1, int y1, int x2, int y2, BoxPtr dstBox, short vid_w, short vid_h, short drw_w, short drw_h); +static void SMI_DisplayVideo0730(ScrnInfoPtr pScrn, int id, int offset, + short width, short height, int pitch, int x1, int y1, int x2, int y2, + BoxPtr dstBox, short vid_w, short vid_h, short drw_w, short drw_h); static void SMI_BlockHandler(int i, pointer blockData, pointer pTimeout, pointer pReadMask); #if 0 @@ -164,7 +154,11 @@ static int SMI_SetSurfaceAttribute(ScrnInfoPtr pScrn, Atom attr, INT32 value); static int SetAttr(ScrnInfoPtr pScrn, int i, int value); static int SetAttrSAA7110(ScrnInfoPtr pScrn, int i, int value); static int SetAttrSAA7111(ScrnInfoPtr pScrn, int i, int value); +static void SetKeyReg(SMIPtr pSmi, int reg, int value); +#if XF86_VERSION_CURRENT < XF86_VERSION_NUMERIC(4,3,99,0,0) +static Bool RegionsEqual(RegionPtr A, RegionPtr B); +#endif /** * Atoms */ @@ -470,6 +464,55 @@ static I2CByte SAA7111InitData[] = /**************************************************************************/ +/* To allow this ddx to work on 4_3_0 and above, we need to include this */ +#if XF86_VERSION_CURRENT < XF86_VERSION_NUMERIC(4,3,99,0,0) +static Bool +RegionsEqual( + RegionPtr A, + RegionPtr B +) +{ + int *dataA, *dataB; + int num; + + ENTER_PROC("RegionsEqual"); + + num = REGION_NUM_RECTS(A); + if (num != REGION_NUM_RECTS(B)) + { + LEAVE_PROC("RegionsEqual"); + return(FALSE); + } + + if ( (A->extents.x1 != B->extents.x1) + || (A->extents.y1 != B->extents.y1) + || (A->extents.x2 != B->extents.x2) + || (A->extents.y2 != B->extents.y2) + ) + { + LEAVE_PROC("RegionsEqual"); + return(FALSE); + } + + dataA = (int*) REGION_RECTS(A); + dataB = (int*) REGION_RECTS(B); + + while (num--) + { + if ((dataA[0] != dataB[0]) || (dataA[1] != dataB[1])) + { + return(FALSE); + } + dataA += 2; + dataB += 2; + } + + LEAVE_PROC("RegionsEqual"); + return(TRUE); +} +#endif + + /** * generates XF86VideoEncoding[i] with video norm norm, video input format * input and video input channel channel @@ -673,7 +716,7 @@ SetAttr(ScrnInfoPtr pScrn, int i, int value) if (i == XV_BRIGHTNESS) { int my_value = (value <= 128? value + 128 : value - 128); - WRITE_VPR(pSmi, 0x5C, 0xEDEDED | (my_value << 24)); + SetKeyReg(pSmi, 0x5C, 0xEDEDED | (my_value << 24)); } else if (pPort->I2CDev.SlaveAddr == SAA7110) { return SetAttrSAA7110(pScrn, i, value); } @@ -863,7 +906,10 @@ SMI_SetupVideo( ptrAdaptor->pImages = SMI_VideoImages; #if SMI_USE_CAPTURE - ptrAdaptor->PutVideo = SMI_PutVideo; + if (pSmi->Chipset == SMI_COUGAR3DR) + ptrAdaptor->PutVideo = NULL; + else + ptrAdaptor->PutVideo = SMI_PutVideo; ptrAdaptor->PutStill = NULL; ptrAdaptor->GetVideo = NULL; ptrAdaptor->GetStill = NULL; @@ -919,7 +965,11 @@ SMI_SetupVideo( } else smiPortPtr->I2CDev.SlaveAddr = 0; +#if defined(REGION_NULL) + REGION_NULL(pScreen, &smiPortPtr->clip); +#else REGION_INIT(pScreen, &smiPortPtr->clip, NullBox, 0); +#endif pSmi->ptrAdaptor = ptrAdaptor; pSmi->BlockHandler = pScreen->BlockHandler; @@ -956,26 +1006,26 @@ SMI_ResetVideo( switch (pScrn->depth) { case 8: - WRITE_VPR(pSmi, 0x04, pPort->Attribute[XV_COLORKEY] & 0x00FF); - WRITE_VPR(pSmi, 0x08, 0); + SetKeyReg(pSmi, FPR04, pPort->Attribute[XV_COLORKEY] & 0x00FF); + SetKeyReg(pSmi, FPR08, 0); break; case 15: case 16: - WRITE_VPR(pSmi, 0x04, pPort->Attribute[XV_COLORKEY] & 0xFFFF); - WRITE_VPR(pSmi, 0x08, 0); + SetKeyReg(pSmi, FPR04, pPort->Attribute[XV_COLORKEY] & 0xFFFF); + SetKeyReg(pSmi, FPR08, 0); break; default: r = (pPort->Attribute[XV_COLORKEY] & pScrn->mask.red) >> pScrn->offset.red; g = (pPort->Attribute[XV_COLORKEY] & pScrn->mask.green) >> pScrn->offset.green; b = (pPort->Attribute[XV_COLORKEY] & pScrn->mask.blue) >> pScrn->offset.blue; - WRITE_VPR(pSmi, 0x04, ((r >> 3) << 11) | ((g >> 2) << 5) | (b >> 3)); - WRITE_VPR(pSmi, 0x08, 0); + SetKeyReg(pSmi, FPR04, ((r >> 3) << 11) | ((g >> 2) << 5) | (b >> 3)); + SetKeyReg(pSmi, FPR08, 0); break; } - WRITE_VPR(pSmi, 0x5C, 0xEDEDED | (pPort->Attribute[XV_BRIGHTNESS] << 24)); + SetKeyReg(pSmi, FPR5C, 0xEDEDED | (pPort->Attribute[XV_BRIGHTNESS] << 24)); LEAVE_PROC("SMI_ResetVideo"); } @@ -1247,17 +1297,16 @@ SMI_PutVideo( vid_address = (pPort->area->box.y1 * fbPitch); DEBUG((VERBLEV, "test RegionsEqual\n")); +#if XF86_VERSION_CURRENT < XF86_VERSION_NUMERIC(4,3,99,0,0) if (!RegionsEqual(&pPort->clip, clipBoxes)) +#else + if (!REGION_EQUAL(pScrn->pScreen, &pPort->clip, clipBoxes)) +#endif { DEBUG((VERBLEV, "RegionCopy\n")); - REGION_COPY(pScreen, &pPort->clip, clipBoxes); -#if USE_XAA - XAAFillSolidRects(pScrn, pPort->Attribute[XV_COLORKEY], GXcopy, ~0, - REGION_NUM_RECTS(clipBoxes), REGION_RECTS(clipBoxes)); -#else + REGION_COPY(pScrn->pScreen, &pPort->clip, clipBoxes); DEBUG((VERBLEV, "FillKey\n")); xf86XVFillKeyHelper(pScrn->pScreen, pPort->Attribute[XV_COLORKEY], clipBoxes); -#endif } @@ -1353,11 +1402,21 @@ SMI_StopVideo( { if (pPort->videoStatus & CLIENT_VIDEO_ON) { - WRITE_VPR(pSmi, 0x00, READ_VPR(pSmi, 0x00) & ~0x01000008); + if (pSmi->Chipset == SMI_COUGAR3DR) + { + WRITE_FPR(pSmi, FPR00, READ_FPR(pSmi, 0x00) & ~(FPR00_VWIENABLE)); + } + else + { + WRITE_VPR(pSmi, 0x00, READ_VPR(pSmi, 0x00) & ~0x01000008); + } #if SMI_USE_CAPTURE - WRITE_CPR(pSmi, 0x00, READ_CPR(pSmi, 0x00) & ~0x00000001); - WRITE_VPR(pSmi, 0x54, READ_VPR(pSmi, 0x54) & ~0x00F00000); -/* #864 OUT_SEQ(pSmi, 0x21, IN_SEQ(pSmi, 0x21) | 0x04); */ + if (pSmi->Chipset != SMI_COUGAR3DR) + { + WRITE_CPR(pSmi, 0x00, READ_CPR(pSmi, 0x00) & ~0x00000001); + WRITE_VPR(pSmi, 0x54, READ_VPR(pSmi, 0x54) & ~0x00F00000); + } + /* #864 OUT_SEQ(pSmi, 0x21, IN_SEQ(pSmi, 0x21) | 0x04); */ #endif } if (pPort->area != NULL) @@ -1402,19 +1461,19 @@ SMI_SetPortAttribute( switch (pScrn->depth) { case 8: - WRITE_VPR(pSmi, 0x04, value & 0x00FF); + SetKeyReg(pSmi, FPR04, value & 0x00FF); break; case 15: case 16: - WRITE_VPR(pSmi, 0x04, value & 0xFFFF); + SetKeyReg(pSmi, FPR04, value & 0xFFFF); break; default: r = (value & pScrn->mask.red) >> pScrn->offset.red; g = (value & pScrn->mask.green) >> pScrn->offset.green; b = (value & pScrn->mask.blue) >> pScrn->offset.blue; - WRITE_VPR(pSmi, 0x04, + SetKeyReg(pSmi, FPR04, ((r >> 3) << 11) | ((g >> 2) << 5) | (b >> 3)); break; } @@ -1653,20 +1712,23 @@ SMI_PutImage( break; } +#if XF86_VERSION_CURRENT < XF86_VERSION_NUMERIC(4,3,99,0,0) if (!RegionsEqual(&pPort->clip, clipBoxes)) - { - REGION_COPY(pScreen, &pPort->clip, clipBoxes); -#if USE_XAA - XAAFillSolidRects(pScrn, pPort->Attribute[XV_COLORKEY], GXcopy, ~0, - REGION_NUM_RECTS(clipBoxes), REGION_RECTS(clipBoxes)); #else - /*aaa*/ - return(BadAlloc); + if (!REGION_EQUAL(pScrn->pScreen, &pPort->clip, clipBoxes)) #endif + { + REGION_COPY(pScrn->pScreen, &pPort->clip, clipBoxes); + xf86XVFillKeyHelper(pScrn->pScreen, pPort->Attribute[XV_COLORKEY], + clipBoxes); } - SMI_DisplayVideo(pScrn, id, offset, width, height, dstPitch, x1, y1, x2, y2, - &dstBox, src_w, src_h, drw_w, drw_h); + if (pSmi->Chipset != SMI_COUGAR3DR) + SMI_DisplayVideo(pScrn, id, offset, width, height, dstPitch, x1, y1, x2, y2, + &dstBox, src_w, src_h, drw_w, drw_h); + else + SMI_DisplayVideo0730(pScrn, id, offset, width, height, dstPitch, x1, y1, x2, y2, + &dstBox, src_w, src_h, drw_w, drw_h); pPort->videoStatus = CLIENT_VIDEO_ON; LEAVE_PROC("SMI_PutImage"); @@ -1792,51 +1854,6 @@ SMI_WaitForSync( #endif static Bool -RegionsEqual( - RegionPtr A, - RegionPtr B -) -{ - int *dataA, *dataB; - int num; - - ENTER_PROC("RegionsEqual"); - - num = REGION_NUM_RECTS(A); - if (num != REGION_NUM_RECTS(B)) - { - LEAVE_PROC("RegionsEqual"); - return(FALSE); - } - - if ( (A->extents.x1 != B->extents.x1) - || (A->extents.y1 != B->extents.y1) - || (A->extents.x2 != B->extents.x2) - || (A->extents.y2 != B->extents.y2) - ) - { - LEAVE_PROC("RegionsEqual"); - return(FALSE); - } - - dataA = (int*) REGION_RECTS(A); - dataB = (int*) REGION_RECTS(B); - - while (num--) - { - if ((dataA[0] != dataB[0]) || (dataA[1] != dataB[1])) - { - return(FALSE); - } - dataA += 2; - dataB += 2; - } - - LEAVE_PROC("RegionsEqual"); - return(TRUE); -} - -static Bool SMI_ClipVideo( ScrnInfoPtr pScrn, BoxPtr dst, @@ -1849,8 +1866,9 @@ SMI_ClipVideo( INT32 height ) { + ScreenPtr pScreen = pScrn->pScreen; INT32 vscale, hscale; - BoxPtr extents = REGION_EXTENTS(pScrn, reg); + BoxPtr extents = REGION_EXTENTS(pScreen, reg); int diff; ENTER_PROC("SMI_ClipVideo"); @@ -1945,9 +1963,9 @@ SMI_ClipVideo( ) { RegionRec clipReg; - REGION_INIT(pScrn, &clipReg, dst, 1); - REGION_INTERSECT(pScrn, reg, reg, &clipReg); - REGION_UNINIT(pScrn, &clipReg); + REGION_INIT(pScreen, &clipReg, dst, 1); + REGION_INTERSECT(pScreen, reg, reg, &clipReg); + REGION_UNINIT(pScreen, &clipReg); } DEBUG((VERBLEV, "ClipVideo(%d): x1=%d y1=%d x2=%d y2=%d\n", __LINE__, *x1 >> 16, *y1 >> 16, *x2 >> 16, *y2 >> 16)); @@ -2041,6 +2059,90 @@ SMI_DisplayVideo( } static void +SMI_DisplayVideo0730( + ScrnInfoPtr pScrn, + int id, + int offset, + short width, + short height, + int pitch, + int x1, + int y1, + int x2, + int y2, + BoxPtr dstBox, + short vid_w, + short vid_h, + short drw_w, + short drw_h +) +{ + SMIPtr pSmi = SMIPTR(pScrn); + CARD32 fpr00; + int hstretch, vstretch; + + ENTER_PROC("SMI_DisplayVideo0730"); + + fpr00 = READ_FPR(pSmi, 0x00) & ~(FPR00_MASKBITS); + + switch (id) + { + case FOURCC_YV12: + case FOURCC_I420: + case FOURCC_YUY2: + fpr00 |= FPR00_FMT_YUV422; + break; + + case FOURCC_RV15: + fpr00 |= FPR00_FMT_15P; + break; + + case FOURCC_RV16: + fpr00 |= FPR00_FMT_16P; + break; + + case FOURCC_RV24: + fpr00 |= FPR00_FMT_24P; + break; + + case FOURCC_RV32: + fpr00 |= FPR00_FMT_32P; + break; + } + + /* the formulas for calculating the stretch values do not match the + documentation, but they're the same as the ddraw driver and they work */ + if (drw_w > vid_w) + { + hstretch = (8192 * vid_w / drw_w); + } + else + { + hstretch = 0; + } + + if (drw_h > vid_h) + { + vstretch = (8192 * vid_h / drw_h); + } + else + { + vstretch = 0; + } + + + WRITE_FPR(pSmi, FPR00, fpr00 | FPR00_VWIENABLE | FPR00_VWIKEYENABLE); + WRITE_FPR(pSmi, FPR14, (dstBox->x1) | (dstBox->y1 << 16)); + WRITE_FPR(pSmi, FPR18, (dstBox->x2) | (dstBox->y2 << 16)); + WRITE_FPR(pSmi, FPR1C, offset >> 3); + WRITE_FPR(pSmi, FPR20, (pitch >> 3) | ((pitch >> 3) << 16)); + WRITE_FPR(pSmi, FPR24, (hstretch & 0xFF00) | ((vstretch & 0xFF00)>>8)); + WRITE_FPR(pSmi, FPR68, ((hstretch & 0x00FF)<<8) | (vstretch & 0x00FF)); + + LEAVE_PROC("SMI_DisplayVideo0730"); +} + +static void SMI_BlockHandler( int i, pointer blockData, @@ -2064,7 +2166,14 @@ SMI_BlockHandler( { if (pPort->offTime < currentTime.milliseconds) { - WRITE_VPR(pSmi, 0x00, READ_VPR(pSmi, 0x00) & ~0x00000008); + if (pSmi->Chipset == SMI_COUGAR3DR) + { + WRITE_FPR(pSmi, FPR00, READ_FPR(pSmi, 0x00) & ~(FPR00_VWIENABLE)); + } + else + { + WRITE_VPR(pSmi, 0x00, READ_VPR(pSmi, 0x00) & ~0x00000008); + } pPort->videoStatus = FREE_TIMER; pPort->freeTime = currentTime.milliseconds + FREE_DELAY; } @@ -2472,23 +2581,28 @@ SMI_DisplaySurface( dstBox.x2 -= surface->pScrn->frameX0; dstBox.y2 -= surface->pScrn->frameY0; -#if USE_XAA - XAAFillSolidRects(surface->pScrn, pPort->Attribute[XV_COLORKEY], GXcopy, ~0, - REGION_NUM_RECTS(clipBoxes), REGION_RECTS(clipBoxes)); -#else - /*aaa*/ - return(BadAlloc); -#endif + xf86XVFillKeyHelper(surface->pScrn->pScreen, + pPort->Attribute[XV_COLORKEY], clipBoxes); - SMI_ResetVideo(surface->pScrn); - SMI_DisplayVideo(surface->pScrn, surface->id, surface->offsets[0], - surface->width, surface->height, surface->pitches[0], x1, y1, x2, - y2, &dstBox, vid_w, vid_h, drw_w, drw_h); + if (pSmi->Chipset != SMI_COUGAR3DR) + { + SMI_ResetVideo(surface->pScrn); + SMI_DisplayVideo(surface->pScrn, surface->id, surface->offsets[0], + surface->width, surface->height, surface->pitches[0], x1, y1, x2, + y2, &dstBox, vid_w, vid_h, drw_w, drw_h); + } + else + { + SMI_ResetVideo(surface->pScrn); + SMI_DisplayVideo0730(surface->pScrn, surface->id, surface->offsets[0], + surface->width, surface->height, surface->pitches[0], x1, y1, x2, + y2, &dstBox, vid_w, vid_h, drw_w, drw_h); + } ptrOffscreen->isOn = TRUE; if (pPort->videoStatus & CLIENT_VIDEO_ON) { - REGION_EMPTY(pScrn->pScreen, &pPort->clip); + REGION_EMPTY(surface->pScrn->pScreen, &pPort->clip); UpdateCurrentTime(); pPort->videoStatus = FREE_TIMER; pPort->freeTime = currentTime.milliseconds + FREE_DELAY; @@ -2510,7 +2624,15 @@ SMI_StopSurface( if (ptrOffscreen->isOn) { SMIPtr pSmi = SMIPTR(surface->pScrn); - WRITE_VPR(pSmi, 0x00, READ_VPR(pSmi, 0x00) & ~0x00000008); + if (pSmi->Chipset == SMI_COUGAR3DR) + { + WRITE_FPR(pSmi, FPR00, READ_FPR(pSmi, 0x00) & ~(FPR00_VWIENABLE)); + } + else + { + WRITE_VPR(pSmi, 0x00, READ_VPR(pSmi, 0x00) & ~0x00000008); + } + ptrOffscreen->isOn = FALSE; } @@ -2543,6 +2665,20 @@ SMI_SetSurfaceAttribute( return(SMI_SetPortAttribute(pScrn, attr, value, (pointer) pSmi->ptrAdaptor->pPortPrivates[0].ptr)); } -#else /* XvExtension */ + +static void +SetKeyReg(SMIPtr pSmi, int reg, int value) +{ + if (pSmi->Chipset == SMI_COUGAR3DR) + { + WRITE_FPR(pSmi, reg, value); + } + else + { + WRITE_VPR(pSmi, reg, value); + } +} + +#else /* SMI_USE_VIDEO */ void SMI_InitVideo(ScreenPtr pScreen) {} #endif |