/* 8x8 mono */ static void SiSSetupForMono8x8PatternFill(ScrnInfoPtr pScrn, int patternx, int patterny, int fg, int bg, int rop, unsigned int planemask) { SISPtr pSiS = SISPTR(pScrn); unsigned int *patternRegPtr; int i; (void)XAAHelpPatternROP(pScrn, &fg, &bg, planemask, &rop); sisBLTSync; if(bg != -1) { sisSETBGROPCOL(0xcc, bg); /* copy */ } else { sisSETBGROPCOL(0xAA, bg); /* noop */ } sisSETFGROPCOL(rop, fg); sisSETPITCH(0, pSiS->scrnOffset); sisSETSRCADDR(0); patternRegPtr = (unsigned int *)sisSETPATREG(); pSiS->sisPatternReg[0] = pSiS->sisPatternReg[2] = patternx ; pSiS->sisPatternReg[1] = pSiS->sisPatternReg[3] = patterny ; for ( i = 0 ; i < 16 /* sisPatternHeight */ ; ) { patternRegPtr[i++] = patternx ; patternRegPtr[i++] = patterny ; } }
/* sync */ static void SiSSync(ScrnInfoPtr pScrn) { SISPtr pSiS = SISPTR(pScrn); sisBLTSync; }
static void SiSSyncAccel(ScrnInfoPtr pScrn) { SISPtr pSiS = SISPTR(pScrn); if(!pSiS->NoAccel) SiSSync(pScrn); }
/* DGAReInit: * Re-initialize our DGA modes. Needs X.org 6.9+. * For older versions, DGA will be disabled if * the dynamic modelist is enabled. */ Bool SISDGAReInit(ScrnInfoPtr pScrn) { #ifdef SISISXORG6899900 SISPtr pSiS = SISPTR(pScrn); DGAModePtr newdgamodes = NULL; int newdgamodenum = 0; /* DGA wasn't enabled */ if(!pSiS->DGAModes || !pSiS->numDGAModes) return TRUE; newdgamodes = SISDGAMakeModes(pScrn, &newdgamodenum, TRUE); if(DGAReInitModes(screenInfo.screens[pScrn->scrnIndex], newdgamodes, newdgamodenum)) { free(pSiS->DGAModes); pSiS->DGAModes = newdgamodes; pSiS->numDGAModes = newdgamodenum; return TRUE; } else { free(newdgamodes); return FALSE; } #else return TRUE; #endif }
static DGAModePtr SISDGAMakeModes(ScrnInfoPtr pScrn, int *num, Bool quiet) { SISPtr pSiS = SISPTR(pScrn); DGAModePtr modes = NULL; *num = 0; /* 8 */ /* We don't support 8bpp modes in dual head or MergedFB mode, * so don't offer them to DGA either. */ #ifdef SISDUALHEAD if(!pSiS->DualHeadMode) { #endif #ifdef SISMERGED if(!(pSiS->MergedFB)) { #endif modes = SISSetupDGAMode(pScrn, modes, num, 8, 8, (pScrn->bitsPerPixel == 8), ((pScrn->bitsPerPixel != 8) ? 0 : pScrn->displayWidth), 0, 0, 0, PseudoColor, quiet); #ifdef SISMERGED } #endif #ifdef SISDUALHEAD } #endif /* 16 */ modes = SISSetupDGAMode(pScrn, modes, num, 16, 16, (pScrn->bitsPerPixel == 16), ((pScrn->depth != 16) ? 0 : pScrn->displayWidth), 0xf800, 0x07e0, 0x001f, TrueColor, quiet); /* 24 */ if((pSiS->VGAEngine == SIS_530_VGA) || (pSiS->VGAEngine == SIS_OLD_VGA)) { modes = SISSetupDGAMode(pScrn, modes, num, 24, 24, (pScrn->bitsPerPixel == 24), ((pScrn->bitsPerPixel != 24) ? 0 : pScrn->displayWidth), 0xff0000, 0x00ff00, 0x0000ff, TrueColor, quiet); } /* 32 */ if(pSiS->VGAEngine != SIS_OLD_VGA) { modes = SISSetupDGAMode(pScrn, modes, num, 32, 24, (pScrn->bitsPerPixel == 32), ((pScrn->bitsPerPixel != 32) ? 0 : pScrn->displayWidth), 0xff0000, 0x00ff00, 0x0000ff, TrueColor, quiet); } return modes; }
/* Line */ static void SiSSetupForSolidLine(ScrnInfoPtr pScrn, int color, int rop, unsigned int planemask) { SISPtr pSiS = SISPTR(pScrn); sisBLTSync; sisSETBGROPCOL(XAACopyROP[rop], 0); sisSETFGROPCOL(XAACopyROP[rop], color); }
/* Clipping */ static void SiSSetClippingRectangle ( ScrnInfoPtr pScrn, int left, int top, int right, int bottom) { SISPtr pSiS = SISPTR(pScrn); sisBLTSync; sisSETCLIPTOP(left,top); sisSETCLIPBOTTOM(right,bottom); pSiS->ClipEnabled = TRUE; }
/* solid fill */ static void SiSSetupForFillRectSolid(ScrnInfoPtr pScrn, int color, int rop, unsigned int planemask) { SISPtr pSiS = SISPTR(pScrn); sisBLTSync; sisSETBGROPCOL(XAACopyROP[rop], color); sisSETFGROPCOL(XAACopyROP[rop], color); sisSETPITCH(pSiS->scrnOffset, pSiS->scrnOffset); }
static void SIS6326SetPortDefaults(ScrnInfoPtr pScrn, SISPortPrivPtr pPriv) { SISPtr pSiS = SISPTR(pScrn); pPriv->colorKey = 0x000101fe; pPriv->videoStatus = 0; pPriv->brightness = pSiS->XvDefBri; /* 0; - see sis_opt.c */ pPriv->contrast = pSiS->XvDefCon; /* 4; */ pPriv->autopaintColorKey = TRUE; pPriv->disablegfx = pSiS->XvDefDisableGfx; }
/* Screen to screen copy */ static void SiSSetupForScreenToScreenCopy(ScrnInfoPtr pScrn, int xdir, int ydir, int rop, unsigned int planemask, int transparency_color) { SISPtr pSiS = SISPTR(pScrn); sisBLTSync; sisSETPITCH(pSiS->scrnOffset, pSiS->scrnOffset); sisSETROP(XAACopyROP[rop]); pSiS->Xdirection = xdir; pSiS->Ydirection = ydir; }
static void SiSSubsequentSolidTwoPointLine(ScrnInfoPtr pScrn, int x1, int y1, int x2, int y2, int flags) { SISPtr pSiS = SISPTR(pScrn); int op ; int major, minor, err,K1,K2, tmp; op = sisCMDLINE | sisSRCFG; if ((flags & OMIT_LAST)) op |= sisLASTPIX; if (pSiS->ClipEnabled) op |= sisCLIPINTRN | sisCLIPENABL; if ((major = x2 - x1) <= 0) { major = -major; } else op |= sisXINCREASE; if ((minor = y2 - y1) <= 0) { minor = -minor; } else op |= sisYINCREASE; if (minor >= major) { tmp = minor; minor = major; major = tmp; } else op |= sisXMAJOR; K1 = (minor - major)<<1; K2 = minor<<1; err = (minor<<1) - major; sisBLTSync; sisSETXStart(x1); sisSETYStart(y1); sisSETLineSteps((short)K1,(short)K2); sisSETLineErrorTerm((short)err); sisSETLineMajorCount((short)major); sisSETCMD(op); }
static void SiSSubsequentScreenToScreenCopy(ScrnInfoPtr pScrn, int x1, int y1, int x2, int y2, int w, int h) { SISPtr pSiS = SISPTR(pScrn); int srcaddr, destaddr, op; op = sisCMDBLT | sisSRCVIDEO; if(pSiS->Ydirection == -1) { op |= sisBOTTOM2TOP; srcaddr = (y1 + h - 1) * pSiS->CurrentLayout.displayWidth; destaddr = (y2 + h - 1) * pSiS->CurrentLayout.displayWidth; } else { op |= sisTOP2BOTTOM; srcaddr = y1 * pSiS->CurrentLayout.displayWidth; destaddr = y2 * pSiS->CurrentLayout.displayWidth; } if(pSiS->Xdirection == -1) { op |= sisRIGHT2LEFT; srcaddr += x1 + w - 1; destaddr += x2 + w - 1; } else { op |= sisLEFT2RIGHT; srcaddr += x1; destaddr += x2; } if(pSiS->ClipEnabled) op |= sisCLIPINTRN | sisCLIPENABL; srcaddr *= (pSiS->CurrentLayout.bitsPerPixel/8); destaddr *= (pSiS->CurrentLayout.bitsPerPixel/8); if(((pSiS->CurrentLayout.bitsPerPixel / 8) > 1) && (pSiS->Xdirection == -1)) { srcaddr += (pSiS->CurrentLayout.bitsPerPixel/8)-1; destaddr += (pSiS->CurrentLayout.bitsPerPixel/8)-1; } sisBLTSync; sisSETSRCADDR(srcaddr); sisSETDSTADDR(destaddr); sisSETHEIGHTWIDTH(h-1, w * (pSiS->CurrentLayout.bitsPerPixel/8)-1); sisSETCMD(op); }
static void SiSSubsequentMono8x8PatternFillRect(ScrnInfoPtr pScrn, int patternx, int patterny, int x, int y, int w, int h) { SISPtr pSiS = SISPTR(pScrn); int dstaddr; register unsigned char *patternRegPtr; register unsigned char *srcPatternRegPtr; register unsigned int *patternRegPtrL; int i, k; unsigned short tmp; int shift; int op = sisCMDCOLEXP | sisTOP2BOTTOM | sisLEFT2RIGHT | sisPATFG | sisSRCBG; if (pSiS->ClipEnabled) op |= sisCLIPINTRN | sisCLIPENABL; dstaddr = ( y * pSiS->CurrentLayout.displayWidth + x ) * pSiS->CurrentLayout.bitsPerPixel / 8; sisBLTSync; patternRegPtr = sisSETPATREG(); srcPatternRegPtr = (unsigned char *)pSiS->sisPatternReg ; shift = 8 - patternx ; for ( i = 0, k = patterny ; i < 8 ; i++, k++ ) { tmp = srcPatternRegPtr[k]<<8 | srcPatternRegPtr[k] ; tmp >>= shift ; patternRegPtr[i] = tmp & 0xff; } patternRegPtrL = (unsigned int *)sisSETPATREG(); for ( i = 2 ; i < 16 /* sisPatternHeight */; ) { patternRegPtrL[i++] = patternRegPtrL[0]; patternRegPtrL[i++] = patternRegPtrL[1]; } sisSETDSTADDR(dstaddr); sisSETHEIGHTWIDTH(h-1, w*(pSiS->CurrentLayout.bitsPerPixel/8)-1); sisSETCMD(op); }
static void SiSSubsequentFillRectSolid(ScrnInfoPtr pScrn, int x, int y, int w, int h) { SISPtr pSiS = SISPTR(pScrn); int destaddr, op; destaddr = y * pSiS->CurrentLayout.displayWidth + x; op = sisCMDBLT | sisSRCBG | sisTOP2BOTTOM | sisLEFT2RIGHT; if(pSiS->ClipEnabled) op |= sisCLIPINTRN | sisCLIPENABL; destaddr *= (pSiS->CurrentLayout.bitsPerPixel / 8); sisBLTSync; sisSETHEIGHTWIDTH(h-1, w * (pSiS->CurrentLayout.bitsPerPixel/8)-1); sisSETDSTADDR(destaddr); sisSETCMD(op); }
static void SiSSubsequentSolidHorVertLine(ScrnInfoPtr pScrn, int x, int y, int len, int dir) { SISPtr pSiS = SISPTR(pScrn); int destaddr, op; destaddr = y * pSiS->CurrentLayout.displayWidth + x; op = sisCMDBLT | sisSRCFG | sisTOP2BOTTOM | sisLEFT2RIGHT; if (pSiS->ClipEnabled) op |= sisCLIPINTRN | sisCLIPENABL; destaddr *= (pSiS->CurrentLayout.bitsPerPixel / 8); sisBLTSync; sisSETPITCH(pSiS->scrnOffset, pSiS->scrnOffset); if(dir == DEGREES_0) { sisSETHEIGHTWIDTH(0, len * (pSiS->CurrentLayout.bitsPerPixel >> 3) - 1); } else {
Bool SISDGAInit(ScreenPtr pScreen) { ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; SISPtr pSiS = SISPTR(pScrn); int num = 0; pSiS->DGAModes = SISDGAMakeModes(pScrn, &num, FALSE); pSiS->numDGAModes = num; if(num) { if((pSiS->VGAEngine == SIS_300_VGA) || (pSiS->VGAEngine == SIS_315_VGA) || (pSiS->VGAEngine == SIS_530_VGA)) { return DGAInit(pScreen, &SISDGAFuncs3xx, pSiS->DGAModes, num); } else { return DGAInit(pScreen, &SISDGAFuncs, pSiS->DGAModes, num); } } else { xf86DrvMsg(pScrn->scrnIndex, X_WARNING, "No DGA-suitable modes found, disabling DGA\n"); return TRUE; } }
static DGAModePtr SISSetupDGAMode( ScrnInfoPtr pScrn, DGAModePtr modes, int *num, int bitsPerPixel, int depth, Bool pixmap, int secondPitch, ULong red, ULong green, ULong blue, short visualClass, Bool quiet ){ SISPtr pSiS = SISPTR(pScrn); DGAModePtr newmodes = NULL, currentMode; DisplayModePtr pMode, firstMode; int otherPitch, Bpp = bitsPerPixel >> 3; Bool oneMore; pMode = firstMode = pScrn->modes; while(pMode) { #ifdef SISMERGED if(pSiS->MergedFB) { Bool nogood = FALSE; /* Filter out all meta modes that would require driver-side panning */ switch(((SiSMergedDisplayModePtr)pMode->Private)->CRT2Position) { case sisClone: if( (((SiSMergedDisplayModePtr)pMode->Private)->CRT1->HDisplay != ((SiSMergedDisplayModePtr)pMode->Private)->CRT2->HDisplay) || (((SiSMergedDisplayModePtr)pMode->Private)->CRT1->VDisplay != ((SiSMergedDisplayModePtr)pMode->Private)->CRT2->VDisplay) || (((SiSMergedDisplayModePtr)pMode->Private)->CRT1->HDisplay != pMode->HDisplay) || (((SiSMergedDisplayModePtr)pMode->Private)->CRT1->VDisplay != pMode->VDisplay) ) nogood = TRUE; break; case sisRightOf: case sisLeftOf: if( (((SiSMergedDisplayModePtr)pMode->Private)->CRT1->VDisplay != ((SiSMergedDisplayModePtr)pMode->Private)->CRT2->VDisplay) || (((SiSMergedDisplayModePtr)pMode->Private)->CRT1->VDisplay != pMode->VDisplay) ) nogood = TRUE; break; default: if( (((SiSMergedDisplayModePtr)pMode->Private)->CRT1->HDisplay != ((SiSMergedDisplayModePtr)pMode->Private)->CRT2->HDisplay) || (((SiSMergedDisplayModePtr)pMode->Private)->CRT1->HDisplay != pMode->HDisplay) ) nogood = TRUE; } if(nogood) { if((depth == 16) && !quiet) { /* Print this only the first time */ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "DGA: MetaMode %dx%d not suitable for DGA\n", pMode->HDisplay, pMode->VDisplay); } goto mode_nogood; } } #endif otherPitch = secondPitch ? secondPitch : pMode->HDisplay; if(pMode->HDisplay != otherPitch) { newmodes = realloc(modes, (*num + 2) * sizeof(DGAModeRec)); oneMore = TRUE; } else { newmodes = realloc(modes, (*num + 1) * sizeof(DGAModeRec)); oneMore = FALSE; } if(!newmodes) { free(modes); return NULL; } modes = newmodes; SECOND_PASS: currentMode = modes + *num; (*num)++; currentMode->mode = pMode; currentMode->flags = DGA_CONCURRENT_ACCESS; if(pixmap) currentMode->flags |= DGA_PIXMAP_AVAILABLE; if(!pSiS->NoAccel) { currentMode->flags |= DGA_FILL_RECT | DGA_BLIT_RECT; if((pSiS->VGAEngine == SIS_300_VGA) || (pSiS->VGAEngine == SIS_315_VGA) || (pSiS->VGAEngine == SIS_530_VGA)) { currentMode->flags |= DGA_BLIT_RECT_TRANS; } } if(pMode->Flags & V_DBLSCAN) currentMode->flags |= DGA_DOUBLESCAN; if(pMode->Flags & V_INTERLACE) currentMode->flags |= DGA_INTERLACED; currentMode->byteOrder = pScrn->imageByteOrder; currentMode->depth = depth; currentMode->bitsPerPixel = bitsPerPixel; currentMode->red_mask = red; currentMode->green_mask = green; currentMode->blue_mask = blue; currentMode->visualClass = visualClass; currentMode->viewportWidth = pMode->HDisplay; currentMode->viewportHeight = pMode->VDisplay; currentMode->xViewportStep = 1; currentMode->yViewportStep = 1; currentMode->viewportFlags = DGA_FLIP_RETRACE; currentMode->offset = 0; currentMode->address = pSiS->FbBase; if(oneMore) { /* first one is narrow width */ currentMode->bytesPerScanline = (((pMode->HDisplay * Bpp) + 3) & ~3L); currentMode->imageWidth = pMode->HDisplay; currentMode->imageHeight = pMode->VDisplay; currentMode->pixmapWidth = currentMode->imageWidth; currentMode->pixmapHeight = currentMode->imageHeight; currentMode->maxViewportX = currentMode->imageWidth - currentMode->viewportWidth; /* this might need to get clamped to some maximum */ currentMode->maxViewportY = (currentMode->imageHeight - currentMode->viewportHeight); oneMore = FALSE; goto SECOND_PASS; } else { currentMode->bytesPerScanline = ((otherPitch * Bpp) + 3) & ~3L; currentMode->imageWidth = otherPitch; currentMode->imageHeight = pMode->VDisplay; currentMode->pixmapWidth = currentMode->imageWidth; currentMode->pixmapHeight = currentMode->imageHeight; currentMode->maxViewportX = (currentMode->imageWidth - currentMode->viewportWidth); /* this might need to get clamped to some maximum */ currentMode->maxViewportY = (currentMode->imageHeight - currentMode->viewportHeight); } #ifdef SISMERGED mode_nogood: #endif pMode = pMode->next; if(pMode == firstMode) break; } return modes; }
static XF86VideoAdaptorPtr SIS6326SetupImageVideo(ScreenPtr pScreen) { ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; SISPtr pSiS = SISPTR(pScrn); XF86VideoAdaptorPtr adapt; SISPortPrivPtr pPriv; #if XF86_VERSION_CURRENT < XF86_VERSION_NUMERIC(4,1,99,1,0) XAAInfoRecPtr pXAA = pSiS->AccelInfoPtr; if(!pXAA || !pXAA->FillSolidRects) return NULL; #endif if(!(adapt = calloc(1, sizeof(XF86VideoAdaptorRec) + sizeof(SISPortPrivRec) + sizeof(DevUnion)))) return NULL; adapt->type = XvWindowMask | XvInputMask | XvImageMask; adapt->flags = VIDEO_OVERLAID_IMAGES | VIDEO_CLIP_TO_VIEWPORT; adapt->name = "SIS 5597/5598/6326/530/620 Video Overlay"; adapt->nEncodings = 1; if(pSiS->oldChipset < OC_SIS6326) { adapt->pEncodings = &DummyEncoding5597; } else { adapt->pEncodings = &DummyEncoding; } adapt->nFormats = NUM_FORMATS; adapt->pFormats = SIS6326Formats; adapt->nPorts = 1; adapt->pPortPrivates = (DevUnion*)(&adapt[1]); pPriv = (SISPortPrivPtr)(&adapt->pPortPrivates[1]); adapt->pPortPrivates[0].ptr = (pointer)(pPriv); adapt->pAttributes = SIS6326Attributes; adapt->nAttributes = NUM_ATTRIBUTES; if(pSiS->NoYV12 == 1) { adapt->nImages = NUM_IMAGES_NOYV12; adapt->pImages = SIS6326ImagesNoYV12; } else { adapt->nImages = NUM_IMAGES; adapt->pImages = SIS6326Images; } adapt->PutVideo = NULL; adapt->PutStill = NULL; adapt->GetVideo = NULL; adapt->GetStill = NULL; adapt->StopVideo = SIS6326StopVideo; adapt->SetPortAttribute = SIS6326SetPortAttribute; adapt->GetPortAttribute = SIS6326GetPortAttribute; adapt->QueryBestSize = SIS6326QueryBestSize; adapt->PutImage = SIS6326PutImage; adapt->QueryImageAttributes = SIS6326QueryImageAttributes; pPriv->videoStatus = 0; pPriv->currentBuf = 0; pPriv->handle = NULL; pPriv->grabbedByV4L= FALSE; SIS6326SetPortDefaults(pScrn, pPriv); /* gotta uninit this someplace */ #if defined(REGION_NULL) REGION_NULL(pScreen, &pPriv->clip); #else REGION_INIT(pScreen, &pPriv->clip, NullBox, 0); #endif pSiS->adaptor = adapt; xvBrightness = MAKE_ATOM("XV_BRIGHTNESS"); xvContrast = MAKE_ATOM("XV_CONTRAST"); xvColorKey = MAKE_ATOM("XV_COLORKEY"); xvAutopaintColorKey = MAKE_ATOM("XV_AUTOPAINT_COLORKEY"); xvSetDefaults = MAKE_ATOM("XV_SET_DEFAULTS"); xvDisableGfx = MAKE_ATOM("XV_DISABLE_GRAPHICS"); SIS6326ResetVideo(pScrn); pSiS->ResetXv = SIS6326ResetVideo; return adapt; }
static void SiSDisableClipping (ScrnInfoPtr pScrn) { SISPtr pSiS = SISPTR(pScrn); pSiS->ClipEnabled = FALSE; }
SIS_OpenFramebuffer( ScrnInfoPtr pScrn, char **name, #ifndef NEW_DGAOPENFRAMEBUFFER UChar **mem, int *size, int *offset, int *flags #else unsigned int *mem, unsigned int *size, unsigned int *offset, unsigned int *flags #endif ){ SISPtr pSiS = SISPTR(pScrn); *name = NULL; /* no special device */ #ifndef NEW_DGAOPENFRAMEBUFFER *mem = (UChar *)pSiS->FbAddress; #else *mem = pSiS->FbAddress; #endif *size = pSiS->maxxfbmem; *offset = 0; #ifndef NEW_DGAOPENFRAMEBUFFER *flags = DGA_NEED_ROOT; #else *flags = 0; #endif
Bool SiSAccelInit(ScreenPtr pScreen) { XAAInfoRecPtr infoPtr; ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; SISPtr pSiS = SISPTR(pScrn); BoxRec AvailFBArea; int topFB, i; int reservedFbSize; int UsableFbSize; unsigned char *AvailBufBase; pSiS->AccelInfoPtr = infoPtr = XAACreateInfoRec(); if (!infoPtr) return FALSE; infoPtr->Flags = LINEAR_FRAMEBUFFER | OFFSCREEN_PIXMAPS | PIXMAP_CACHE; /* Sync */ infoPtr->Sync = SiSSync; /* Screen To Screen copy */ infoPtr->SetupForScreenToScreenCopy = SiSSetupForScreenToScreenCopy; infoPtr->SubsequentScreenToScreenCopy = SiSSubsequentScreenToScreenCopy; infoPtr->ScreenToScreenCopyFlags = NO_TRANSPARENCY | NO_PLANEMASK; /* Solid fill */ infoPtr->SetupForSolidFill = SiSSetupForFillRectSolid; infoPtr->SubsequentSolidFillRect = SiSSubsequentFillRectSolid; infoPtr->SolidFillFlags = NO_PLANEMASK; /* On 5597/5598 and 6326, clipping and lines only work for 1024, 2048, 4096 logical width */ if(pSiS->ValidWidth) { /* Clipping */ infoPtr->SetClippingRectangle = SiSSetClippingRectangle; infoPtr->DisableClipping = SiSDisableClipping; infoPtr->ClippingFlags = HARDWARE_CLIP_SOLID_LINE | HARDWARE_CLIP_SCREEN_TO_SCREEN_COPY | HARDWARE_CLIP_MONO_8x8_FILL | HARDWARE_CLIP_SOLID_FILL ; /* Solid Lines */ infoPtr->SetupForSolidLine = SiSSetupForSolidLine; infoPtr->SubsequentSolidTwoPointLine = SiSSubsequentSolidTwoPointLine; infoPtr->SubsequentSolidHorVertLine = SiSSubsequentSolidHorVertLine; infoPtr->SolidLineFlags = NO_PLANEMASK; } if(pScrn->bitsPerPixel != 24) { /* 8x8 mono pattern */ infoPtr->SetupForMono8x8PatternFill = SiSSetupForMono8x8PatternFill; infoPtr->SubsequentMono8x8PatternFillRect = SiSSubsequentMono8x8PatternFillRect; infoPtr->Mono8x8PatternFillFlags = NO_PLANEMASK | HARDWARE_PATTERN_PROGRAMMED_BITS | HARDWARE_PATTERN_PROGRAMMED_ORIGIN | BIT_ORDER_IN_BYTE_MSBFIRST; } #ifdef CTSCE if(pScrn->bitsPerPixel != 24) { /* TW: per-scanline color expansion (using indirect method) */ pSiS->ColorExpandBufferNumber = 4; pSiS->ColorExpandBufferCountMask = 0x03; pSiS->PerColorExpandBufferSize = ((pScrn->virtualX + 31) / 32) * 4; infoPtr->NumScanlineColorExpandBuffers = pSiS->ColorExpandBufferNumber; infoPtr->ScanlineColorExpandBuffers = (unsigned char **)&pSiS->ColorExpandBufferAddr[0]; infoPtr->SetupForScanlineCPUToScreenColorExpandFill = SiSSetupForScanlineCPUToScreenColorExpandFill; infoPtr->SubsequentScanlineCPUToScreenColorExpandFill = SiSSubsequentScanlineCPUToScreenColorExpandFill; infoPtr->SubsequentColorExpandScanline = SiSSubsequentColorExpandScanline; infoPtr->ScanlineCPUToScreenColorExpandFillFlags = NO_PLANEMASK | CPU_TRANSFER_PAD_DWORD | SCANLINE_PAD_DWORD | BIT_ORDER_IN_BYTE_MSBFIRST | LEFT_EDGE_CLIPPING; } else { pSiS->ColorExpandBufferNumber = 0; } #else pSiS->ColorExpandBufferNumber = 0; #endif topFB = pSiS->maxxfbmem; reservedFbSize = pSiS->ColorExpandBufferNumber * pSiS->PerColorExpandBufferSize; UsableFbSize = topFB - reservedFbSize; /* Layout: (Sizes do not reflect correct proportions) * |--------------++++++++++++++++++++| ====================~~~~~~~~~~~~| * UsableFbSize ColorExpandBuffers | TurboQueue HWCursor * topFB */ if(pSiS->ColorExpandBufferNumber) { AvailBufBase = pSiS->FbBase + UsableFbSize; for (i = 0; i < pSiS->ColorExpandBufferNumber; i++) { pSiS->ColorExpandBufferAddr[i] = AvailBufBase + i * pSiS->PerColorExpandBufferSize; pSiS->ColorExpandBufferScreenOffset[i] = UsableFbSize + i * pSiS->PerColorExpandBufferSize; } } AvailFBArea.x1 = 0; AvailFBArea.y1 = 0; AvailFBArea.x2 = pScrn->displayWidth; AvailFBArea.y2 = UsableFbSize / (pScrn->displayWidth * pScrn->bitsPerPixel / 8) - 1; if (AvailFBArea.y2 < 0) AvailFBArea.y2 = 32767; if(AvailFBArea.y2 < pScrn->currentMode->VDisplay) { xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Not enough video RAM for accelerator. At least " "%dKB needed, %dKB available\n", ((((pScrn->displayWidth * pScrn->bitsPerPixel/8) /* TW: +8 for make it sure */ * pScrn->currentMode->VDisplay) + reservedFbSize) / 1024) + 8, pSiS->maxxfbmem/1024); pSiS->NoAccel = TRUE; pSiS->NoXvideo = TRUE; XAADestroyInfoRec(pSiS->AccelInfoPtr); pSiS->AccelInfoPtr = NULL; return FALSE; } xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Frame Buffer From (%d,%d) To (%d,%d)\n", AvailFBArea.x1, AvailFBArea.y1, AvailFBArea.x2, AvailFBArea.y2); xf86InitFBManager(pScreen, &AvailFBArea); return(XAAInit(pScreen, infoPtr)); }
static void SIS6326ResetVideo(ScrnInfoPtr pScrn) { SISPtr pSiS = SISPTR(pScrn); /* Unlock registers */ #ifdef UNLOCK_ALWAYS sisSaveUnlockExtRegisterLock(pSiS, NULL, NULL); #endif if(getvideoreg(pSiS, Index_VI6326_Passwd) != 0xa1) { setvideoreg(pSiS, Index_VI6326_Passwd, 0x86); if(getvideoreg(pSiS, Index_VI6326_Passwd) != 0xa1) xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Xv: Video password could not unlock video registers\n"); } /* Initialize the overlay ----------------------------------- */ switch(pSiS->Chipset) { case PCI_CHIP_SIS5597: /* Disable overlay (D[1]) & capture (D[0]) */ setvideoregmask(pSiS, Index_VI6326_Control_Misc0, 0x00, 0x03); /* What do these do? (Datasheet names these bits "reserved") */ setvideoregmask(pSiS, Index_VI6326_Control_Misc0, 0x00, 0x18); setvideoregmask(pSiS, Index_VI6326_Control_Misc0, 0x00, 0x0c); /* Select YUV format (D[6]) and "gfx + video" mode (D[4]), odd polarity? (D[7]) */ setvideoregmask(pSiS, Index_VI6326_Control_Misc0, 0x40, 0xD0); /* No interrupt, no filter, disable dithering */ setvideoregmask(pSiS, Index_VI6326_Control_Misc1, 0x00, 0x7A); /* Disable Brooktree support (D[6]) and system memory framebuffer (D[7]) */ setvideoregmask(pSiS, Index_VI6326_Control_Misc3, 0x00, 0xC0); /* Disable video decimation (has a really strange effect if enabled) */ setvideoregmask(pSiS, Index_VI6326_Control_Misc6, 0x00, 0x80); break; case PCI_CHIP_SIS6326: /* Disable overlay (D[1]) & capture (D[0]) */ setvideoregmask(pSiS, Index_VI6326_Control_Misc0, 0x00, 0x03); /* What do these do? (Datasheet names these bits "reserved") */ setvideoregmask(pSiS, Index_VI6326_Control_Misc0, 0x00, 0x18); setvideoregmask(pSiS, Index_VI6326_Control_Misc0, 0x00, 0x0c); /* Select YUV format (D[6]) and "gfx + video" mode (D[4]), odd polarity? (D[7]) */ setvideoregmask(pSiS, Index_VI6326_Control_Misc0, 0x40, 0xD0); /* No interrupt, no filter, disable dithering */ setvideoregmask(pSiS, Index_VI6326_Control_Misc1, 0x00, 0x7A); /* Disable VMI (D[4:3]), Brooktree support (D[6]) and system memory framebuffer (D[7]) */ setvideoregmask(pSiS, Index_VI6326_Control_Misc3, 0x00, 0xF8); /* Disable video decimation */ setvideoregmask(pSiS, Index_VI6326_Control_Misc6, 0x00, 0x80); break; case PCI_CHIP_SIS530: setvideoregmask(pSiS, Index_VI6326_Control_Misc4, 0x40, 0x40); /* Disable overlay (D[1]) */ setvideoregmask(pSiS, Index_VI6326_Control_Misc0, 0x00, 0x02); /* What do D[3:2] do? (Datasheet names these bits "reserved") */ setvideoregmask(pSiS, Index_VI6326_Control_Misc0, 0x00, 0x18); setvideoregmask(pSiS, Index_VI6326_Control_Misc0, 0x00, 0x0c); /* Select YUV format (D[6]) and "gfx + video" mode (D[4]) */ setvideoregmask(pSiS, Index_VI6326_Control_Misc0, 0x40, 0x50); break; default: xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Internal error: SiS6326ResetVideo() called with invalid chipset (%x)\n", pSiS->Chipset); return; } /* Clear format selection */ setvideoregmask(pSiS, Index_VI6326_Control_Misc1, 0x00, 0x04); if(pSiS->oldChipset >= OC_SIS5597) { setvideoregmask(pSiS, Index_VI6326_Control_Misc4, 0x00, 0x05); } /* Select RGB Chromakey format (D[2]=0), CCIR 601 UV data format (D[1]=0) */ /* D[1]: 1 = 2's complement, 0 = CCIR 601 format */ setvideoregmask(pSiS, Index_VI6326_Control_Misc3, 0x00, 0x06); /* Reset contrast control */ setvideoregmask(pSiS, Index_VI6326_Contrast_Enh_Ctrl, 0x04, 0x1F); /* Set threshold */ if(pSiS->oldChipset < OC_SIS6326) { CARD8 temp; inSISIDXREG(SISSR, 0x33, temp); /* Synchronous DRAM Timing? */ if(temp & 0x01) temp = 0x50; else temp = 0; setvideoreg(pSiS, Index_VI6326_Play_Threshold_Low, temp); setvideoreg(pSiS, Index_VI6326_Play_Threshold_High, temp); } else { CARD8 temp; setvideoreg(pSiS, Index_VI6326_Play_Threshold_Low, 0x00); setvideoreg(pSiS, Index_VI6326_Play_Threshold_High, 0x00); inSISIDXREG(SISSR, 0x33, temp); /* Are we using SGRAM Timing? */ if(temp & 0x01) temp = 0x10; else temp = 0; setvideoregmask(pSiS, Index_VI6326_Control_Misc4, temp, 0x10); } /* set default properties for overlay ------------------------------- */ setvideoregmask(pSiS, Index_VI6326_Contrast_Enh_Ctrl, 0x04, 0x07); setvideoreg(pSiS, Index_VI6326_Brightness, 0x20); if(pSiS->oldChipset < OC_SIS6205A || pSiS->oldChipset > OC_SIS82204) { setvideoregmask(pSiS, Index_VI6326_AlphaGraph, 0x00, 0xF8); setvideoregmask(pSiS, Index_VI6326_AlphaVideo, 0xF8, 0xF8); } else { setvideoregmask(pSiS, Index_VI6326_AlphaGraph, 0x00, 0xE1); setvideoregmask(pSiS, Index_VI6326_AlphaVideo, 0xE1, 0xE1); } }