📄 r128_accel.c
字号:
int x, int y, int w, int h){ R128InfoPtr info = R128PTR(pScrn); RING_LOCALS; R128CCE_REFRESH( pScrn, info ); BEGIN_RING( 4 ); OUT_RING_REG( R128_DST_Y_X, (y << 16) | x ); OUT_RING_REG( R128_DST_WIDTH_HEIGHT, (w << 16) | h ); ADVANCE_RING();}/* Setup for XAA screen-to-screen copy. Tests: xtest CH06/fllrctngl (also tests transparency).*/static void R128CCESetupForScreenToScreenCopy(ScrnInfoPtr pScrn, int xdir, int ydir, int rop, unsigned int planemask, int trans_color){ R128InfoPtr info = R128PTR(pScrn); RING_LOCALS; R128CCE_REFRESH( pScrn, info ); info->xdir = xdir; info->ydir = ydir; BEGIN_RING( 6 ); OUT_RING_REG( R128_DP_GUI_MASTER_CNTL, (info->dp_gui_master_cntl | R128_GMC_BRUSH_NONE | R128_GMC_SRC_DATATYPE_COLOR | R128_ROP[rop].rop | R128_DP_SRC_SOURCE_MEMORY) ); OUT_RING_REG( R128_DP_WRITE_MASK, planemask ); OUT_RING_REG( R128_DP_CNTL, ((xdir >= 0 ? R128_DST_X_LEFT_TO_RIGHT : 0) | (ydir >= 0 ? R128_DST_Y_TOP_TO_BOTTOM : 0)) ); ADVANCE_RING(); if ((trans_color != -1) || (info->XAAForceTransBlit == TRUE)) { BEGIN_RING( 6 ); OUT_RING_REG( R128_CLR_CMP_CLR_SRC, trans_color ); OUT_RING_REG( R128_CLR_CMP_MASK, R128_CLR_CMP_MSK ); OUT_RING_REG( R128_CLR_CMP_CNTL, (R128_SRC_CMP_NEQ_COLOR | R128_CLR_CMP_SRC_SOURCE) ); ADVANCE_RING(); }}/* Subsequent XAA screen-to-screen copy. */static void R128CCESubsequentScreenToScreenCopy(ScrnInfoPtr pScrn, int xa, int ya, int xb, int yb, int w, int h){ R128InfoPtr info = R128PTR(pScrn); RING_LOCALS; R128CCE_REFRESH( pScrn, info ); if (info->xdir < 0) xa += w - 1, xb += w - 1; if (info->ydir < 0) ya += h - 1, yb += h - 1; BEGIN_RING( 6 ); OUT_RING_REG( R128_SRC_Y_X, (ya << 16) | xa ); OUT_RING_REG( R128_DST_Y_X, (yb << 16) | xb ); OUT_RING_REG( R128_DST_HEIGHT_WIDTH, (h << 16) | w ); ADVANCE_RING();}/* * XAA scanline color expansion * * We use HOSTDATA_BLT CCE packets, dividing the image in chunks that fit into * the indirect buffer if necessary. */static void R128CCESetupForScanlineCPUToScreenColorExpandFill(ScrnInfoPtr pScrn, int fg, int bg, int rop, unsigned int planemask){ R128InfoPtr info = R128PTR(pScrn); RING_LOCALS; R128CCE_REFRESH( pScrn, info ); BEGIN_RING( 2 ); OUT_RING_REG(R128_DP_WRITE_MASK, planemask); ADVANCE_RING(); info->scanline_rop = rop; info->scanline_fg = fg; info->scanline_bg = bg;}/* Helper function to write out a HOSTDATA_BLT packet into the indirect buffer and set the XAA scratch buffer address appropriately */static void R128CCEScanlineCPUToScreenColorExpandFillPacket(ScrnInfoPtr pScrn, int bufno){ R128InfoPtr info = R128PTR(pScrn); int chunk_words = info->scanline_hpass * info->scanline_words; RING_LOCALS; R128CCE_REFRESH( pScrn, info ); BEGIN_RING( chunk_words+9 ); OUT_RING( CCE_PACKET3( R128_CCE_PACKET3_CNTL_HOSTDATA_BLT, chunk_words+9-2 ) );#if X_BYTE_ORDER == X_LITTLE_ENDIAN OUT_RING( (info->dp_gui_master_cntl | R128_GMC_DST_CLIPPING | R128_GMC_BRUSH_NONE | (info->scanline_bg == -1 ? R128_GMC_SRC_DATATYPE_MONO_FG_LA : R128_GMC_SRC_DATATYPE_MONO_FG_BG) | R128_ROP[info->scanline_rop].rop | R128_GMC_BYTE_LSB_TO_MSB | R128_DP_SRC_SOURCE_HOST_DATA));#else /* X_BYTE_ORDER == X_BIG_ENDIAN */ OUT_RING( (info->dp_gui_master_cntl | R128_GMC_DST_CLIPPING | R128_GMC_BRUSH_NONE | (info->scanline_bg == -1 ? R128_GMC_SRC_DATATYPE_MONO_FG_LA : R128_GMC_SRC_DATATYPE_MONO_FG_BG) | R128_ROP[info->scanline_rop].rop | R128_DP_SRC_SOURCE_HOST_DATA));#endif OUT_RING( (info->scanline_y << 16) | (info->scanline_x1clip & 0xffff) ); OUT_RING( ((info->scanline_y+info->scanline_hpass-1) << 16) | ((info->scanline_x2clip-1) & 0xffff) ); OUT_RING( info->scanline_fg ); OUT_RING( info->scanline_bg ); OUT_RING( (info->scanline_y << 16) | (info->scanline_x & 0xffff)); /* Have to pad the width here and use clipping engine */ OUT_RING( (info->scanline_hpass << 16) | ((info->scanline_w + 31) & ~31)); OUT_RING( chunk_words ); info->scratch_buffer[bufno] = (unsigned char *) &__head[__count]; __count += chunk_words; ADVANCE_RING(); info->scanline_y += info->scanline_hpass; info->scanline_h -= info->scanline_hpass; if ( R128_VERBOSE ) xf86DrvMsg( pScrn->scrnIndex, X_INFO, "%s: hpass=%d, words=%d => chunk_words=%d, y=%d, h=%d\n", __FUNCTION__, info->scanline_hpass, info->scanline_words, chunk_words, info->scanline_y, info->scanline_h );}/* Subsequent XAA indirect CPU-to-screen color expansion. This is only called once for each rectangle. */static void R128CCESubsequentScanlineCPUToScreenColorExpandFill(ScrnInfoPtr pScrn, int x, int y, int w, int h, int skipleft){ R128InfoPtr info = R128PTR(pScrn);#define BUFSIZE ( R128_BUFFER_SIZE/4-9 ) info->scanline_x = x; info->scanline_y = y; info->scanline_w = w; info->scanline_h = h; info->scanline_x1clip = x+skipleft; info->scanline_x2clip = x+w; info->scanline_words = (w + 31) >> 5; info->scanline_hpass = min(h,(BUFSIZE/info->scanline_words)); if ( R128_VERBOSE ) xf86DrvMsg( pScrn->scrnIndex, X_INFO, "%s: x=%d, y=%d, w=%d, h=%d, skipleft=%d => x1clip=%d, x2clip=%d, hpass=%d, words=%d\n", __FUNCTION__, x, y, w, h, skipleft, info->scanline_x1clip, info->scanline_x2clip, info->scanline_hpass, info->scanline_words ); R128CCEScanlineCPUToScreenColorExpandFillPacket(pScrn, 0);}/* Subsequent XAA indirect CPU-to-screen color expansion. This is called once for each scanline. */static void R128CCESubsequentColorExpandScanline(ScrnInfoPtr pScrn, int bufno){ R128InfoPtr info = R128PTR(pScrn); if ( R128_VERBOSE ) xf86DrvMsg( pScrn->scrnIndex, X_INFO, "%s enter: scanline_hpass=%d, scanline_h=%d\n", __FUNCTION__, info->scanline_hpass, info->scanline_h ); if (--info->scanline_hpass) { info->scratch_buffer[bufno] += 4 * info->scanline_words; } else if(info->scanline_h) { info->scanline_hpass = min(info->scanline_h,(BUFSIZE/info->scanline_words)); R128CCEScanlineCPUToScreenColorExpandFillPacket(pScrn, bufno); } if ( R128_VERBOSE ) xf86DrvMsg( pScrn->scrnIndex, X_INFO, "%s exit: scanline_hpass=%d, scanline_h=%d\n", __FUNCTION__, info->scanline_hpass, info->scanline_h );}/* Solid lines */static void R128CCESetupForSolidLine(ScrnInfoPtr pScrn, int color, int rop, unsigned int planemask){ R128InfoPtr info = R128PTR(pScrn); RING_LOCALS; R128CCE_REFRESH( pScrn, info ); BEGIN_RING( 6 ); OUT_RING_REG(R128_DP_GUI_MASTER_CNTL, (info->dp_gui_master_cntl | R128_GMC_BRUSH_SOLID_COLOR | R128_GMC_SRC_DATATYPE_COLOR | R128_ROP[rop].pattern)); OUT_RING_REG(R128_DP_BRUSH_FRGD_CLR, color); OUT_RING_REG(R128_DP_WRITE_MASK, planemask); ADVANCE_RING();}static void R128CCESubsequentSolidBresenhamLine(ScrnInfoPtr pScrn, int x, int y, int major, int minor, int err, int len, int octant){ R128InfoPtr info = R128PTR(pScrn); int flags = 0; RING_LOCALS; R128CCE_REFRESH( pScrn, info ); if (octant & YMAJOR) flags |= R128_DST_Y_MAJOR; if (!(octant & XDECREASING)) flags |= R128_DST_X_DIR_LEFT_TO_RIGHT; if (!(octant & YDECREASING)) flags |= R128_DST_Y_DIR_TOP_TO_BOTTOM; BEGIN_RING( 12 ); OUT_RING_REG(R128_DP_CNTL_XDIR_YDIR_YMAJOR, flags); OUT_RING_REG(R128_DST_Y_X, (y << 16) | x); OUT_RING_REG(R128_DST_BRES_ERR, err); OUT_RING_REG(R128_DST_BRES_INC, minor); OUT_RING_REG(R128_DST_BRES_DEC, -major); OUT_RING_REG(R128_DST_BRES_LNTH, len); ADVANCE_RING();}static void R128CCESubsequentSolidHorVertLine(ScrnInfoPtr pScrn, int x, int y, int len, int dir ){ R128InfoPtr info = R128PTR(pScrn); RING_LOCALS; R128CCE_REFRESH( pScrn, info ); BEGIN_RING( 2 ); OUT_RING_REG(R128_DP_CNTL, (R128_DST_X_LEFT_TO_RIGHT | R128_DST_Y_TOP_TO_BOTTOM)); ADVANCE_RING(); if (dir == DEGREES_0) { R128CCESubsequentSolidFillRect(pScrn, x, y, len, 1); } else { R128CCESubsequentSolidFillRect(pScrn, x, y, 1, len); }}/* Dashed lines */static void R128CCESetupForDashedLine(ScrnInfoPtr pScrn, int fg, int bg, int rop, unsigned int planemask, int length, unsigned char *pattern){ R128InfoPtr info = R128PTR(pScrn); CARD32 pat = *(CARD32 *)(pointer)pattern; RING_LOCALS; R128CCE_REFRESH( pScrn, info );#if X_BYTE_ORDER == X_LITTLE_ENDIAN# define PAT_SHIFT(pat,n) pat << n#else# define PAT_SHIFT(pat,n) pat >> n#endif switch (length) { case 2: pat |= PAT_SHIFT(pat,2); /* fall through */ case 4: pat |= PAT_SHIFT(pat,4); /* fall through */ case 8: pat |= PAT_SHIFT(pat,8); /* fall through */ case 16: pat |= PAT_SHIFT(pat,16); } BEGIN_RING( 10 ); OUT_RING_REG(R128_DP_GUI_MASTER_CNTL, (info->dp_gui_master_cntl | (bg == -1 ? R128_GMC_BRUSH_32x1_MONO_FG_LA : R128_GMC_BRUSH_32x1_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, pat); ADVANCE_RING();}static void R128CCESubsequentDashedBresenhamLine(ScrnInfoPtr pScrn, int x, int y, int major, int minor, int err, int len, int octant, int phase){ R128InfoPtr info = R128PTR(pScrn); int flags = 0; RING_LOCALS; R128CCE_REFRESH( pScrn, info ); if (octant & YMAJOR) flags |= R128_DST_Y_MAJOR; if (!(octant & XDECREASING)) flags |= R128_DST_X_DIR_LEFT_TO_RIGHT; if (!(octant & YDECREASING)) flags |= R128_DST_Y_DIR_TOP_TO_BOTTOM; BEGIN_RING( 14 ); OUT_RING_REG(R128_DP_CNTL_XDIR_YDIR_YMAJOR, flags); OUT_RING_REG(R128_DST_Y_X, (y << 16) | x); OUT_RING_REG(R128_BRUSH_Y_X, (phase << 16) | phase); OUT_RING_REG(R128_DST_BRES_ERR, err); OUT_RING_REG(R128_DST_BRES_INC, minor); OUT_RING_REG(R128_DST_BRES_DEC, -major); OUT_RING_REG(R128_DST_BRES_LNTH, len); ADVANCE_RING();}/* Mono 8x8 pattern color expansion */static void R128CCESetupForMono8x8PatternFill(ScrnInfoPtr pScrn, int patternx, int patterny, int fg, int bg, int rop, unsigned int planemask){ R128InfoPtr info = R128PTR(pScrn); RING_LOCALS; R128CCE_REFRESH( pScrn, info );
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -