configure.ac | 118 ++++++++ man/r128.man | 21 + src/Makefile.am | 8 src/compat-api.h | 99 +++++++ src/r128.h | 98 ++++++- src/r128_accel.c | 48 +++ src/r128_cursor.c | 56 ++-- src/r128_dga.c | 20 - src/r128_dri.c | 90 +++++- src/r128_driver.c | 469 ++++++++++++++++++++++----------- src/r128_exa.c | 493 +++++++++++++++++++++++++++++++++++ src/r128_exa_render.c | 695 ++++++++++++++++++++++++++++++++++++++++++++++++++ src/r128_misc.c | 3 src/r128_probe.c | 4 src/r128_probe.h | 14 - src/r128_video.c | 158 ++++++++--- 16 files changed, 2137 insertions(+), 257 deletions(-)
New commits: commit ef4467b4aac70b9a8a1ef1194eb02d7551be2602 Author: Dave Airlie <airl...@redhat.com> Date: Fri Sep 28 11:25:17 2012 +1000 r128: bump to 6.9.1 Signed-off-by: Dave Airlie <airl...@redhat.com> diff --git a/configure.ac b/configure.ac index c5cbc69..38dc9bd 100644 --- a/configure.ac +++ b/configure.ac @@ -23,7 +23,7 @@ # Initialize Autoconf AC_PREREQ([2.60]) AC_INIT([xf86-video-r128], - [6.9.0], + [6.9.1], [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], [xf86-video-r128]) AC_CONFIG_SRCDIR([Makefile.am]) commit 1793fe6e84a0ee4e4924d90e9e777213a6a5ea20 Author: Dave Airlie <airl...@redhat.com> Date: Fri Sep 28 11:24:53 2012 +1000 fix make distcheck Signed-off-by: Dave Airlie <airl...@redhat.com> diff --git a/src/Makefile.am b/src/Makefile.am index 4ee9725..23e6c49 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -53,4 +53,5 @@ EXTRA_DIST = \ r128_reg.h \ r128_sarea.h \ r128_version.h \ + r128_exa_render.c \ atipcirename.h commit e0222a5f5e7cad482044a542e4b1ebc32f774648 Author: Dave Airlie <airl...@redhat.com> Date: Fri Sep 28 11:22:40 2012 +1000 r128: bump release to 6.9.0 Signed-off-by: Dave Airlie <airl...@redhat.com> diff --git a/configure.ac b/configure.ac index edb65a3..c5cbc69 100644 --- a/configure.ac +++ b/configure.ac @@ -23,7 +23,7 @@ # Initialize Autoconf AC_PREREQ([2.60]) AC_INIT([xf86-video-r128], - [6.8.4], + [6.9.0], [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg], [xf86-video-r128]) AC_CONFIG_SRCDIR([Makefile.am]) commit e8b741e8fd4acebd79ee495cdd5437746ae80c39 Author: Dave Airlie <airl...@redhat.com> Date: Fri Sep 28 11:20:41 2012 +1000 r128: enable EXA by default if XAA isn't available at build time. Signed-off-by: Dave Airlie <airl...@redhat.com> diff --git a/src/r128_driver.c b/src/r128_driver.c index ae16e97..a062a60 100644 --- a/src/r128_driver.c +++ b/src/r128_driver.c @@ -2251,6 +2251,11 @@ Bool R128ScreenInit(SCREEN_INIT_ARGS_DECL) R128TRACE(("R128ScreenInit %x %d\n", pScrn->memPhysBase, pScrn->fbOffset)); info->useEXA = FALSE; +#ifdef USE_EXA +#ifndef HAVE_XAA_H + info->useEXA = TRUE; +#endif +#endif #ifdef USE_EXA optstr = (char *)xf86GetOptValString(info->Options, OPTION_ACCELMETHOD); commit 4ecd6e67fbbfd52e0ac77a6c48bd3c6a6d5598e7 Author: Connor Behan <connor.be...@gmail.com> Date: Fri Aug 31 00:19:21 2012 -0700 Scale Xv with the vertical stretch ratio If we are using a resolution lower than the native resolution of the flat panel, the video overlay needs to know this. Otherwise a black bar appears beneath the video. This is essentially Conn's patch from the bug tracker except it doesn't always rely on info->PanelYRes. ACPI events can change this without the driver's knowledge. Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=6493 Signed-off-by: Connor Behan <connor.be...@gmail.com> diff --git a/src/r128_video.c b/src/r128_video.c index 4507b30..bb5a655 100644 --- a/src/r128_video.c +++ b/src/r128_video.c @@ -661,13 +661,25 @@ R128DisplayVideo422( R128InfoPtr info = R128PTR(pScrn); unsigned char *R128MMIO = info->MMIO; R128PortPrivPtr pPriv = info->adaptor->pPortPrivates[0].ptr; - int v_inc, h_inc, step_by, tmp; + int v_inc, h_inc, step_by, tmp, v_inc_shift; int p1_h_accum_init, p23_h_accum_init; int p1_v_accum_init; + Bool rmx_active; R128ECP(pScrn, pPriv); - v_inc = (src_h << 20) / drw_h; + v_inc_shift = 20; + if (pScrn->currentMode->Flags & V_INTERLACE) + v_inc_shift++; + if (pScrn->currentMode->Flags & V_DBLSCAN) + v_inc_shift--; + + rmx_active = INREG(R128_FP_VERT_STRETCH) & R128_VERT_STRETCH_ENABLE; + if (rmx_active) { + v_inc = ((src_h * pScrn->currentMode->CrtcVDisplay / info->PanelYRes) << v_inc_shift) / drw_h; + } else { + v_inc = (src_h << v_inc_shift) / drw_h; + } h_inc = (src_w << (12 + pPriv->ecp_div)) / drw_w; step_by = 1; @@ -735,11 +747,23 @@ R128DisplayVideo420( R128InfoPtr info = R128PTR(pScrn); unsigned char *R128MMIO = info->MMIO; R128PortPrivPtr pPriv = info->adaptor->pPortPrivates[0].ptr; - int v_inc, h_inc, step_by, tmp, leftUV; + int v_inc, h_inc, step_by, tmp, leftUV, v_inc_shift; int p1_h_accum_init, p23_h_accum_init; int p1_v_accum_init, p23_v_accum_init; - - v_inc = (src_h << 20) / drw_h; + Bool rmx_active; + + v_inc_shift = 20; + if (pScrn->currentMode->Flags & V_INTERLACE) + v_inc_shift++; + if (pScrn->currentMode->Flags & V_DBLSCAN) + v_inc_shift--; + + rmx_active = INREG(R128_FP_VERT_STRETCH) & R128_VERT_STRETCH_ENABLE; + if (rmx_active) { + v_inc = ((src_h * pScrn->currentMode->CrtcVDisplay / info->PanelYRes) << v_inc_shift) / drw_h; + } else { + v_inc = (src_h << v_inc_shift) / drw_h; + } h_inc = (src_w << (12 + pPriv->ecp_div)) / drw_w; step_by = 1; commit 7f279e9d4e329ccb95de16f205ea4cd0ab37a65b Author: Connor Behan <connor.be...@gmail.com> Date: Wed Aug 29 16:06:39 2012 -0700 Remove nested preprocessor checks When checking for R128DRI and RENDER, it is better to use two lines instead of four. Signed-off-by: Connor Behan <connor.be...@gmail.com> diff --git a/src/r128.h b/src/r128.h index 9b2556f..9c0ecb6 100644 --- a/src/r128.h +++ b/src/r128.h @@ -284,8 +284,7 @@ struct r128_2d_state { uint32_t dp_src_frgd_clr; uint32_t dp_src_bkgd_clr; uint32_t default_sc_bottom_right; -#ifdef R128DRI -#ifdef RENDER +#if defined(R128DRI) && defined(RENDER) Bool has_mask; int x_offset; int y_offset; @@ -296,7 +295,6 @@ struct r128_2d_state { PixmapPtr src_pix; PixmapPtr msk_pix; #endif -#endif }; #endif diff --git a/src/r128_exa.c b/src/r128_exa.c index b3e2406..2a628a8 100644 --- a/src/r128_exa.c +++ b/src/r128_exa.c @@ -335,8 +335,7 @@ R128Done(PixmapPtr pPixmap) R128InfoPtr info = R128PTR(pScrn); info->state_2d.in_use = FALSE; -#ifdef R128DRI -#ifdef RENDER +#if defined(R128DRI) && defined(RENDER) if (info->state_2d.src_pix) { pScreen->DestroyPixmap(info->state_2d.src_pix); info->state_2d.src_pix = NULL; @@ -346,7 +345,6 @@ R128Done(PixmapPtr pPixmap) info->state_2d.msk_pix = NULL; } #endif -#endif } #ifdef R128DRI commit deb05ac9cf58608b3d8d9947f52e9bcc5e0ae6b5 Author: Connor Behan <connor.be...@gmail.com> Date: Mon Jul 30 14:28:05 2012 +1000 Fix build without XAA again referring to info->accel instead of info->accelOn Signed-off-by: Connor Behan <connor.be...@gmail.com> Signed-off-by: Dave Airlie <airl...@redhat.com> diff --git a/src/r128_accel.c b/src/r128_accel.c index 1df4eb8..1b8c023 100644 --- a/src/r128_accel.c +++ b/src/r128_accel.c @@ -1875,7 +1875,6 @@ Bool R128AccelInit(ScreenPtr pScreen) { ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); R128InfoPtr info = R128PTR(pScrn); - XAAInfoRecPtr a; #ifdef USE_EXA if (info->useEXA) { @@ -1895,15 +1894,18 @@ Bool R128AccelInit(ScreenPtr pScreen) info->ExaDriver = exaDriverAlloc(); if (!info->ExaDriver) { xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Could not allocate EXA driver...\n"); - info->accel = FALSE; + info->accelOn = FALSE; } return TRUE; } #endif + #ifndef HAVE_XAA_H return FALSE; #else + XAAInfoRecPtr a; + if (!info->useEXA) { if (!xf86LoadSubModule(pScrn, "xaa")) return FALSE; } commit 310d998b7bb6d1befb1001deb565fb51a4b17013 Author: Connor Behan <connor.be...@gmail.com> Date: Fri Jul 27 11:49:38 2012 +1000 r128: fix missing preprocessor check for R128DRI This fixes one build problem seen in tinderbox. [airlied: split out from larger patch] Signed-off-by: Connor Behan <connor.be...@gmail.com> Signed-off-by: Dave Airlie <airl...@redhat.com> diff --git a/src/r128_exa.c b/src/r128_exa.c index 8fb8b64..b3e2406 100644 --- a/src/r128_exa.c +++ b/src/r128_exa.c @@ -142,6 +142,7 @@ static void Emit2DState(ScrnInfoPtr pScrn) if (has_src) OUTREG(R128_SRC_PITCH_OFFSET, info->state_2d.src_pitch_offset); } +#ifdef R128DRI static void EmitCCE2DState(ScrnInfoPtr pScrn) { R128InfoPtr info = R128PTR(pScrn); @@ -166,6 +167,7 @@ static void EmitCCE2DState(ScrnInfoPtr pScrn) ADVANCE_RING(); } +#endif /* EXA Callbacks */ commit f83ee3144236bcca35eeadee2924e8bc15092447 Author: Connor Behan <connor.be...@gmail.com> Date: Tue Jul 17 22:53:17 2012 -0700 Fix build without EXA The offscreen area used by EXA needs to be declared even with lazy evaluation. Signed-off-by: Connor Behan <connor.be...@gmail.com> diff --git a/src/r128_cursor.c b/src/r128_cursor.c index 974a6d5..b76913c 100644 --- a/src/r128_cursor.c +++ b/src/r128_cursor.c @@ -261,6 +261,8 @@ Bool R128CursorInit(ScreenPtr pScreen) FBAreaPtr fbarea = NULL; #ifdef USE_EXA ExaOffscreenArea* osArea = NULL; +#else + void* osArea = NULL; #endif int width; int height; diff --git a/src/r128_driver.c b/src/r128_driver.c index f4a5e1b..ae16e97 100644 --- a/src/r128_driver.c +++ b/src/r128_driver.c @@ -2244,6 +2244,8 @@ Bool R128ScreenInit(SCREEN_INIT_ARGS_DECL) Bool noAccel; #ifdef USE_EXA ExaOffscreenArea* osArea = NULL; +#else + void* osArea = NULL; #endif char *optstr; commit 599c69a9cbf78c8717fb9ec92d9e764d9b358cf3 Author: Connor Behan <connor.be...@gmail.com> Date: Tue Jul 17 22:33:43 2012 -0700 Make debug mode work again The source should not assume that debugging is turned off. It should build even if the user edits r128.h and enables it. Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=47785 Signed-off-by: Connor Behan <connor.be...@gmail.com> diff --git a/src/r128.h b/src/r128.h index fe42f79..9b2556f 100644 --- a/src/r128.h +++ b/src/r128.h @@ -118,6 +118,7 @@ #define R128_VBIOS_SIZE 0x00010000 #if R128_DEBUG +#include "r128_version.h" #define R128TRACE(x) \ do { \ diff --git a/src/r128_driver.c b/src/r128_driver.c index bb03e80..f4a5e1b 100644 --- a/src/r128_driver.c +++ b/src/r128_driver.c @@ -3043,11 +3043,11 @@ static void R128RestorePLL2Registers(ScrnInfoPtr pScrn, R128SavePtr restore) restore->p2pll_ref_div, restore->p2pll_div_0, restore->htotal_cntl2, - INPLL(pScrn, RADEON_P2PLL_CNTL))); + INPLL(pScrn, R128_P2PLL_CNTL))); R128TRACE(("Wrote: rd=%d, fd=%d, pd=%d\n", - restore->p2pll_ref_div & RADEON_P2PLL_REF_DIV_MASK, - restore->p2pll_div_0 & RADEON_P2PLL_FB3_DIV_MASK, - (restore->p2pll_div_0 & RADEON_P2PLL_POST3_DIV_MASK) >>16)); + restore->p2pll_ref_div & R128_P2PLL_REF_DIV_MASK, + restore->p2pll_div_0 & R128_P2PLL_FB0_DIV_MASK, + (restore->p2pll_div_0 & R128_P2PLL_POST0_DIV_MASK) >>16)); usleep(5000); /* Let the clock to lock */ @@ -3895,8 +3895,8 @@ static void R128InitPLLRegisters(ScrnInfoPtr pScrn, R128SavePtr save, } /* Define PLL2 registers for requested video mode. */ -static void R128InitPLL2Registers(R128SavePtr save, R128PLLPtr pll, - double dot_clock) +static void R128InitPLL2Registers(ScrnInfoPtr pScrn, R128SavePtr save, + R128PLLPtr pll, double dot_clock) { unsigned long freq = dot_clock * 100; struct { @@ -4158,7 +4158,7 @@ static Bool R128Init(ScrnInfoPtr pScrn, DisplayModePtr mode, R128SavePtr save) if (!R128InitCrtc2Registers(pScrn, save, pScrn->currentMode,info)) return FALSE; - R128InitPLL2Registers(save, &info->pll, dot_clock); + R128InitPLL2Registers(pScrn, save, &info->pll, dot_clock); if (!R128InitDDA2Registers(pScrn, save, &info->pll, info, mode)) return FALSE; } commit c16d4e8bc068cb8127fa95347d26c7b80258f816 Author: Connor Behan <connor.be...@gmail.com> Date: Mon Jul 16 12:56:00 2012 -0700 Add EXA support This introduces EXA acceleration which can improve performance and allow 2D acceleration to be used without XAA. Implemented hooks are Solid, Copy and Composite. They appear to pass all rendercheck tests, except the gradient test which XAA also fails. Tested on multiple color depths, with and without DRI, with and without the composite extension. Hardware cursor, Xvideo and page flipping are supported as well. Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=47866 [ Michel Dänzer: Drop unrelated addition of #include "r128_version.h" ] Signed-off-by: Connor Behan <connor.be...@gmail.com> Signed-off-by: Michel Dänzer <michel.daen...@amd.com> diff --git a/configure.ac b/configure.ac index e45a402..edb65a3 100644 --- a/configure.ac +++ b/configure.ac @@ -63,6 +63,11 @@ AC_ARG_ENABLE(dri, AS_HELP_STRING([--disable-dri], [DRI="$enableval"], [DRI=auto]) +AC_ARG_ENABLE(exa, AS_HELP_STRING([--disable-exa], + [Disable EXA support [[default=enabled]]]), + [EXA="$enableval"], + [EXA=yes]) + # Store the list of server defined optional extensions in REQUIRED_MODULES XORG_DRIVER_CHECK_EXT(RANDR, randrproto) XORG_DRIVER_CHECK_EXT(RENDER, renderproto) @@ -112,6 +117,39 @@ fi SAVE_CPPFLAGS="$CPPFLAGS" CPPFLAGS="$CPPFLAGS $XORG_CFLAGS" +# Properly handle EXA. +AC_MSG_CHECKING([whether to enable EXA support]) +if test "x$EXA" = xyes; then + AC_MSG_RESULT(yes) + + SAVE_CPPFLAGS="$CPPFLAGS" + CPPFLAGS="$CPPFLAGS $XORG_CFLAGS" + AC_CHECK_HEADER(exa.h, + [have_exa_h="yes"], [have_exa_h="no"]) + CPPFLAGS="$SAVE_CPPFLAGS" +else + AC_MSG_RESULT(no) +fi + +SAVE_CPPFLAGS="$CPPFLAGS" +CPPFLAGS="$CPPFLAGS $XORG_CFLAGS" +if test "x$have_exa_h" = xyes; then + AC_MSG_CHECKING([whether EXA version is at least 2.0.0]) + AC_PREPROC_IFELSE([AC_LANG_PROGRAM([[ +#include "exa.h" +#if EXA_VERSION_MAJOR < 2 +#error OLD EXA! +#endif + ]])], + [USE_EXA=yes], + [USE_EXA=no]) + AC_MSG_RESULT($USE_EXA) + + if test "x$USE_EXA" = xyes; then + AC_DEFINE(USE_EXA, 1, [Build support for Exa]) + fi +fi + AC_CHECK_DECL(XSERVER_LIBPCIACCESS, [XSERVER_LIBPCIACCESS=yes],[XSERVER_LIBPCIACCESS=no], [#include "xorg-server.h"]) @@ -143,6 +181,66 @@ if test "x$XSERVER_LIBPCIACCESS" = xyes; then fi AM_CONDITIONAL(XSERVER_LIBPCIACCESS, test "x$XSERVER_LIBPCIACCESS" = xyes) +# Checks for headers/macros for byte swapping +# Known variants: +# <byteswap.h> bswap_16, bswap_32, bswap_64 (glibc) +# <sys/endian.h> __swap16, __swap32, __swap64 (OpenBSD) +# <sys/endian.h> bswap16, bswap32, bswap64 (other BSD's) +# and a fallback to local macros if none of the above are found + +# if <byteswap.h> is found, assume it's the correct version +AC_CHECK_HEADERS([byteswap.h]) + +# if <sys/endian.h> is found, have to check which version +AC_CHECK_HEADER([sys/endian.h], [HAVE_SYS_ENDIAN_H="yes"], [HAVE_SYS_ENDIAN_H="no"]) + +if test "x$HAVE_SYS_ENDIAN_H" = "xyes" ; then + AC_MSG_CHECKING([for __swap16 variant of <sys/endian.h> byteswapping macros]) + AC_LINK_IFELSE([AC_LANG_PROGRAM([ +#include <sys/types.h> +#include <sys/endian.h> + ], [ +int a = 1, b; +b = __swap16(a); + ]) +], [SYS_ENDIAN__SWAP='yes'], [SYS_ENDIAN__SWAP='no']) + AC_MSG_RESULT([$SYS_ENDIAN__SWAP]) + + AC_MSG_CHECKING([for bswap16 variant of <sys/endian.h> byteswapping macros]) + AC_LINK_IFELSE([AC_LANG_PROGRAM([ +#include <sys/types.h> +#include <sys/endian.h> + ], [ +int a = 1, b; +b = bswap16(a); + ]) +], [SYS_ENDIAN_BSWAP='yes'], [SYS_ENDIAN_BSWAP='no']) + AC_MSG_RESULT([$SYS_ENDIAN_BSWAP]) + + if test "$SYS_ENDIAN_BSWAP" = "yes" ; then + USE_SYS_ENDIAN_H=yes + BSWAP=bswap + else + if test "$SYS_ENDIAN__SWAP" = "yes" ; then + USE_SYS_ENDIAN_H=yes + BSWAP=__swap + else + USE_SYS_ENDIAN_H=no + fi + fi + + if test "$USE_SYS_ENDIAN_H" = "yes" ; then + AC_DEFINE([USE_SYS_ENDIAN_H], 1, + [Define to use byteswap macros from <sys/endian.h>]) + AC_DEFINE_UNQUOTED([bswap_16], ${BSWAP}16, + [Define to 16-bit byteswap macro]) + AC_DEFINE_UNQUOTED([bswap_32], ${BSWAP}32, + [Define to 32-bit byteswap macro]) + AC_DEFINE_UNQUOTED([bswap_64], ${BSWAP}64, + [Define to 64-bit byteswap macro]) + fi +fi + AC_SUBST([moduledir]) DRIVER_NAME=r128 diff --git a/man/r128.man b/man/r128.man index 4ba933d..d490f93 100644 --- a/man/r128.man +++ b/man/r128.man @@ -57,6 +57,27 @@ Enables or disables all hardware acceleration. The default is to .B enable hardware acceleration. .TP +.BI "Option \*qEnablePageFlip\*q \*q" boolean \*q +Enable page flipping for 3D acceleration. This will increase performance +but not work correctly in some rare cases, hence the default is +.B off. +.TP +.BI "Option \*qRenderAccel\*q \*q" boolean \*q +Enables or disables hardware Render acceleration. It is only supported when +using EXA acceleration and DRI. The default is to +.B enable +Render acceleration. +.TP +.BI "Option \*qAccelMethod\*q \*q" "string" \*q +Chooses between available acceleration architectures. Valid options are +.B XAA +and +.B EXA. +XAA is the traditional acceleration architecture and support for it is very +stable. EXA is a newer acceleration architecture with better performance for +the Render and Composite extensions. The default is +.B XAA. +.TP .BI "Option \*qDac6Bit\*q \*q" boolean \*q Enables or disables the use of 6 bits per color component when in 8 bpp mode (emulates VGA mode). By default, all 8 bits per color component diff --git a/src/Makefile.am b/src/Makefile.am index f8bc8d1..4ee9725 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -30,6 +30,10 @@ if DRI R128_DRI_SRCS = r128_dri.c endif +if USE_EXA +R128_EXA_SRCS = r128_exa.c +endif + AM_CFLAGS = @XORG_CFLAGS@ @DRI_CFLAGS@ r128_drv_la_LTLIBRARIES = r128_drv.la @@ -37,7 +41,7 @@ r128_drv_la_LDFLAGS = -module -avoid-version r128_drv_ladir = @moduledir@/drivers r128_drv_la_SOURCES = \ r128_accel.c r128_cursor.c r128_dga.c r128_driver.c \ - r128_video.c r128_misc.c r128_probe.c $(R128_DRI_SRCS) + r128_video.c r128_misc.c r128_probe.c $(R128_EXA_SRCS) $(R128_DRI_SRCS) EXTRA_DIST = \ compat-api.h \ diff --git a/src/r128.h b/src/r128.h index bee1562..fe42f79 100644 --- a/src/r128.h +++ b/src/r128.h @@ -43,6 +43,11 @@ /* PCI support */ #include "xf86Pci.h" + /* EXA support */ +#ifdef USE_EXA +#include "exa.h" +#endif + /* XAA and Cursor Support */ #ifdef HAVE_XAA_H #include "xaa.h" @@ -75,6 +80,36 @@ #include "r128_probe.h" +#if HAVE_BYTESWAP_H +#include <byteswap.h> +#elif defined(USE_SYS_ENDIAN_H) +#include <sys/endian.h> +#else +#define bswap_16(value) \ + ((((value) & 0xff) << 8) | ((value) >> 8)) + +#define bswap_32(value) \ + (((uint32_t)bswap_16((uint16_t)((value) & 0xffff)) << 16) | \ + (uint32_t)bswap_16((uint16_t)((value) >> 16))) + +#define bswap_64(value) \ + (((uint64_t)bswap_32((uint32_t)((value) & 0xffffffff)) \ + << 32) | \ + (uint64_t)bswap_32((uint32_t)((value) >> 32))) +#endif + +#if X_BYTE_ORDER == X_BIG_ENDIAN +#define le32_to_cpu(x) bswap_32(x) +#define le16_to_cpu(x) bswap_16(x) +#define cpu_to_le32(x) bswap_32(x) +#define cpu_to_le16(x) bswap_16(x) +#else +#define le32_to_cpu(x) (x) +#define le16_to_cpu(x) (x) +#define cpu_to_le32(x) (x) +#define cpu_to_le16(x) (x) +#endif + #define R128_DEBUG 0 /* Turn off debugging output */ #define R128_IDLE_RETRY 32 /* Fall out of idle loops after this count */ #define R128_TIMEOUT 2000000 /* Fall out of wait loops after this count */ @@ -83,6 +118,7 @@ #define R128_VBIOS_SIZE 0x00010000 #if R128_DEBUG + #define R128TRACE(x) \ do { \ ErrorF("(**) %s(%d): ", R128_NAME, pScrn->scrnIndex); \ @@ -233,6 +269,36 @@ typedef enum MT_STV } R128MonitorType; +#ifdef USE_EXA +struct r128_2d_state { + Bool in_use; + Bool composite_setup; + uint32_t dst_pitch_offset; + uint32_t src_pitch_offset; + uint32_t dp_gui_master_cntl; + uint32_t dp_cntl; + uint32_t dp_write_mask; + uint32_t dp_brush_frgd_clr; + uint32_t dp_brush_bkgd_clr; + uint32_t dp_src_frgd_clr; + uint32_t dp_src_bkgd_clr; + uint32_t default_sc_bottom_right; +#ifdef R128DRI +#ifdef RENDER + Bool has_mask; + int x_offset; + int y_offset; + int widths[2]; + int heights[2]; + Bool is_transform[2]; + PictTransform *transform[2]; + PixmapPtr src_pix; + PixmapPtr msk_pix; +#endif +#endif +}; +#endif + typedef struct { EntityInfoPtr pEnt; pciVideoPtr PciInfo; @@ -285,6 +351,15 @@ typedef struct { XAAInfoRecPtr accel; #endif Bool accelOn; + + Bool useEXA; + Bool RenderAccel; +#ifdef USE_EXA + ExaDriverPtr ExaDriver; + XF86ModReqInfo exaReq; + struct r128_2d_state state_2d; +#endif + xf86CursorInfoPtr cursor; unsigned long cursor_start; unsigned long cursor_end; @@ -529,6 +604,14 @@ extern void R128CCEReleaseIndirect(ScrnInfoPtr pScrn); extern void R128CCEWaitForIdle(ScrnInfoPtr pScrn); extern int R128CCEStop(ScrnInfoPtr pScrn); +#ifdef USE_EXA +extern Bool R128EXAInit(ScreenPtr pScreen); +extern Bool R128GetDatatypeBpp(int bpp, uint32_t *type); +extern Bool R128GetPixmapOffsetPitch(PixmapPtr pPix, uint32_t *pitch_offset); +extern void R128DoPrepareCopy(ScrnInfoPtr pScrn, uint32_t src_pitch_offset, + uint32_t dst_pitch_offset, uint32_t datatype, int alu, Pixel planemask); +#endif + #define CCE_PACKET0( reg, n ) \ (R128_CCE_PACKET0 | ((n) << 16) | ((reg) >> 2)) diff --git a/src/r128_accel.c b/src/r128_accel.c index defc076..1df4eb8 100644 --- a/src/r128_accel.c +++ b/src/r128_accel.c @@ -1641,7 +1641,6 @@ void R128CCEFlushIndirect( ScrnInfoPtr pScrn, int discard ) info->indirectStart = buffer->used; } -#ifdef HAVE_XAA_H /* Flush and release the indirect buffer. */ void R128CCEReleaseIndirect( ScrnInfoPtr pScrn ) @@ -1666,6 +1665,7 @@ void R128CCEReleaseIndirect( ScrnInfoPtr pScrn ) &indirect, sizeof(drmR128Indirect)); } +#ifdef HAVE_XAA_H /* This callback is required for multihead cards using XAA */ static void R128RestoreCCEAccelState(ScrnInfoPtr pScrn) @@ -1873,15 +1873,40 @@ static void R128MMIOAccelInit(ScrnInfoPtr pScrn, XAAInfoRecPtr a) graphics hardware for acceleration. */ Bool R128AccelInit(ScreenPtr pScreen) { -#ifndef HAVE_XAA_H - return FALSE; -#else ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); R128InfoPtr info = R128PTR(pScrn); XAAInfoRecPtr a; - if (!xf86LoadSubModule(pScrn, "xaa")) - return FALSE; +#ifdef USE_EXA + if (info->useEXA) { + int errmaj = 0, errmin = 0; + + info->exaReq.majorversion = EXA_VERSION_MAJOR; + info->exaReq.minorversion = EXA_VERSION_MINOR; + + xf86DrvMsg(pScrn->scrnIndex,X_INFO,"Loading EXA module...\n"); + if (!LoadSubModule(pScrn->module, "exa", NULL, NULL, NULL, &info->exaReq, &errmaj, &errmin)) { + LoaderErrorMsg(NULL, "exa", errmaj, errmin); + return FALSE; + } + + /* Don't init EXA here because it'll be taken care of in mm init */ + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Allocating EXA driver...\n"); + info->ExaDriver = exaDriverAlloc(); + if (!info->ExaDriver) { + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Could not allocate EXA driver...\n"); + info->accel = FALSE; + } + + return TRUE; + } +#endif +#ifndef HAVE_XAA_H + return FALSE; +#else + if (!info->useEXA) { + if (!xf86LoadSubModule(pScrn, "xaa")) return FALSE; + } if (!(a = info->accel = XAACreateInfoRec())) return FALSE; diff --git a/src/r128_cursor.c b/src/r128_cursor.c index 62d277d..974a6d5 100644 --- a/src/r128_cursor.c +++ b/src/r128_cursor.c @@ -54,6 +54,11 @@ /* X and server generic header files */ #include "xf86.h" + /* Because for EXA we need to use a different allocator */ +#ifdef USE_EXA +#include "exa.h" +#endif + #if X_BYTE_ORDER == X_BIG_ENDIAN #define P_SWAP32( a , b ) \ ((char *)a)[0] = ((char *)b)[3]; \ @@ -253,11 +258,15 @@ Bool R128CursorInit(ScreenPtr pScreen) ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); R128InfoPtr info = R128PTR(pScrn); xf86CursorInfoPtr cursor; - FBAreaPtr fbarea; + FBAreaPtr fbarea = NULL; +#ifdef USE_EXA + ExaOffscreenArea* osArea = NULL; +#endif int width; int height; int size; + int cpp = info->CurrentLayout.pixel_bytes; if (!(cursor = info->cursor = xf86CreateCursorInfoRec())) return FALSE; @@ -284,24 +293,35 @@ Bool R128CursorInit(ScreenPtr pScreen) size = (cursor->MaxWidth/4) * cursor->MaxHeight; width = pScrn->displayWidth; height = (size*2 + 1023) / pScrn->displayWidth; - fbarea = xf86AllocateOffscreenArea(pScreen, - width, - height, - 16, - NULL, - NULL, - NULL); - - if (!fbarea) { + + if(!info->useEXA) { + fbarea = xf86AllocateOffscreenArea(pScreen, width, height, + 16, NULL, NULL, NULL); + + if (fbarea) { + info->cursor_start = R128_ALIGN((fbarea->box.x1 + + width * fbarea->box.y1) + * cpp, 16); + info->cursor_end = info->cursor_start + size; + } + } +#ifdef USE_EXA + else { + osArea = exaOffscreenAlloc(pScreen, width * height, 16, + TRUE, NULL, NULL); + + if (osArea) { + info->cursor_start = osArea->offset; + info->cursor_end = osArea->offset + osArea->size; + } + } +#endif + + if ((!info->useEXA && !fbarea) || (info->useEXA && !osArea)) { info->cursor_start = 0; xf86DrvMsg(pScrn->scrnIndex, X_WARNING, "Hardware cursor disabled" " due to insufficient offscreen memory\n"); - } else { - info->cursor_start = R128_ALIGN((fbarea->box.x1 - + width * fbarea->box.y1) - * info->CurrentLayout.pixel_bytes, 16); - info->cursor_end = info->cursor_start + size; } R128TRACE(("R128CursorInit (0x%08x-0x%08x)\n", diff --git a/src/r128_dri.c b/src/r128_dri.c index 09b3cff..67e8d1d 100644 --- a/src/r128_dri.c +++ b/src/r128_dri.c @@ -301,11 +301,16 @@ static void R128DestroyContext(ScreenPtr pScreen, drm_context_t hwContext, can start/stop the engine. */ static void R128EnterServer(ScreenPtr pScreen) { -#ifdef HAVE_XAA_H ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); R128InfoPtr info = R128PTR(pScrn); + +#ifdef HAVE_XAA_H if (info->accel) info->accel->NeedToSync = TRUE; #endif +#ifdef USE_EXA + if (info->ExaDriver) exaMarkSync(pScreen); + info->state_2d.composite_setup = FALSE; +#endif } /* Called when the X server goes to sleep to allow the X server's @@ -1390,11 +1395,10 @@ void R128DRICloseScreen(ScreenPtr pScreen) static void R128DRIRefreshArea(ScrnInfoPtr pScrn, int num, BoxPtr pbox) { -#ifdef HAVE_XAA_H R128InfoPtr info = R128PTR(pScrn); int i; -#endif R128SAREAPrivPtr pSAREAPriv = DRIGetSAREAPrivate(pScrn->pScreen); + PixmapPtr pPix = pScrn->pScreen->GetScreenPixmap(pScrn->pScreen); /* Don't want to do this when no 3d is active and pages are * right-way-round @@ -1403,49 +1407,89 @@ static void R128DRIRefreshArea(ScrnInfoPtr pScrn, int num, BoxPtr pbox) return; #ifdef HAVE_XAA_H - (*info->accel->SetupForScreenToScreenCopy)(pScrn, + if (!info->useEXA) { + (*info->accel->SetupForScreenToScreenCopy)(pScrn, 1, 1, GXcopy, (CARD32)(-1), -1); + } +#endif +#ifdef USE_EXA + if (info->useEXA) { + CARD32 src_pitch_offset, dst_pitch_offset, datatype; + + R128GetPixmapOffsetPitch(pPix, &src_pitch_offset); + dst_pitch_offset = src_pitch_offset + (info->backOffset >> 5); + R128GetDatatypeBpp(pScrn->bitsPerPixel, &datatype); + info->xdir = info->ydir = 1; + + R128DoPrepareCopy(pScrn, src_pitch_offset, dst_pitch_offset, datatype, GXcopy, ~0); + } +#endif for (i = 0 ; i < num ; i++, pbox++) { int xa = max(pbox->x1, 0), xb = min(pbox->x2, pScrn->virtualX-1); int ya = max(pbox->y1, 0), yb = min(pbox->y2, pScrn->virtualY-1); if (xa <= xb && ya <= yb) { - (*info->accel->SubsequentScreenToScreenCopy)(pScrn, xa, ya, +#ifdef HAVE_XAA_H + if (!info->useEXA) { + (*info->accel->SubsequentScreenToScreenCopy)(pScrn, xa, ya, xa + info->backX, ya + info->backY, xb - xa + 1, yb - ya + 1); + } +#endif +#ifdef USE_EXA + if (info->useEXA) { + (*info->ExaDriver->Copy)(pPix, xa, ya, xa, ya, xb - xa + 1, yb - ya + 1); + } +#endif } } -#endif } static void R128EnablePageFlip(ScreenPtr pScreen) { -#ifdef HAVE_XAA_H ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); R128InfoPtr info = R128PTR(pScrn); R128SAREAPrivPtr pSAREAPriv = DRIGetSAREAPrivate(pScreen); + PixmapPtr pPix = pScreen->GetScreenPixmap(pScreen); if (info->allowPageFlip) { /* Duplicate the frontbuffer to the backbuffer */ - (*info->accel->SetupForScreenToScreenCopy)(pScrn, +#ifdef HAVE_XAA_H + if (!info->useEXA) { + (*info->accel->SetupForScreenToScreenCopy)(pScrn, 1, 1, GXcopy, (CARD32)(-1), -1); - (*info->accel->SubsequentScreenToScreenCopy)(pScrn, + (*info->accel->SubsequentScreenToScreenCopy)(pScrn, 0, 0, info->backX, -- To UNSUBSCRIBE, email to debian-x-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org Archive: http://lists.debian.org/e1vhx1y-0002tq...@vasks.debian.org