[Intel-gfx] [PATCH] Fix UXA for server 1.4.

Eric Anholt eric at anholt.net
Wed Feb 25 07:42:46 CET 2009


---
 Makefile.am       |    6 +----
 configure.ac      |   19 +++++++--------
 src/Makefile.am   |    9 ++-----
 src/i830.h        |    4 +++
 src/i830_driver.c |    4 ++-
 src/i830_exa.c    |   50 +++++++++++++++++++++++++++++++++++------
 uxa/uxa-accel.c   |   62 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 uxa/uxa-glyphs.c  |    4 +++
 uxa/uxa-priv.h    |   22 ++++++++++++++++++-
 uxa/uxa-render.c  |    5 ++++
 uxa/uxa-unaccel.c |   18 +++++++++++++++
 uxa/uxa.c         |   31 +++++++++++++++++++++++++-
 12 files changed, 202 insertions(+), 32 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index 896427f..d1118fe 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -20,11 +20,7 @@
 
 AUTOMAKE_OPTIONS = foreign
 
-if BUILD_UXA
-UXA_DIR = uxa
-endif
-
-SUBDIRS = $(UXA_DIR) src man
+SUBDIRS = uxa src man
 
 EXTRA_DIST = README
 DISTCLEANFILES = doltcompile
diff --git a/configure.ac b/configure.ac
index a6ced67..3f6f1b8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -84,7 +84,13 @@ XORG_DRIVER_CHECK_EXT(DPMSExtension, xextproto)
 
 # Checks for pkg-config packages
 PKG_CHECK_MODULES(XORG, [xorg-server xproto fontsproto $REQUIRED_MODULES])
-PKG_CHECK_MODULES(UXA, [xorg-server >= 1.5], [BUILD_UXA=yes], [BUILD_UXA=no])
+
+PKG_CHECK_MODULES(SERVER_1_5, [xorg-server >= 1.5],
+			      [SERVER_1_5=yes], [SERVER_1_5=no])
+
+if test "$SERVER_1_5" = yes; then
+   AC_DEFINE(SERVER_1_5, 1, [Building against server 1.5])
+fi
 
 sdkdir=$(pkg-config --variable=sdkdir xorg-server)
 drm_cflags=$(pkg-config --cflags libdrm)
@@ -118,11 +124,6 @@ if test x$DRI = xauto; then
 fi
 AC_MSG_RESULT([$DRI])
 
-AM_CONDITIONAL(BUILD_UXA, test $BUILD_UXA = yes)
-if test "$BUILD_UXA" = yes; then
-	AC_DEFINE(I830_USE_UXA, 1, [UMA Acceleration Architecture support])
-fi
-
 AC_CHECK_HEADER(xf86Modes.h,[XMODES=yes],[XMODES=no],[#include "xorg-server.h"])
 AC_CHECK_DECL(XSERVER_LIBPCIACCESS,
 	      [XSERVER_LIBPCIACCESS=yes],[XSERVER_LIBPCIACCESS=no],
@@ -182,8 +183,6 @@ else
 fi
 
 AC_SUBST([XMODES_CFLAGS])
-UXA_CFLAGS='-I$(top_srcdir)/uxa'
-AC_SUBST([UXA_CFLAGS])
 
 SAVE_CPPFLAGS="$CPPFLAGS"
 CPPFLAGS="$CPPFLAGS $XORG_CFLAGS"
@@ -215,9 +214,9 @@ if test "$DRI" = yes; then
         AC_DEFINE(XF86DRI_DEVEL,1,[Enable developmental DRI driver support])
 fi
 
-dnl exaGetPixmapDriverPrivate required for DRM_MODE.
+dnl Server 1.5's set_mode_major required for DRM_MODE.
 PKG_CHECK_MODULES(DRM_MODE, [xorg-server >= 1.5],
-		  [DRM_MODE=yes], [DRM_MODE=no])
+		 [DRM_MODE=yes], [DRM_MODE=no])
 if test "x$DRM_MODE" = xyes; then
 	AC_DEFINE(XF86DRM_MODE,1,[DRM kernel modesetting])
 fi
diff --git a/src/Makefile.am b/src/Makefile.am
index cbe9fb1..e05dbab 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -31,16 +31,13 @@ SUBDIRS = xvmc bios_reader ch7017 ch7xxx ivch sil164 tfp410 $(REGDUMPER)
 # TODO: -nostdlib/-Bstatic/-lgcc platform magic, not installing the .a, etc.
 
 AM_CFLAGS = @WARN_CFLAGS@ @XORG_CFLAGS@ @DRM_CFLAGS@ @DRI_CFLAGS@ \
-	@PCIACCESS_CFLAGS@ @UXA_CFLAGS@ \
-	@XMODES_CFLAGS@ -DI830_XV -DI830_USE_XAA -DI830_USE_EXA
+	@PCIACCESS_CFLAGS@ -I$(top_srcdir)/uxa \
+	@XMODES_CFLAGS@ -DI830_XV -DI830_USE_XAA -DI830_USE_EXA -DI830_USE_UXA
 
 intel_drv_la_LTLIBRARIES = intel_drv.la
 intel_drv_la_LDFLAGS = -module -avoid-version
 intel_drv_ladir = @moduledir@/drivers
-intel_drv_la_LIBADD = -lm @DRM_LIBS@ -ldrm_intel
-if BUILD_UXA
-intel_drv_la_LIBADD += ../uxa/libuxa.la
-endif
+intel_drv_la_LIBADD = -lm @DRM_LIBS@ -ldrm_intel ../uxa/libuxa.la
 if XSERVER_LIBPCIACCESS
 intel_drv_la_LIBADD += @PCIACCESS_LIBS@
 endif
diff --git a/src/i830.h b/src/i830.h
index 8d3f0a3..ae6c588 100644
--- a/src/i830.h
+++ b/src/i830.h
@@ -974,6 +974,10 @@ i830_get_transformed_coordinates_3d(int x, int y, PictTransformPtr transform,
 
 void i830_enter_render(ScrnInfoPtr);
 
+#ifndef SERVER_1_5
+Bool xf86MonitorIsHDMI(xf86MonPtr mon);
+#endif
+
 static inline void
 i830_wait_ring_idle(ScrnInfoPtr pScrn)
 {
diff --git a/src/i830_driver.c b/src/i830_driver.c
index ff65bb4..fcd12ef 100644
--- a/src/i830_driver.c
+++ b/src/i830_driver.c
@@ -1140,10 +1140,12 @@ i830_pad_drawable_width(int width, int cpp)
 static Bool
 i830_xf86crtc_resize (ScrnInfoPtr scrn, int width, int height)
 {
+#ifdef DRI2
     I830Ptr	i830 = I830PTR(scrn);
+    int		old_width = scrn->displayWidth;
+#endif
     int		old_x = scrn->virtualX;
     int		old_y = scrn->virtualY;
-    int		old_width = scrn->displayWidth;
 
     if (old_x == width && old_y == height)
 	return TRUE;
diff --git a/src/i830_exa.c b/src/i830_exa.c
index 20e7a13..b9d6c64 100644
--- a/src/i830_exa.c
+++ b/src/i830_exa.c
@@ -81,6 +81,22 @@ const int I830PatternROP[16] =
     ROP_1
 };
 
+#ifdef I830_USE_UXA
+static int uxa_pixmap_index;
+#endif
+
+#ifndef SERVER_1_5
+static inline void *dixLookupPrivate(DevUnion **privates, int *key)
+{
+    return (*privates)[*key].ptr;
+}
+
+static inline void dixSetPrivate(DevUnion **privates, int *key, void *val)
+{
+    (*privates)[*key].ptr = val;
+}
+#endif
+
 /**
  * Returns whether a given pixmap is tiled or not.
  *
@@ -761,10 +777,6 @@ I830EXAInit(ScreenPtr pScreen)
     return TRUE;
 }
 
-#ifdef I830_USE_UXA
-static int uxa_pixmap_index;
-#endif
-
 dri_bo *
 i830_get_pixmap_bo(PixmapPtr pixmap)
 {
@@ -841,7 +853,7 @@ i830_uxa_prepare_access (PixmapPtr pixmap, uxa_access_t access)
 	    i830->need_sync = FALSE;
 	}
 
-	if (pScrn->vtSema && !pI830->use_drm_mode) {
+	if (pScrn->vtSema && !pI830->use_drm_mode && pI830->memory_manager) {
 	    if (drm_intel_bo_pin(bo, 4096) != 0)
 		return FALSE;
 	    drm_intel_gem_bo_start_gtt_access(bo, access == UXA_ACCESS_RW);
@@ -867,7 +879,7 @@ i830_uxa_finish_access (PixmapPtr pixmap)
 	ScrnInfoPtr scrn = xf86Screens[screen->myNum];
 	I830Ptr i830 = I830PTR(scrn);
 
-	if (pScrn->vtSema && !pI830->use_drm_mode)
+	if (pScrn->vtSema && !pI830->use_drm_mode && pI830->memory_manager)
 	    drm_intel_bo_unpin(bo);
 	else
 	    dri_bo_unmap(bo);
@@ -914,8 +926,12 @@ i830_uxa_create_pixmap (ScreenPtr screen, int w, int h, int depth, unsigned usag
     if (w > 32767 || h > 32767)
 	return NullPixmap;
 
+#ifdef SERVER_1_5
     pixmap = fbCreatePixmap (screen, 0, 0, depth, usage);
-    
+#else
+    pixmap = fbCreatePixmap (screen, 0, 0, depth);
+#endif
+
     if (w && h)
     {
 	unsigned int size;
@@ -950,6 +966,15 @@ i830_uxa_create_pixmap (ScreenPtr screen, int w, int h, int depth, unsigned usag
     return pixmap;
 }
 
+
+#ifndef SERVER_1_5
+static PixmapPtr
+i830_uxa_server_14_create_pixmap (ScreenPtr screen, int w, int h, int depth)
+{
+    return i830_uxa_create_pixmap(screen, w, h, depth, 0);
+}
+#endif
+
 static Bool
 i830_uxa_destroy_pixmap (PixmapPtr pixmap)
 {
@@ -982,9 +1007,14 @@ i830_uxa_init (ScreenPtr pScreen)
     ScrnInfoPtr scrn = xf86Screens[pScreen->myNum];
     I830Ptr i830 = I830PTR(scrn);
 
+#ifdef SERVER_1_5
     if (!dixRequestPrivate(&uxa_pixmap_index, 0))
 	return FALSE;
-    
+#else
+    if (!AllocatePixmapPrivate(pScreen, uxa_pixmap_index, 0))
+	return FALSE;
+#endif
+
     i830->uxa_driver = uxa_driver_alloc();
     if (i830->uxa_driver == NULL) {
 	i830->accel = ACCEL_NONE;
@@ -1038,7 +1068,11 @@ i830_uxa_init (ScreenPtr pScreen)
 	return FALSE;
     }
 
+#ifdef SERVER_1_5
     pScreen->CreatePixmap = i830_uxa_create_pixmap;
+#else
+    pScreen->CreatePixmap = i830_uxa_server_14_create_pixmap;
+#endif
     pScreen->DestroyPixmap = i830_uxa_destroy_pixmap;
 
     I830SelectBuffer(scrn, I830_SELECT_FRONT);
diff --git a/uxa/uxa-accel.c b/uxa/uxa-accel.c
index 1b0af9c..e322054 100644
--- a/uxa/uxa-accel.c
+++ b/uxa/uxa-accel.c
@@ -977,6 +977,68 @@ out:
     return ret;
 }
 
+#ifndef SERVER_1_5
+void
+uxa_paint_window(WindowPtr pWin, RegionPtr pRegion, int what)
+{
+    ScreenPtr       screen = pWin->drawable.pScreen;
+    uxa_screen_t    *uxa_screen = uxa_get_screen(screen);
+    DDXPointRec     zeros = { 0, 0 };
+
+    if (REGION_NIL(pRegion))
+	return;
+
+    if (uxa_screen->swappedOut) {
+	uxa_check_paint_window(pWin, pRegion, what);
+	return;
+    }
+
+    switch (what) {
+    case PW_BACKGROUND:
+	switch (pWin->backgroundState) {
+	case None:
+	    return;
+	case ParentRelative:
+	    do {
+		pWin = pWin->parent;
+	    } while (pWin->backgroundState == ParentRelative);
+	    (*pWin->drawable.pScreen->PaintWindowBackground)(pWin, pRegion,
+							     what);
+	    return;
+	case BackgroundPixel:
+	    if (uxa_fill_region_solid(&pWin->drawable, pRegion,
+				      pWin->background.pixel,
+				      FB_ALLONES, GXcopy))
+		return;
+	    break;
+	case BackgroundPixmap:
+	    if (uxa_fill_region_tiled(&pWin->drawable, pRegion,
+				      pWin->background.pixmap,
+				      &zeros, FB_ALLONES, GXcopy))
+		return;
+	    break;
+	}
+	break;
+    case PW_BORDER:
+	if (pWin->borderIsPixel) {
+	    if (uxa_fill_region_solid(&pWin->drawable, pRegion,
+				      pWin->border.pixel,
+				      FB_ALLONES, GXcopy))
+		return;
+	    break;
+	} else {
+	    if (uxa_fill_region_tiled(&pWin->drawable, pRegion,
+				      pWin->border.pixmap,
+				      &zeros, FB_ALLONES, GXcopy))
+		return;
+	    break;
+	}
+	break;
+    }
+
+    uxa_check_paint_window(pWin, pRegion, what);
+}
+#endif /* !SERVER_1_5 */
 
 /**
  * Accelerates GetImage for solid ZPixmap downloads from framebuffer memory.
diff --git a/uxa/uxa-glyphs.c b/uxa/uxa-glyphs.c
index 1c06e6d..5abd001 100644
--- a/uxa/uxa-glyphs.c
+++ b/uxa/uxa-glyphs.c
@@ -50,6 +50,8 @@
 
 #include "mipict.h"
 
+#ifdef SERVER_1_5
+
 #if DEBUG_GLYPH_CACHE
 #define DBG_GLYPH_CACHE(a) ErrorF a
 #else
@@ -887,3 +889,5 @@ uxa_glyphs (CARD8 	 op,
 	(*pScreen->DestroyPixmap) (pMaskPixmap);
     }
 }
+
+#endif /* SERVER_1_5 */
diff --git a/uxa/uxa-priv.h b/uxa/uxa-priv.h
index bdc6e82..d1cd341 100644
--- a/uxa/uxa-priv.h
+++ b/uxa/uxa-priv.h
@@ -26,6 +26,9 @@
 #ifndef UXAPRIV_H
 #define UXAPRIV_H
 
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
 #ifdef HAVE_DIX_CONFIG_H
 #include <dix-config.h>
 #else
@@ -126,6 +129,10 @@ typedef struct {
     CloseScreenProcPtr 		 SavedCloseScreen;
     GetImageProcPtr 		 SavedGetImage;
     GetSpansProcPtr 		 SavedGetSpans;
+#ifndef SERVER_1_5
+    PaintWindowBackgroundProcPtr SavedPaintWindowBackground;
+    PaintWindowBorderProcPtr	 SavedPaintWindowBorder;
+#endif
     CreatePixmapProcPtr 	 SavedCreatePixmap;
     DestroyPixmapProcPtr 	 SavedDestroyPixmap;
     CopyWindowProcPtr 		 SavedCopyWindow;
@@ -161,7 +168,16 @@ typedef struct {
 #endif
 
 extern int uxa_screen_index;
-#define uxa_get_screen(s) ((uxa_screen_t *)dixLookupPrivate(&(s)->devPrivates, &uxa_screen_index))
+static inline uxa_screen_t *
+uxa_get_screen(ScreenPtr screen)
+{
+#ifdef SERVER_1_5
+    return (uxa_screen_t *)dixLookupPrivate(&screen->devPrivates,
+					    &uxa_screen_index);
+#else
+    return screen->devPrivates[uxa_screen_index].ptr;
+#endif
+}
 
 /** Align an offset to an arbitrary alignment */
 #define UXA_ALIGN(offset, align) (((offset) + (align) - 1) - \
@@ -262,6 +278,8 @@ uxa_check_get_spans (DrawablePtr pDrawable,
 		 int nspans,
 		 char *pdstStart);
 
+void uxa_check_paint_window (WindowPtr pWin, RegionPtr pRegion, int what);
+
 void
 uxa_check_add_traps (PicturePtr	pPicture,
 		  INT16		x_off,
@@ -292,6 +310,8 @@ uxa_shm_put_image(DrawablePtr pDrawable, GCPtr pGC, int depth, unsigned int form
 	       int w, int h, int sx, int sy, int sw, int sh, int dx, int dy,
 	       char *data);
 
+void uxa_paint_window(WindowPtr pWin, RegionPtr pRegion, int what);
+
 void
 uxa_get_image (DrawablePtr pDrawable, int x, int y, int w, int h,
 	     unsigned int format, unsigned long planeMask, char *d);
diff --git a/uxa/uxa-render.c b/uxa/uxa-render.c
index b377bf5..edbf0d8 100644
--- a/uxa/uxa-render.c
+++ b/uxa/uxa-render.c
@@ -818,8 +818,13 @@ uxa_create_alpha_picture (ScreenPtr     pScreen,
 	    return 0;
     }
 
+#ifdef SERVER_1_5
     pPixmap = (*pScreen->CreatePixmap) (pScreen, width, height,
 					pPictFormat->depth, 0);
+#else
+    pPixmap = (*pScreen->CreatePixmap) (pScreen, width, height,
+					pPictFormat->depth);
+#endif
     if (!pPixmap)
 	return 0;
     pGC = GetScratchGC (pPixmap->drawable.depth, pScreen);
diff --git a/uxa/uxa-unaccel.c b/uxa/uxa-unaccel.c
index 8f86468..f63c03b 100644
--- a/uxa/uxa-unaccel.c
+++ b/uxa/uxa-unaccel.c
@@ -336,6 +336,24 @@ uxa_check_get_spans (DrawablePtr pDrawable,
     }
 }
 
+#ifndef SERVER_1_5
+void
+uxa_check_paint_window (WindowPtr pWin, RegionPtr pRegion, int what)
+{
+    ScreenPtr screen = pWin->drawable.pScreen;
+
+    UXA_FALLBACK(("from %p (%c)\n", pWin,
+		  uxa_drawable_location (&pWin->drawable)));
+    if (uxa_prepare_access (&pWin->drawable, UXA_ACCESS_RW)) {
+	if (uxa_prepare_access_window (pWin)) {
+	    fbPaintWindow (pWin, pRegion, what);
+	    uxa_finish_access_window (pWin);
+	}
+	uxa_finish_access(&pWin->drawable);
+    }
+}
+#endif
+
 void
 uxa_check_composite (CARD8      op,
                    PicturePtr pSrc,
diff --git a/uxa/uxa.c b/uxa/uxa.c
index 0de408c..b51a282 100644
--- a/uxa/uxa.c
+++ b/uxa/uxa.c
@@ -40,6 +40,9 @@
 #include "uxa.h"
 
 int uxa_screen_index;
+#ifndef SERVER_1_5
+static int uxa_generation;
+#endif
 
 /**
  * uxa_get_drawable_pixmap() returns a backing pixmap for a given drawable.
@@ -367,12 +370,18 @@ uxa_close_screen(int i, ScreenPtr pScreen)
     PictureScreenPtr	ps = GetPictureScreenIfSet(pScreen);
 #endif
 
+#ifdef SERVER_1_5
     uxa_glyphs_fini(pScreen);
+#endif
 
     pScreen->CreateGC = uxa_screen->SavedCreateGC;
     pScreen->CloseScreen = uxa_screen->SavedCloseScreen;
     pScreen->GetImage = uxa_screen->SavedGetImage;
     pScreen->GetSpans = uxa_screen->SavedGetSpans;
+#ifndef SERVER_1_5
+    pScreen->PaintWindowBackground = uxa_screen->SavedPaintWindowBackground;
+    pScreen->PaintWindowBorder = uxa_screen->SavedPaintWindowBorder;
+#endif
     pScreen->CreatePixmap = uxa_screen->SavedCreatePixmap;
     pScreen->DestroyPixmap = uxa_screen->SavedDestroyPixmap;
     pScreen->CopyWindow = uxa_screen->SavedCopyWindow;
@@ -469,7 +478,15 @@ uxa_driver_init(ScreenPtr screen, uxa_driver_t *uxa_driver)
 
     uxa_screen->info = uxa_driver;
 
+#ifdef SERVER_1_5
     dixSetPrivate(&screen->devPrivates, &uxa_screen_index, uxa_screen);
+#else
+    if (uxa_generation != serverGeneration) {
+	uxa_screen_index = AllocateScreenPrivateIndex();
+	uxa_generation = serverGeneration;
+    }
+    screen->devPrivates[uxa_screen_index].ptr = uxa_screen;
+#endif
 
 //    exaDDXDriverInit(screen);
 
@@ -488,6 +505,14 @@ uxa_driver_init(ScreenPtr screen, uxa_driver_t *uxa_driver)
     uxa_screen->SavedGetSpans = screen->GetSpans;
     screen->GetSpans = uxa_check_get_spans;
 
+#ifndef SERVER_1_5
+    uxa_screen->SavedPaintWindowBackground = screen->PaintWindowBackground;
+    screen->PaintWindowBackground = uxa_paint_window;
+
+    uxa_screen->SavedPaintWindowBorder = screen->PaintWindowBorder;
+    screen->PaintWindowBorder = uxa_paint_window;
+#endif /* !SERVER_1_5 */
+
     uxa_screen->SavedCopyWindow = screen->CopyWindow;
     screen->CopyWindow = uxa_copy_window;
 
@@ -505,9 +530,11 @@ uxa_driver_init(ScreenPtr screen, uxa_driver_t *uxa_driver)
         uxa_screen->SavedComposite = ps->Composite;
 	ps->Composite = uxa_composite;
 
+#ifdef SERVER_1_5
 	uxa_screen->SavedGlyphs = ps->Glyphs;
 	ps->Glyphs = uxa_glyphs;
-	
+#endif
+
 	uxa_screen->SavedTriangles = ps->Triangles;
 	ps->Triangles = uxa_triangles;
 
@@ -527,7 +554,9 @@ uxa_driver_init(ScreenPtr screen, uxa_driver_t *uxa_driver)
     ShmRegisterFuncs(screen, &uxa_shm_funcs);
 #endif
 
+#ifdef SERVER_1_5
     uxa_glyphs_init(screen);
+#endif
 
     LogMessage(X_INFO, "UXA(%d): Driver registered support for the following"
 	       " operations:\n", screen->myNum);
-- 
1.5.6.5




More information about the Intel-gfx mailing list