[PATCH 18/18] Add "none" acceleration option
Keith Packard
keithp at keithp.com
Sat Aug 16 23:13:21 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 | 5 +
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 | 268 ++++++++++++++++++++++++++++++++++++++++++++++++
src/uxa/intel_none.h | 43 ++++++++
src/uxa/intel_uxa.c | 3 +
13 files changed, 508 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 2126f35..9cb0756 100644
--- a/configure.ac
+++ b/configure.ac
@@ -396,7 +396,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
@@ -417,6 +416,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`
@@ -661,6 +662,8 @@ if test "x$accel" = "xauto"; then
else
if test "x$GLAMOR" != "xno"; then
accel="glamor"
+ else
+ accel="none"
fi
fi
fi
@@ -669,11 +672,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
@@ -682,7 +683,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
@@ -691,22 +691,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=""
@@ -859,11 +852,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
@@ -871,13 +859,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
@@ -892,6 +873,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 b1902a2..c9143ea 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;
@@ -475,6 +478,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 14a7398..a04da6d 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)
@@ -1495,6 +1496,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++) {
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 b3ac742..732282a 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;
intel_copy_fb(scrn);
#endif
+ case ACCEL_NONE:
+ if (!intel_none_create_screen_resources(screen))
+ return FALSE;
+ break;
}
return TRUE;
@@ -201,6 +206,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;
@@ -222,6 +230,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;
@@ -242,6 +252,8 @@ intel_flush(intel_screen_private *intel)
intel_batch_submit(intel->scrn);
break;
#endif
+ default:
+ break;
}
}
@@ -278,6 +290,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) {
@@ -292,6 +307,9 @@ static void intel_check_accel_option(ScrnInfoPtr scrn)
intel->accel = ACCEL_UXA;
break;
#endif
+ case NOACCEL:
+ intel->accel = ACCEL_NONE;
+ break;
}
}
@@ -378,10 +396,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);
@@ -390,6 +411,7 @@ static int intel_init_bufmgr(intel_screen_private *intel)
drm_intel_bo_alloc(intel->bufmgr, "wa scratch",
4096, 4096);
}
+#endif
return TRUE;
}
@@ -399,7 +421,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);
}
@@ -713,7 +738,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
@@ -724,12 +753,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;
}
@@ -767,7 +798,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);
@@ -834,8 +865,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
@@ -981,12 +1016,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;
@@ -1017,32 +1086,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:
@@ -1064,6 +1107,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;
@@ -1071,7 +1130,8 @@ I830ScreenInit(SCREEN_INIT_ARGS_DECL)
intel->dri3 = DRI_ACTIVE;
#endif
break;
-#endif
+ default:
+ break;
}
#if HAVE_DRI2
@@ -1163,6 +1223,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:
@@ -1182,7 +1245,6 @@ I830ScreenInit(SCREEN_INIT_ARGS_DECL)
xf86DrvMsg(scrn->scrnIndex, X_INFO,
"DRI3: Not available\n");
#endif
-#endif
break;
default:
break;
@@ -1292,16 +1354,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;
@@ -1332,9 +1387,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);
@@ -1356,7 +1430,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 15fe369..05e8a43 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..b1091aa
--- /dev/null
+++ b/src/uxa/intel_none.c
@@ -0,0 +1,268 @@
+/*
+ * 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;
+}
diff --git a/src/uxa/intel_none.h b/src/uxa/intel_none.h
new file mode 100644
index 0000000..0341a7e
--- /dev/null
+++ b/src/uxa/intel_none.h
@@ -0,0 +1,43 @@
+/*
+ * 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);
+
+#endif /* _INTEL_NONE_H_ */
diff --git a/src/uxa/intel_uxa.c b/src/uxa/intel_uxa.c
index 9eaa1a1..d40820e 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.0.1
More information about the xorg-devel
mailing list