⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 r128_accel.c

📁 x.org上有关ati系列显卡最新驱动
💻 C
📖 第 1 页 / 共 5 页
字号:
    BEGIN_RING( 12 );    OUT_RING_REG(R128_DP_GUI_MASTER_CNTL, (info->dp_gui_master_cntl				     | (bg == -1					? R128_GMC_BRUSH_8X8_MONO_FG_LA					: R128_GMC_BRUSH_8X8_MONO_FG_BG)				     | R128_ROP[rop].pattern				     | R128_GMC_BYTE_LSB_TO_MSB));    OUT_RING_REG(R128_DP_WRITE_MASK,      planemask);    OUT_RING_REG(R128_DP_BRUSH_FRGD_CLR,  fg);    OUT_RING_REG(R128_DP_BRUSH_BKGD_CLR,  bg);    OUT_RING_REG(R128_BRUSH_DATA0,        patternx);    OUT_RING_REG(R128_BRUSH_DATA1,        patterny);    ADVANCE_RING();}static void R128CCESubsequentMono8x8PatternFillRect(ScrnInfoPtr pScrn,						 int patternx, int patterny,						 int x, int y, int w, int h){    R128InfoPtr   info      = R128PTR(pScrn);    RING_LOCALS;    R128CCE_REFRESH( pScrn, info );    BEGIN_RING( 6 );    OUT_RING_REG(R128_BRUSH_Y_X,        (patterny << 8) | patternx);    OUT_RING_REG(R128_DST_Y_X,          (y << 16) | x);    OUT_RING_REG(R128_DST_HEIGHT_WIDTH, (h << 16) | w);    ADVANCE_RING();}/* Get an indirect buffer for the CCE 2D acceleration commands. */drmBufPtr R128CCEGetBuffer( ScrnInfoPtr pScrn ){    R128InfoPtr   info = R128PTR(pScrn);    drmDMAReq dma;    drmBufPtr buf = NULL;    int indx = 0;    int size = 0;    int ret, i = 0;#if 0    /* FIXME: pScrn->pScreen has not been initialized when this is first       called from RADEONSelectBuffer via RADEONDRICPInit.  We could use       the screen index from pScrn, which is initialized, and then get       the screen from screenInfo.screens[index], but that is a hack. */    dma.context = DRIGetContext(pScrn->pScreen);#else    dma.context = 0x00000001; /* This is the X server's context */#endif    dma.send_count = 0;    dma.send_list = NULL;    dma.send_sizes = NULL;    dma.flags = 0;    dma.request_count = 1;    dma.request_size = R128_BUFFER_SIZE;    dma.request_list = &indx;    dma.request_sizes = &size;    dma.granted_count = 0;    while ( 1 ) {	do {	    ret = drmDMA( info->drmFD, &dma );	    if ( ret && ret != -EAGAIN ) {		xf86DrvMsg( pScrn->scrnIndex, X_ERROR,			    "%s: CCE GetBuffer %d\n", __FUNCTION__, ret );	    }	} while ( ( ret == -EAGAIN ) && ( i++ < R128_TIMEOUT ) );	if ( ret == 0 ) {	    buf = &info->buffers->list[indx];	    buf->used = 0;	    if ( R128_VERBOSE ) {		xf86DrvMsg( pScrn->scrnIndex, X_INFO,			    "   GetBuffer returning %d\n", buf->idx );	    }	    return buf;	}	xf86DrvMsg( pScrn->scrnIndex, X_ERROR,		    "GetBuffer timed out, resetting engine...\n");	R128EngineReset( pScrn );	/* R128EngineRestore( pScrn ); FIXME ??? */	/* Always restart the engine when doing CCE 2D acceleration */	R128CCE_RESET( pScrn, info );	R128CCE_START( pScrn, info );    }}/* Flush the indirect buffer to the kernel for submission to the card. */void R128CCEFlushIndirect( ScrnInfoPtr pScrn, int discard ){    R128InfoPtr   info = R128PTR(pScrn);    drmBufPtr buffer = info->indirectBuffer;    int start = info->indirectStart;    drmR128Indirect indirect;    if ( !buffer )	return;    if ( (start == buffer->used) && !discard )        return;    indirect.idx = buffer->idx;    indirect.start = start;    indirect.end = buffer->used;    indirect.discard = discard;    drmCommandWriteRead( info->drmFD, DRM_R128_INDIRECT,                         &indirect, sizeof(drmR128Indirect));    if ( discard )        buffer = info->indirectBuffer = R128CCEGetBuffer( pScrn );    /* pad to an even number of dwords */    if (buffer->used & 7)        buffer->used = ( buffer->used+7 ) & ~7;    info->indirectStart = buffer->used;}/* Flush and release the indirect buffer. */void R128CCEReleaseIndirect( ScrnInfoPtr pScrn ){    R128InfoPtr   info = R128PTR(pScrn);    drmBufPtr buffer = info->indirectBuffer;    int start = info->indirectStart;    drmR128Indirect indirect;    info->indirectBuffer = NULL;    info->indirectStart = 0;    if ( !buffer )	return;    indirect.idx = buffer->idx;    indirect.start = start;    indirect.end = buffer->used;    indirect.discard = 1;    drmCommandWriteRead( info->drmFD, DRM_R128_INDIRECT,                         &indirect, sizeof(drmR128Indirect));}/* This callback is required for multihead cards using XAA */staticvoid R128RestoreCCEAccelState(ScrnInfoPtr pScrn){    R128InfoPtr info        = R128PTR(pScrn);/*    unsigned char *R128MMIO = info->MMIO;  needed for OUTREG below */    /*xf86DrvMsg(pScrn->scrnIndex, X_INFO, "===>RestoreCP\n");*/    R128WaitForFifo(pScrn, 1);/* is this needed on r128    OUTREG( R128_DEFAULT_OFFSET, info->frontPitchOffset);*/    R128WaitForIdle(pScrn);    /* FIXME: May need to restore other things,        like BKGD_CLK FG_CLK...*/}static void R128CCEAccelInit(ScrnInfoPtr pScrn, XAAInfoRecPtr a){    R128InfoPtr info = R128PTR(pScrn);    a->Flags                            = (PIXMAP_CACHE					   | OFFSCREEN_PIXMAPS					   | LINEAR_FRAMEBUFFER);				/* Sync */    a->Sync                             = R128CCEWaitForIdle;    /* Solid Filled Rectangle */    a->PolyFillRectSolidFlags           = 0;    a->SetupForSolidFill                = R128CCESetupForSolidFill;    a->SubsequentSolidFillRect          = R128CCESubsequentSolidFillRect;				/* Screen-to-screen Copy */				/* Transparency uses the wrong colors for				   24 bpp mode -- the transparent part is				   correct, but the opaque color is wrong.				   This can be seen with netscape's I-bar				   cursor when editing in the URL location				   box. */    a->ScreenToScreenCopyFlags          = ((pScrn->bitsPerPixel == 24)					   ? NO_TRANSPARENCY					   : 0);    a->SetupForScreenToScreenCopy       = R128CCESetupForScreenToScreenCopy;    a->SubsequentScreenToScreenCopy     = R128CCESubsequentScreenToScreenCopy;				/* Indirect CPU-To-Screen Color Expand */    a->ScanlineCPUToScreenColorExpandFillFlags = LEFT_EDGE_CLIPPING					       | LEFT_EDGE_CLIPPING_NEGATIVE_X;    a->NumScanlineColorExpandBuffers   = 1;    a->ScanlineColorExpandBuffers      = info->scratch_buffer;    info->scratch_buffer[0]            = NULL;    a->SetupForScanlineCPUToScreenColorExpandFill	= R128CCESetupForScanlineCPUToScreenColorExpandFill;    a->SubsequentScanlineCPUToScreenColorExpandFill	= R128CCESubsequentScanlineCPUToScreenColorExpandFill;    a->SubsequentColorExpandScanline   = R128CCESubsequentColorExpandScanline;				/* Bresenham Solid Lines */    a->SetupForSolidLine               = R128CCESetupForSolidLine;    a->SubsequentSolidBresenhamLine    = R128CCESubsequentSolidBresenhamLine;    a->SubsequentSolidHorVertLine      = R128CCESubsequentSolidHorVertLine;				/* Bresenham Dashed Lines*/    a->SetupForDashedLine              = R128CCESetupForDashedLine;    a->SubsequentDashedBresenhamLine   = R128CCESubsequentDashedBresenhamLine;    a->DashPatternMaxLength            = 32;    a->DashedLineFlags                 = (LINE_PATTERN_LSBFIRST_LSBJUSTIFIED					  | LINE_PATTERN_POWER_OF_2_ONLY);				/* Mono 8x8 Pattern Fill (Color Expand) */    a->SetupForMono8x8PatternFill       = R128CCESetupForMono8x8PatternFill;    a->SubsequentMono8x8PatternFillRect = R128CCESubsequentMono8x8PatternFillRect;    a->Mono8x8PatternFillFlags          = (HARDWARE_PATTERN_PROGRAMMED_BITS					   | HARDWARE_PATTERN_PROGRAMMED_ORIGIN					   | HARDWARE_PATTERN_SCREEN_ORIGIN					   | BIT_ORDER_IN_BYTE_LSBFIRST);    if(!info->IsSecondary && xf86IsEntityShared(pScrn->entityList[0]))        a->RestoreAccelState           = R128RestoreCCEAccelState;}#endif/* This callback is required for multihead cards using XAA */staticvoid R128RestoreAccelState(ScrnInfoPtr pScrn){    R128InfoPtr info        = R128PTR(pScrn);    unsigned char *R128MMIO = info->MMIO;    R128WaitForFifo(pScrn, 2);    OUTREG(R128_DEFAULT_OFFSET, pScrn->fbOffset);    OUTREG(R128_DEFAULT_PITCH,  info->pitch);    /* FIXME: May need to restore other things,        like BKGD_CLK FG_CLK...*/    R128WaitForIdle(pScrn);}static void R128MMIOAccelInit(ScrnInfoPtr pScrn, XAAInfoRecPtr a){    R128InfoPtr info = R128PTR(pScrn);    a->Flags                            = (PIXMAP_CACHE					   | OFFSCREEN_PIXMAPS					   | LINEAR_FRAMEBUFFER);				/* Sync */    a->Sync                             = R128WaitForIdle;				/* Solid Filled Rectangle */    a->PolyFillRectSolidFlags           = 0;    a->SetupForSolidFill                = R128SetupForSolidFill;    a->SubsequentSolidFillRect          = R128SubsequentSolidFillRect;				/* Screen-to-screen Copy */				/* Transparency uses the wrong colors for				   24 bpp mode -- the transparent part is				   correct, but the opaque color is wrong.				   This can be seen with netscape's I-bar				   cursor when editing in the URL location				   box. */    a->ScreenToScreenCopyFlags          = ((pScrn->bitsPerPixel == 24)					   ? NO_TRANSPARENCY					   : 0);    a->SetupForScreenToScreenCopy       = R128SetupForScreenToScreenCopy;    a->SubsequentScreenToScreenCopy     = R128SubsequentScreenToScreenCopy;				/* Mono 8x8 Pattern Fill (Color Expand) */    a->SetupForMono8x8PatternFill       = R128SetupForMono8x8PatternFill;    a->SubsequentMono8x8PatternFillRect = R128SubsequentMono8x8PatternFillRect;    a->Mono8x8PatternFillFlags          = (HARDWARE_PATTERN_PROGRAMMED_BITS					   | HARDWARE_PATTERN_PROGRAMMED_ORIGIN					   | HARDWARE_PATTERN_SCREEN_ORIGIN					   | BIT_ORDER_IN_BYTE_LSBFIRST);				/* Indirect CPU-To-Screen Color Expand */    a->ScanlineCPUToScreenColorExpandFillFlags = LEFT_EDGE_CLIPPING					       | LEFT_EDGE_CLIPPING_NEGATIVE_X;    a->NumScanlineColorExpandBuffers   = 1;    a->ScanlineColorExpandBuffers      = info->scratch_buffer;    info->scratch_save                 = xalloc(((pScrn->virtualX+31)/32*4)					    + (pScrn->virtualX					    * info->CurrentLayout.pixel_bytes));    info->scratch_buffer[0]            = info->scratch_save;    a->SetupForScanlineCPUToScreenColorExpandFill	= R128SetupForScanlineCPUToScreenColorExpandFill;    a->SubsequentScanlineCPUToScreenColorExpandFill	= R128SubsequentScanlineCPUToScreenColorExpandFill;    a->SubsequentColorExpandScanline   = R128SubsequentColorExpandScanline;				/* Bresenham Solid Lines */    a->SetupForSolidLine               = R128SetupForSolidLine;    a->SubsequentSolidBresenhamLine    = R128SubsequentSolidBresenhamLine;    a->SubsequentSolidHorVertLine      = R128SubsequentSolidHorVertLine;				/* Bresenham Dashed Lines*/    a->SetupForDashedLine              = R128SetupForDashedLine;    a->SubsequentDashedBresenhamLine   = R128SubsequentDashedBresenhamLine;    a->DashPatternMaxLength            = 32;    a->DashedLineFlags                 = (LINE_PATTERN_LSBFIRST_LSBJUSTIFIED					  | LINE_PATTERN_POWER_OF_2_ONLY);				/* ImageWrite */    a->NumScanlineImageWriteBuffers    = 1;    a->ScanlineImageWriteBuffers       = info->scratch_buffer;    info->scratch_buffer[0]            = info->scratch_save;    a->SetupForScanlineImageWrite      = R128SetupForScanlineImageWrite;    a->SubsequentScanlineImageWriteRect= R128SubsequentScanlineImageWriteRect;    a->SubsequentImageWriteScanline    = R128SubsequentImageWriteScanline;    a->ScanlineImageWriteFlags         = CPU_TRANSFER_PAD_DWORD		/* Performance tests show that we shouldn't use GXcopy for		 * uploads as a memcpy is faster */					  | NO_GXCOPY					  | LEFT_EDGE_CLIPPING					  | LEFT_EDGE_CLIPPING_NEGATIVE_X					  | SCANLINE_PAD_DWORD;    if(xf86IsEntityShared(pScrn->entityList[0]))    {        DevUnion* pPriv;        R128EntPtr pR128Ent;        pPriv = xf86GetEntityPrivate(pScrn->entityList[0],                getR128EntityIndex());        pR128Ent = pPriv->ptr;                /*if there are more than one devices sharing this entity, we          have to assign this call back, otherwise the XAA will be          disabled */        if(pR128Ent->HasSecondary || pR128Ent->BypassSecondary)           a->RestoreAccelState           = R128RestoreAccelState;    }}/* Initialize XAA for supported acceleration and also initialize the   graphics hardware for acceleration. */Bool R128AccelInit(ScreenPtr pScreen){    ScrnInfoPtr   pScrn = xf86Screens[pScreen->myNum];    R128InfoPtr   info  = R128PTR(pScrn);    XAAInfoRecPtr a;    if (!(a = info->accel = XAACreateInfoRec())) return FALSE;#ifdef XF86DRI    if (info->directRenderingEnabled)	R128CCEAccelInit(pScrn, a);    else#endif	R128MMIOAccelInit(pScrn, a);    R128EngineInit(pScrn);    return XAAInit(pScreen, a);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -