From 27ef7adf3c1f6c3ca79b42b468d08b8542348cdd Mon Sep 17 00:00:00 2001 From: Michel Daenzer Date: Wed, 4 Aug 2004 13:17:31 +0000 Subject: Use info->ModeReg.surface_cntl to restore byte swapping for the framebuffer aperture on big endian machines, remove superfluous local variables and register reads. Adapt framebuffer aperture byte swapping to texture format before copying data to offscreen area and restore it afterwards on big endian machines, fixes Render acceleration there. reviewed by: Hui Yu , Kevin E. Martin --- src/radeon_render.c | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) (limited to 'src/radeon_render.c') diff --git a/src/radeon_render.c b/src/radeon_render.c index 7eb293d..8b4f5da 100644 --- a/src/radeon_render.c +++ b/src/radeon_render.c @@ -368,6 +368,9 @@ static Bool FUNC_NAME(R100SetupTexture)( CARD8 *dst; CARD32 tex_size = 0, txformat; int dst_pitch, offset, size, i, tex_bytepp; +#if X_BYTE_ORDER == X_BIG_ENDIAN && defined(ACCEL_CP) + unsigned char *RADEONMMIO = info->MMIO; +#endif ACCEL_PREAMBLE(); if ((width > 2048) || (height > 2048)) @@ -376,6 +379,31 @@ static Bool FUNC_NAME(R100SetupTexture)( txformat = RadeonGetTextureFormat(format); tex_bytepp = PICT_FORMAT_BPP(format) >> 3; +#if X_BYTE_ORDER == X_BIG_ENDIAN + /* Set up byte swapping for the framebuffer aperture as needed */ + switch (tex_bytepp) { + case 1: + OUTREG(RADEON_SURFACE_CNTL, info->ModeReg.surface_cntl & + ~(RADEON_NONSURF_AP0_SWP_32BPP + | RADEON_NONSURF_AP0_SWP_16BPP)); + break; + case 2: + OUTREG(RADEON_SURFACE_CNTL, (info->ModeReg.surface_cntl & + ~RADEON_NONSURF_AP0_SWP_32BPP) + | RADEON_NONSURF_AP0_SWP_16BPP); + break; + case 4: + OUTREG(RADEON_SURFACE_CNTL, info->ModeReg.surface_cntl + | RADEON_NONSURF_AP0_SWP_32BPP + | RADEON_NONSURF_AP0_SWP_16BPP); + break; + default: + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "%s: Don't know what to do for " + "tex_bytepp == %d!\n", __func__, tex_bytepp); + return FALSE; + } +#endif + dst_pitch = (width * tex_bytepp + 31) & ~31; size = dst_pitch * height; @@ -403,6 +431,11 @@ static Bool FUNC_NAME(R100SetupTexture)( dst += dst_pitch; } +#if X_BYTE_ORDER == X_BIG_ENDIAN + /* restore byte swapping */ + OUTREG(RADEON_SURFACE_CNTL, info->ModeReg.surface_cntl); +#endif + BEGIN_ACCEL(5); OUT_ACCEL_REG(RADEON_PP_TXFORMAT_0, txformat); OUT_ACCEL_REG(RADEON_PP_TEX_SIZE_0, tex_size); @@ -639,6 +672,9 @@ static Bool FUNC_NAME(R200SetupTexture)( CARD8 *dst; CARD32 tex_size = 0, txformat; int dst_pitch, offset, size, i, tex_bytepp; +#if X_BYTE_ORDER == X_BIG_ENDIAN && defined(ACCEL_CP) + unsigned char *RADEONMMIO = info->MMIO; +#endif ACCEL_PREAMBLE(); if ((width > 2048) || (height > 2048)) @@ -647,6 +683,31 @@ static Bool FUNC_NAME(R200SetupTexture)( txformat = RadeonGetTextureFormat(format); tex_bytepp = PICT_FORMAT_BPP(format) >> 3; +#if X_BYTE_ORDER == X_BIG_ENDIAN + /* Set up byte swapping for the framebuffer aperture as needed */ + switch (tex_bytepp) { + case 1: + OUTREG(RADEON_SURFACE_CNTL, info->ModeReg.surface_cntl & + ~(RADEON_NONSURF_AP0_SWP_32BPP + | RADEON_NONSURF_AP0_SWP_16BPP)); + break; + case 2: + OUTREG(RADEON_SURFACE_CNTL, (info->ModeReg.surface_cntl & + ~RADEON_NONSURF_AP0_SWP_32BPP) + | RADEON_NONSURF_AP0_SWP_16BPP); + break; + case 4: + OUTREG(RADEON_SURFACE_CNTL, info->ModeReg.surface_cntl + | RADEON_NONSURF_AP0_SWP_32BPP + | RADEON_NONSURF_AP0_SWP_16BPP); + break; + default: + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "%s: Don't know what to do for " + "tex_bytepp == %d!\n", __func__, tex_bytepp); + return FALSE; + } +#endif + dst_pitch = (width * tex_bytepp + 31) & ~31; size = dst_pitch * height; @@ -674,6 +735,11 @@ static Bool FUNC_NAME(R200SetupTexture)( dst += dst_pitch; } +#if X_BYTE_ORDER == X_BIG_ENDIAN + /* restore byte swapping */ + OUTREG(RADEON_SURFACE_CNTL, info->ModeReg.surface_cntl); +#endif + BEGIN_ACCEL(6); OUT_ACCEL_REG(R200_PP_TXFORMAT_0, txformat); OUT_ACCEL_REG(R200_PP_TXFORMAT_X_0, 0); -- cgit v1.2.3