📄 i810_accel.c
字号:
/**************************************************************************Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.All Rights Reserved.Permission is hereby granted, free of charge, to any person obtaining acopy of this software and associated documentation files (the"Software"), to deal in the Software without restriction, includingwithout limitation the rights to use, copy, modify, merge, publish,distribute, sub license, and/or sell copies of the Software, and topermit persons to whom the Software is furnished to do so, subject tothe following conditions:The above copyright notice and this permission notice (including thenext paragraph) shall be included in all copies or substantial portionsof the Software.THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESSOR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OFMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FORANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THESOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.**************************************************************************//* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/i810/i810_accel.c,v 1.21 2004/01/02 20:22:17 dawes Exp $ *//* * Reformatted with GNU indent (2.2.8), using the following options: * * -bad -bap -c41 -cd0 -ncdb -ci6 -cli0 -cp0 -ncs -d0 -di3 -i3 -ip3 -l78 * -lp -npcs -psl -sob -ss -br -ce -sc -hnl * * This provides a good match with the original i810 code and preferred * XFree86 formatting conventions. * * When editing this driver, please follow the existing formatting, and edit * with <TAB> characters expanded at 8-column intervals. *//* * Authors: * Keith Whitwell <keith@tungstengraphics.com> * */#include "xf86_ansic.h"#include "xf86.h"#include "xaarop.h"#include "i810.h"static void I810SetupForMono8x8PatternFill(ScrnInfoPtr pScrn, int pattx, int patty, int fg, int bg, int rop, unsigned int planemask);static void I810SubsequentMono8x8PatternFillRect(ScrnInfoPtr pScrn, int pattx, int patty, int x, int y, int w, int h);static void I810SetupForScanlineCPUToScreenColorExpandFill(ScrnInfoPtr pScrn, int fg, int bg, int rop, unsigned int mask);static void I810SubsequentScanlineCPUToScreenColorExpandFill(ScrnInfoPtr pScrn, int x, int y, int w, int h, int skipleft);static void I810SubsequentColorExpandScanline(ScrnInfoPtr pScrn, int bufno);/* The following function sets up the supported acceleration. Call it * from the FbInit() function in the SVGA driver, or before ScreenInit * in a monolithic server. */BoolI810AccelInit(ScreenPtr pScreen){ XAAInfoRecPtr infoPtr; ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; I810Ptr pI810 = I810PTR(pScrn); if (I810_DEBUG & DEBUG_VERBOSE_ACCEL) ErrorF("I810AccelInit\n"); pI810->AccelInfoRec = infoPtr = XAACreateInfoRec(); if (!infoPtr) return FALSE; pI810->bufferOffset = 0; infoPtr->Flags = LINEAR_FRAMEBUFFER | OFFSCREEN_PIXMAPS; infoPtr->Flags |= PIXMAP_CACHE; /* Sync */ infoPtr->Sync = I810Sync; /* Solid filled rectangles */ { infoPtr->SolidFillFlags = NO_PLANEMASK; infoPtr->SetupForSolidFill = I810SetupForSolidFill; infoPtr->SubsequentSolidFillRect = I810SubsequentSolidFillRect; } /* Screen to screen copy * - the transparency op hangs the blit engine, disable for now. */ { infoPtr->ScreenToScreenCopyFlags = (0 | NO_PLANEMASK | NO_TRANSPARENCY | 0); infoPtr->SetupForScreenToScreenCopy = I810SetupForScreenToScreenCopy; infoPtr->SubsequentScreenToScreenCopy = I810SubsequentScreenToScreenCopy; } /* 8x8 pattern fills */ { infoPtr->SetupForMono8x8PatternFill = I810SetupForMono8x8PatternFill; infoPtr->SubsequentMono8x8PatternFillRect = I810SubsequentMono8x8PatternFillRect; infoPtr->Mono8x8PatternFillFlags = (HARDWARE_PATTERN_PROGRAMMED_BITS | HARDWARE_PATTERN_SCREEN_ORIGIN | BIT_ORDER_IN_BYTE_MSBFIRST | NO_PLANEMASK | 0); } /* 8x8 color fills - not considered useful for XAA. */ /* Scanline color expansion - Use the same scheme as the 3.3 driver. * */ if (pI810->Scratch.Size != 0) { int i; int width = ((pScrn->displayWidth + 31) & ~31) / 8; int nr_buffers = pI810->Scratch.Size / width; unsigned char *ptr = pI810->FbBase + pI810->Scratch.Start; pI810->NumScanlineColorExpandBuffers = nr_buffers; pI810->ScanlineColorExpandBuffers = (unsigned char **) xnfcalloc(nr_buffers, sizeof(unsigned char *)); for (i = 0; i < nr_buffers; i++, ptr += width) pI810->ScanlineColorExpandBuffers[i] = ptr; infoPtr->ScanlineCPUToScreenColorExpandFillFlags = (NO_PLANEMASK | ROP_NEEDS_SOURCE | BIT_ORDER_IN_BYTE_MSBFIRST | 0); infoPtr->ScanlineColorExpandBuffers = (unsigned char **) xnfcalloc(1, sizeof(unsigned char *)); infoPtr->NumScanlineColorExpandBuffers = 1; infoPtr->ScanlineColorExpandBuffers[0] = pI810->ScanlineColorExpandBuffers[0]; pI810->nextColorExpandBuf = 0; infoPtr->SetupForScanlineCPUToScreenColorExpandFill = I810SetupForScanlineCPUToScreenColorExpandFill; infoPtr->SubsequentScanlineCPUToScreenColorExpandFill = I810SubsequentScanlineCPUToScreenColorExpandFill; infoPtr->SubsequentColorExpandScanline = I810SubsequentColorExpandScanline; } /* Possible todo: Image writes w/ non-GXCOPY rop. */ I810SelectBuffer(pScrn, I810_SELECT_FRONT); return XAAInit(pScreen, infoPtr);}intI810WaitLpRing(ScrnInfoPtr pScrn, int n, int timeout_millis){ I810Ptr pI810 = I810PTR(pScrn); I810RingBuffer *ring = pI810->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 & DEBUG_VERBOSE_ACCEL) { ErrorF("I810WaitLpRing %d\n", n); first = GetTimeInMillis(); } while (ring->space < n) { 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 & DEBUG_VERBOSE_ACCEL) if (now > start) ErrorF("space: %d wanted %d\n", ring->space, n); start = now; last_head = ring->head; } else if (now - start > timeout_millis) { ErrorF("Error in I810WaitLpRing(), now is %d, start is %d\n", now, start); I810PrintErrorState(pScrn); ErrorF("space: %d wanted %d\n", ring->space, n);#ifdef XF86DRI if (pI810->directRenderingEnabled) { DRIUnlock(screenInfo.screens[pScrn->scrnIndex]); DRICloseScreen(screenInfo.screens[pScrn->scrnIndex]); }#endif pI810->AccelInfoRec = NULL; /* Stops recursive behavior */ FatalError("lockup\n"); } DELAY(10000); } if (I810_DEBUG & DEBUG_VERBOSE_ACCEL) { now = GetTimeInMillis(); if (now - first) { ErrorF("Elapsed %d ms\n", now - first); ErrorF("space: %d wanted %d\n", ring->space, n); } } return iters;}voidI810Sync(ScrnInfoPtr pScrn){ I810Ptr pI810 = I810PTR(pScrn); if (I810_DEBUG & (DEBUG_VERBOSE_ACCEL | DEBUG_VERBOSE_SYNC)) ErrorF("I810Sync\n");#ifdef XF86DRI /* VT switching tries to do this. */ if (!pI810->LockHeld && pI810->directRenderingEnabled) { return; }#endif /* 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(pScrn, pI810->LpRing->mem.Size - 8, 0); pI810->LpRing->space = pI810->LpRing->mem.Size - 8; pI810->nextColorExpandBuf = 0;}voidI810SetupForSolidFill(ScrnInfoPtr pScrn, int color, int rop, unsigned int planemask){ I810Ptr pI810 = I810PTR(pScrn); if (I810_DEBUG & DEBUG_VERBOSE_ACCEL) ErrorF("I810SetupForFillRectSolid color: %x rop: %x mask: %x\n", color, rop, planemask); /* Color blit, p166 */ pI810->BR[13] = (BR13_SOLID_PATTERN | (XAAGetPatternROP(rop) << 16) | (pScrn->displayWidth * pI810->cpp)); pI810->BR[16] = color;}voidI810SubsequentSolidFillRect(ScrnInfoPtr pScrn, int x, int y, int w, int h){ I810Ptr pI810 = I810PTR(pScrn); 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(pI810->BR[13]); OUT_RING((h << 16) | (w * pI810->cpp));
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -