diff options
author | Alex Deucher <alex@samba.(none)> | 2008-03-10 21:41:42 -0400 |
---|---|---|
committer | Alex Deucher <alex@samba.(none)> | 2008-03-10 21:41:42 -0400 |
commit | 924c98f7002420ec2a701127073293daafb3f336 (patch) | |
tree | ff7da4feabdba3f553c374a06985537c62ac40f6 | |
parent | e2208048f7913aba536ebe4c007698e57698d13f (diff) |
R128: add support for Xv using the blitterr128-support
Ported from Eric's kdrive ati driver
-rw-r--r-- | src/radeon_driver.c | 3 | ||||
-rw-r--r-- | src/radeon_reg.h | 120 | ||||
-rw-r--r-- | src/radeon_textured_video.c | 24 | ||||
-rw-r--r-- | src/radeon_textured_videofuncs.c | 112 | ||||
-rw-r--r-- | src/radeon_video.c | 2 |
5 files changed, 253 insertions, 8 deletions
diff --git a/src/radeon_driver.c b/src/radeon_driver.c index 2e7f42a..ce5d30c 100644 --- a/src/radeon_driver.c +++ b/src/radeon_driver.c @@ -3551,8 +3551,7 @@ Bool RADEONScreenInit(int scrnIndex, ScreenPtr pScreen, if (info->ChipFamily < CHIP_FAMILY_R600) { xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, RADEON_LOGLEVEL_DEBUG, "Initializing Xv\n"); - if (!IS_R128) - RADEONInitVideo(pScreen); + RADEONInitVideo(pScreen); } if (info->r600_shadow_fb == TRUE) { diff --git a/src/radeon_reg.h b/src/radeon_reg.h index 357fa25..49de158 100644 --- a/src/radeon_reg.h +++ b/src/radeon_reg.h @@ -1687,6 +1687,126 @@ /* Registers for 3D/TCL */ +#define R128_SCALE_3D_CNTL 0x1a00 +# define R128_SCALE_DITHER_ERR_DIFF (0 << 1) +# define R128_SCALE_DITHER_TABLE (1 << 1) +# define R128_TEX_CACHE_SIZE_FULL (0 << 2) +# define R128_TEX_CACHE_SIZE_HALF (1 << 2) +# define R128_DITHER_INIT_CURR (0 << 3) +# define R128_DITHER_INIT_RESET (1 << 3) +# define R128_ROUND_24BIT (1 << 4) +# define R128_TEX_CACHE_DISABLE (1 << 5) +# define R128_SCALE_3D_NOOP (0 << 6) +# define R128_SCALE_3D_SCALE (1 << 6) +# define R128_SCALE_3D_TEXMAP_SHADE (2 << 6) +# define R128_SCALE_PIX_BLEND (0 << 8) +# define R128_SCALE_PIX_REPLICATE (1 << 8) +# define R128_TEX_CACHE_SPLIT (1 << 9) +# define R128_APPLE_YUV_MODE (1 << 10) +# define R128_TEX_CACHE_PALLETE_MODE (1 << 11) +# define R128_ALPHA_COMB_ADD_CLAMP (0 << 12) +# define R128_ALPHA_COMB_ADD_NCLAMP (1 << 12) +# define R128_ALPHA_COMB_SUB_DST_SRC_CLAMP (2 << 12) +# define R128_ALPHA_COMB_SUB_DST_SRC_NCLAMP (3 << 12) +# define R128_FOG_TABLE (1 << 14) +# define R128_SIGNED_DST_CLAMP (1 << 15) +#define R128_SCALE_3D_DATATYPE 0x1a20 +#define R128_TEX_CNTL_C 0x1c9c +# define R128_Z_ENABLE (1 << 0) +# define R128_Z_WRITE_ENABLE (1 << 1) +# define R128_STENCIL_ENABLE (1 << 3) +# define R128_SHADE_ENABLE (0 << 4) +# define R128_TEXMAP_ENABLE (1 << 4) +# define R128_SEC_TEXMAP_ENABLE (1 << 5) +# define R128_FOG_ENABLE (1 << 7) +# define R128_DITHER_ENABLE (1 << 8) +# define R128_ALPHA_ENABLE (1 << 9) +# define R128_ALPHA_TEST_ENABLE (1 << 10) +# define R128_SPEC_LIGHT_ENABLE (1 << 11) +# define R128_TEX_CHROMA_KEY_ENABLE (1 << 12) +# define R128_ALPHA_IN_TEX_COMPLETE_A (0 << 13) +# define R128_ALPHA_IN_TEX_LSB_A (1 << 13) +# define R128_LIGHT_DIS (0 << 14) +# define R128_LIGHT_COPY (1 << 14) +# define R128_LIGHT_MODULATE (2 << 14) +# define R128_LIGHT_ADD (3 << 14) +# define R128_LIGHT_BLEND_CONSTANT (4 << 14) +# define R128_LIGHT_BLEND_TEXTURE (5 << 14) +# define R128_LIGHT_BLEND_VERTEX (6 << 14) +# define R128_LIGHT_BLEND_CONST_COLOR (7 << 14) +# define R128_ALPHA_LIGHT_DIS (0 << 18) +# define R128_ALPHA_LIGHT_COPY (1 << 18) +# define R128_ALPHA_LIGHT_MODULATE (2 << 18) +# define R128_ALPHA_LIGHT_ADD (3 << 18) +# define R128_ANTI_ALIAS (1 << 21) +# define R128_TEX_CACHE_FLUSH (1 << 23) +# define R128_LOD_BIAS_SHIFT 24 +# define R128_LOD_BIAS_MASK (0xff << 24) +#define R128_TEX_CNTL 0x1800 +#define R128_SECONDARY_SCALE_OFFSET 0x1980 +#define R128_SECONDARY_SCALE_PITCH 0x1980 +#define R128_SECONDARY_SCALE_X_INC 0x1984 +#define R128_SECONDARY_SCALE_Y_INC 0x1988 +#define R128_SECONDARY_SCALE_HACC 0x198c +#define R128_SECONDARY_SCALE_VACC 0x1990 +#define R128_SCALE_SRC_HEIGHT_WIDTH 0x1994 +#define R128_SCALE_OFFSET_0 0x1998 +#define R128_SCALE_PITCH 0x199c +#define R128_SCALE_X_INC 0x19a0 +#define R128_SCALE_Y_INC 0x19a4 +#define R128_SCALE_HACC 0x19a8 +#define R128_SCALE_VACC 0x19ac +#define R128_SCALE_DST_X_Y 0x19b0 +#define R128_SCALE_DST_HEIGHT_WIDTH 0x19b4 +#define R128_MISC_3D_STATE_CNTL 0x1ca0 +# define R128_REF_ALPHA_MASK 0xff +# define R128_MISC_SCALE_3D_NOOP (0 << 8) +# define R128_MISC_SCALE_3D_SCALE (1 << 8) +# define R128_MISC_SCALE_3D_TEXMAP_SHADE (2 << 8) +# define R128_MISC_SCALE_PIX_BLEND (0 << 10) +# define R128_MISC_SCALE_PIX_REPLICATE (1 << 10) +# define R128_ALPHA_COMB_ADD_CLAMP (0 << 12) +# define R128_ALPHA_COMB_ADD_NO_CLAMP (1 << 12) +# define R128_ALPHA_COMB_SUB_SRC_DST_CLAMP (2 << 12) +# define R128_ALPHA_COMB_SUB_SRC_DST_NO_CLAMP (3 << 12) +# define R128_FOG_VERTEX (0 << 14) +# define R128_FOG_TABLE (1 << 14) +# define R128_SBLEND_ZERO (0 << 16) +# define R128_SBLEND_ONE (1 << 16) +# define R128_SBLEND_SRCCOLOR (2 << 16) +# define R128_SBLEND_INVSRCCOLOR (3 << 16) +# define R128_SBLEND_SRC_ALPHA (4 << 16) +# define R128_SBLEND_INV_SRC_ALPHA (5 << 16) +# define R128_SBLEND_DST_ALPHA (6 << 16) +# define R128_SBLEND_INV_DST_ALPHA (7 << 16) +# define R128_SBLEND_DSTCOLOR (8 << 16) +# define R128_SBLEND_INVDSTCOLOR (9 << 16) +# define R128_SBLEND_SRC_ALPHASAT (10 << 16) +# define R128_SBLEND_BOTHSRC_ALPHA (11 << 16) +# define R128_SBLEND_BOTHINV_SRC_ALPHA (12 << 16) +# define R128_SBLEND_MASK (15 << 16) +# define R128_DBLEND_ZERO (0 << 20) +# define R128_DBLEND_ONE (1 << 20) +# define R128_DBLEND_SRCCOLOR (2 << 20) +# define R128_DBLEND_INVSRCCOLOR (3 << 20) +# define R128_DBLEND_SRC_ALPHA (4 << 20) +# define R128_DBLEND_INV_SRC_ALPHA (5 << 20) +# define R128_DBLEND_DST_ALPHA (6 << 20) +# define R128_DBLEND_INV_DST_ALPHA (7 << 20) +# define R128_DBLEND_DSTCOLOR (8 << 20) +# define R128_DBLEND_INVDSTCOLOR (9 << 20) +# define R128_DBLEND_SRC_ALPHASAT (10 << 20) +# define R128_DBLEND_MASK (15 << 20) +# define R128_ALPHA_TEST_NEVER (0 << 24) +# define R128_ALPHA_TEST_LESS (1 << 24) +# define R128_ALPHA_TEST_LESSEQUAL (2 << 24) +# define R128_ALPHA_TEST_EQUAL (3 << 24) +# define R128_ALPHA_TEST_GREATEREQUAL (4 << 24) +# define R128_ALPHA_TEST_GREATER (5 << 24) +# define R128_ALPHA_TEST_NEQUAL (6 << 24) +# define R128_ALPHA_TEST_ALWAYS (7 << 24) +# define R128_ALPHA_TEST_MASK (7 << 24) + #define RADEON_PP_BORDER_COLOR_0 0x1d40 #define RADEON_PP_BORDER_COLOR_1 0x1d44 #define RADEON_PP_BORDER_COLOR_2 0x1d48 diff --git a/src/radeon_textured_video.c b/src/radeon_textured_video.c index 329a834..4f24b24 100644 --- a/src/radeon_textured_video.c +++ b/src/radeon_textured_video.c @@ -279,12 +279,21 @@ RADEONPutImageTextured(ScrnInfoPtr pScrn, pPriv->w = width; pPriv->h = height; + if (IS_R128) { #ifdef XF86DRI - if (info->directRenderingEnabled) - RADEONDisplayTexturedVideoCP(pScrn, pPriv); - else + if (info->directRenderingEnabled) + R128DisplayBlitVideoCP(pScrn, pPriv); + else #endif - RADEONDisplayTexturedVideoMMIO(pScrn, pPriv); + R128DisplayBlitVideoMMIO(pScrn, pPriv); + } else { +#ifdef XF86DRI + if (info->directRenderingEnabled) + RADEONDisplayTexturedVideoCP(pScrn, pPriv); + else +#endif + RADEONDisplayTexturedVideoMMIO(pScrn, pPriv); + } return Success; } @@ -326,6 +335,8 @@ static XF86ImageRec Images[NUM_IMAGES] = XF86VideoAdaptorPtr RADEONSetupImageTexturedVideo(ScreenPtr pScreen) { + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + RADEONInfoPtr info = RADEONPTR(pScrn); RADEONPortPrivPtr pPortPriv; XF86VideoAdaptorPtr adapt; int i; @@ -338,7 +349,10 @@ RADEONSetupImageTexturedVideo(ScreenPtr pScreen) adapt->type = XvWindowMask | XvInputMask | XvImageMask; adapt->flags = 0; - adapt->name = "Radeon Textured Video"; + if (IS_R128) + adapt->name = "R128 Blitter Video"; + else + adapt->name = "Radeon Textured Video"; adapt->nEncodings = 1; adapt->pEncodings = DummyEncoding; adapt->nFormats = NUM_FORMATS; diff --git a/src/radeon_textured_videofuncs.c b/src/radeon_textured_videofuncs.c index 4ebb73b..32f619c 100644 --- a/src/radeon_textured_videofuncs.c +++ b/src/radeon_textured_videofuncs.c @@ -70,6 +70,118 @@ do { \ #endif /* !ACCEL_CP */ static void +FUNC_NAME(R128DisplayBlitVideo)(ScrnInfoPtr pScrn, RADEONPortPrivPtr pPriv) +{ + RADEONInfoPtr info = RADEONPTR(pScrn); + PixmapPtr pPixmap = pPriv->pPixmap; + CARD32 dstDatatype, srcDatatype; + CARD32 dst_offset, dst_pitch; + int dstxoff, dstyoff; + int bpp = pPixmap->drawable.bitsPerPixel; + VIDEO_PREAMBLE(); + + BoxPtr pBox = REGION_RECTS(&pPriv->clip); + int nBox = REGION_NUM_RECTS(&pPriv->clip); + + if (pPriv->id == FOURCC_UYVY) + srcDatatype = ATI_DATATYPE_YVYU_422; + else + srcDatatype = ATI_DATATYPE_VYUY_422; + + switch (bpp) { + case 16: + if (pPixmap->drawable.depth == 15) + dstDatatype = ATI_DATATYPE_ARGB1555; + else + dstDatatype = ATI_DATATYPE_RGB565; + break; + case 32: + dstDatatype = ATI_DATATYPE_ARGB8888; + break; + default: + return; + } + +#ifdef USE_EXA + if (info->useEXA) { + dst_offset = exaGetPixmapOffset(pPixmap) + info->fbLocation; + dst_pitch = exaGetPixmapPitch(pPixmap); + } else +#endif + { + dst_offset = (pPixmap->devPrivate.ptr - info->FB) + + info->fbLocation + pScrn->fbOffset; + dst_pitch = pPixmap->devKind; + } + +#ifdef COMPOSITE + dstxoff = -pPixmap->screen_x + pPixmap->drawable.x; + dstyoff = -pPixmap->screen_y + pPixmap->drawable.y; +#else + dstxoff = 0; + dstyoff = 0; +#endif + + BEGIN_VIDEO(11); + OUT_VIDEO_REG(RADEON_DST_PITCH_OFFSET, + ((dst_pitch / bpp) << 21) | (dst_offset >> 5)); + OUT_VIDEO_REG(RADEON_DP_GUI_MASTER_CNTL, + RADEON_GMC_DST_PITCH_OFFSET_CNTL | + RADEON_GMC_BRUSH_NONE | + (dstDatatype << 8) | + RADEON_GMC_SRC_DATATYPE_COLOR | + (0xcc << 16) | /* GXcopy */ + RADEON_GMC_3D_FCN_EN | + RADEON_GMC_CLR_CMP_CNTL_DIS | + RADEON_GMC_AUX_CLIP_DIS); + OUT_VIDEO_REG(RADEON_DP_CNTL, + RADEON_DST_X_LEFT_TO_RIGHT | RADEON_DST_Y_TOP_TO_BOTTOM); + OUT_VIDEO_REG(R128_SCALE_3D_CNTL, + R128_SCALE_3D_SCALE | + R128_SBLEND_ONE | + R128_DBLEND_ZERO); + OUT_VIDEO_REG(R128_TEX_CNTL_C, R128_TEX_CACHE_FLUSH); + OUT_VIDEO_REG(R128_SCALE_3D_DATATYPE, srcDatatype); + + OUT_VIDEO_REG(R128_SCALE_PITCH, pPriv->src_pitch / 16); + OUT_VIDEO_REG(R128_SCALE_X_INC, + (pPriv->src_w << 16) / pPriv->dst_w); + OUT_VIDEO_REG(R128_SCALE_Y_INC, + (pPriv->src_h << 16) / pPriv->dst_h); + OUT_VIDEO_REG(R128_SCALE_HACC, 0); + OUT_VIDEO_REG(R128_SCALE_VACC, 0); + FINISH_VIDEO(); + + while (nBox--) { + int srcX, srcY, dstX, dstY, srcw, srch, dstw, dsth; + + dstX = pBox->x1 + dstxoff; + dstY = pBox->y1 + dstyoff; + dstw = pBox->x2 - pBox->x1; + dsth = pBox->y2 - pBox->y1; + srcX = (pBox->x1 - pPriv->drw_x) * + pPriv->src_w / pPriv->dst_w; + srcY = (pBox->y1 - pPriv->drw_y) * + pPriv->src_h / pPriv->dst_h; + srcw = pPriv->src_w - srcX; + srch = pPriv->src_h - srcY; + + BEGIN_VIDEO(4); + OUT_VIDEO_REG(R128_SCALE_SRC_HEIGHT_WIDTH, (srch << 16) | srcw); + OUT_VIDEO_REG(R128_SCALE_OFFSET_0, pPriv->src_offset + + srcY * pPriv->src_pitch + srcX * 2); + OUT_VIDEO_REG(R128_SCALE_DST_X_Y, (dstX << 16) | dstY); + OUT_VIDEO_REG(R128_SCALE_DST_HEIGHT_WIDTH, (dsth << 16) | dstw); + FINISH_VIDEO(); + + pBox++; + } + + DamageDamageRegion(pPriv->pDraw, &pPriv->clip); + +} + +static void FUNC_NAME(RADEONDisplayTexturedVideo)(ScrnInfoPtr pScrn, RADEONPortPrivPtr pPriv) { RADEONInfoPtr info = RADEONPTR(pScrn); diff --git a/src/radeon_video.c b/src/radeon_video.c index 555186a..b3865bd 100644 --- a/src/radeon_video.c +++ b/src/radeon_video.c @@ -275,7 +275,7 @@ void RADEONInitVideo(ScreenPtr pScreen) memcpy(newAdaptors, adaptors, num_adaptors * sizeof(XF86VideoAdaptorPtr)); adaptors = newAdaptors; - if (!IS_AVIVO_VARIANT) { + if (!IS_AVIVO_VARIANT && !IS_R128) { overlayAdaptor = RADEONSetupImageVideo(pScreen); if (overlayAdaptor != NULL) { adaptors[num_adaptors++] = overlayAdaptor; |