summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichel Daenzer <michel@daenzer.net>2004-08-04 13:17:31 +0000
committerMichel Daenzer <michel@daenzer.net>2004-08-04 13:17:31 +0000
commit3a054dceb2d8d934d4e985e4b9e8b0ef28692518 (patch)
treee07bfd5b8842d98fcc6aaa051a1fdd1aba5b50f7
parent8531a9696bf081e4521c5cf8cc05e16e65aa8e46 (diff)
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 <hyu@ati.com>, Kevin E. Martin <kem@freedesktop.org>
-rw-r--r--src/radeon_cursor.c10
-rw-r--r--src/radeon_render.c66
-rw-r--r--src/radeon_video.c14
3 files changed, 75 insertions, 15 deletions
diff --git a/src/radeon_cursor.c b/src/radeon_cursor.c
index 885144b..fba00f3 100644
--- a/src/radeon_cursor.c
+++ b/src/radeon_cursor.c
@@ -73,18 +73,17 @@ static CARD32 mono_cursor_color[] = {
#if X_BYTE_ORDER == X_BIG_ENDIAN
#define CURSOR_SWAPPING_DECL_MMIO unsigned char *RADEONMMIO = info->MMIO;
-#define CURSOR_SWAPPING_DECL CARD32 __surface_cntl;
#define CURSOR_SWAPPING_START() \
OUTREG(RADEON_SURFACE_CNTL, \
- ((__surface_cntl = INREG(RADEON_SURFACE_CNTL)) | \
+ (info->ModeReg.surface_cntl | \
RADEON_NONSURF_AP0_SWP_32BPP) & \
~RADEON_NONSURF_AP0_SWP_16BPP)
-#define CURSOR_SWAPPING_END() (OUTREG(RADEON_SURFACE_CNTL, __surface_cntl))
+#define CURSOR_SWAPPING_END() (OUTREG(RADEON_SURFACE_CNTL, \
+ info->ModeReg.surface_cntl))
#else
#define CURSOR_SWAPPING_DECL_MMIO
-#define CURSOR_SWAPPING_DECL
#define CURSOR_SWAPPING_START()
#define CURSOR_SWAPPING_END()
@@ -98,7 +97,6 @@ static void RADEONSetCursorColors(ScrnInfoPtr pScrn, int bg, int fg)
CARD32 *pixels = (CARD32 *)(pointer)(info->FB + info->cursor_start);
int pixel, i;
CURSOR_SWAPPING_DECL_MMIO
- CURSOR_SWAPPING_DECL
#ifdef ARGB_CURSOR
/* Don't recolour cursors set with SetCursorARGB. */
@@ -188,7 +186,6 @@ static void RADEONLoadCursorImage(ScrnInfoPtr pScrn, unsigned char *image)
CARD32 save2 = 0;
CARD8 chunk;
CARD32 i, j;
- CURSOR_SWAPPING_DECL
if (!info->IsSecondary) {
save1 = INREG(RADEON_CRTC_GEN_CNTL) & ~(CARD32) (3 << 20);
@@ -295,7 +292,6 @@ static void RADEONLoadCursorARGB (ScrnInfoPtr pScrn, CursorPtr pCurs)
CARD32 save2 = 0;
CARD32 *image = pCurs->bits->argb;
CARD32 *i;
- CURSOR_SWAPPING_DECL
if (!image)
return; /* XXX can't happen */
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);
diff --git a/src/radeon_video.c b/src/radeon_video.c
index 761fd5b..548b608 100644
--- a/src/radeon_video.c
+++ b/src/radeon_video.c
@@ -1503,10 +1503,6 @@ RADEONPutImage(
CARD32 tmp;
#if X_BYTE_ORDER == X_BIG_ENDIAN
unsigned char *RADEONMMIO = info->MMIO;
- CARD32 surface_cntl = INREG(RADEON_SURFACE_CNTL);
-
- OUTREG(RADEON_SURFACE_CNTL, (surface_cntl |
- RADEON_NONSURF_AP0_SWP_32BPP) & ~RADEON_NONSURF_AP0_SWP_16BPP);
#endif
/*
@@ -1613,7 +1609,8 @@ RADEONPutImage(
}
nlines = ((((yb + 0xffff) >> 16) + 1) & ~1) - top;
#if X_BYTE_ORDER == X_BIG_ENDIAN
- OUTREG(RADEON_SURFACE_CNTL, (surface_cntl | RADEON_NONSURF_AP0_SWP_32BPP)
+ OUTREG(RADEON_SURFACE_CNTL, (info->ModeReg.surface_cntl |
+ RADEON_NONSURF_AP0_SWP_32BPP)
& ~RADEON_NONSURF_AP0_SWP_16BPP);
#endif
RADEONCopyMungedData(buf + (top * srcPitch) + left, buf + s2offset,
@@ -1628,8 +1625,9 @@ RADEONPutImage(
nlines = ((yb + 0xffff) >> 16) - top;
dst_start += left;
#if X_BYTE_ORDER == X_BIG_ENDIAN
- OUTREG(RADEON_SURFACE_CNTL, surface_cntl & ~(RADEON_NONSURF_AP0_SWP_32BPP
- | RADEON_NONSURF_AP0_SWP_16BPP));
+ OUTREG(RADEON_SURFACE_CNTL, info->ModeReg.surface_cntl &
+ ~(RADEON_NONSURF_AP0_SWP_32BPP
+ | RADEON_NONSURF_AP0_SWP_16BPP));
#endif
RADEONCopyData(buf, dst_start, srcPitch, dstPitch, nlines, npixels);
break;
@@ -1637,7 +1635,7 @@ RADEONPutImage(
#if X_BYTE_ORDER == X_BIG_ENDIAN
/* restore byte swapping */
- OUTREG(RADEON_SURFACE_CNTL, surface_cntl);
+ OUTREG(RADEON_SURFACE_CNTL, info->ModeReg.surface_cntl);
#endif
/* update cliplist */