[PATCH 3/4] Add "none" acceleration option

Keith Packard keithp at keithp.com
Fri Sep 26 20:35:34 PDT 2014


This uses fb directly, and supports DRI2 and DRI3.

Signed-off-by: Keith Packard <keithp at keithp.com>
---
 configure.ac            |  39 +++----
 src/Makefile.am         |   9 +-
 src/intel_module.c      |  14 +--
 src/uxa/Makefile.am     |   2 +
 src/uxa/intel.h         |   6 +
 src/uxa/intel_display.c |   8 ++
 src/uxa/intel_dri.c     |   4 +
 src/uxa/intel_dri3.c    |  49 +++++---
 src/uxa/intel_driver.c  | 171 +++++++++++++++++++--------
 src/uxa/intel_glamor.c  |   4 +
 src/uxa/intel_none.c    | 299 ++++++++++++++++++++++++++++++++++++++++++++++++
 src/uxa/intel_none.h    |  46 ++++++++
 src/uxa/intel_uxa.c     |   3 +
 13 files changed, 545 insertions(+), 109 deletions(-)
 create mode 100644 src/uxa/intel_none.c
 create mode 100644 src/uxa/intel_none.h

diff --git a/configure.ac b/configure.ac
index 36f6e63..1ebd377 100644
--- a/configure.ac
+++ b/configure.ac
@@ -419,7 +419,6 @@ if test "x$UXA" = "xauto"; then
 fi
 if test "x$UXA" != "xno"; then
 	AC_DEFINE(USE_UXA, 1, [Enable UXA support])
-	PKG_CHECK_MODULES(DRMINTEL, [libdrm_intel >= $uxa_requires_libdrm])
 	required_pixman_version=0.24
 	UXA=yes
 fi
@@ -440,6 +439,8 @@ if test "x$GLAMOR" != "xno"; then
 	AC_DEFINE(USE_GLAMOR, 1, [Enable glamor acceleration])
 fi
 
+PKG_CHECK_MODULES(DRMINTEL, [libdrm_intel >= $uxa_requires_libdrm])
+
 PKG_CHECK_MODULES(XORG, [xorg-server >= $required_xorg_server_version xproto fontsproto pixman-1 >= $required_pixman_version $REQUIRED_MODULES])
 ABI_VERSION=`$PKG_CONFIG --variable=abi_videodrv xorg-server`
 
@@ -684,6 +685,8 @@ if test "x$accel" = "xauto"; then
 		else
 			if test "x$GLAMOR" != "xno"; then
 				accel="glamor"
+			else
+				accel="none"
 			fi
 		fi
 	fi
@@ -692,11 +695,9 @@ if test "x$accel" = "xauto"; then
 	fi
 fi
 
-have_accel="none"
 if test "x$accel" = "xsna"; then
 	if test "x$SNA" != "xno"; then
 		AC_DEFINE(DEFAULT_ACCEL_METHOD, SNA, [Default acceleration method])
-		have_accel="yes"
 	else
 		AC_MSG_ERROR([SNA requested as default, but is not enabled])
 	fi
@@ -705,7 +706,6 @@ fi
 if test "x$accel" = "xuxa"; then
 	if test "x$UXA" != "xno"; then
 		AC_DEFINE(DEFAULT_ACCEL_METHOD, UXA, [Default acceleration method])
-		have_accel="yes"
 	else
 		AC_MSG_ERROR([UXA requested as default, but is not enabled])
 	fi
@@ -714,22 +714,15 @@ fi
 if test "x$accel" = "xglamor"; then
 	if test "x$GLAMOR" != "xno"; then
 		AC_DEFINE(DEFAULT_ACCEL_METHOD, GLAMOR, [Default acceleration method])
-		have_accel="yes"
 	else
 		AC_MSG_ERROR([glamor acceleration requested as default, but is not enabled])
 	fi
 fi
 
-if test "x$have_accel" = "xnone"; then
-	if test "x$KMS" = "xyes"; then
-		if test "x$SNA" != "xno" -o "x$UXA" != "xno"; then
-			AC_DEFINE(DEFAULT_ACCEL_METHOD, NOACCEL, [Default acceleration method])
-		else
-			AC_MSG_ERROR([Invalid default acceleration option])
-		fi
-	fi
-	accel="none"
+if test "x$accel" = "xnone"; then
+	AC_DEFINE(DEFAULT_ACCEL_METHOD, NOACCEL, [Default acceleration method])
 fi
+
 AC_MSG_RESULT($accel)
 
 xp_msg=""
@@ -882,11 +875,6 @@ test -e `pwd $0`/README && cat `pwd $0`/README
 
 accel_msg=""
 if test "x$SNA" != "xno"; then
-	if test "$accel" = "none"; then
-		accel_msg="$accel_msg *none"
-	else
-		accel_msg="$accel_msg none"
-	fi
 	if test "$accel" = "sna"; then
 		accel_msg="$accel_msg *sna"
 	else
@@ -894,13 +882,6 @@ if test "x$SNA" != "xno"; then
 	fi
 fi
 if test "x$UXA" != "xno"; then
-	if test "x$SNA" = "xno"; then
-		if test "$accel" = "none"; then
-			accel_msg="$accel_msg *none"
-		else
-			accel_msg="$accel_msg none"
-		fi
-	fi
 	if test "$accel" = "uxa"; then
 		accel_msg="$accel_msg *uxa"
 	else
@@ -915,6 +896,12 @@ if test "x$GLAMOR" != "xno"; then
 	fi
 fi
 
+if test "$accel" = "none"; then
+	accel_msg="$accel_msg *none"
+else
+	accel_msg="$accel_msg none"
+fi
+
 if test "x$dri_msg" = "x"; then
 	dri_msg=" none"
 fi
diff --git a/src/Makefile.am b/src/Makefile.am
index aa8b47e..ce6f836 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -18,7 +18,7 @@
 #  IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 #  CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
-SUBDIRS = render_program legacy
+SUBDIRS = render_program legacy uxa
 
 # this is obnoxious:
 # -module lets us name the module exactly how we want
@@ -41,18 +41,13 @@ endif
 intel_drv_la_LTLIBRARIES = intel_drv.la
 intel_drv_la_LDFLAGS = -module -avoid-version
 intel_drv_ladir = $(moduledir)/drivers
-intel_drv_la_LIBADD = legacy/liblegacy.la $(PCIACCESS_LIBS) $(XORG_LIBS)
+intel_drv_la_LIBADD = legacy/liblegacy.la uxa/libuxa.la $(PCIACCESS_LIBS) $(XORG_LIBS)
 
 if SNA
 SUBDIRS += sna
 intel_drv_la_LIBADD += sna/libsna.la
 endif
 
-if UXA
-SUBDIRS += uxa
-intel_drv_la_LIBADD += uxa/libuxa.la
-endif
-
 NULL:=#
 
 intel_drv_la_SOURCES = \
diff --git a/src/intel_module.c b/src/intel_module.c
index 57ac5ef..536bf37 100644
--- a/src/intel_module.c
+++ b/src/intel_module.c
@@ -564,20 +564,18 @@ intel_scrn_create(DriverPtr		driver,
 #if KMS
 	switch (get_accel_method()) {
 #if USE_SNA
-	case NOACCEL:
 	case SNA:
 		return sna_init_scrn(scrn, entity_num);
 #endif
-#if USE_UXA
-#if !USE_SNA
-	case NOACCEL:
-#endif
+#if USE_GLAMOR
 	case GLAMOR:
+#endif
+#if USE_UXA
 	case UXA:
-		  return intel_init_scrn(scrn);
 #endif
-
-	default: break;
+        case NOACCEL:
+        default:
+		  return intel_init_scrn(scrn);
 	}
 #endif
 
diff --git a/src/uxa/Makefile.am b/src/uxa/Makefile.am
index 5d342d3..81b5c0a 100644
--- a/src/uxa/Makefile.am
+++ b/src/uxa/Makefile.am
@@ -31,6 +31,8 @@ libuxa_la_SOURCES = \
 	intel_driver.c \
 	intel_glamor.h \
 	intel_memory.c \
+	intel_none.c \
+	intel_none.h \
 	intel_video.c \
 	intel_video.h \
 	intel_video_overlay.c \
diff --git a/src/uxa/intel.h b/src/uxa/intel.h
index 3c1a321..3cf61db 100644
--- a/src/uxa/intel.h
+++ b/src/uxa/intel.h
@@ -112,6 +112,7 @@ enum dri_type {
 };
 
 enum accel_type {
+        ACCEL_NONE,
 #if USE_GLAMOR
         ACCEL_GLAMOR,
 #endif
@@ -126,9 +127,11 @@ typedef struct intel_screen_private {
 
         enum accel_type accel;
 
+#if USE_UXA
 #define RENDER_BATCH			I915_EXEC_RENDER
 #define BLT_BATCH			I915_EXEC_BLT
 	unsigned int current_batch;
+#endif
 
 	void *modes;
 	drm_intel_bo *front_buffer, *back_buffer;
@@ -474,6 +477,9 @@ void I830DRI2FrameEventHandler(unsigned int frame, unsigned int tv_sec,
 void I830DRI2FlipEventHandler(unsigned int frame, unsigned int tv_sec,
 			      unsigned int tv_usec, DRI2FrameEventPtr flip_info);
 
+Bool
+intel_fb_init(ScreenPtr screen, void *pbits);
+
 /* intel_dri3.c */
 Bool intel_dri3_screen_init(ScreenPtr screen);
 
diff --git a/src/uxa/intel_display.c b/src/uxa/intel_display.c
index e9efa0d..6159841 100644
--- a/src/uxa/intel_display.c
+++ b/src/uxa/intel_display.c
@@ -63,6 +63,7 @@
 #if USE_GLAMOR
 #include "intel_glamor.h"
 #endif
+#include "intel_none.h"
 
 #define KNOWN_MODE_FLAGS ((1<<14)-1)
 
@@ -1631,6 +1632,10 @@ intel_xf86crtc_resize(ScrnInfoPtr scrn, int width, int height)
                         goto fail;
                 break;
 #endif
+        case ACCEL_NONE:
+                if (!intel_none_create_screen_resources(scrn->pScreen))
+                        goto fail;
+                break;
         }
 
 	for (i = 0; i < xf86_config->num_crtc; i++) {
@@ -2476,6 +2481,9 @@ intel_copy_pixmap(PixmapPtr src, PixmapPtr dst) {
                 ret = intel_uxa_copy_pixmap(src, dst);
                 break;
 #endif
+        case ACCEL_NONE:
+		ret = intel_none_copy_pixmap(src, dst);
+                break;
         }
         return ret;
 }
diff --git a/src/uxa/intel_dri.c b/src/uxa/intel_dri.c
index f191af7..47ac0d4 100644
--- a/src/uxa/intel_dri.c
+++ b/src/uxa/intel_dri.c
@@ -72,6 +72,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 #if USE_GLAMOR
 #include "intel_glamor.h"
 #endif
+#include "intel_none.h"
 
 typedef struct {
 	int refcnt;
@@ -646,6 +647,9 @@ intel_exchange_pixmap_buffers(struct intel_screen_private *intel, PixmapPtr fron
                 intel_uxa_exchange_buffers(intel, front, back);
                 break;
 #endif
+        case ACCEL_NONE:
+                intel_none_exchange_buffers(intel, front, back);
+                break;
         }
 
 	DamageRegionProcessPending(&front->drawable);
diff --git a/src/uxa/intel_dri3.c b/src/uxa/intel_dri3.c
index 2c44442..dae0c71 100644
--- a/src/uxa/intel_dri3.c
+++ b/src/uxa/intel_dri3.c
@@ -59,7 +59,6 @@ static PixmapPtr intel_dri3_pixmap_from_fd(ScreenPtr screen,
 {
 	ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
 	intel_screen_private *intel = intel_get_screen_private(scrn);
-	struct intel_uxa_pixmap *priv;
 	PixmapPtr pixmap;
 	dri_bo *bo;
 
@@ -87,14 +86,19 @@ static PixmapPtr intel_dri3_pixmap_from_fd(ScreenPtr screen,
 	if (bo == NULL)
 		goto free_pixmap;
 
-	intel_uxa_set_pixmap_bo(pixmap, bo);
+	intel_set_pixmap_bo(pixmap, bo);
 	dri_bo_unreference(bo);
 
-	priv = intel_uxa_get_pixmap_private(pixmap);
-	if (priv == NULL)
-		goto free_pixmap;
-
-	priv->pinned |= PIN_DRI3;
+#if USE_UXA
+        if (intel->accel == ACCEL_UXA) {
+                struct intel_uxa_pixmap *priv;
+                priv = intel_uxa_get_pixmap_private(pixmap);
+                if (priv == NULL)
+                        goto free_pixmap;
+
+                priv->pinned |= PIN_DRI3;
+        }
+#endif
 
 	return pixmap;
 
@@ -108,23 +112,30 @@ static int intel_dri3_fd_from_pixmap(ScreenPtr screen,
 				     CARD16 *stride,
 				     CARD32 *size)
 {
-	struct intel_uxa_pixmap *priv;
-	int fd;
+        dri_bo *bo;
+        int fd;
 
-	priv = intel_uxa_get_pixmap_private(pixmap);
-	if (!priv)
-		return -1;
+        bo = intel_get_pixmap_bo(pixmap);
+        if (!bo)
+                return -1;
 
-	if (intel_pixmap_pitch(pixmap) > UINT16_MAX)
+	if (drm_intel_bo_gem_export_to_prime(bo, &fd) < 0)
 		return -1;
 
-	if (drm_intel_bo_gem_export_to_prime(priv->bo, &fd) < 0)
-		return -1;
-
-	priv->pinned |= PIN_DRI3;
-
+#if USE_UXA
+        if (intel_get_screen_private(xf86ScreenToScrn(screen))->accel== ACCEL_UXA) {
+                struct intel_uxa_pixmap *priv;
+
+                if (intel_pixmap_pitch(pixmap) > UINT16_MAX)
+                        return -1;
+                priv = intel_uxa_get_pixmap_private(pixmap);
+                if (!priv)
+                        return -1;
+                priv->pinned |= PIN_DRI3;
+        }
+#endif
 	*stride = intel_pixmap_pitch(pixmap);
-	*size = priv->bo->size;
+	*size = bo->size;
 	return fd;
 }
 
diff --git a/src/uxa/intel_driver.c b/src/uxa/intel_driver.c
index 2e78fb3..619ac50 100644
--- a/src/uxa/intel_driver.c
+++ b/src/uxa/intel_driver.c
@@ -62,6 +62,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "intel.h"
 #include "intel_video.h"
 #include "uxa_module.h"
+#include "intel_none.h"
 
 #ifdef INTEL_XVMC
 #define _INTEL_XVMC_SERVER_
@@ -179,6 +180,10 @@ static Bool i830CreateScreenResources(ScreenPtr screen)
                         return FALSE;
                 break;
 #endif
+        case ACCEL_NONE:
+                if (!intel_none_create_screen_resources(screen))
+                        return FALSE;
+                break;
         }
 
 	intel_copy_fb(scrn);
@@ -202,6 +207,9 @@ intel_set_pixmap_bo(PixmapPtr pixmap, dri_bo *bo)
                 intel_uxa_set_pixmap_bo(pixmap, bo);
                 break;
 #endif
+        case ACCEL_NONE:
+                intel_none_set_pixmap_bo(pixmap, bo);
+                break;
         default:
                 ErrorF("No accel architecture, cannot set pixmap bo\n");
                 break;
@@ -223,6 +231,8 @@ intel_get_pixmap_bo(PixmapPtr pixmap)
         case ACCEL_UXA:
 		return intel_uxa_get_pixmap_bo(pixmap);
 #endif
+        case ACCEL_NONE:
+                return intel_none_get_pixmap_bo(pixmap);
         default:
                 ErrorF("No accel architecture, cannot set pixmap bo\n");
 	        return NULL;
@@ -243,6 +253,8 @@ intel_flush(intel_screen_private *intel)
                 intel_batch_submit(intel->scrn);
                 break;
 #endif
+        default:
+                break;
         }
 }
 
@@ -279,6 +291,9 @@ static void intel_check_accel_option(ScrnInfoPtr scrn)
                         accel_method = UXA;
                 else
 #endif
+                if (strcasecmp(s, "none") == 0)
+                        accel_method = NOACCEL;
+                else
                         accel_method = DEFAULT_ACCEL_METHOD;
         }
         switch (accel_method) {
@@ -293,6 +308,9 @@ static void intel_check_accel_option(ScrnInfoPtr scrn)
                 intel->accel = ACCEL_UXA;
                 break;
 #endif
+        case NOACCEL:
+                intel->accel = ACCEL_NONE;
+                break;
         }
 }
 
@@ -379,10 +397,13 @@ static int intel_init_bufmgr(intel_screen_private *intel)
 	if (!intel->bufmgr)
 		return FALSE;
 
-	if (xf86ReturnOptValBool(intel->Options, OPTION_BUFFER_CACHE, TRUE))
-		drm_intel_bufmgr_gem_enable_reuse(intel->bufmgr);
-	drm_intel_bufmgr_gem_set_vma_cache_size(intel->bufmgr, 512);
-	drm_intel_bufmgr_gem_enable_fenced_relocs(intel->bufmgr);
+#if USE_UXA
+        if (intel->accel == ACCEL_UXA) {
+                if (xf86ReturnOptValBool(intel->Options, OPTION_BUFFER_CACHE, TRUE))
+                        drm_intel_bufmgr_gem_enable_reuse(intel->bufmgr);
+                drm_intel_bufmgr_gem_set_vma_cache_size(intel->bufmgr, 512);
+                drm_intel_bufmgr_gem_enable_fenced_relocs(intel->bufmgr);
+        }
 
 	list_init(&intel->batch_pixmaps);
 
@@ -391,6 +412,7 @@ static int intel_init_bufmgr(intel_screen_private *intel)
 			drm_intel_bo_alloc(intel->bufmgr, "wa scratch",
 					   4096, 4096);
 	}
+#endif
 
 	return TRUE;
 }
@@ -400,7 +422,10 @@ static void intel_bufmgr_fini(intel_screen_private *intel)
 	if (intel->bufmgr == NULL)
 		return;
 
-	drm_intel_bo_unreference(intel->wa_scratch_bo);
+#if USE_UXA
+        if (intel->accel == ACCEL_UXA)
+                drm_intel_bo_unreference(intel->wa_scratch_bo);
+#endif
 	drm_intel_bufmgr_destroy(intel->bufmgr);
 }
 
@@ -714,7 +739,11 @@ static Bool I830PreInit(ScrnInfoPtr scrn, int flags)
                         PreInitCleanup(scrn);
                         xf86DrvMsg(scrn->scrnIndex, X_ERROR,
                                    "Failed to pre init glamor display.\n");
+#if USE_UXA
                         intel->accel = ACCEL_UXA;
+#else
+                        intel->accel = ACCEL_NONE;
+#endif
                 }
                 break;
 #endif
@@ -725,12 +754,14 @@ static Bool I830PreInit(ScrnInfoPtr scrn, int flags)
         switch (intel->accel) {
 #if USE_UXA
         case ACCEL_UXA:
+                /* fall through ... */
+#endif
+        case ACCEL_NONE:
 #if HAVE_DRI3
                 if (intel->dri3 != DRI_DISABLED && !xf86LoadSubModule(scrn, "dri3"))
                         intel->dri3 = DRI_DISABLED;
 #endif
                 break;
-#endif
         default:
                 break;
         }
@@ -768,7 +799,7 @@ redisplay_dirty(ScreenPtr screen, PixmapDirtyUpdatePtr dirty)
 
         intel_flush(intel);
 	if (!intel->has_prime_vmap_flush) {
-		drm_intel_bo *bo = intel_uxa_get_pixmap_bo(dirty->slave_dst->master_pixmap);
+		drm_intel_bo *bo = (drm_intel_bo *) intel_get_pixmap_bo(dirty->slave_dst->master_pixmap);
 		was_blocked = xf86BlockSIGIO();
 		drm_intel_bo_map(bo, FALSE);
 		drm_intel_bo_unmap(bo);
@@ -812,8 +843,12 @@ I830BlockHandler(BLOCKHANDLER_ARGS_DECL)
 	intel->BlockHandler = screen->BlockHandler;
 	screen->BlockHandler = I830BlockHandler;
 
-	intel_uxa_block_handler(intel);
-	intel_video_block_handler(intel);
+#if USE_UXA
+        if (intel->accel == ACCEL_UXA) {
+                intel_uxa_block_handler(intel);
+                intel_video_block_handler(intel);
+        }
+#endif
 #ifdef INTEL_PIXMAP_SHARING
 	intel_dirty_update(screen);
 #endif
@@ -961,12 +996,46 @@ I830UeventFini(ScrnInfoPtr scrn)
 }
 #endif /* HAVE_UDEV */
 
+Bool
+intel_fb_init(ScreenPtr screen, void *pbits)
+{
+	ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
+	VisualPtr visual;
+
+	/* Must be first, before anything else installs screen callbacks. */
+	if (!fbScreenInit(screen, pbits,
+			  scrn->virtualX, scrn->virtualY,
+			  scrn->xDpi, scrn->yDpi,
+			  scrn->displayWidth, scrn->bitsPerPixel))
+		return FALSE;
+
+	if (scrn->bitsPerPixel > 8) {
+		/* Fixup RGB ordering */
+		visual = screen->visuals + screen->numVisuals;
+		while (--visual >= screen->visuals) {
+			if ((visual->class | DynamicClass) == DirectColor) {
+				visual->offsetRed = scrn->offset.red;
+				visual->offsetGreen = scrn->offset.green;
+				visual->offsetBlue = scrn->offset.blue;
+				visual->redMask = scrn->mask.red;
+				visual->greenMask = scrn->mask.green;
+				visual->blueMask = scrn->mask.blue;
+			}
+		}
+	}
+
+	fbPictureInit(screen, NULL, 0);
+
+	xf86SetBlackWhitePixels(screen);
+
+        return TRUE;
+}
+
 static Bool
 I830ScreenInit(SCREEN_INIT_ARGS_DECL)
 {
 	ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
 	intel_screen_private *intel = intel_get_screen_private(scrn);
-	VisualPtr visual;
 #if USE_UXA
 #ifdef INTEL_XVMC
 	MessageType from;
@@ -997,32 +1066,6 @@ I830ScreenInit(SCREEN_INIT_ARGS_DECL)
 	if (!miSetPixmapDepths())
 		return FALSE;
 
-	/* Must be first, before anything else installs screen callbacks. */
-	if (!fbScreenInit(screen, NULL,
-			  scrn->virtualX, scrn->virtualY,
-			  scrn->xDpi, scrn->yDpi,
-			  scrn->displayWidth, scrn->bitsPerPixel))
-		return FALSE;
-
-	if (scrn->bitsPerPixel > 8) {
-		/* Fixup RGB ordering */
-		visual = screen->visuals + screen->numVisuals;
-		while (--visual >= screen->visuals) {
-			if ((visual->class | DynamicClass) == DirectColor) {
-				visual->offsetRed = scrn->offset.red;
-				visual->offsetGreen = scrn->offset.green;
-				visual->offsetBlue = scrn->offset.blue;
-				visual->redMask = scrn->mask.red;
-				visual->greenMask = scrn->mask.green;
-				visual->blueMask = scrn->mask.blue;
-			}
-		}
-	}
-
-	fbPictureInit(screen, NULL, 0);
-
-	xf86SetBlackWhitePixels(screen);
-
         switch (intel->accel) {
 #if USE_GLAMOR
         case ACCEL_GLAMOR:
@@ -1044,6 +1087,22 @@ I830ScreenInit(SCREEN_INIT_ARGS_DECL)
                                    "Hardware acceleration initialization failed\n");
                         return FALSE;
                 }
+                break;
+#endif
+        case ACCEL_NONE:
+                if (!intel_none_init(screen)) {
+                        xf86DrvMsg(scrn->scrnIndex, X_ERROR,
+                                   "Screen initialization failed\n");
+                        return FALSE;
+                }
+        }
+
+        switch (intel->accel) {
+#if USE_UXA
+        case ACCEL_UXA:
+                /* fall through ... */
+#endif /* USE_UXA */
+        case ACCEL_NONE:
 #if HAVE_DRI3
                 if (!intel_sync_init(screen))
                         intel->dri3 = DRI_DISABLED;
@@ -1051,7 +1110,8 @@ I830ScreenInit(SCREEN_INIT_ARGS_DECL)
                         intel->dri3 = DRI_ACTIVE;
 #endif
                 break;
-#endif
+        default:
+                break;
         }
 
 #if HAVE_DRI2
@@ -1143,6 +1203,9 @@ I830ScreenInit(SCREEN_INIT_ARGS_DECL)
                 xf86DrvMsg(scrn->scrnIndex, from, "Intel XvMC decoder %sabled\n",
                            intel->XvMCEnabled ? "en" : "dis");
 #endif
+                /* fall through */
+#endif
+        case ACCEL_NONE:
 #if HAVE_DRI3
                 switch (intel->dri3) {
                 case DRI_ACTIVE:
@@ -1162,7 +1225,6 @@ I830ScreenInit(SCREEN_INIT_ARGS_DECL)
                 xf86DrvMsg(scrn->scrnIndex, X_INFO,
                            "DRI3: Not available\n");
 #endif
-#endif
                 break;
         default:
                 break;
@@ -1271,16 +1333,9 @@ static Bool I830CloseScreen(CLOSE_SCREEN_ARGS_DECL)
 #endif
 #if USE_UXA
         case ACCEL_UXA:
-
-                TimerFree(intel->cache_expire);
-                intel->cache_expire = NULL;
-
-                intel_batch_teardown(scrn);
-
-                if (INTEL_INFO(intel)->gen >= 040 && INTEL_INFO(intel)->gen < 0100)
-                        gen4_render_state_cleanup(scrn);
-
                 if (intel->uxa_driver) {
+                        TimerFree(intel->cache_expire);
+                        intel->cache_expire = NULL;
                         uxa_driver_fini(screen);
                         free(intel->uxa_driver);
                         intel->uxa_driver = NULL;
@@ -1311,9 +1366,28 @@ static Bool I830CloseScreen(CLOSE_SCREEN_ARGS_DECL)
 		I830LeaveVT(VT_FUNC_ARGS(0));
 	}
 
+        switch (intel->accel) {
+#if USE_UXA
+        case ACCEL_UXA:
+                intel_batch_teardown(scrn);
+
+                if (INTEL_INFO(intel)->gen >= 040 && INTEL_INFO(intel)->gen < 0100)
+                        gen4_render_state_cleanup(scrn);
+
+                i965_free_video(scrn);
+                /* fall through ... */
+#endif
+        case ACCEL_NONE:
+#if HAVE_DRI3
+                intel_sync_close(screen);
+#endif
+                break;
+        default:
+                break;
+        }
+
 	xf86_cursors_fini(screen);
 
-	i965_free_video(scrn);
 
 	screen->CloseScreen = intel->CloseScreen;
 	(*screen->CloseScreen) (CLOSE_SCREEN_ARGS);
@@ -1335,7 +1409,6 @@ static Bool I830CloseScreen(CLOSE_SCREEN_ARGS_DECL)
                 }
                 intel_sync_close(screen);
 #endif
-
                 break;
 #endif
         default:
diff --git a/src/uxa/intel_glamor.c b/src/uxa/intel_glamor.c
index 893ba9f..00aa971 100644
--- a/src/uxa/intel_glamor.c
+++ b/src/uxa/intel_glamor.c
@@ -36,6 +36,7 @@
 #define GLAMOR_FOR_XORG  1
 #include <glamor.h>
 #include <unistd.h>
+#include <mipict.h>
 
 #include "intel.h"
 #include "i915_drm.h"
@@ -210,6 +211,9 @@ intel_glamor_init(ScreenPtr screen)
 {
 	ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
 
+        if (!intel_fb_init(screen, NULL))
+                return FALSE;
+
         if (!dixRegisterPrivateKey(&intel_glamor_pixmap_key, PRIVATE_PIXMAP, sizeof (struct intel_glamor_pixmap)))
                 return FALSE;
 
diff --git a/src/uxa/intel_none.c b/src/uxa/intel_none.c
new file mode 100644
index 0000000..c9c0354
--- /dev/null
+++ b/src/uxa/intel_none.c
@@ -0,0 +1,299 @@
+/*
+ * Copyright © 2014 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that copyright
+ * notice and this permission notice appear in supporting documentation, and
+ * that the name of the copyright holders not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission.  The copyright holders make no representations
+ * about the suitability of this software for any purpose.  It is provided "as
+ * is" without express or implied warranty.
+ *
+ * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <assert.h>
+#include <string.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <errno.h>
+
+#include "xorg-server.h"
+#include "xf86.h"
+#include "xf86_OSproc.h"
+#include "xf86cmap.h"
+#include "xf86drm.h"
+#include "compiler.h"
+#include "mipointer.h"
+#include "micmap.h"
+#include <X11/extensions/randr.h>
+#include "fb.h"
+#include "miscstruct.h"
+#include "dixstruct.h"
+#include "xf86xv.h"
+#include "shadow.h"
+#include "intel.h"
+#include "intel_video.h"
+#include "intel_none.h"
+#include "intel_bufmgr.h"
+
+struct intel_none_screen {
+        DestroyPixmapProcPtr    DestroyPixmap;
+        CreatePixmapProcPtr     CreatePixmap;
+};
+
+static DevPrivateKeyRec intel_none_screen_key;
+
+static inline struct intel_none_screen *intel_none_get_screen(ScreenPtr screen)
+{
+        return dixGetPrivateAddr(&screen->devPrivates, &intel_none_screen_key);
+}
+
+struct intel_none_pixmap {
+        drm_intel_bo  *bo;
+};
+
+static DevPrivateKeyRec intel_none_pixmap_key;
+
+static inline struct intel_none_pixmap *intel_none_get_pixmap(PixmapPtr pixmap)
+{
+        return dixGetPrivateAddr(&pixmap->devPrivates, &intel_none_pixmap_key);
+}
+
+dri_bo *
+intel_none_get_pixmap_bo(PixmapPtr pixmap)
+{
+        return (dri_bo *) intel_none_get_pixmap(pixmap)->bo;
+}
+
+Bool
+intel_none_set_pixmap_bo(PixmapPtr pixmap, dri_bo *d_bo)
+{
+        struct intel_none_pixmap        *none_pixmap = intel_none_get_pixmap(pixmap);
+        drm_intel_bo                    *bo = (drm_intel_bo *) d_bo;
+
+        if (bo) {
+                if (drm_intel_gem_bo_map_gtt(bo) != 0)
+                        return FALSE;
+        }
+
+        if (none_pixmap->bo) {
+                drm_intel_bo_unreference(none_pixmap->bo);
+                none_pixmap->bo = NULL;
+                pixmap->devPrivate.ptr = NULL;
+        }
+
+        if (bo) {
+                pixmap->devPrivate.ptr = bo->virtual;
+                dri_bo_reference(d_bo);
+                none_pixmap->bo = bo;
+        }
+        return TRUE;
+}
+
+static Bool
+intel_none_need_bo(unsigned usage)
+{
+        if (usage == CREATE_PIXMAP_USAGE_BACKING_PIXMAP)
+                return TRUE;
+        if (usage & INTEL_CREATE_PIXMAP_DRI2)
+                return TRUE;
+        return FALSE;
+}
+
+static PixmapPtr
+intel_none_create_pixmap(ScreenPtr screen, int width, int height, int depth,
+                         unsigned usage)
+{
+	struct intel_none_screen        *none_screen = intel_none_get_screen(screen);
+        PixmapPtr                       pixmap;
+
+        screen->CreatePixmap = none_screen->CreatePixmap;
+        if (!intel_none_need_bo(usage) || width == 0 || height == 0) {
+                pixmap = screen->CreatePixmap(screen, width, height, depth, usage);
+                goto done;
+        }
+
+	pixmap = screen->CreatePixmap(screen, 0, 0, depth, usage);
+
+        if (pixmap && width && height) {
+                unsigned int                    size, tiling;
+                int                             ret, stride;
+                struct intel_none_pixmap        *none_pixmap = intel_none_get_pixmap(pixmap);
+                ScrnInfoPtr                     scrn = xf86ScreenToScrn(screen);
+                intel_screen_private            *intel = intel_get_screen_private(scrn);
+
+                tiling = I915_TILING_X;
+		size = intel_compute_size(intel,
+                                          width, height,
+                                          pixmap->drawable.bitsPerPixel, usage,
+                                          &tiling, &stride);
+                none_pixmap->bo = drm_intel_bo_alloc(intel->bufmgr,
+                                                     "pixmap", size, 0);
+
+                if (!none_pixmap->bo) {
+                        screen->DestroyPixmap(pixmap);
+                        pixmap = NULL;
+                        goto done;
+                }
+
+		if (tiling != I915_TILING_NONE)
+			drm_intel_bo_set_tiling(none_pixmap->bo, &tiling, stride);
+
+                ret = drm_intel_gem_bo_map_gtt(none_pixmap->bo);
+                if (ret) {
+                        screen->DestroyPixmap(pixmap);
+                        pixmap = NULL;
+                        goto done;
+                }
+
+		screen->ModifyPixmapHeader(pixmap, width, height, 0, 0, stride,
+                                           none_pixmap->bo->virtual);
+        }
+done:
+        none_screen->CreatePixmap = screen->CreatePixmap;
+        screen->CreatePixmap = intel_none_create_pixmap;
+        return pixmap;
+}
+
+static Bool
+intel_none_destroy_pixmap(PixmapPtr pixmap)
+{
+        ScreenPtr                       screen = pixmap->drawable.pScreen;
+	struct intel_none_screen        *none_screen = intel_none_get_screen(screen);
+        struct intel_none_pixmap        *none_pixmap = intel_none_get_pixmap(pixmap);
+        Bool                            ret;
+
+        screen->DestroyPixmap = none_screen->DestroyPixmap;
+        if (pixmap->refcnt <= 1) {
+                if (none_pixmap->bo) {
+                        drm_intel_bo_unreference(none_pixmap->bo);
+                        none_pixmap->bo = NULL;
+                }
+        }
+
+        ret = screen->DestroyPixmap(pixmap);
+
+        none_screen->DestroyPixmap = screen->DestroyPixmap;
+        screen->DestroyPixmap = intel_none_destroy_pixmap;
+        return ret;
+}
+
+Bool
+intel_none_init(ScreenPtr screen)
+{
+	ScrnInfoPtr                     scrn = xf86ScreenToScrn(screen);
+	intel_screen_private            *intel = intel_get_screen_private(scrn);
+        struct intel_none_screen        *none_screen;
+	dri_bo                          *bo = intel->front_buffer;
+        int                             ret;
+
+	ret = drm_intel_gem_bo_map_gtt(bo);
+        if (ret)
+                return FALSE;
+
+        if (!intel_fb_init(screen, bo->virtual))
+                return FALSE;
+
+        if (!dixRegisterPrivateKey(&intel_none_screen_key, PRIVATE_SCREEN, sizeof (struct intel_none_screen)))
+                return FALSE;
+
+        if (!dixRegisterPrivateKey(&intel_none_pixmap_key, PRIVATE_PIXMAP, sizeof (struct intel_none_pixmap)))
+                return FALSE;
+
+        none_screen = intel_none_get_screen(screen);
+
+        none_screen->CreatePixmap = screen->CreatePixmap;
+        screen->CreatePixmap = intel_none_create_pixmap;
+
+        none_screen->DestroyPixmap = screen->DestroyPixmap;
+        screen->DestroyPixmap = intel_none_destroy_pixmap;
+
+        return TRUE;
+}
+
+Bool
+intel_none_create_screen_resources(ScreenPtr screen)
+{
+	ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
+	PixmapPtr pixmap;
+	intel_screen_private *intel = intel_get_screen_private(scrn);
+	dri_bo *bo = intel->front_buffer;
+
+	pixmap = screen->GetScreenPixmap(screen);
+
+        if (!intel_none_set_pixmap_bo(pixmap, bo))
+                return FALSE;
+
+	if (!screen->ModifyPixmapHeader(pixmap,
+					scrn->virtualX,
+					scrn->virtualY,
+					-1, -1,
+					intel->front_pitch,
+					NULL))
+		return FALSE;
+
+	scrn->displayWidth = intel->front_pitch / intel->cpp;
+
+	return TRUE;
+}
+
+void
+intel_none_exchange_buffers(struct intel_screen_private *intel,
+                            PixmapPtr front,
+                            PixmapPtr back)
+{
+	struct intel_none_pixmap *front_priv, *back_priv;
+        dri_bo *tmp;
+
+	front_priv = intel_none_get_pixmap(front);
+	back_priv = intel_none_get_pixmap(back);
+        tmp = front_priv->bo;
+        front_priv->bo = back_priv->bo;
+        back_priv->bo = tmp;
+}
+
+Bool
+intel_none_copy_pixmap(PixmapPtr src_pixmap, PixmapPtr dst_pixmap)
+{
+	FbBits *src;
+	FbStride srcStride;
+	int srcBpp;
+	int srcXoff, srcYoff;
+	FbBits *dst;
+	FbStride dstStride;
+	int dstBpp;
+	int dstXoff, dstYoff;
+	int width, height;
+
+	width = min (src_pixmap->drawable.width, dst_pixmap->drawable.width);
+	height = min (src_pixmap->drawable.height, dst_pixmap->drawable.height);
+
+	fbGetDrawable(&src_pixmap->drawable, src, srcStride, srcBpp, srcXoff, srcYoff);
+	fbGetDrawable(&dst_pixmap->drawable, dst, dstStride, dstBpp, dstXoff, dstYoff);
+
+	pixman_blt((uint32_t *) src,
+		   (uint32_t *) dst,
+		   srcStride,
+		   dstStride,
+		   srcBpp,
+		   dstBpp,
+		   srcXoff, srcYoff, dstXoff, dstYoff,
+		   width, height);
+	return TRUE;
+}
+
diff --git a/src/uxa/intel_none.h b/src/uxa/intel_none.h
new file mode 100644
index 0000000..ec587c0
--- /dev/null
+++ b/src/uxa/intel_none.h
@@ -0,0 +1,46 @@
+/*
+ * Copyright © 2014 Keith Packard
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that copyright
+ * notice and this permission notice appear in supporting documentation, and
+ * that the name of the copyright holders not be used in advertising or
+ * publicity pertaining to distribution of the software without specific,
+ * written prior permission.  The copyright holders make no representations
+ * about the suitability of this software for any purpose.  It is provided "as
+ * is" without express or implied warranty.
+ *
+ * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+#ifndef _INTEL_NONE_H_
+#define _INTEL_NONE_H_
+
+Bool
+intel_none_init(ScreenPtr screen);
+
+Bool
+intel_none_create_screen_resources(ScreenPtr screen);
+
+dri_bo *
+intel_none_get_pixmap_bo(PixmapPtr pixmap);
+
+Bool
+intel_none_set_pixmap_bo(PixmapPtr pixmap, dri_bo *dri_bo);
+
+void
+intel_none_exchange_buffers(struct intel_screen_private *intel,
+                            PixmapPtr front,
+                            PixmapPtr back);
+
+Bool
+intel_none_copy_pixmap(PixmapPtr src_pixmap, PixmapPtr dst_pixmap);
+
+#endif /* _INTEL_NONE_H_ */
diff --git a/src/uxa/intel_uxa.c b/src/uxa/intel_uxa.c
index b078921..cd1d0a5 100644
--- a/src/uxa/intel_uxa.c
+++ b/src/uxa/intel_uxa.c
@@ -1277,6 +1277,9 @@ Bool intel_uxa_init(ScreenPtr screen)
 	ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
 	intel_screen_private *intel = intel_get_screen_private(scrn);
 
+        if (!intel_fb_init(screen, NULL))
+		return FALSE;
+
 	intel_batch_init(scrn);
 
 	if (INTEL_INFO(intel)->gen >= 040 && INTEL_INFO(intel)->gen < 0100)
-- 
2.1.1



More information about the xorg-devel mailing list