xf86-video-r128: Branch 'master' - 2 commits
Connor Behan
cbehan at kemper.freedesktop.org
Thu Jul 24 00:18:07 PDT 2014
src/r128.h | 1
src/r128_crtc.c | 72 +++----------------------------------
src/r128_cursor.c | 67 ++++-------------------------------
src/r128_probe.h | 7 ---
src/r128_video.c | 103 +++++++++++++++++++++++++++---------------------------
5 files changed, 70 insertions(+), 180 deletions(-)
New commits:
commit 6dc5e9ab12dc31ae5de24f1d5c10c4fe80e7fe07
Author: Connor Behan <connor.behan at gmail.com>
Date: Thu Jul 24 00:01:46 2014 -0700
Unify byte swappers
The cursor loading function was using a lot of code to swap bytes for
big endian systems. For awhile now, the solid picture support for EXA
has had a more optimized function that does the same thing.
Signed-off-by: Connor Behan <connor.behan at gmail.com>
Reviewed-by: Alex Deucher <alexander.deucher at amd.com>
diff --git a/src/r128_cursor.c b/src/r128_cursor.c
index d42bea6..048e6c1 100644
--- a/src/r128_cursor.c
+++ b/src/r128_cursor.c
@@ -62,20 +62,6 @@
#define CURSOR_WIDTH 64
#define CURSOR_HEIGHT 64
-#if X_BYTE_ORDER == X_BIG_ENDIAN
-#define P_SWAP32( a , b ) \
- ((char *)a)[0] = ((char *)b)[3]; \
- ((char *)a)[1] = ((char *)b)[2]; \
- ((char *)a)[2] = ((char *)b)[1]; \
- ((char *)a)[3] = ((char *)b)[0]
-
-#define P_SWAP16( a , b ) \
- ((char *)a)[0] = ((char *)b)[1]; \
- ((char *)a)[1] = ((char *)b)[0]; \
- ((char *)a)[2] = ((char *)b)[3]; \
- ((char *)a)[3] = ((char *)b)[2]
-#endif
-
void r128_crtc_show_cursor(xf86CrtcPtr crtc)
{
ScrnInfoPtr pScrn = crtc->scrn;
@@ -176,14 +162,10 @@ void r128_crtc_load_cursor_image(xf86CrtcPtr crtc, unsigned char *src)
R128CrtcPrivatePtr r128_crtc = crtc->driver_private;
int crtc_id = r128_crtc->crtc_id;
-
R128InfoPtr info = R128PTR(pScrn);
unsigned char *R128MMIO = info->MMIO;
- uint32_t *s = (pointer)src;
- uint32_t *d = (pointer)(info->FB + r128_crtc->cursor_offset + pScrn->fbOffset);
uint32_t save1 = 0;
uint32_t save2 = 0;
- int y;
if (crtc_id == 0) {
save1 = INREG(R128_CRTC_GEN_CNTL);
@@ -194,48 +176,15 @@ void r128_crtc_load_cursor_image(xf86CrtcPtr crtc, unsigned char *src)
}
#if X_BYTE_ORDER == X_BIG_ENDIAN
- switch(info->CurrentLayout.pixel_bytes) {
- case 4:
- case 3:
- for (y = 0; y < 64; y++) {
- P_SWAP32(d,s);
- d++; s++;
- P_SWAP32(d,s);
- d++; s++;
- P_SWAP32(d,s);
- d++; s++;
- P_SWAP32(d,s);
- d++; s++;
- }
- break;
- case 2:
- for (y = 0; y < 64; y++) {
- P_SWAP16(d,s);
- d++; s++;
- P_SWAP16(d,s);
- d++; s++;
- P_SWAP16(d,s);
- d++; s++;
- P_SWAP16(d,s);
- d++; s++;
- }
- break;
- default:
- for (y = 0; y < 64; y++) {
- *d++ = *s++;
- *d++ = *s++;
- *d++ = *s++;
- *d++ = *s++;
- }
- }
-#else
- for (y = 0; y < 64; y++) {
- *d++ = *s++;
- *d++ = *s++;
- *d++ = *s++;
- *d++ = *s++;
- }
+ if (info->CurrentLayout.pixel_bytes == 4 || info->CurrentLayout.pixel_bytes == 3)
+ R128CopySwap(info->FB + r128_crtc->cursor_offset + pScrn->fbOffset, src,
+ CURSOR_WIDTH * CURSOR_HEIGHT / 4, APER_0_BIG_ENDIAN_32BPP_SWAP);
+ else if (info->CurrentLayout.pixel_bytes == 2)
+ R128CopySwap(info->FB + r128_crtc->cursor_offset + pScrn->fbOffset, src,
+ CURSOR_WIDTH * CURSOR_HEIGHT / 4, APER_0_BIG_ENDIAN_16BPP_SWAP);
+ else
#endif
+ memcpy(info->FB + r128_crtc->cursor_offset + pScrn->fbOffset, src, CURSOR_WIDTH * CURSOR_HEIGHT / 4);
if (crtc_id == 0)
OUTREG(R128_CRTC_GEN_CNTL, save1);
commit 48e9b2359e8ab07095e1cb024e61b223a67cbc1a
Author: Connor Behan <connor.behan at gmail.com>
Date: Thu Jul 24 00:00:24 2014 -0700
Unify allocators
RandR and Xv were using almost the same code to grab offscreen memory
from EXA and XAA.
Signed-off-by: Connor Behan <connor.behan at gmail.com>
Reviewed-by: Alex Deucher <alexander.deucher at amd.com>
diff --git a/src/r128.h b/src/r128.h
index f361c2a..6df1b51 100644
--- a/src/r128.h
+++ b/src/r128.h
@@ -570,6 +570,7 @@ extern void r128_crtc_show_cursor(xf86CrtcPtr crtc);
extern void r128_crtc_hide_cursor(xf86CrtcPtr crtc);
extern void r128_crtc_load_cursor_image(xf86CrtcPtr crtc, unsigned char *src);
+extern uint32_t R128AllocateMemory(ScrnInfoPtr pScrn, void **mem_struct, int size, int align, Bool need_accel);
extern Bool R128SetupConnectors(ScrnInfoPtr pScrn);
extern Bool R128AllocateControllers(ScrnInfoPtr pScrn, int mask);
extern void R128Blank(ScrnInfoPtr pScrn);
diff --git a/src/r128_crtc.c b/src/r128_crtc.c
index 5f076cd..92a6c30 100644
--- a/src/r128_crtc.c
+++ b/src/r128_crtc.c
@@ -233,33 +233,9 @@ static void r128_crtc_unlock(xf86CrtcPtr crtc)
#endif
}
-#ifdef HAVE_XAA_H
-static FBLinearPtr r128_xf86AllocateOffscreenLinear(ScreenPtr pScreen, int length, int granularity,
- MoveLinearCallbackProcPtr moveCB,
- RemoveLinearCallbackProcPtr removeCB,
- pointer privData)
-{
- FBLinearPtr linear;
- int max_size;
-
- linear = xf86AllocateOffscreenLinear(pScreen, length, granularity, moveCB, removeCB, privData);
- if (linear != NULL) return linear;
-
- /* The above allocation did not succeed, so purge unlocked stuff and try again. */
- xf86QueryLargestOffscreenLinear(pScreen, &max_size, granularity, PRIORITY_EXTREME);
-
- if (max_size < length) return NULL;
- xf86PurgeUnlockedOffscreenAreas(pScreen);
-
- linear = xf86AllocateOffscreenLinear(pScreen, length, granularity, moveCB, removeCB, privData);
- return linear;
-}
-#endif
-
static void *r128_crtc_shadow_allocate(xf86CrtcPtr crtc, int width, int height)
{
ScrnInfoPtr pScrn = crtc->scrn;
- ScreenPtr pScreen = xf86ScrnToScreen(pScrn);
R128InfoPtr info = R128PTR(pScrn);
R128CrtcPrivatePtr r128_crtc = crtc->driver_private;
@@ -271,38 +247,7 @@ static void *r128_crtc_shadow_allocate(xf86CrtcPtr crtc, int width, int height)
rotate_pitch = pScrn->displayWidth * cpp;
size = rotate_pitch * height;
-
-#ifdef USE_EXA
- if (info->ExaDriver) {
- assert(r128_crtc->rotate_mem_exa == NULL);
- r128_crtc->rotate_mem_exa = exaOffscreenAlloc(pScreen, size, align, TRUE, NULL, NULL);
-
- if (r128_crtc->rotate_mem_exa == NULL) {
- xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
- "Couldn't allocate shadow memory for rotated CRTC\n");
- return NULL;
- }
-
- rotate_offset = r128_crtc->rotate_mem_exa->offset;
- }
-#endif
-#ifdef HAVE_XAA_H
- if (info->accel) {
- size = (size + cpp - 1) / cpp;
- align = (align + cpp - 1) / cpp;
-
- assert(r128_crtc->rotate_mem_xaa == NULL);
- r128_crtc->rotate_mem_xaa = r128_xf86AllocateOffscreenLinear(pScreen, size, align, NULL, NULL, NULL);
-
- if (r128_crtc->rotate_mem_exa == NULL) {
- xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
- "Couldn't allocate shadow memory for rotated CRTC\n");
- return NULL;
- }
-
- rotate_offset = r128_crtc->rotate_mem_xaa->offset * cpp;
- }
-#endif
+ rotate_offset = R128AllocateMemory(pScrn, &(r128_crtc->rotate_mem), size, align, TRUE);
/* If allocations failed or if there was no accel. */
if (rotate_offset == 0)
@@ -347,19 +292,16 @@ static void r128_crtc_shadow_destroy(xf86CrtcPtr crtc, PixmapPtr rotate_pixmap,
if (rotate_pixmap) FreeScratchPixmapHeader(rotate_pixmap);
- if (data) {
+ if (data && r128_crtc->rotate_mem != NULL) {
#ifdef USE_EXA
- if (info->ExaDriver && r128_crtc->rotate_mem_exa != NULL) {
- exaOffscreenFree(pScreen, r128_crtc->rotate_mem_exa);
- r128_crtc->rotate_mem_exa = NULL;
- }
+ if (info->ExaDriver)
+ exaOffscreenFree(pScreen, (ExaOffscreenArea *) r128_crtc->rotate_mem);
#endif
#ifdef HAVE_XAA_H
- if (info->accel) {
- xf86FreeOffscreenLinear(r128_crtc->rotate_mem_xaa);
- r128_crtc->rotate_mem_xaa = NULL;
- }
+ if (info->accel)
+ xf86FreeOffscreenLinear((FBLinearPtr) r128_crtc->rotate_mem);
#endif
+ r128_crtc->rotate_mem = NULL;
}
}
diff --git a/src/r128_probe.h b/src/r128_probe.h
index 40fe82b..433463b 100644
--- a/src/r128_probe.h
+++ b/src/r128_probe.h
@@ -137,12 +137,7 @@ typedef struct {
} R128I2CBusRec, *R128I2CBusPtr;
typedef struct _R128CrtcPrivateRec {
-#ifdef HAVE_XAA_H
- FBLinearPtr rotate_mem_xaa;
-#endif
-#ifdef USE_EXA
- ExaOffscreenArea *rotate_mem_exa;
-#endif
+ void *rotate_mem;
int crtc_id;
uint32_t cursor_offset;
/* Lookup table values to be set when the CRTC is enabled */
diff --git a/src/r128_video.c b/src/r128_video.c
index bcf36fc..b0059b5 100644
--- a/src/r128_video.c
+++ b/src/r128_video.c
@@ -572,76 +572,78 @@ R128CopyData420(
}
-static uint32_t
+uint32_t
R128AllocateMemory(
ScrnInfoPtr pScrn,
void **mem_struct,
- int size
+ int size,
+ int align,
+ Bool need_accel
){
R128InfoPtr info = R128PTR(pScrn);
ScreenPtr pScreen = xf86ScrnToScreen(pScrn);
- int offset = 0;
+ Bool do_linear = !need_accel;
+ uint32_t offset = 0;
- if(!info->useEXA) {
+#ifdef HAVE_XAA_H
+ if (!info->accel && need_accel)
+ do_linear = FALSE;
+ else
+ do_linear = TRUE;
+#endif
+#ifdef USE_EXA
+ if (info->ExaDriver) {
+ ExaOffscreenArea *area = *mem_struct;
+
+ if (area != NULL) {
+ if (area->size >= size) return area->offset;
+
+ exaOffscreenFree(pScreen, area);
+ }
+
+ area = exaOffscreenAlloc(pScreen, size, align, TRUE, NULL, NULL);
+ *mem_struct = area;
+
+ if (area == NULL) return 0;
+ offset = area->offset;
+ }
+#endif
+ if (!info->useEXA && do_linear) {
FBLinearPtr linear = *mem_struct;
int cpp = info->CurrentLayout.pixel_bytes;
- /* XAA allocates in units of pixels at the screen bpp, so adjust size appropriately. */
- size = (size + cpp - 1) / cpp;
+ /* XAA allocates in units of pixels at the screen bpp, so adjust size appropriately. */
+ size = (size + cpp - 1) / cpp;
+ align = (align + cpp - 1) / cpp;
if(linear) {
- if(linear->size >= size)
- return linear->offset * cpp;
+ if(linear->size >= size)
+ return linear->offset * cpp;
- if(xf86ResizeOffscreenLinear(linear, size))
- return linear->offset * cpp;
+ if(xf86ResizeOffscreenLinear(linear, size))
+ return linear->offset * cpp;
- xf86FreeOffscreenLinear(linear);
+ xf86FreeOffscreenLinear(linear);
}
-
- linear = xf86AllocateOffscreenLinear(pScreen, size, 8,
- NULL, NULL, NULL);
+ linear = xf86AllocateOffscreenLinear(pScreen, size, align, NULL, NULL, NULL);
*mem_struct = linear;
if(!linear) {
- int max_size;
-
- xf86QueryLargestOffscreenLinear(pScreen, &max_size, 8,
- PRIORITY_EXTREME);
+ int max_size;
- if(max_size < size)
- return 0;
+ xf86QueryLargestOffscreenLinear(pScreen, &max_size, align, PRIORITY_EXTREME);
+ if(max_size < size) return 0;
- xf86PurgeUnlockedOffscreenAreas(pScreen);
- linear = xf86AllocateOffscreenLinear(pScreen, size, 8,
- NULL, NULL, NULL);
+ xf86PurgeUnlockedOffscreenAreas(pScreen);
+ linear = xf86AllocateOffscreenLinear(pScreen, size, align, NULL, NULL, NULL);
- if(!linear) return 0;
+ *mem_struct = linear;
+ if(!linear) return 0;
}
- offset = linear->offset * cpp;
+ offset = linear->offset * cpp;
}
-#ifdef USE_EXA
- else {
- /* EXA support based on mga driver */
- ExaOffscreenArea *area = *mem_struct;
-
- if(area) {
- if(area->size >= size)
- return area->offset;
-
- exaOffscreenFree(pScrn->pScreen, area);
- }
-
- area = exaOffscreenAlloc(pScrn->pScreen, size, 64, TRUE, NULL, NULL);
- *mem_struct = area;
-
- if(!area) return 0;
-
- offset = area->offset;
- }
-#endif
return offset;
}
@@ -929,11 +931,12 @@ R128PutImage(
break;
}
- if(!(pPriv->videoOffset = R128AllocateMemory(pScrn, &(pPriv->BufferHandle),
- pPriv->doubleBuffer ? (new_size << 1) : new_size)))
- {
- return BadAlloc;
- }
+ pPriv->videoOffset = R128AllocateMemory(pScrn, &(pPriv->BufferHandle),
+ pPriv->doubleBuffer ? (new_size << 1) : new_size,
+ 64, FALSE);
+
+ if (pPriv->videoOffset == 0)
+ return BadAlloc;
pPriv->currentBuffer ^= 1;
More information about the xorg-commit
mailing list