summaryrefslogtreecommitdiffstats
path: root/abs
diff options
context:
space:
mode:
authorJames Meyer <james.meyer@operamail.com>2014-08-16 19:51:12 (GMT)
committerJames Meyer <james.meyer@operamail.com>2014-08-16 19:51:12 (GMT)
commit4bcecbbe9042ee7b2d002525e53b4af86abb8139 (patch)
tree793c257dcf6419d40639d9eb8b360d079775c13b /abs
parentb89c550af6853616fbc83bd61744b2b2b04c6875 (diff)
downloadlinhes_pkgbuild-4bcecbbe9042ee7b2d002525e53b4af86abb8139.zip
linhes_pkgbuild-4bcecbbe9042ee7b2d002525e53b4af86abb8139.tar.gz
linhes_pkgbuild-4bcecbbe9042ee7b2d002525e53b4af86abb8139.tar.bz2
xf86-video-vmware: 13.0.1 updated due to mesa update to 10
Diffstat (limited to 'abs')
-rw-r--r--abs/core/xf86-video-vmware/PKGBUILD30
-rw-r--r--abs/core/xf86-video-vmware/git_fixes.diff894
-rw-r--r--abs/core/xf86-video-vmware/xatracker-v2-fixes.patch1583
3 files changed, 1601 insertions, 906 deletions
diff --git a/abs/core/xf86-video-vmware/PKGBUILD b/abs/core/xf86-video-vmware/PKGBUILD
index fe55462..488d62a 100644
--- a/abs/core/xf86-video-vmware/PKGBUILD
+++ b/abs/core/xf86-video-vmware/PKGBUILD
@@ -1,31 +1,37 @@
-# $Id: PKGBUILD 168595 2012-10-13 11:46:27Z andyrtr $
+# $Id: PKGBUILD 202951 2013-12-29 08:00:15Z andyrtr $
# Maintainer: Jan de Groot <jgc@archlinux.org>
pkgname=xf86-video-vmware
-pkgver=12.0.2
-pkgrel=2
+pkgver=13.0.1
+pkgrel=3
pkgdesc="X.org vmware video driver"
arch=(i686 x86_64)
url="http://xorg.freedesktop.org/"
license=('custom')
-depends=('libdrm' 'svga-dri' 'mesa')
-makedepends=('xorg-server-devel' 'X-ABI-VIDEODRV_VERSION=13' 'resourceproto' 'scrnsaverproto')
+depends=('libdrm' 'svga-dri' 'mesa>=10.0')
+makedepends=('xorg-server-devel' 'X-ABI-VIDEODRV_VERSION=13')
conflicts=('xorg-server<1.13.0' 'X-ABI-VIDEODRV_VERSION<13' 'X-ABI-VIDEODRV_VERSION>=14')
groups=('xorg-drivers' 'xorg')
-options=('!libtool' '!emptydirs')
-source=(${url}/releases/individual/driver/${pkgname}-${pkgver}.tar.bz2 git_fixes.diff)
-sha1sums=('efa47f365d88da245804a9934719ff860ed04f95'
- 'ad475b37e2614f365533a40da0fb5b9e2709e3c6')
+options=('!emptydirs')
+source=(${url}/releases/individual/driver/${pkgname}-${pkgver}.tar.bz2
+ xatracker-v2-fixes.patch)
+sha256sums=('802dda415c22412edad6c3df44fe18a06e91d0f8456d9a58bac0d340fdf8fe3d'
+ '7ab392cbc6258dc36df14ef60072c655d850bcfb6885111b41bcfe25dc1faacc')
+
+prepare() {
+ cd ${pkgname}-${pkgver}
+ # grab from upstream git repo, needed for mesa>10.0
+ patch -Np1 -i ../xatracker-v2-fixes.patch
+}
build() {
- cd "${srcdir}/${pkgname}-${pkgver}"
- patch -Np1 -i ${srcdir}/git_fixes.diff
+ cd ${pkgname}-${pkgver}
./configure --prefix=/usr --enable-vmwarectrl-client
make
}
package() {
- cd "${srcdir}/${pkgname}-${pkgver}"
+ cd ${pkgname}-${pkgver}
make DESTDIR="${pkgdir}" install
install -m755 -d "${pkgdir}/usr/share/licenses/${pkgname}"
diff --git a/abs/core/xf86-video-vmware/git_fixes.diff b/abs/core/xf86-video-vmware/git_fixes.diff
deleted file mode 100644
index 8589416..0000000
--- a/abs/core/xf86-video-vmware/git_fixes.diff
+++ /dev/null
@@ -1,894 +0,0 @@
-From 46cdf0ed0ad9df66f36f95e27b209d454f67d526 Mon Sep 17 00:00:00 2001
-From: Brian Paul <brianp@vmware.com>
-Date: Fri, 20 Apr 2012 20:24:26 +0000
-Subject: vmwgfx: set the XA_FLAG_SHARED flag for composite dest surfaces
-
-This fixes a failed assertion in the gallium/svga driver in the
-svga_texture_get_handle() function. The texture resource wasn't
-getting created with the PIPE_BIND_SHARED flag so the !cachable
-assertion would fail and the X session would abort. This didn't
-happen with release builds.
-
-Reviewed-by: Jakob Bornecrantz <jakob@vmware.com>
----
-diff --git a/vmwgfx/vmwgfx_xa_surface.c b/vmwgfx/vmwgfx_xa_surface.c
-index 2a18762..8b30e45 100644
---- a/vmwgfx/vmwgfx_xa_surface.c
-+++ b/vmwgfx/vmwgfx_xa_surface.c
-@@ -148,7 +148,7 @@ vmwgfx_hw_composite_dst_stage(PixmapPtr pixmap,
-
- vpix->staging_format = format;
- vpix->staging_remove_flags = 0;
-- vpix->staging_add_flags = XA_FLAG_RENDER_TARGET;
-+ vpix->staging_add_flags = XA_FLAG_RENDER_TARGET | XA_FLAG_SHARED;
-
- return TRUE;
- }
---
-cgit v0.9.0.2-2-gbebe
-From 61df95a86f4997e342d50d7779b00aba2e8849a6 Mon Sep 17 00:00:00 2001
-From: Dave Airlie <airlied@redhat.com>
-Date: Wed, 06 Jun 2012 08:58:01 +0000
-Subject: vmware: port vmware driver to new compat API
-
-This is a port of the vmware driver to the new compat API.
-
-Tested-by: Jakob Bornecrantz <jakob@vmware.com>
-Reviewed-by: Jakob Bornecrantz <jakob@vmware.com>
-Signed-off-by: Dave Airlie <airlied@redhat.com>
-Signed-off-by: Jakob Bornecrantz <jakob@vmware.com>
----
-diff --git a/saa/saa.c b/saa/saa.c
-index 173c090..f2d68e9 100644
---- a/saa/saa.c
-+++ b/saa/saa.c
-@@ -594,7 +594,7 @@ saa_set_fallback_debug(ScreenPtr screen, Bool enable)
- * screen private, before calling down to the next CloseScreen.
- */
- Bool
--saa_close_screen(int i, ScreenPtr pScreen)
-+saa_close_screen(CLOSE_SCREEN_ARGS_DECL)
- {
- struct saa_screen_priv *sscreen = saa_screen(pScreen);
- struct saa_driver *driver = sscreen->driver;
-@@ -624,7 +624,7 @@ saa_close_screen(int i, ScreenPtr pScreen)
-
- free(sscreen);
-
-- return (*pScreen->CloseScreen) (i, pScreen);
-+ return (*pScreen->CloseScreen) (CLOSE_SCREEN_ARGS);
- }
-
- struct saa_driver *
-diff --git a/saa/saa.h b/saa/saa.h
-index c7aa3b6..4e5ced5 100644
---- a/saa/saa.h
-+++ b/saa/saa.h
-@@ -44,6 +44,8 @@
- #include <damage.h>
- #include <picturestr.h>
-
-+#include "../src/compat-api.h"
-+
- #define SAA_VERSION_MAJOR 0
- #define SAA_VERSION_MINOR 1
-
-@@ -173,7 +175,7 @@ extern _X_EXPORT RegionPtr
- saa_bitmap_to_region(PixmapPtr pPix);
-
- extern _X_EXPORT Bool
--saa_close_screen(int i, ScreenPtr pScreen);
-+saa_close_screen(CLOSE_SCREEN_ARGS_DECL);
-
- extern _X_EXPORT Bool
- saa_gc_reads_destination(DrawablePtr pDrawable, GCPtr pGC);
-diff --git a/src/Makefile.am b/src/Makefile.am
-index 04c9e0d..b0dd147 100644
---- a/src/Makefile.am
-+++ b/src/Makefile.am
-@@ -37,6 +37,7 @@ endif
- vmware_drv_la_SOURCES = \
- bits2pixels.c \
- bits2pixels.h \
-+ compat-api.h \
- guest_os.h \
- includeCheck.h \
- svga_escape.h \
-diff --git a/src/compat-api.h b/src/compat-api.h
-new file mode 100644
-index 0000000..6bc946f
---- a/dev/null
-+++ b/src/compat-api.h
-@@ -0,0 +1,99 @@
-+/*
-+ * Copyright 2012 Red Hat, Inc.
-+ *
-+ * Permission is hereby granted, free of charge, to any person obtaining a
-+ * copy of this software and associated documentation files (the "Software"),
-+ * to deal in the Software without restriction, including without limitation
-+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
-+ * and/or sell copies of the Software, and to permit persons to whom the
-+ * Software is furnished to do so, subject to the following conditions:
-+ *
-+ * The above copyright notice and this permission notice (including the next
-+ * paragraph) shall be included in all copies or substantial portions of the
-+ * Software.
-+ *
-+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
-+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-+ * LIABILITY, WHETHER 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.
-+ *
-+ * Author: Dave Airlie <airlied@redhat.com>
-+ */
-+
-+/* this file provides API compat between server post 1.13 and pre it,
-+ it should be reused inside as many drivers as possible */
-+#ifndef COMPAT_API_H
-+#define COMPAT_API_H
-+
-+#ifndef GLYPH_HAS_GLYPH_PICTURE_ACCESSOR
-+#define GetGlyphPicture(g, s) GlyphPicture((g))[(s)->myNum]
-+#define SetGlyphPicture(g, s, p) GlyphPicture((g))[(s)->myNum] = p
-+#endif
-+
-+#ifndef XF86_HAS_SCRN_CONV
-+#define xf86ScreenToScrn(s) xf86Screens[(s)->myNum]
-+#define xf86ScrnToScreen(s) screenInfo.screens[(s)->scrnIndex]
-+#endif
-+
-+#ifndef XF86_SCRN_INTERFACE
-+
-+#define SCRN_ARG_TYPE int
-+#define SCRN_INFO_PTR(arg1) ScrnInfoPtr pScrn = xf86Screens[(arg1)]
-+
-+#define SCREEN_ARG_TYPE int
-+#define SCREEN_PTR(arg1) ScreenPtr pScreen = screenInfo.screens[(arg1)]
-+
-+#define SCREEN_INIT_ARGS_DECL int i, ScreenPtr pScreen, int argc, char **argv
-+
-+#define BLOCKHANDLER_ARGS_DECL int arg, pointer blockData, pointer pTimeout, pointer pReadmask
-+#define BLOCKHANDLER_ARGS arg, blockData, pTimeout, pReadmask
-+
-+#define CLOSE_SCREEN_ARGS_DECL int scrnIndex, ScreenPtr pScreen
-+#define CLOSE_SCREEN_ARGS scrnIndex, pScreen
-+
-+#define ADJUST_FRAME_ARGS_DECL int arg, int x, int y, int flags
-+#define ADJUST_FRAME_ARGS(arg, x, y) (arg)->scrnIndex, x, y, 0
-+
-+#define SWITCH_MODE_ARGS_DECL int arg, DisplayModePtr mode, int flags
-+#define SWITCH_MODE_ARGS(arg, m) (arg)->scrnIndex, m, 0
-+
-+#define FREE_SCREEN_ARGS_DECL int arg, int flags
-+
-+#define VT_FUNC_ARGS_DECL int arg, int flags
-+#define VT_FUNC_ARGS pScrn->scrnIndex, 0
-+
-+#define XF86_SCRN_ARG(x) ((x)->scrnIndex)
-+#else
-+#define SCRN_ARG_TYPE ScrnInfoPtr
-+#define SCRN_INFO_PTR(arg1) ScrnInfoPtr pScrn = (arg1)
-+
-+#define SCREEN_ARG_TYPE ScreenPtr
-+#define SCREEN_PTR(arg1) ScreenPtr pScreen = (arg1)
-+
-+#define SCREEN_INIT_ARGS_DECL ScreenPtr pScreen, int argc, char **argv
-+
-+#define BLOCKHANDLER_ARGS_DECL ScreenPtr arg, pointer pTimeout, pointer pReadmask
-+#define BLOCKHANDLER_ARGS arg, pTimeout, pReadmask
-+
-+#define CLOSE_SCREEN_ARGS_DECL ScreenPtr pScreen
-+#define CLOSE_SCREEN_ARGS pScreen
-+
-+#define ADJUST_FRAME_ARGS_DECL ScrnInfoPtr arg, int x, int y
-+#define ADJUST_FRAME_ARGS(arg, x, y) arg, x, y
-+
-+#define SWITCH_MODE_ARGS_DECL ScrnInfoPtr arg, DisplayModePtr mode
-+#define SWITCH_MODE_ARGS(arg, m) arg, m
-+
-+#define FREE_SCREEN_ARGS_DECL ScrnInfoPtr arg
-+
-+#define VT_FUNC_ARGS_DECL ScrnInfoPtr arg
-+#define VT_FUNC_ARGS pScrn
-+
-+#define XF86_SCRN_ARG(x) (x)
-+
-+#endif
-+
-+#endif
-diff --git a/src/vmware.c b/src/vmware.c
-index e3892f1..41201f1 100644
---- a/src/vmware.c
-+++ b/src/vmware.c
-@@ -901,8 +901,8 @@ VMWAREModeInit(ScrnInfoPtr pScrn, DisplayModePtr mode, Bool rebuildPixmap)
- pScrn->pScreen->rootDepth),
- (pointer)(pVMWARE->FbBase + pScrn->fbOffset));
-
-- (*pScrn->EnableDisableFBAccess)(pScrn->pScreen->myNum, FALSE);
-- (*pScrn->EnableDisableFBAccess)(pScrn->pScreen->myNum, TRUE);
-+ (*pScrn->EnableDisableFBAccess)(XF86_SCRN_ARG(pScrn), FALSE);
-+ (*pScrn->EnableDisableFBAccess)(XF86_SCRN_ARG(pScrn), TRUE);
- }
-
- vgaHWProtect(pScrn, FALSE);
-@@ -1018,7 +1018,7 @@ vmwareNextXineramaState(VMWAREPtr pVMWARE)
- }
-
- static void
--VMWAREAdjustFrame(int scrnIndex, int x, int y, int flags)
-+VMWAREAdjustFrame(ADJUST_FRAME_ARGS_DECL)
- {
- /* FIXME */
- }
-@@ -1089,9 +1089,9 @@ VMWAREStopFIFO(ScrnInfoPtr pScrn)
- }
-
- static Bool
--VMWARECloseScreen(int scrnIndex, ScreenPtr pScreen)
-+VMWARECloseScreen(CLOSE_SCREEN_ARGS_DECL)
- {
-- ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
-+ ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
- VMWAREPtr pVMWARE = VMWAREPTR(pScrn);
- ScreenPtr save = &pVMWARE->ScrnFuncs;
-
-@@ -1119,7 +1119,7 @@ VMWARECloseScreen(int scrnIndex, ScreenPtr pScreen)
- pScrn->DriverFunc = NULL;
- #endif
-
-- return (*pScreen->CloseScreen)(scrnIndex, pScreen);
-+ return (*pScreen->CloseScreen)(CLOSE_SCREEN_ARGS);
- }
-
- static Bool
-@@ -1296,16 +1296,14 @@ vmwareIsRegionEqual(const RegionPtr reg1,
- }
-
- static Bool
--VMWAREScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
-+VMWAREScreenInit(SCREEN_INIT_ARGS_DECL)
- {
-- ScrnInfoPtr pScrn;
-+ ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
- vgaHWPtr hwp;
- VMWAREPtr pVMWARE;
- OptionInfoPtr options;
- Bool useXinerama = TRUE;
-
-- /* Get the ScrnInfoRec */
-- pScrn = xf86Screens[pScreen->myNum];
- pVMWARE = VMWAREPTR(pScrn);
-
-
-@@ -1381,7 +1379,7 @@ VMWAREScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
- VMWAREModeInit(pScrn, pScrn->currentMode, FALSE);
-
- /* Set the viewport if supported */
-- VMWAREAdjustFrame(scrnIndex, pScrn->frameX0, pScrn->frameY0, 0);
-+ VMWAREAdjustFrame(ADJUST_FRAME_ARGS(pScrn, pScrn->frameX0, pScrn->frameY0));
-
- /*
- * Setup the screen's visuals, and initialise the framebuffer
-@@ -1582,10 +1580,9 @@ VMWAREScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
- }
-
- static Bool
--VMWARESwitchMode(int scrnIndex, DisplayModePtr mode, int flags)
--
-+VMWARESwitchMode(SWITCH_MODE_ARGS_DECL)
- {
-- ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
-+ SCRN_INFO_PTR(arg);
- ScreenPtr pScreen = pScrn->pScreen;
-
- pScreen->mmWidth = (pScreen->width * VMWARE_INCHTOMM +
-@@ -1597,9 +1594,9 @@ VMWARESwitchMode(int scrnIndex, DisplayModePtr mode, int flags)
- }
-
- static Bool
--VMWAREEnterVT(int scrnIndex, int flags)
-+VMWAREEnterVT(VT_FUNC_ARGS_DECL)
- {
-- ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
-+ SCRN_INFO_PTR(arg);
- VMWAREPtr pVMWARE = VMWAREPTR(pScrn);
-
- /*
-@@ -1616,9 +1613,9 @@ VMWAREEnterVT(int scrnIndex, int flags)
- }
-
- static void
--VMWARELeaveVT(int scrnIndex, int flags)
-+VMWARELeaveVT(VT_FUNC_ARGS_DECL)
- {
-- ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
-+ SCRN_INFO_PTR(arg);
- VMWAREPtr pVMWARE = VMWAREPTR(pScrn);
-
- /*
-@@ -1631,17 +1628,18 @@ VMWARELeaveVT(int scrnIndex, int flags)
- }
-
- static void
--VMWAREFreeScreen(int scrnIndex, int flags)
-+VMWAREFreeScreen(FREE_SCREEN_ARGS_DECL)
- {
-+ SCRN_INFO_PTR(arg);
- /*
- * If the vgahw module is used vgaHWFreeHWRec() would be called
- * here.
- */
-- VMWAREFreeRec(xf86Screens[scrnIndex]);
-+ VMWAREFreeRec(pScrn);
- }
-
- static ModeStatus
--VMWAREValidMode(int scrnIndex, DisplayModePtr mode, Bool verbose, int flags)
-+VMWAREValidMode(SCRN_ARG_TYPE arg, DisplayModePtr mode, Bool verbose, int flags)
- {
- return MODE_OK;
- }
-diff --git a/src/vmware.h b/src/vmware.h
-index 458390a..4818e16 100644
---- a/src/vmware.h
-+++ b/src/vmware.h
-@@ -177,7 +177,7 @@ typedef struct {
- #define VMWAREPTR(p) ((VMWAREPtr)((p)->driverPrivate))
-
- static __inline ScrnInfoPtr infoFromScreen(ScreenPtr s) {
-- return xf86Screens[s->myNum];
-+ return xf86ScreenToScrn(s);
- }
-
- #define MIN(a,b) ((a)<(b)?(a):(b))
-diff --git a/src/vmware_common.h b/src/vmware_common.h
-index 9cd7194..5629c10 100644
---- a/src/vmware_common.h
-+++ b/src/vmware_common.h
-@@ -32,6 +32,8 @@
- #include <X11/extensions/panoramiXproto.h>
- #include <xf86.h>
-
-+#include "compat-api.h"
-+
- xXineramaScreenInfo *
- VMWAREParseTopologyString(ScrnInfoPtr pScrn,
- const char *topology,
-diff --git a/vmwgfx/vmwgfx_dri2.c b/vmwgfx/vmwgfx_dri2.c
-index 1b82ac4..7de0772 100644
---- a/vmwgfx/vmwgfx_dri2.c
-+++ b/vmwgfx/vmwgfx_dri2.c
-@@ -83,7 +83,7 @@ static Bool
- dri2_do_create_buffer(DrawablePtr pDraw, DRI2Buffer2Ptr buffer, unsigned int format)
- {
- ScreenPtr pScreen = pDraw->pScreen;
-- ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
-+ ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
- modesettingPtr ms = modesettingPTR(pScrn);
- BufferPrivatePtr private = buffer->driverPrivate;
- PixmapPtr pPixmap;
-@@ -371,7 +371,7 @@ dri2_copy_region(DrawablePtr pDraw, RegionPtr pRegion,
- Bool
- xorg_dri2_init(ScreenPtr pScreen)
- {
-- ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
-+ ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
- modesettingPtr ms = modesettingPTR(pScrn);
- DRI2InfoRec dri2info;
- int major, minor;
-diff --git a/vmwgfx/vmwgfx_driver.c b/vmwgfx/vmwgfx_driver.c
-index ed1eb8c..9959ffb 100644
---- a/vmwgfx/vmwgfx_driver.c
-+++ b/vmwgfx/vmwgfx_driver.c
-@@ -107,14 +107,13 @@ typedef uint8_t uint8;
- */
-
- static Bool drv_pre_init(ScrnInfoPtr pScrn, int flags);
--static Bool drv_screen_init(int scrnIndex, ScreenPtr pScreen, int argc,
-- char **argv);
--static Bool drv_switch_mode(int scrnIndex, DisplayModePtr mode, int flags);
--static void drv_adjust_frame(int scrnIndex, int x, int y, int flags);
--static Bool drv_enter_vt(int scrnIndex, int flags);
--static void drv_leave_vt(int scrnIndex, int flags);
--static void drv_free_screen(int scrnIndex, int flags);
--static ModeStatus drv_valid_mode(int scrnIndex, DisplayModePtr mode, Bool verbose,
-+static Bool drv_screen_init(SCREEN_INIT_ARGS_DECL);
-+static Bool drv_switch_mode(SWITCH_MODE_ARGS_DECL);
-+static void drv_adjust_frame(ADJUST_FRAME_ARGS_DECL);
-+static Bool drv_enter_vt(VT_FUNC_ARGS_DECL);
-+static void drv_leave_vt(VT_FUNC_ARGS_DECL);
-+static void drv_free_screen(FREE_SCREEN_ARGS_DECL);
-+static ModeStatus drv_valid_mode(SCRN_ARG_TYPE arg, DisplayModePtr mode, Bool verbose,
- int flags);
-
- extern void xorg_tracker_set_functions(ScrnInfoPtr scrn);
-@@ -133,7 +132,7 @@ vmwgfx_hookup(ScrnInfoPtr pScrn)
- * Internal function definitions
- */
-
--static Bool drv_close_screen(int scrnIndex, ScreenPtr pScreen);
-+static Bool drv_close_screen(CLOSE_SCREEN_ARGS_DECL);
-
- /*
- * Internal functions
-@@ -633,7 +632,7 @@ vmwgfx_scanout_present(ScreenPtr pScreen, int drm_fd,
-
- void xorg_flush(ScreenPtr pScreen)
- {
-- ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
-+ ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
- modesettingPtr ms = modesettingPTR(pScrn);
- xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn);
- PixmapPtr pixmap = NULL;
-@@ -708,14 +707,13 @@ void xorg_flush(ScreenPtr pScreen)
- free(pixmaps);
- }
-
--static void drv_block_handler(int i, pointer blockData, pointer pTimeout,
-- pointer pReadmask)
-+static void drv_block_handler(BLOCKHANDLER_ARGS_DECL)
- {
-- ScreenPtr pScreen = screenInfo.screens[i];
-- modesettingPtr ms = modesettingPTR(xf86Screens[pScreen->myNum]);
-+ SCREEN_PTR(arg);
-+ modesettingPtr ms = modesettingPTR(xf86ScreenToScrn(pScreen));
-
- vmwgfx_swap(ms, pScreen, BlockHandler);
-- pScreen->BlockHandler(i, blockData, pTimeout, pReadmask);
-+ pScreen->BlockHandler(BLOCKHANDLER_ARGS);
- vmwgfx_swap(ms, pScreen, BlockHandler);
-
- vmwgfx_flush_dri2(pScreen);
-@@ -725,7 +723,7 @@ static void drv_block_handler(int i, pointer blockData, pointer pTimeout,
- static Bool
- drv_create_screen_resources(ScreenPtr pScreen)
- {
-- ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
-+ ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
- modesettingPtr ms = modesettingPTR(pScrn);
- Bool ret;
-
-@@ -735,9 +733,9 @@ drv_create_screen_resources(ScreenPtr pScreen)
- if (!ret)
- return ret;
-
-- drv_adjust_frame(pScrn->scrnIndex, pScrn->frameX0, pScrn->frameY0, 0);
-+ drv_adjust_frame(ADJUST_FRAME_ARGS(pScrn, pScrn->frameX0, pScrn->frameY0));
-
-- return drv_enter_vt(pScreen->myNum, 1);
-+ return drv_enter_vt(VT_FUNC_ARGS);
- }
-
- static Bool
-@@ -773,7 +771,7 @@ drv_set_master(ScrnInfoPtr pScrn)
- static Bool
- vmwgfx_use_hw_cursor_argb(ScreenPtr screen, CursorPtr cursor)
- {
-- ScrnInfoPtr pScrn = xf86Screens[screen->myNum];
-+ ScrnInfoPtr pScrn = xf86ScreenToScrn(screen);
- xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(pScrn);
- xf86CursorInfoPtr cursor_info = xf86_config->cursor_info;
- modesettingPtr ms = modesettingPTR(pScrn);
-@@ -804,7 +802,7 @@ vmwgfx_use_hw_cursor_argb(ScreenPtr screen, CursorPtr cursor)
- static Bool
- vmwgfx_use_hw_cursor(ScreenPtr screen, CursorPtr cursor)
- {
-- ScrnInfoPtr pScrn = xf86Screens[screen->myNum];
-+ ScrnInfoPtr pScrn = xf86ScreenToScrn(screen);
- xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(pScrn);
- xf86CursorInfoPtr cursor_info = xf86_config->cursor_info;
- modesettingPtr ms = modesettingPTR(pScrn);
-@@ -902,9 +900,9 @@ static void drv_load_palette(ScrnInfoPtr pScrn, int numColors,
-
-
- static Bool
--drv_screen_init(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
-+drv_screen_init(SCREEN_INIT_ARGS_DECL)
- {
-- ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
-+ ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
- modesettingPtr ms = modesettingPTR(pScrn);
- VisualPtr visual;
-
-@@ -1088,9 +1086,9 @@ drv_screen_init(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
- }
-
- static void
--drv_adjust_frame(int scrnIndex, int x, int y, int flags)
-+drv_adjust_frame(ADJUST_FRAME_ARGS_DECL)
- {
-- ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
-+ SCRN_INFO_PTR(arg);
- xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn);
- xf86OutputPtr output = config->output[config->compat_output];
- xf86CrtcPtr crtc = output->crtc;
-@@ -1104,15 +1102,16 @@ drv_adjust_frame(int scrnIndex, int x, int y, int flags)
- }
-
- static void
--drv_free_screen(int scrnIndex, int flags)
-+drv_free_screen(FREE_SCREEN_ARGS_DECL)
- {
-- drv_free_rec(xf86Screens[scrnIndex]);
-+ SCRN_INFO_PTR(arg);
-+ drv_free_rec(pScrn);
- }
-
- static void
--drv_leave_vt(int scrnIndex, int flags)
-+drv_leave_vt(VT_FUNC_ARGS_DECL)
- {
-- ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
-+ SCRN_INFO_PTR(arg);
- modesettingPtr ms = modesettingPTR(pScrn);
-
- vmwgfx_cursor_bypass(ms->fd, 0, 0);
-@@ -1130,9 +1129,9 @@ drv_leave_vt(int scrnIndex, int flags)
- * This gets called when gaining control of the VT, and from ScreenInit().
- */
- static Bool
--drv_enter_vt(int scrnIndex, int flags)
-+drv_enter_vt(VT_FUNC_ARGS_DECL)
- {
-- ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
-+ SCRN_INFO_PTR(arg);
-
- if (!drv_set_master(pScrn))
- return FALSE;
-@@ -1144,17 +1143,17 @@ drv_enter_vt(int scrnIndex, int flags)
- }
-
- static Bool
--drv_switch_mode(int scrnIndex, DisplayModePtr mode, int flags)
-+drv_switch_mode(SWITCH_MODE_ARGS_DECL)
- {
-- ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
-+ SCRN_INFO_PTR(arg);
-
- return xf86SetSingleMode(pScrn, mode, RR_Rotate_0);
- }
-
- static Bool
--drv_close_screen(int scrnIndex, ScreenPtr pScreen)
-+drv_close_screen(CLOSE_SCREEN_ARGS_DECL)
- {
-- ScrnInfoPtr pScrn = xf86Screens[scrnIndex];
-+ ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
- modesettingPtr ms = modesettingPTR(pScrn);
-
- if (ms->cursor) {
-@@ -1166,7 +1165,7 @@ drv_close_screen(int scrnIndex, ScreenPtr pScreen)
- xorg_dri2_close(pScreen);
-
- if (pScrn->vtSema)
-- pScrn->LeaveVT(scrnIndex, 0);
-+ pScrn->LeaveVT(VT_FUNC_ARGS);
-
- pScrn->vtSema = FALSE;
-
-@@ -1180,11 +1179,11 @@ drv_close_screen(int scrnIndex, ScreenPtr pScreen)
- if (ms->xat)
- xa_tracker_destroy(ms->xat);
-
-- return (*pScreen->CloseScreen) (scrnIndex, pScreen);
-+ return (*pScreen->CloseScreen) (CLOSE_SCREEN_ARGS);
- }
-
- static ModeStatus
--drv_valid_mode(int scrnIndex, DisplayModePtr mode, Bool verbose, int flags)
-+drv_valid_mode(SCRN_ARG_TYPE arg, DisplayModePtr mode, Bool verbose, int flags)
- {
- return MODE_OK;
- }
-diff --git a/vmwgfx/vmwgfx_driver.h b/vmwgfx/vmwgfx_driver.h
-index 4fcfed6..f78a85f 100644
---- a/vmwgfx/vmwgfx_driver.h
-+++ b/vmwgfx/vmwgfx_driver.h
-@@ -46,6 +46,7 @@
- #include <xa_tracker.h>
- #include <xf86Module.h>
-
-+#include "../src/compat-api.h"
- #ifdef DRI2
- #include <dri2.h>
- #if (!defined(DRI2INFOREC_VERSION) || (DRI2INFOREC_VERSION < 3))
-@@ -118,9 +119,9 @@ typedef struct _modesettingRec
- ScreenBlockHandlerProcPtr saved_BlockHandler;
- CreateScreenResourcesProcPtr saved_CreateScreenResources;
- CloseScreenProcPtr saved_CloseScreen;
-- Bool (*saved_EnterVT)(int, int);
-- void (*saved_LeaveVT)(int, int);
-- void (*saved_AdjustFrame)(int, int, int, int);
-+ Bool (*saved_EnterVT)(VT_FUNC_ARGS_DECL);
-+ void (*saved_LeaveVT)(VT_FUNC_ARGS_DECL);
-+ void (*saved_AdjustFrame)(ADJUST_FRAME_ARGS_DECL);
- Bool (*saved_UseHWCursor)(ScreenPtr, CursorPtr);
- Bool (*saved_UseHWCursorARGB)(ScreenPtr, CursorPtr);
-
-diff --git a/vmwgfx/vmwgfx_saa.c b/vmwgfx/vmwgfx_saa.c
-index 469598a..63df3a1 100644
---- a/vmwgfx/vmwgfx_saa.c
-+++ b/vmwgfx/vmwgfx_saa.c
-@@ -460,7 +460,7 @@ vmwgfx_flush_dri2(ScreenPtr pScreen)
- struct vmwgfx_saa *vsaa =
- to_vmwgfx_saa(saa_get_driver(pScreen));
- struct _WsbmListHead *list, *next;
-- ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
-+ ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
-
- if (!pScrn->vtSema)
- return;
-@@ -1199,7 +1199,7 @@ vmwgfx_operation_complete(struct saa_driver *driver,
- struct vmwgfx_saa *vsaa = to_vmwgfx_saa(driver);
- struct saa_pixmap *spix = saa_get_saa_pixmap(pixmap);
- struct vmwgfx_saa_pixmap *vpix = to_vmwgfx_saa_pixmap(spix);
-- ScrnInfoPtr pScrn = xf86Screens[vsaa->pScreen->myNum];
-+ ScrnInfoPtr pScrn = xf86ScreenToScrn(vsaa->pScreen);
-
- /*
- * Make dri2 drawables up to date, or add them to the flush list
-diff --git a/vmwgfx/vmwgfx_tex_video.c b/vmwgfx/vmwgfx_tex_video.c
-index af53379..449266b 100644
---- a/vmwgfx/vmwgfx_tex_video.c
-+++ b/vmwgfx/vmwgfx_tex_video.c
-@@ -638,7 +638,7 @@ put_image(ScrnInfoPtr pScrn,
- DrawablePtr pDraw)
- {
- struct xorg_xv_port_priv *pPriv = (struct xorg_xv_port_priv *) data;
-- ScreenPtr pScreen = screenInfo.screens[pScrn->scrnIndex];
-+ ScreenPtr pScreen = xf86ScrnToScreen(pScrn);
- PixmapPtr pPixmap;
- INT32 x1, x2, y1, y2;
- BoxRec dstBox;
-@@ -732,7 +732,7 @@ vmwgfx_free_textured_adaptor(XF86VideoAdaptorPtr adaptor, Bool free_ports)
- static XF86VideoAdaptorPtr
- xorg_setup_textured_adapter(ScreenPtr pScreen)
- {
-- ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
-+ ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
- modesettingPtr ms = modesettingPTR(pScrn);
- XF86VideoAdaptorPtr adapt;
- XF86AttributePtr attrs;
-@@ -799,7 +799,7 @@ xorg_setup_textured_adapter(ScreenPtr pScreen)
- void
- xorg_xv_init(ScreenPtr pScreen)
- {
-- ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
-+ ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
- modesettingPtr ms = modesettingPTR(pScrn);
- XF86VideoAdaptorPtr *adaptors, *new_adaptors = NULL;
- XF86VideoAdaptorPtr textured_adapter = NULL, overlay_adaptor = NULL;
---
-cgit v0.9.0.2-2-gbebe
-From 50c01998c7800bc02fd6656cc14efa715bf63e08 Mon Sep 17 00:00:00 2001
-From: Robert Hooker <sarvatt@ubuntu.com>
-Date: Fri, 15 Jun 2012 15:56:59 +0000
-Subject: vmware: Fix up some warnings after new compat API change.
-
-Fixes multiple instances of these warnings on x86_64:
-../../src/vmware.h:180:5: warning: implicit declaration of function 'xf86ScreenToScrn' [-Wimplicit-function-declaration]
-../../src/vmware.h:180:5: warning: nested extern declaration of 'xf86ScreenToScrn' [-Wnested-externs]
-../../src/vmware.h:180:5: warning: return makes pointer from integer without a cast [enabled by default]
-Function `xf86ScreenToScrn' implicitly converted to pointer at ../../src/vmware.h:180
-
-Reviewed-by: Jakob Bornecrantz <jakob@vmware.com>
-Signed-off-by: Robert Hooker <sarvatt@ubuntu.com>
-Signed-off-by: Jakob Bornecrantz <jakob@vmware.com>
----
-diff --git a/src/vmware.h b/src/vmware.h
-index 4818e16..be113bb 100644
---- a/src/vmware.h
-+++ b/src/vmware.h
-@@ -18,6 +18,7 @@
- #include "xf86.h"
- #include "xf86_OSproc.h"
-
-+#include "compat-api.h"
-
- #include <X11/extensions/panoramiXproto.h>
-
---
-cgit v0.9.0.2-2-gbebe
-From 46c0862d205eefa985e36a74391ca392640cb898 Mon Sep 17 00:00:00 2001
-From: Dave Airlie <airlied@redhat.com>
-Date: Sat, 16 Jun 2012 13:43:52 +0000
-Subject: vmware: drop infoFromScreen inline in favour of new interface
-
-This also should fix the build regression introduced with the fix
-for this macro.
-
-Signed-off-by: Dave Airlie <airlied@redhat.com>
----
-diff --git a/src/vmware.h b/src/vmware.h
-index be113bb..028dff3 100644
---- a/src/vmware.h
-+++ b/src/vmware.h
-@@ -18,8 +18,6 @@
- #include "xf86.h"
- #include "xf86_OSproc.h"
-
--#include "compat-api.h"
--
- #include <X11/extensions/panoramiXproto.h>
-
- #ifdef XSERVER_LIBPCIACCESS
-@@ -177,10 +175,6 @@ typedef struct {
-
- #define VMWAREPTR(p) ((VMWAREPtr)((p)->driverPrivate))
-
--static __inline ScrnInfoPtr infoFromScreen(ScreenPtr s) {
-- return xf86ScreenToScrn(s);
--}
--
- #define MIN(a,b) ((a)<(b)?(a):(b))
- #define MAX(a,b) ((a)>(b)?(a):(b))
- #define ABS(x) (((x) >= 0) ? (x) : -(x))
-diff --git a/src/vmwarecurs.c b/src/vmwarecurs.c
-index 2e2effb..93dacc0 100644
---- a/src/vmwarecurs.c
-+++ b/src/vmwarecurs.c
-@@ -12,6 +12,7 @@ char rcsId_vmwarecurs[] =
- #endif
-
- #include "vmware.h"
-+#include "vmware_common.h"
- #include "bits2pixels.h"
-
- static void VMWAREGetImage(DrawablePtr src, int x, int y, int w, int h,
-@@ -110,7 +111,7 @@ vmwareSetCursorColors(ScrnInfoPtr pScrn, int bg, int fg)
- static Bool
- vmwareUseHWCursor(ScreenPtr pScreen, CursorPtr pCurs)
- {
-- ScrnInfoPtr pScrn = infoFromScreen(pScreen);
-+ ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
- VMWAREPtr pVMWARE = VMWAREPTR(pScrn);
- VmwareLog(("UseHWCursor new cursor %p refcnt %i old cursor %p refcnt %i\n",
- pCurs, pCurs->refcnt, pVMWARE->oldCurs, pVMWARE->oldCurs ? pVMWARE->oldCurs->refcnt : 0));
-@@ -145,7 +146,7 @@ vmwareLoadCursorImage(ScrnInfoPtr pScrn, unsigned char *src )
- static Bool
- vmwareUseHWCursorARGB(ScreenPtr pScreen, CursorPtr pCurs)
- {
-- ScrnInfoPtr pScrn = infoFromScreen(pScreen);
-+ ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
- VMWAREPtr pVMWARE = VMWAREPTR(pScrn);
- VmwareLog(("UseHWCursorARGB new cursor %p refcnt %i old cursor %p refcnt %i\n",
- pCurs, pCurs->refcnt, pVMWARE->oldCurs, pVMWARE->oldCurs ? pVMWARE->oldCurs->refcnt : 0));
-@@ -283,7 +284,7 @@ Bool
- vmwareCursorInit(ScreenPtr pScreen)
- {
- xf86CursorInfoPtr infoPtr;
-- VMWAREPtr pVMWARE = VMWAREPTR(infoFromScreen(pScreen));
-+ VMWAREPtr pVMWARE = VMWAREPTR(xf86ScreenToScrn(pScreen));
- Bool ret;
-
- TRACEPOINT
-@@ -330,7 +331,7 @@ vmwareCursorInit(ScreenPtr pScreen)
- void
- vmwareCursorCloseScreen(ScreenPtr pScreen)
- {
-- ScrnInfoPtr pScrn = infoFromScreen(pScreen);
-+ ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
- VMWAREPtr pVMWARE = VMWAREPTR(pScrn);
- #ifdef RENDER
- PictureScreenPtr ps = GetPictureScreenIfSet(pScreen);
-@@ -356,7 +357,7 @@ vmwareCursorCloseScreen(ScreenPtr pScreen)
- void
- vmwareCursorHookWrappers(ScreenPtr pScreen)
- {
-- VMWAREPtr pVMWARE = VMWAREPTR(infoFromScreen(pScreen));
-+ VMWAREPtr pVMWARE = VMWAREPTR(xf86ScreenToScrn(pScreen));
- #ifdef RENDER
- PictureScreenPtr ps = GetPictureScreenIfSet(pScreen);
- #endif
-@@ -382,7 +383,7 @@ VMWAREGetImage(DrawablePtr src, int x, int y, int w, int h,
- unsigned int format, unsigned long planeMask, char *pBinImage)
- {
- ScreenPtr pScreen = src->pScreen;
-- VMWAREPtr pVMWARE = VMWAREPTR(infoFromScreen(src->pScreen));
-+ VMWAREPtr pVMWARE = VMWAREPTR(xf86ScreenToScrn(src->pScreen));
- BoxRec box;
- Bool hidden = FALSE;
-
-@@ -412,7 +413,7 @@ static void
- VMWARECopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc)
- {
- ScreenPtr pScreen = pWin->drawable.pScreen;
-- VMWAREPtr pVMWARE = VMWAREPTR(infoFromScreen(pWin->drawable.pScreen));
-+ VMWAREPtr pVMWARE = VMWAREPTR(xf86ScreenToScrn(pWin->drawable.pScreen));
- BoxPtr pBB;
- Bool hidden = FALSE;
-
-@@ -448,7 +449,7 @@ VMWAREComposite(CARD8 op, PicturePtr pSrc, PicturePtr pMask,
- CARD16 width, CARD16 height)
- {
- ScreenPtr pScreen = pDst->pDrawable->pScreen;
-- VMWAREPtr pVMWARE = VMWAREPTR(infoFromScreen(pScreen));
-+ VMWAREPtr pVMWARE = VMWAREPTR(xf86ScreenToScrn(pScreen));
- PictureScreenPtr ps = GetPictureScreen(pScreen);
- BoxRec box;
- Bool hidden = FALSE;
-diff --git a/src/vmwarevideo.c b/src/vmwarevideo.c
-index 71f21fe..745c71f 100644
---- a/src/vmwarevideo.c
-+++ b/src/vmwarevideo.c
-@@ -39,6 +39,7 @@
- #endif
-
- #include "vmware.h"
-+#include "vmware_common.h"
- #include "xf86xv.h"
- #include "fourcc.h"
- #include "svga_escape.h"
-@@ -435,7 +436,7 @@ vmwareVideoEnabled(VMWAREPtr pVMWARE)
- Bool
- vmwareVideoInit(ScreenPtr pScreen)
- {
-- ScrnInfoPtr pScrn = infoFromScreen(pScreen);
-+ ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
- XF86VideoAdaptorPtr *overlayAdaptors, *newAdaptors = NULL;
- XF86VideoAdaptorPtr newAdaptor = NULL;
- int numAdaptors;
-@@ -504,7 +505,7 @@ vmwareVideoInit(ScreenPtr pScreen)
- void
- vmwareVideoEnd(ScreenPtr pScreen)
- {
-- ScrnInfoPtr pScrn = infoFromScreen(pScreen);
-+ ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
- VMWAREPtr pVMWARE = VMWAREPTR(pScrn);
- VMWAREVideoPtr pVid;
- int i;
---
-cgit v0.9.0.2-2-gbebe
-From e5ac80d8f72963313358e31cfb1ab98583e26f23 Mon Sep 17 00:00:00 2001
-From: Dave Airlie <airlied@redhat.com>
-Date: Tue, 03 Jul 2012 12:50:30 +0000
-Subject: vmware: avoid warnings about shadowing 'i'
-
-Signed-off-by: Dave Airlie <airlied@redhat.com>
----
-diff --git a/src/compat-api.h b/src/compat-api.h
-index 6bc946f..205ac59 100644
---- a/src/compat-api.h
-+++ b/src/compat-api.h
-@@ -46,7 +46,7 @@
- #define SCREEN_ARG_TYPE int
- #define SCREEN_PTR(arg1) ScreenPtr pScreen = screenInfo.screens[(arg1)]
-
--#define SCREEN_INIT_ARGS_DECL int i, ScreenPtr pScreen, int argc, char **argv
-+#define SCREEN_INIT_ARGS_DECL int scrnIndex, ScreenPtr pScreen, int argc, char **argv
-
- #define BLOCKHANDLER_ARGS_DECL int arg, pointer blockData, pointer pTimeout, pointer pReadmask
- #define BLOCKHANDLER_ARGS arg, blockData, pTimeout, pReadmask
---
-cgit v0.9.0.2-2-gbebe
-From 007bed30270ca9548dfe6e359972b56cbb8e2f13 Mon Sep 17 00:00:00 2001
-From: Jakob Bornecrantz <jakob@vmware.com>
-Date: Tue, 29 May 2012 21:01:14 +0000
-Subject: vmwgfx: Guard against null rotate pixmap in shadow destroy
-
-Reviewed-by: Thomas Hellström <thellstrom@vmware.com>
-Signed-off-by: Jakob Bornecrantz <jakob@vmware.com>
----
-diff --git a/vmwgfx/vmwgfx_crtc.c b/vmwgfx/vmwgfx_crtc.c
-index eaf87b2..fec04c0 100644
---- a/vmwgfx/vmwgfx_crtc.c
-+++ b/vmwgfx/vmwgfx_crtc.c
-@@ -250,8 +250,12 @@ crtc_shadow_create(xf86CrtcPtr crtc, void *data, int width, int height)
- static void
- crtc_shadow_destroy(xf86CrtcPtr crtc, PixmapPtr rotate_pixmap, void *data)
- {
-- ScreenPtr pScreen = rotate_pixmap->drawable.pScreen;
-+ ScreenPtr pScreen;
-
-+ if (rotate_pixmap == NULL)
-+ return;
-+
-+ pScreen = rotate_pixmap->drawable.pScreen;
- pScreen->DestroyPixmap(rotate_pixmap);
- }
-
---
-cgit v0.9.0.2-2-gbebe
diff --git a/abs/core/xf86-video-vmware/xatracker-v2-fixes.patch b/abs/core/xf86-video-vmware/xatracker-v2-fixes.patch
new file mode 100644
index 0000000..9b8ed54
--- /dev/null
+++ b/abs/core/xf86-video-vmware/xatracker-v2-fixes.patch
@@ -0,0 +1,1583 @@
+From 0945bea5fc32eacb7bf42639efbd45dcd43e7ab5 Mon Sep 17 00:00:00 2001
+From: Rob Clark <robdclark@gmail.com>
+Date: Mon, 10 Jun 2013 13:31:31 -0400
+Subject: [PATCH 01/11] vmwgfx: update for XA API changes
+
+Signed-off-by: Rob Clark <robdclark@gmail.com>
+Signed-off-by: Jakob Bornecrantz <jakob@vmware.com>
+Reviewed-by: Jakob Bornecrantz <jakob@vmware.com>
+Tested-by: Jakob Bornecrantz <jakob@vmware.com>
+---
+ configure.ac | 2 +-
+ vmwgfx/vmwgfx_dri2.c | 5 +++--
+ vmwgfx/vmwgfx_driver.c | 3 ++-
+ vmwgfx/vmwgfx_saa.c | 20 ++++++++++++++------
+ vmwgfx/vmwgfx_tex_video.c | 5 +++--
+ 5 files changed, 23 insertions(+), 12 deletions(-)
+
+diff --git a/configure.ac b/configure.ac
+index 0631bcc..dccfb27 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -118,7 +118,7 @@ if test x$BUILD_VMWGFX = xyes; then
+ PKG_CHECK_MODULES([LIBDRM], [libdrm],[],[BUILD_VMWGFX=no])
+ fi
+ if test x$BUILD_VMWGFX = xyes; then
+- PKG_CHECK_MODULES([XATRACKER], [xatracker >= 0.4.0],[],[BUILD_VMWGFX=no])
++ PKG_CHECK_MODULES([XATRACKER], [xatracker >= 2.0.0],[],[BUILD_VMWGFX=no])
+ fi
+
+ DRIVER_NAME=vmware
+diff --git a/vmwgfx/vmwgfx_dri2.c b/vmwgfx/vmwgfx_dri2.c
+index 7de0772..2f007f0 100644
+--- a/vmwgfx/vmwgfx_dri2.c
++++ b/vmwgfx/vmwgfx_dri2.c
+@@ -201,7 +201,8 @@ dri2_do_create_buffer(DrawablePtr pDraw, DRI2Buffer2Ptr buffer, unsigned int for
+ }
+
+ private->srf = srf;
+- if (xa_surface_handle(srf, &buffer->name, &buffer->pitch) != 0)
++ if (xa_surface_handle(srf, xa_handle_type_shared,
++ &buffer->name, &buffer->pitch) != 0)
+ return FALSE;
+
+ buffer->cpp = xa_format_depth(xa_surface_format(srf)) / 8;
+@@ -222,7 +223,7 @@ dri2_do_destroy_buffer(DrawablePtr pDraw, DRI2BufferPtr buffer)
+ struct vmwgfx_saa_pixmap *vpix = vmwgfx_saa_pixmap(private->pPixmap);
+
+ if (--private->refcount == 0 && srf) {
+- xa_surface_destroy(srf);
++ xa_surface_unref(srf);
+ }
+
+ /*
+diff --git a/vmwgfx/vmwgfx_driver.c b/vmwgfx/vmwgfx_driver.c
+index 7863ba2..3002285 100644
+--- a/vmwgfx/vmwgfx_driver.c
++++ b/vmwgfx/vmwgfx_driver.c
+@@ -617,7 +617,8 @@ vmwgfx_scanout_present(ScreenPtr pScreen, int drm_fd,
+ return FALSE;
+ }
+
+- if (xa_surface_handle(vpix->hw, &handle, &dummy) != 0) {
++ if (xa_surface_handle(vpix->hw, xa_handle_type_shared,
++ &handle, &dummy) != 0) {
+ LogMessage(X_ERROR, "Could not get present surface handle.\n");
+ return FALSE;
+ }
+diff --git a/vmwgfx/vmwgfx_saa.c b/vmwgfx/vmwgfx_saa.c
+index 63df3a1..ed3c1ee 100644
+--- a/vmwgfx/vmwgfx_saa.c
++++ b/vmwgfx/vmwgfx_saa.c
+@@ -140,7 +140,7 @@ vmwgfx_pixmap_free_storage(struct vmwgfx_saa_pixmap *vpix)
+ vpix->malloc = NULL;
+ }
+ if (!(vpix->backing & VMWGFX_PIX_SURFACE) && vpix->hw) {
+- xa_surface_destroy(vpix->hw);
++ xa_surface_unref(vpix->hw);
+ vpix->hw = NULL;
+ }
+ if (!(vpix->backing & VMWGFX_PIX_GMR) && vpix->gmr) {
+@@ -286,7 +286,8 @@ vmwgfx_saa_dma(struct vmwgfx_saa *vsaa,
+ if (vpix->gmr && vsaa->can_optimize_dma) {
+ uint32_t handle, dummy;
+
+- if (xa_surface_handle(vpix->hw, &handle, &dummy) != 0)
++ if (xa_surface_handle(vpix->hw, xa_handle_type_shared,
++ &handle, &dummy) != 0)
+ goto out_err;
+ if (vmwgfx_dma(0, 0, reg, vpix->gmr, pixmap->devKind, handle,
+ to_hw) != 0)
+@@ -305,6 +306,8 @@ vmwgfx_saa_dma(struct vmwgfx_saa *vsaa,
+ (int) to_hw,
+ (struct xa_box *) REGION_RECTS(reg),
+ REGION_NUM_RECTS(reg));
++ if (to_hw)
++ xa_context_flush(vsaa->xa_ctx);
+ if (vpix->gmr)
+ vmwgfx_dmabuf_unmap(vpix->gmr);
+ if (ret)
+@@ -441,7 +444,7 @@ vmwgfx_hw_kill(struct vmwgfx_saa *vsaa,
+ &spix->dirty_hw))
+ return FALSE;
+
+- xa_surface_destroy(vpix->hw);
++ xa_surface_unref(vpix->hw);
+ vpix->hw = NULL;
+
+ /*
+@@ -683,7 +686,8 @@ vmwgfx_present_prepare(struct vmwgfx_saa *vsaa,
+
+ (void) pScreen;
+ if (src_vpix == dst_vpix || !src_vpix->hw ||
+- xa_surface_handle(src_vpix->hw, &vsaa->src_handle, &dummy) != 0)
++ xa_surface_handle(src_vpix->hw, xa_handle_type_shared,
++ &vsaa->src_handle, &dummy) != 0)
+ return FALSE;
+
+ REGION_NULL(pScreen, &vsaa->present_region);
+@@ -784,7 +788,7 @@ vmwgfx_create_hw(struct vmwgfx_saa *vsaa,
+ return TRUE;
+
+ out_no_damage:
+- xa_surface_destroy(hw);
++ xa_surface_unref(hw);
+ return FALSE;
+ }
+
+@@ -929,6 +933,7 @@ vmwgfx_copy_prepare(struct saa_driver *driver,
+
+ if (!vmwgfx_hw_validate(src_pixmap, src_reg)) {
+ xa_copy_done(vsaa->xa_ctx);
++ xa_context_flush(vsaa->xa_ctx);
+ return FALSE;
+ }
+
+@@ -1029,6 +1034,7 @@ vmwgfx_copy_done(struct saa_driver *driver)
+ return;
+ }
+ xa_copy_done(vsaa->xa_ctx);
++ xa_context_flush(vsaa->xa_ctx);
+ }
+
+ static Bool
+@@ -1175,6 +1181,7 @@ vmwgfx_composite_done(struct saa_driver *driver)
+ struct vmwgfx_saa *vsaa = to_vmwgfx_saa(driver);
+
+ xa_composite_done(vsaa->xa_ctx);
++ xa_context_flush(vsaa->xa_ctx);
+ }
+
+ static void
+@@ -1436,7 +1443,8 @@ vmwgfx_scanout_ref(struct vmwgfx_screen_entry *entry)
+ */
+ if (!vmwgfx_hw_accel_validate(pixmap, 0, XA_FLAG_SCANOUT, 0, NULL))
+ goto out_err;
+- if (xa_surface_handle(vpix->hw, &handle, &dummy) != 0)
++ if (xa_surface_handle(vpix->hw, xa_handle_type_shared,
++ &handle, &dummy) != 0)
+ goto out_err;
+ depth = xa_format_depth(xa_surface_format(vpix->hw));
+
+diff --git a/vmwgfx/vmwgfx_tex_video.c b/vmwgfx/vmwgfx_tex_video.c
+index 449266b..2971ed7 100644
+--- a/vmwgfx/vmwgfx_tex_video.c
++++ b/vmwgfx/vmwgfx_tex_video.c
+@@ -199,7 +199,7 @@ stop_video(ScrnInfoPtr pScrn, pointer data, Bool shutdown)
+
+ for (i=0; i<3; ++i) {
+ if (priv->yuv[i]) {
+- xa_surface_destroy(priv->yuv[i]);
++ xa_surface_unref(priv->yuv[i]);
+ priv->yuv[i] = NULL;
+ }
+ for (j=0; j<2; ++j) {
+@@ -539,7 +539,8 @@ copy_packed_data(ScrnInfoPtr pScrn,
+ REGION_RESET(pScrn->pScreen, &reg, &box);
+ }
+
+- if (xa_surface_handle(srf, &handle, &stride) != 0) {
++ if (xa_surface_handle(srf, xa_handle_type_shared,
++ &handle, &stride) != 0) {
+ ret = BadAlloc;
+ break;
+ }
+--
+1.8.5.1
+
+
+From 835ce4698f916ba080f4132988fd4caf898e0b1e Mon Sep 17 00:00:00 2001
+From: Thomas Hellstrom <thellstrom@vmware.com>
+Date: Thu, 26 Sep 2013 01:25:33 -0700
+Subject: [PATCH 02/11] vmwgfx: Avoid HW operations when not master
+
+Note that for DRI2, a dri2_copy_region becomes a NOP when not master.
+Additionally, all dri2 operations that lead to a potential kernel
+access will return FALSE.
+
+Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com>
+Reviewed-by: Jakob Bornecrantz <jakob@vmware.com>
+---
+ vmwgfx/vmwgfx_dri2.c | 13 +++++++++++++
+ vmwgfx/vmwgfx_driver.c | 3 +++
+ vmwgfx/vmwgfx_saa.c | 44 +++++++++++++++++++++++++++++++++++++++++++-
+ vmwgfx/vmwgfx_saa.h | 8 ++++++++
+ vmwgfx/vmwgfx_saa_priv.h | 2 ++
+ vmwgfx/vmwgfx_xa_surface.c | 6 ++++++
+ 6 files changed, 75 insertions(+), 1 deletion(-)
+
+diff --git a/vmwgfx/vmwgfx_dri2.c b/vmwgfx/vmwgfx_dri2.c
+index 2f007f0..57f2d9d 100644
+--- a/vmwgfx/vmwgfx_dri2.c
++++ b/vmwgfx/vmwgfx_dri2.c
+@@ -138,6 +138,8 @@ dri2_do_create_buffer(DrawablePtr pDraw, DRI2Buffer2Ptr buffer, unsigned int for
+ return TRUE;
+ case DRI2BufferStencil:
+ case DRI2BufferDepthStencil:
++ if (!pScrn->vtSema)
++ return FALSE;
+
+ depth = (format) ? vmwgfx_zs_format_to_depth(format) : 32;
+
+@@ -155,6 +157,9 @@ dri2_do_create_buffer(DrawablePtr pDraw, DRI2Buffer2Ptr buffer, unsigned int for
+
+ break;
+ case DRI2BufferDepth:
++ if (!pScrn->vtSema)
++ return FALSE;
++
+ depth = (format) ? vmwgfx_z_format_to_depth(format) :
+ pDraw->bitsPerPixel;
+
+@@ -291,6 +296,14 @@ dri2_copy_region(DrawablePtr pDraw, RegionPtr pRegion,
+ DrawablePtr dst_draw;
+ RegionPtr myClip;
+ GCPtr gc;
++ ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
++
++ /*
++ * This is a fragile protection against HW operations when not master.
++ * Needs to be blocked higher up in the dri2 code.
++ */
++ if (!pScrn->vtSema)
++ return;
+
+ /*
+ * In driCreateBuffers we dewrap windows into the
+diff --git a/vmwgfx/vmwgfx_driver.c b/vmwgfx/vmwgfx_driver.c
+index 3002285..eeaea4b 100644
+--- a/vmwgfx/vmwgfx_driver.c
++++ b/vmwgfx/vmwgfx_driver.c
+@@ -1116,6 +1116,7 @@ drv_leave_vt(VT_FUNC_ARGS_DECL)
+
+ vmwgfx_cursor_bypass(ms->fd, 0, 0);
+ vmwgfx_disable_scanout(pScrn);
++ vmwgfx_saa_drop_master(pScrn->pScreen);
+
+ if (drmDropMaster(ms->fd))
+ xf86DrvMsg(pScrn->scrnIndex, X_WARNING,
+@@ -1136,6 +1137,8 @@ drv_enter_vt(VT_FUNC_ARGS_DECL)
+ if (!drv_set_master(pScrn))
+ return FALSE;
+
++ vmwgfx_saa_set_master(pScrn->pScreen);
++
+ if (!xf86SetDesiredModes(pScrn))
+ return FALSE;
+
+diff --git a/vmwgfx/vmwgfx_saa.c b/vmwgfx/vmwgfx_saa.c
+index ed3c1ee..5534ca3 100644
+--- a/vmwgfx/vmwgfx_saa.c
++++ b/vmwgfx/vmwgfx_saa.c
+@@ -423,6 +423,7 @@ vmwgfx_create_pixmap(struct saa_driver *driver, struct saa_pixmap *spix,
+
+ WSBMINITLISTHEAD(&vpix->sync_x_head);
+ WSBMINITLISTHEAD(&vpix->scanout_list);
++ WSBMINITLISTHEAD(&vpix->pixmap_list);
+
+ return TRUE;
+ }
+@@ -499,6 +500,7 @@ vmwgfx_destroy_pixmap(struct saa_driver *driver, PixmapPtr pixmap)
+ */
+
+ vmwgfx_pixmap_remove_present(vpix);
++ WSBMLISTDELINIT(&vpix->pixmap_list);
+ WSBMLISTDELINIT(&vpix->sync_x_head);
+
+ if (vpix->hw_is_dri2_fronts)
+@@ -627,6 +629,8 @@ vmwgfx_modify_pixmap_header (PixmapPtr pixmap, int w, int h, int depth,
+ int bpp, int devkind, void *pixdata)
+ {
+ struct vmwgfx_saa_pixmap *vpix = vmwgfx_saa_pixmap(pixmap);
++ ScreenPtr pScreen = pixmap->drawable.pScreen;
++ struct vmwgfx_saa *vsaa = to_vmwgfx_saa(saa_get_driver(pScreen));
+ unsigned int old_height;
+ unsigned int old_width;
+ unsigned int old_pitch;
+@@ -670,6 +674,8 @@ vmwgfx_modify_pixmap_header (PixmapPtr pixmap, int w, int h, int depth,
+
+ vmwgfx_pix_resize(pixmap, old_pitch, old_height, old_width);
+ vmwgfx_pixmap_free_storage(vpix);
++ WSBMLISTADDTAIL(&vpix->pixmap_list, &vsaa->pixmaps);
++
+ return TRUE;
+
+ out_no_modify:
+@@ -860,7 +866,7 @@ vmwgfx_copy_prepare(struct saa_driver *driver,
+ Bool has_valid_hw;
+
+ if (!vsaa->xat || !SAA_PM_IS_SOLID(&dst_pixmap->drawable, plane_mask) ||
+- alu != GXcopy)
++ alu != GXcopy || !vsaa->is_master)
+ return FALSE;
+
+ src_vpix = vmwgfx_saa_pixmap(src_pixmap);
+@@ -1057,6 +1063,9 @@ vmwgfx_composite_prepare(struct saa_driver *driver, CARD8 op,
+ RegionRec empty;
+ struct xa_composite *xa_comp;
+
++ if (!vsaa->is_master)
++ return FALSE;
++
+ REGION_NULL(pScreen, &empty);
+
+ /*
+@@ -1367,7 +1376,9 @@ vmwgfx_saa_init(ScreenPtr pScreen, int drm_fd, struct xa_tracker *xat,
+ vsaa->use_present_opt = direct_presents;
+ vsaa->only_hw_presents = only_hw_presents;
+ vsaa->rendercheck = rendercheck;
++ vsaa->is_master = TRUE;
+ WSBMINITLISTHEAD(&vsaa->sync_x_list);
++ WSBMINITLISTHEAD(&vsaa->pixmaps);
+
+ vsaa->driver = vmwgfx_saa_driver;
+ vsaa->vcomp = vmwgfx_alloc_composite();
+@@ -1518,3 +1529,34 @@ vmwgfx_scanout_unref(struct vmwgfx_screen_entry *entry)
+ entry->pixmap = NULL;
+ pixmap->drawable.pScreen->DestroyPixmap(pixmap);
+ }
++
++void
++vmwgfx_saa_set_master(ScreenPtr pScreen)
++{
++ struct vmwgfx_saa *vsaa = to_vmwgfx_saa(saa_get_driver(pScreen));
++
++ vsaa->is_master = TRUE;
++}
++
++void
++vmwgfx_saa_drop_master(ScreenPtr pScreen)
++{
++ struct vmwgfx_saa *vsaa = to_vmwgfx_saa(saa_get_driver(pScreen));
++ struct _WsbmListHead *list;
++ struct vmwgfx_saa_pixmap *vpix;
++ struct saa_pixmap *spix;
++
++ WSBMLISTFOREACH(list, &vsaa->pixmaps) {
++ vpix = WSBMLISTENTRY(list, struct vmwgfx_saa_pixmap, pixmap_list);
++ spix = &vpix->base;
++
++ if (!vpix->hw)
++ continue;
++
++ (void) vmwgfx_download_from_hw(&vsaa->driver, spix->pixmap,
++ &spix->dirty_hw);
++ REGION_EMPTY(draw->pScreen, &spix->dirty_hw);
++ }
++
++ vsaa->is_master = FALSE;
++}
+diff --git a/vmwgfx/vmwgfx_saa.h b/vmwgfx/vmwgfx_saa.h
+index bb8ec96..d8aa3d3 100644
+--- a/vmwgfx/vmwgfx_saa.h
++++ b/vmwgfx/vmwgfx_saa.h
+@@ -54,6 +54,7 @@ struct vmwgfx_saa_pixmap {
+ int hw_is_dri2_fronts;
+ struct _WsbmListHead sync_x_head;
+ struct _WsbmListHead scanout_list;
++ struct _WsbmListHead pixmap_list;
+
+ uint32_t xa_flags;
+ uint32_t staging_add_flags;
+@@ -107,4 +108,11 @@ Bool
+ vmwgfx_hw_accel_validate(PixmapPtr pixmap, unsigned int depth,
+ uint32_t add_flags, uint32_t remove_flags,
+ RegionPtr region);
++
++void
++vmwgfx_saa_set_master(ScreenPtr pScreen);
++
++void
++vmwgfx_saa_drop_master(ScreenPtr pScreen);
++
+ #endif
+diff --git a/vmwgfx/vmwgfx_saa_priv.h b/vmwgfx/vmwgfx_saa_priv.h
+index 5f46dee..16583b0 100644
+--- a/vmwgfx/vmwgfx_saa_priv.h
++++ b/vmwgfx/vmwgfx_saa_priv.h
+@@ -54,8 +54,10 @@ struct vmwgfx_saa {
+ Bool use_present_opt;
+ Bool only_hw_presents;
+ Bool rendercheck;
++ Bool is_master;
+ void (*present_flush) (ScreenPtr pScreen);
+ struct _WsbmListHead sync_x_list;
++ struct _WsbmListHead pixmaps;
+ struct vmwgfx_composite *vcomp;
+ };
+
+diff --git a/vmwgfx/vmwgfx_xa_surface.c b/vmwgfx/vmwgfx_xa_surface.c
+index 8b30e45..2f23c57 100644
+--- a/vmwgfx/vmwgfx_xa_surface.c
++++ b/vmwgfx/vmwgfx_xa_surface.c
+@@ -362,6 +362,12 @@ vmwgfx_hw_accel_validate(PixmapPtr pixmap, unsigned int depth,
+ Bool
+ vmwgfx_hw_dri2_validate(PixmapPtr pixmap, unsigned int depth)
+ {
++ struct vmwgfx_saa *vsaa =
++ to_vmwgfx_saa(saa_get_driver(pixmap->drawable.pScreen));
++
++ if (!vsaa->is_master)
++ return FALSE;
++
+ return (vmwgfx_hw_dri2_stage(pixmap, depth) &&
+ vmwgfx_hw_commit(pixmap) &&
+ vmwgfx_hw_validate(pixmap, NULL));
+--
+1.8.5.1
+
+
+From 7192acf9f0bf8e7176ab0b803b861a858623f709 Mon Sep 17 00:00:00 2001
+From: Thomas Hellstrom <thellstrom@vmware.com>
+Date: Wed, 19 Sep 2012 20:36:57 +0200
+Subject: [PATCH 03/11] vmwgfx: Implement textured video completely on top of
+ XA.
+
+Remove device-specific hacks. This may increase resource usage a little
+on old hardware revisions, but we don't need separate code paths on
+different hardware revisions.
+
+Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com>
+Reviewed-by: Zack Rusin <zackr@vmware.com>
+---
+ vmwgfx/vmwgfx_tex_video.c | 109 ++++++----------------------------------------
+ 1 file changed, 14 insertions(+), 95 deletions(-)
+
+diff --git a/vmwgfx/vmwgfx_tex_video.c b/vmwgfx/vmwgfx_tex_video.c
+index 2971ed7..a0a4f4a 100644
+--- a/vmwgfx/vmwgfx_tex_video.c
++++ b/vmwgfx/vmwgfx_tex_video.c
+@@ -111,8 +111,7 @@ struct xorg_xv_port_priv {
+ int hue;
+
+ int current_set;
+- struct vmwgfx_dmabuf *bounce[2][3];
+- struct xa_surface *yuv[3];
++ struct xa_surface *yuv[2][3];
+
+ int drm_fd;
+
+@@ -198,14 +197,10 @@ stop_video(ScrnInfoPtr pScrn, pointer data, Bool shutdown)
+ priv->fence = NULL;
+
+ for (i=0; i<3; ++i) {
+- if (priv->yuv[i]) {
+- xa_surface_unref(priv->yuv[i]);
+- priv->yuv[i] = NULL;
+- }
+ for (j=0; j<2; ++j) {
+- if (priv->bounce[j][i]) {
+- vmwgfx_dmabuf_destroy(priv->bounce[j][i]);
+- priv->bounce[0][i] = NULL;
++ if (priv->yuv[i]) {
++ xa_surface_unref(priv->yuv[j][i]);
++ priv->yuv[j][i] = NULL;
+ }
+ }
+ }
+@@ -297,11 +292,9 @@ static int
+ check_yuv_surfaces(struct xorg_xv_port_priv *priv, int id,
+ int width, int height)
+ {
+- struct xa_surface **yuv = priv->yuv;
+- struct vmwgfx_dmabuf **bounce = priv->bounce[priv->current_set];
++ struct xa_surface **yuv = priv->yuv[priv->current_set];
+ int ret = 0;
+ int i;
+- size_t size;
+
+ for (i=0; i<3; ++i) {
+
+@@ -334,19 +327,6 @@ check_yuv_surfaces(struct xorg_xv_port_priv *priv, int id,
+ if (ret || !yuv[i])
+ return BadAlloc;
+
+- size = width * height;
+-
+- if (bounce[i] && (bounce[i]->size < size ||
+- bounce[i]->size > 2*size)) {
+- vmwgfx_dmabuf_destroy(bounce[i]);
+- bounce[i] = NULL;
+- }
+-
+- if (!bounce[i]) {
+- bounce[i] = vmwgfx_dmabuf_alloc(priv->drm_fd, size);
+- if (!bounce[i])
+- return BadAlloc;
+- }
+ }
+ return Success;
+ }
+@@ -413,28 +393,20 @@ copy_packed_data(ScrnInfoPtr pScrn,
+ unsigned short w, unsigned short h)
+ {
+ int i;
+- struct vmwgfx_dmabuf **bounce = port->bounce[port->current_set];
++ struct xa_surface **yuv = port->yuv[port->current_set];
+ char *ymap, *vmap, *umap;
+ unsigned char y1, y2, u, v;
+ int yidx, uidx, vidx;
+ int y_array_size = w * h;
+ int ret = BadAlloc;
+
+- /*
+- * Here, we could use xa_surface_[map|unmap], but given the size of
+- * the yuv textures, that could stress the xa tracker dma buffer pool,
+- * particularaly with multiple videos rendering simultaneously.
+- *
+- * Instead, cheat and allocate vmwgfx dma buffers directly.
+- */
+-
+- ymap = (char *)vmwgfx_dmabuf_map(bounce[0]);
++ ymap = xa_surface_map(port->r, yuv[0], XA_MAP_WRITE);
+ if (!ymap)
+ return BadAlloc;
+- umap = (char *)vmwgfx_dmabuf_map(bounce[1]);
++ umap = xa_surface_map(port->r, yuv[1], XA_MAP_WRITE);
+ if (!umap)
+ goto out_no_umap;
+- vmap = (char *)vmwgfx_dmabuf_map(bounce[2]);
++ vmap = xa_surface_map(port->r, yuv[2], XA_MAP_WRITE);
+ if (!vmap)
+ goto out_no_vmap;
+
+@@ -493,65 +465,11 @@ copy_packed_data(ScrnInfoPtr pScrn,
+ }
+
+ ret = Success;
+- vmwgfx_dmabuf_unmap(bounce[2]);
++ xa_surface_unmap(yuv[2]);
+ out_no_vmap:
+- vmwgfx_dmabuf_unmap(bounce[1]);
++ xa_surface_unmap(yuv[1]);
+ out_no_umap:
+- vmwgfx_dmabuf_unmap(bounce[0]);
+-
+- if (ret == Success) {
+- struct xa_surface *srf;
+- struct vmwgfx_dmabuf *buf;
+- uint32_t handle;
+- unsigned int stride;
+- BoxRec box;
+- RegionRec reg;
+-
+- box.x1 = 0;
+- box.x2 = w;
+- box.y1 = 0;
+- box.y2 = h;
+-
+- REGION_INIT(pScrn->pScreen, &reg, &box, 1);
+-
+- for (i=0; i<3; ++i) {
+- srf = port->yuv[i];
+- buf = bounce[i];
+-
+- if (i == 1) {
+- switch(id) {
+- case FOURCC_YV12:
+- h /= 2;
+- /* Fall through */
+- case FOURCC_YUY2:
+- case FOURCC_UYVY:
+- w /= 2;
+- break;
+- default:
+- break;
+- }
+-
+- box.x1 = 0;
+- box.x2 = w;
+- box.y1 = 0;
+- box.y2 = h;
+-
+- REGION_RESET(pScrn->pScreen, &reg, &box);
+- }
+-
+- if (xa_surface_handle(srf, xa_handle_type_shared,
+- &handle, &stride) != 0) {
+- ret = BadAlloc;
+- break;
+- }
+-
+- if (vmwgfx_dma(0, 0, &reg, buf, w, handle, 1) != 0) {
+- ret = BadAlloc;
+- break;
+- }
+- }
+- REGION_UNINIT(pScrn->pScreen, &reg);
+- }
++ xa_surface_unmap(yuv[0]);
+
+ return ret;
+ }
+@@ -610,7 +528,8 @@ display_video(ScreenPtr pScreen, struct xorg_xv_port_priv *pPriv, int id,
+ (struct xa_box *)REGION_RECTS(dstRegion),
+ REGION_NUM_RECTS(dstRegion),
+ pPriv->cm,
+- vpix->hw, pPriv->yuv);
++ vpix->hw,
++ pPriv->yuv[pPriv->current_set ]);
+
+ saa_pixmap_dirty(pPixmap, TRUE, dstRegion);
+ DamageRegionProcessPending(&pPixmap->drawable);
+--
+1.8.5.1
+
+
+From 45b2457516a9db4bd1d60fbb24a1efbe2d9dd932 Mon Sep 17 00:00:00 2001
+From: Thomas Hellstrom <thellstrom@vmware.com>
+Date: Wed, 19 Sep 2012 21:50:40 +0200
+Subject: [PATCH 04/11] vmwgfx: Get rid of device-specific DMA code
+
+It's rarely used and things seem to work well enough on top of XA.
+
+Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com>
+Reviewed-by: Zack Rusin <zackr@vmware.com>
+---
+ vmwgfx/vmwgfx_drmi.c | 103 -----------------------------------------------
+ vmwgfx/vmwgfx_drmi.h | 5 ---
+ vmwgfx/vmwgfx_saa.c | 53 ++++++++++++------------
+ vmwgfx/vmwgfx_saa_priv.h | 1 -
+ 4 files changed, 26 insertions(+), 136 deletions(-)
+
+diff --git a/vmwgfx/vmwgfx_drmi.c b/vmwgfx/vmwgfx_drmi.c
+index 496a16b..1e23f4a 100644
+--- a/vmwgfx/vmwgfx_drmi.c
++++ b/vmwgfx/vmwgfx_drmi.c
+@@ -284,109 +284,6 @@ vmwgfx_dmabuf_destroy(struct vmwgfx_dmabuf *buf)
+ }
+
+ int
+-vmwgfx_dma(unsigned int host_x, unsigned int host_y,
+- RegionPtr region, struct vmwgfx_dmabuf *buf,
+- uint32_t buf_pitch, uint32_t surface_handle, int to_surface)
+-{
+- BoxPtr clips = REGION_RECTS(region);
+- unsigned int num_clips = REGION_NUM_RECTS(region);
+- struct drm_vmw_execbuf_arg arg;
+- struct drm_vmw_fence_rep rep;
+- int ret;
+- unsigned int size;
+- unsigned i;
+- SVGA3dCopyBox *cb;
+- SVGA3dCmdSurfaceDMASuffix *suffix;
+- SVGA3dCmdSurfaceDMA *body;
+- struct vmwgfx_int_dmabuf *ibuf = vmwgfx_int_dmabuf(buf);
+-
+- struct {
+- SVGA3dCmdHeader header;
+- SVGA3dCmdSurfaceDMA body;
+- SVGA3dCopyBox cb;
+- } *cmd;
+-
+- if (num_clips == 0)
+- return 0;
+-
+- size = sizeof(*cmd) + (num_clips - 1) * sizeof(cmd->cb) +
+- sizeof(*suffix);
+- cmd = malloc(size);
+- if (!cmd)
+- return -1;
+-
+- cmd->header.id = SVGA_3D_CMD_SURFACE_DMA;
+- cmd->header.size = sizeof(cmd->body) + num_clips * sizeof(cmd->cb) +
+- sizeof(*suffix);
+- cb = &cmd->cb;
+-
+- suffix = (SVGA3dCmdSurfaceDMASuffix *) &cb[num_clips];
+- suffix->suffixSize = sizeof(*suffix);
+- suffix->maximumOffset = (uint32_t) -1;
+- suffix->flags.discard = 0;
+- suffix->flags.unsynchronized = 0;
+- suffix->flags.reserved = 0;
+-
+- body = &cmd->body;
+- body->guest.ptr.gmrId = buf->gmr_id;
+- body->guest.ptr.offset = buf->gmr_offset;
+- body->guest.pitch = buf_pitch;
+- body->host.sid = surface_handle;
+- body->host.face = 0;
+- body->host.mipmap = 0;
+-
+- body->transfer = (to_surface ? SVGA3D_WRITE_HOST_VRAM :
+- SVGA3D_READ_HOST_VRAM);
+-
+-
+- for (i=0; i < num_clips; i++, cb++, clips++) {
+- cb->x = (uint16_t) clips->x1 + host_x;
+- cb->y = (uint16_t) clips->y1 + host_y;
+- cb->z = 0;
+- cb->srcx = (uint16_t) clips->x1;
+- cb->srcy = (uint16_t) clips->y1;
+- cb->srcz = 0;
+- cb->w = (uint16_t) (clips->x2 - clips->x1);
+- cb->h = (uint16_t) (clips->y2 - clips->y1);
+- cb->d = 1;
+-#if 0
+- LogMessage(X_INFO, "DMA! x: %u y: %u srcx: %u srcy: %u w: %u h: %u %s\n",
+- cb->x, cb->y, cb->srcx, cb->srcy, cb->w, cb->h,
+- to_surface ? "to" : "from");
+-#endif
+-
+- }
+-
+- memset(&arg, 0, sizeof(arg));
+- memset(&rep, 0, sizeof(rep));
+-
+- rep.error = -EFAULT;
+- arg.fence_rep = ((to_surface) ? 0UL : (unsigned long)&rep);
+- arg.commands = (unsigned long)cmd;
+- arg.command_size = size;
+- arg.throttle_us = 0;
+- arg.version = DRM_VMW_EXECBUF_VERSION;
+-
+- ret = drmCommandWrite(ibuf->drm_fd, DRM_VMW_EXECBUF, &arg, sizeof(arg));
+- if (ret) {
+- LogMessage(X_ERROR, "DMA error %s.\n", strerror(-ret));
+- }
+-
+- free(cmd);
+-
+- if (rep.error == 0) {
+- ret = vmwgfx_fence_wait(ibuf->drm_fd, rep.handle, TRUE);
+- if (ret) {
+- LogMessage(X_ERROR, "DMA from host fence wait error %s.\n",
+- strerror(-ret));
+- vmwgfx_fence_unref(ibuf->drm_fd, rep.handle);
+- }
+- }
+-
+- return 0;
+-}
+-
+-int
+ vmwgfx_get_param(int drm_fd, uint32_t param, uint64_t *out)
+ {
+ struct drm_vmw_getparam_arg gp_arg;
+diff --git a/vmwgfx/vmwgfx_drmi.h b/vmwgfx/vmwgfx_drmi.h
+index 2435009..fff728a 100644
+--- a/vmwgfx/vmwgfx_drmi.h
++++ b/vmwgfx/vmwgfx_drmi.h
+@@ -60,11 +60,6 @@ extern void
+ vmwgfx_dmabuf_unmap(struct vmwgfx_dmabuf *buf);
+
+ extern int
+-vmwgfx_dma(unsigned int host_x, unsigned int host_y,
+- RegionPtr region, struct vmwgfx_dmabuf *buf,
+- uint32_t buf_pitch, uint32_t surface_handle, int to_surface);
+-
+-extern int
+ vmwgfx_num_streams(int drm_fd, uint32_t *ntot, uint32_t *nfree);
+
+ extern int
+diff --git a/vmwgfx/vmwgfx_saa.c b/vmwgfx/vmwgfx_saa.c
+index 5534ca3..fd80682 100644
+--- a/vmwgfx/vmwgfx_saa.c
++++ b/vmwgfx/vmwgfx_saa.c
+@@ -279,40 +279,40 @@ vmwgfx_saa_dma(struct vmwgfx_saa *vsaa,
+ Bool to_hw)
+ {
+ struct vmwgfx_saa_pixmap *vpix = vmwgfx_saa_pixmap(pixmap);
++ void *data = vpix->malloc;
++ int ret;
+
+ if (!vpix->hw || (!vpix->gmr && !vpix->malloc))
+ return TRUE;
+
+- if (vpix->gmr && vsaa->can_optimize_dma) {
+- uint32_t handle, dummy;
+
+- if (xa_surface_handle(vpix->hw, xa_handle_type_shared,
+- &handle, &dummy) != 0)
+- goto out_err;
+- if (vmwgfx_dma(0, 0, reg, vpix->gmr, pixmap->devKind, handle,
+- to_hw) != 0)
++ if (vpix->gmr) {
++ data = vmwgfx_dmabuf_map(vpix->gmr);
++ if (!data)
+ goto out_err;
+- } else {
+- void *data = vpix->malloc;
+- int ret;
++ }
+
+- if (vpix->gmr) {
+- data = vmwgfx_dmabuf_map(vpix->gmr);
+- if (!data)
+- goto out_err;
+- }
++ ret = xa_surface_dma(vsaa->xa_ctx, vpix->hw, data, pixmap->devKind,
++ (int) to_hw,
++ (struct xa_box *) REGION_RECTS(reg),
++ REGION_NUM_RECTS(reg));
++ if (vpix->gmr)
++ vmwgfx_dmabuf_unmap(vpix->gmr);
++
++ if (ret)
++ goto out_err;
++
++ ret = xa_surface_dma(vsaa->xa_ctx, vpix->hw, data, pixmap->devKind,
++ (int) to_hw,
++ (struct xa_box *) REGION_RECTS(reg),
++ REGION_NUM_RECTS(reg));
++ if (to_hw)
++ xa_context_flush(vsaa->xa_ctx);
++ if (vpix->gmr)
++ vmwgfx_dmabuf_unmap(vpix->gmr);
++ if (ret)
++ goto out_err;
+
+- ret = xa_surface_dma(vsaa->xa_ctx, vpix->hw, data, pixmap->devKind,
+- (int) to_hw,
+- (struct xa_box *) REGION_RECTS(reg),
+- REGION_NUM_RECTS(reg));
+- if (to_hw)
+- xa_context_flush(vsaa->xa_ctx);
+- if (vpix->gmr)
+- vmwgfx_dmabuf_unmap(vpix->gmr);
+- if (ret)
+- goto out_err;
+- }
+ return TRUE;
+ out_err:
+ LogMessage(X_ERROR, "DMA %s surface failed.\n",
+@@ -1372,7 +1372,6 @@ vmwgfx_saa_init(ScreenPtr pScreen, int drm_fd, struct xa_tracker *xat,
+ vsaa->xa_ctx = xa_context_default(xat);
+ vsaa->drm_fd = drm_fd;
+ vsaa->present_flush = present_flush;
+- vsaa->can_optimize_dma = FALSE;
+ vsaa->use_present_opt = direct_presents;
+ vsaa->only_hw_presents = only_hw_presents;
+ vsaa->rendercheck = rendercheck;
+diff --git a/vmwgfx/vmwgfx_saa_priv.h b/vmwgfx/vmwgfx_saa_priv.h
+index 16583b0..f5f45ba 100644
+--- a/vmwgfx/vmwgfx_saa_priv.h
++++ b/vmwgfx/vmwgfx_saa_priv.h
+@@ -50,7 +50,6 @@ struct vmwgfx_saa {
+ int ydiff;
+ RegionRec present_region;
+ uint32_t src_handle;
+- Bool can_optimize_dma;
+ Bool use_present_opt;
+ Bool only_hw_presents;
+ Bool rendercheck;
+--
+1.8.5.1
+
+
+From e26dec8f5278df74a102493bf6d2d8444dab5d6d Mon Sep 17 00:00:00 2001
+From: Gaetan Nadon <memsize@videotron.ca>
+Date: Mon, 28 Oct 2013 18:21:29 -0400
+Subject: [PATCH 05/11] vmwgfx: handle changes of DamageUnregister API in
+ 1.14.99.2
+
+Fix is inspired from the intel driver.
+
+Reviewed-by: Jakob Bornecrantz <jakob@vmware.com>
+Signed-off-by: Gaetan Nadon <memsize@videotron.ca>
+Signed-off-by: Jakob Bornecrantz <jakob@vmware.com>
+---
+ vmwgfx/vmwgfx_saa.c | 6 ++++++
+ 1 file changed, 6 insertions(+)
+
+diff --git a/vmwgfx/vmwgfx_saa.c b/vmwgfx/vmwgfx_saa.c
+index fd80682..346e7f4 100644
+--- a/vmwgfx/vmwgfx_saa.c
++++ b/vmwgfx/vmwgfx_saa.c
+@@ -26,6 +26,7 @@
+ */
+
+ #include <xorg-server.h>
++#include <xorgVersion.h>
+ #include <mi.h>
+ #include <fb.h>
+ #include <xf86drmMode.h>
+@@ -76,7 +77,12 @@ vmwgfx_pixmap_remove_damage(PixmapPtr pixmap)
+ if (!spix->damage || vpix->hw || vpix->gmr || vpix->malloc)
+ return;
+
++#if XORG_VERSION_CURRENT >= XORG_VERSION_NUMERIC(1,14,99,2,0)
++ DamageUnregister(spix->damage);
++#else
+ DamageUnregister(&pixmap->drawable, spix->damage);
++#endif
++
+ DamageDestroy(spix->damage);
+ spix->damage = NULL;
+ }
+--
+1.8.5.1
+
+
+From 7ac45326eccbf3bea9a4a8f95b9662a36ab58eb0 Mon Sep 17 00:00:00 2001
+From: Thomas Hellstrom <thellstrom@vmware.com>
+Date: Thu, 28 Nov 2013 02:02:20 -0800
+Subject: [PATCH 06/11] vmwgfx: Fix some compilation warnings and indentations
+
+Most of the compilation warnings we're seeing are due to bad xorg headers,
+but fix the ones we can fix in the driver. Some indentation fixes as well.
+
+Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com>
+Reviewed-by: Jakob Bornecrantz <jakob@vmware.com>
+---
+ src/vmware_bootstrap.c | 2 --
+ src/vmwarevideo.c | 4 ++--
+ vmwgfx/vmwgfx_driver.c | 1 -
+ vmwgfx/vmwgfx_output.c | 2 +-
+ vmwgfx/vmwgfx_overlay.c | 4 ++--
+ vmwgfx/vmwgfx_tex_video.c | 26 +++++++++++++-------------
+ 6 files changed, 18 insertions(+), 21 deletions(-)
+
+diff --git a/src/vmware_bootstrap.c b/src/vmware_bootstrap.c
+index ea5be19..bb58325 100644
+--- a/src/vmware_bootstrap.c
++++ b/src/vmware_bootstrap.c
+@@ -256,7 +256,6 @@ VMwarePciProbe (DriverPtr drv,
+ intptr_t match_data)
+ {
+ ScrnInfoPtr scrn = NULL;
+- EntityInfoPtr entity;
+
+ scrn = xf86ConfigPciEntity(scrn, 0, entity_num, VMWAREPciChipsets,
+ NULL, NULL, NULL, NULL, NULL);
+@@ -267,7 +266,6 @@ VMwarePciProbe (DriverPtr drv,
+ scrn->Probe = NULL;
+ }
+
+- entity = xf86GetEntityInfo(entity_num);
+ switch (DEVICE_ID(device)) {
+ case PCI_DEVICE_ID_VMWARE_SVGA2:
+ case PCI_DEVICE_ID_VMWARE_SVGA:
+diff --git a/src/vmwarevideo.c b/src/vmwarevideo.c
+index 745c71f..8d7d171 100644
+--- a/src/vmwarevideo.c
++++ b/src/vmwarevideo.c
+@@ -82,7 +82,7 @@
+ #define VMWARE_VID_MAX_HEIGHT 2048
+
+ #define VMWARE_VID_NUM_ENCODINGS 1
+-static XF86VideoEncodingRec vmwareVideoEncodings[] =
++static const XF86VideoEncodingRec vmwareVideoEncodings[] =
+ {
+ {
+ 0,
+@@ -108,7 +108,7 @@ static XF86ImageRec vmwareVideoImages[] =
+ };
+
+ #define VMWARE_VID_NUM_ATTRIBUTES 2
+-static XF86AttributeRec vmwareVideoAttributes[] =
++static const XF86AttributeRec vmwareVideoAttributes[] =
+ {
+ {
+ XvGettable | XvSettable,
+diff --git a/vmwgfx/vmwgfx_driver.c b/vmwgfx/vmwgfx_driver.c
+index eeaea4b..bfc07f8 100644
+--- a/vmwgfx/vmwgfx_driver.c
++++ b/vmwgfx/vmwgfx_driver.c
+@@ -658,7 +658,6 @@ void xorg_flush(ScreenPtr pScreen)
+ if (crtc->enabled) {
+ pixmap = crtc_get_scanout(crtc);
+ if (pixmap) {
+- unsigned int j;
+
+ /*
+ * Remove duplicates.
+diff --git a/vmwgfx/vmwgfx_output.c b/vmwgfx/vmwgfx_output.c
+index 4f52f1d..f9e4263 100644
+--- a/vmwgfx/vmwgfx_output.c
++++ b/vmwgfx/vmwgfx_output.c
+@@ -60,7 +60,7 @@ struct output_private
+ Bool is_implicit;
+ };
+
+-static char *output_enum_list[] = {
++static const char *output_enum_list[] = {
+ "Unknown",
+ "VGA",
+ "DVI",
+diff --git a/vmwgfx/vmwgfx_overlay.c b/vmwgfx/vmwgfx_overlay.c
+index 6624a10..986dd06 100644
+--- a/vmwgfx/vmwgfx_overlay.c
++++ b/vmwgfx/vmwgfx_overlay.c
+@@ -84,7 +84,7 @@ typedef uint8_t uint8;
+ #define VMWARE_VID_MAX_HEIGHT 2048
+
+ #define VMWARE_VID_NUM_ENCODINGS 1
+-static XF86VideoEncodingRec vmwareVideoEncodings[] =
++static const XF86VideoEncodingRec vmwareVideoEncodings[] =
+ {
+ {
+ 0,
+@@ -110,7 +110,7 @@ static XF86ImageRec vmwareVideoImages[] =
+ };
+
+ #define VMWARE_VID_NUM_ATTRIBUTES 2
+-static XF86AttributeRec vmwareVideoAttributes[] =
++static const XF86AttributeRec vmwareVideoAttributes[] =
+ {
+ {
+ XvGettable | XvSettable,
+diff --git a/vmwgfx/vmwgfx_tex_video.c b/vmwgfx/vmwgfx_tex_video.c
+index a0a4f4a..3ba40ef 100644
+--- a/vmwgfx/vmwgfx_tex_video.c
++++ b/vmwgfx/vmwgfx_tex_video.c
+@@ -70,11 +70,11 @@ static const float bt_709[] = {
+ static Atom xvBrightness, xvContrast, xvSaturation, xvHue;
+
+ #define NUM_TEXTURED_ATTRIBUTES 4
+-static XF86AttributeRec TexturedAttributes[NUM_TEXTURED_ATTRIBUTES] = {
+- {XvSettable | XvGettable, -1000, 1000, "XV_BRIGHTNESS"},
+- {XvSettable | XvGettable, -1000, 1000, "XV_CONTRAST"},
+- {XvSettable | XvGettable, -1000, 1000, "XV_SATURATION"},
+- {XvSettable | XvGettable, -1000, 1000, "XV_HUE"}
++static const XF86AttributeRec TexturedAttributes[NUM_TEXTURED_ATTRIBUTES] = {
++ {XvSettable | XvGettable, -1000, 1000, "XV_BRIGHTNESS"},
++ {XvSettable | XvGettable, -1000, 1000, "XV_CONTRAST"},
++ {XvSettable | XvGettable, -1000, 1000, "XV_SATURATION"},
++ {XvSettable | XvGettable, -1000, 1000, "XV_HUE"}
+ };
+
+ #define NUM_FORMATS 3
+@@ -82,7 +82,7 @@ static XF86VideoFormatRec Formats[NUM_FORMATS] = {
+ {15, TrueColor}, {16, TrueColor}, {24, TrueColor}
+ };
+
+-static XF86VideoEncodingRec DummyEncoding[1] = {
++static const XF86VideoEncodingRec DummyEncoding[1] = {
+ {
+ 0,
+ "XV_IMAGE",
+@@ -416,16 +416,16 @@ copy_packed_data(ScrnInfoPtr pScrn,
+ switch (id) {
+ case FOURCC_YV12: {
+ int pitches[3], offsets[3];
+- unsigned char *y, *u, *v;
++ unsigned char *yp, *up, *vp;
+ query_image_attributes(pScrn, FOURCC_YV12,
+ &w, &h, pitches, offsets);
+
+- y = buf + offsets[0];
+- v = buf + offsets[1];
+- u = buf + offsets[2];
+- memcpy(ymap, y, w*h);
+- memcpy(vmap, v, w*h/4);
+- memcpy(umap, u, w*h/4);
++ yp = buf + offsets[0];
++ vp = buf + offsets[1];
++ up = buf + offsets[2];
++ memcpy(ymap, yp, w*h);
++ memcpy(vmap, vp, w*h/4);
++ memcpy(umap, up, w*h/4);
+ break;
+ }
+ case FOURCC_UYVY:
+--
+1.8.5.1
+
+
+From a40cbd7b4fa19219849b4b0a48f07538772c3e22 Mon Sep 17 00:00:00 2001
+From: Thomas Hellstrom <thellstrom@vmware.com>
+Date: Thu, 5 Dec 2013 02:58:47 -0800
+Subject: [PATCH 07/11] vmwgfx: Support also XA version 1 v2
+
+We need to support also XA version 1, since we want to be backwards
+compatible with older mesa releases.
+Unfortunately, the intended way of detecting XA major version at
+compile-time was broken on mesa 10 so we need a workaround that tests
+for XA version 2 at config time.
+
+v2: Update the test for XA version 2.
+
+Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com>
+Reviewed-by: Jakob Bornecrantz <jakob@vmware.com>
+---
+ configure.ac | 10 +++++++++-
+ vmwgfx/vmwgfx_dri2.c | 5 ++---
+ vmwgfx/vmwgfx_driver.c | 3 +--
+ vmwgfx/vmwgfx_saa.c | 12 +++++-------
+ vmwgfx/vmwgfx_saa.h | 12 ++++++++++++
+ vmwgfx/vmwgfx_tex_video.c | 2 +-
+ 6 files changed, 30 insertions(+), 14 deletions(-)
+
+diff --git a/configure.ac b/configure.ac
+index dccfb27..123356c 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -118,7 +118,15 @@ if test x$BUILD_VMWGFX = xyes; then
+ PKG_CHECK_MODULES([LIBDRM], [libdrm],[],[BUILD_VMWGFX=no])
+ fi
+ if test x$BUILD_VMWGFX = xyes; then
+- PKG_CHECK_MODULES([XATRACKER], [xatracker >= 2.0.0],[],[BUILD_VMWGFX=no])
++#
++# Early versions of mesa 10 forgot to bump the XA major version number in
++# the xa_tracker.h header
++#
++ PKG_CHECK_MODULES([XATRACKER], [xatracker >= 0.4.0],
++ [PKG_CHECK_EXISTS([xatracker = 2.0.0],
++ [AC_DEFINE([HAVE_XA_2], 1,
++ [Has version 2 of XA])])],
++ [],[BUILD_VMWGFX=no])
+ fi
+
+ DRIVER_NAME=vmware
+diff --git a/vmwgfx/vmwgfx_dri2.c b/vmwgfx/vmwgfx_dri2.c
+index 57f2d9d..4c74a6b 100644
+--- a/vmwgfx/vmwgfx_dri2.c
++++ b/vmwgfx/vmwgfx_dri2.c
+@@ -206,8 +206,7 @@ dri2_do_create_buffer(DrawablePtr pDraw, DRI2Buffer2Ptr buffer, unsigned int for
+ }
+
+ private->srf = srf;
+- if (xa_surface_handle(srf, xa_handle_type_shared,
+- &buffer->name, &buffer->pitch) != 0)
++ if (_xa_surface_handle(srf, &buffer->name, &buffer->pitch) != 0)
+ return FALSE;
+
+ buffer->cpp = xa_format_depth(xa_surface_format(srf)) / 8;
+@@ -228,7 +227,7 @@ dri2_do_destroy_buffer(DrawablePtr pDraw, DRI2BufferPtr buffer)
+ struct vmwgfx_saa_pixmap *vpix = vmwgfx_saa_pixmap(private->pPixmap);
+
+ if (--private->refcount == 0 && srf) {
+- xa_surface_unref(srf);
++ xa_surface_destroy(srf);
+ }
+
+ /*
+diff --git a/vmwgfx/vmwgfx_driver.c b/vmwgfx/vmwgfx_driver.c
+index bfc07f8..6301c29 100644
+--- a/vmwgfx/vmwgfx_driver.c
++++ b/vmwgfx/vmwgfx_driver.c
+@@ -617,8 +617,7 @@ vmwgfx_scanout_present(ScreenPtr pScreen, int drm_fd,
+ return FALSE;
+ }
+
+- if (xa_surface_handle(vpix->hw, xa_handle_type_shared,
+- &handle, &dummy) != 0) {
++ if (_xa_surface_handle(vpix->hw, &handle, &dummy) != 0) {
+ LogMessage(X_ERROR, "Could not get present surface handle.\n");
+ return FALSE;
+ }
+diff --git a/vmwgfx/vmwgfx_saa.c b/vmwgfx/vmwgfx_saa.c
+index 346e7f4..1459933 100644
+--- a/vmwgfx/vmwgfx_saa.c
++++ b/vmwgfx/vmwgfx_saa.c
+@@ -146,7 +146,7 @@ vmwgfx_pixmap_free_storage(struct vmwgfx_saa_pixmap *vpix)
+ vpix->malloc = NULL;
+ }
+ if (!(vpix->backing & VMWGFX_PIX_SURFACE) && vpix->hw) {
+- xa_surface_unref(vpix->hw);
++ xa_surface_destroy(vpix->hw);
+ vpix->hw = NULL;
+ }
+ if (!(vpix->backing & VMWGFX_PIX_GMR) && vpix->gmr) {
+@@ -451,7 +451,7 @@ vmwgfx_hw_kill(struct vmwgfx_saa *vsaa,
+ &spix->dirty_hw))
+ return FALSE;
+
+- xa_surface_unref(vpix->hw);
++ xa_surface_destroy(vpix->hw);
+ vpix->hw = NULL;
+
+ /*
+@@ -698,8 +698,7 @@ vmwgfx_present_prepare(struct vmwgfx_saa *vsaa,
+
+ (void) pScreen;
+ if (src_vpix == dst_vpix || !src_vpix->hw ||
+- xa_surface_handle(src_vpix->hw, xa_handle_type_shared,
+- &vsaa->src_handle, &dummy) != 0)
++ _xa_surface_handle(src_vpix->hw, &vsaa->src_handle, &dummy) != 0)
+ return FALSE;
+
+ REGION_NULL(pScreen, &vsaa->present_region);
+@@ -800,7 +799,7 @@ vmwgfx_create_hw(struct vmwgfx_saa *vsaa,
+ return TRUE;
+
+ out_no_damage:
+- xa_surface_unref(hw);
++ xa_surface_destroy(hw);
+ return FALSE;
+ }
+
+@@ -1459,8 +1458,7 @@ vmwgfx_scanout_ref(struct vmwgfx_screen_entry *entry)
+ */
+ if (!vmwgfx_hw_accel_validate(pixmap, 0, XA_FLAG_SCANOUT, 0, NULL))
+ goto out_err;
+- if (xa_surface_handle(vpix->hw, xa_handle_type_shared,
+- &handle, &dummy) != 0)
++ if (_xa_surface_handle(vpix->hw, &handle, &dummy) != 0)
+ goto out_err;
+ depth = xa_format_depth(xa_surface_format(vpix->hw));
+
+diff --git a/vmwgfx/vmwgfx_saa.h b/vmwgfx/vmwgfx_saa.h
+index d8aa3d3..5e1f40c 100644
+--- a/vmwgfx/vmwgfx_saa.h
++++ b/vmwgfx/vmwgfx_saa.h
+@@ -115,4 +115,16 @@ vmwgfx_saa_set_master(ScreenPtr pScreen);
+ void
+ vmwgfx_saa_drop_master(ScreenPtr pScreen);
+
++#if (XA_TRACKER_VERSION_MAJOR <= 1) && !defined(HAVE_XA_2)
++
++#define _xa_surface_handle(_a, _b, _c) xa_surface_handle(_a, _b, _c)
++#define xa_context_flush(_a)
++
++#else
++
++#define xa_surface_destroy(_a) xa_surface_unref(_a)
++#define _xa_surface_handle(_a, _b, _c) \
++ xa_surface_handle(_a, xa_handle_type_shared, _b, _c)
++
++#endif /* (XA_TRACKER_VERSION_MAJOR <= 1) */
+ #endif
+diff --git a/vmwgfx/vmwgfx_tex_video.c b/vmwgfx/vmwgfx_tex_video.c
+index 3ba40ef..9fd8f22 100644
+--- a/vmwgfx/vmwgfx_tex_video.c
++++ b/vmwgfx/vmwgfx_tex_video.c
+@@ -199,7 +199,7 @@ stop_video(ScrnInfoPtr pScrn, pointer data, Bool shutdown)
+ for (i=0; i<3; ++i) {
+ for (j=0; j<2; ++j) {
+ if (priv->yuv[i]) {
+- xa_surface_unref(priv->yuv[j][i]);
++ xa_surface_destroy(priv->yuv[j][i]);
+ priv->yuv[j][i] = NULL;
+ }
+ }
+--
+1.8.5.1
+
+
+From c36cbcefb8526944141eb431e1e736dc4485a36e Mon Sep 17 00:00:00 2001
+From: Thomas Hellstrom <thellstrom@vmware.com>
+Date: Mon, 9 Dec 2013 00:19:55 -0800
+Subject: [PATCH 08/11] vmwgfx: Remove stray 1
+
+Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com>
+Reviewed-by: Jakob Bornecrantz <jakob@vmware.com>
+---
+ vmwgfx/vmwgfx_saa.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/vmwgfx/vmwgfx_saa.c b/vmwgfx/vmwgfx_saa.c
+index 1459933..28819c1 100644
+--- a/vmwgfx/vmwgfx_saa.c
++++ b/vmwgfx/vmwgfx_saa.c
+@@ -1230,7 +1230,7 @@ vmwgfx_operation_complete(struct saa_driver *driver,
+ */
+
+ if (vpix->hw && vpix->hw_is_dri2_fronts) {
+- if (1 && pScrn->vtSema &&
++ if (pScrn->vtSema &&
+ vmwgfx_upload_to_hw(driver, pixmap, &spix->dirty_shadow)) {
+
+ REGION_EMPTY(vsaa->pScreen, &spix->dirty_shadow);
+--
+1.8.5.1
+
+
+From 4af6062ce281a7f4aaa50985fe757e9569208ee1 Mon Sep 17 00:00:00 2001
+From: Thomas Hellstrom <thellstrom@vmware.com>
+Date: Wed, 11 Dec 2013 04:59:49 -0800
+Subject: [PATCH 09/11] Revert "vmwgfx: Get rid of device-specific DMA code"
+
+This reverts commit 45b2457516a9db4bd1d60fbb24a1efbe2d9dd932.
+
+Reverting this because using direct DMA for shared pixmaps should
+boost performance. It should be usable both in a composited environment
+and when running hosted. Need to retest the DMA flaws I saw before disabling
+this code.
+
+Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com>
+Reviewed-by: Jakob Bornecrantz <jakob@vmware.com>
+---
+ vmwgfx/vmwgfx_drmi.c | 103 +++++++++++++++++++++++++++++++++++++++++++++++
+ vmwgfx/vmwgfx_drmi.h | 5 +++
+ vmwgfx/vmwgfx_saa.c | 53 ++++++++++++------------
+ vmwgfx/vmwgfx_saa_priv.h | 1 +
+ 4 files changed, 136 insertions(+), 26 deletions(-)
+
+diff --git a/vmwgfx/vmwgfx_drmi.c b/vmwgfx/vmwgfx_drmi.c
+index 1e23f4a..496a16b 100644
+--- a/vmwgfx/vmwgfx_drmi.c
++++ b/vmwgfx/vmwgfx_drmi.c
+@@ -284,6 +284,109 @@ vmwgfx_dmabuf_destroy(struct vmwgfx_dmabuf *buf)
+ }
+
+ int
++vmwgfx_dma(unsigned int host_x, unsigned int host_y,
++ RegionPtr region, struct vmwgfx_dmabuf *buf,
++ uint32_t buf_pitch, uint32_t surface_handle, int to_surface)
++{
++ BoxPtr clips = REGION_RECTS(region);
++ unsigned int num_clips = REGION_NUM_RECTS(region);
++ struct drm_vmw_execbuf_arg arg;
++ struct drm_vmw_fence_rep rep;
++ int ret;
++ unsigned int size;
++ unsigned i;
++ SVGA3dCopyBox *cb;
++ SVGA3dCmdSurfaceDMASuffix *suffix;
++ SVGA3dCmdSurfaceDMA *body;
++ struct vmwgfx_int_dmabuf *ibuf = vmwgfx_int_dmabuf(buf);
++
++ struct {
++ SVGA3dCmdHeader header;
++ SVGA3dCmdSurfaceDMA body;
++ SVGA3dCopyBox cb;
++ } *cmd;
++
++ if (num_clips == 0)
++ return 0;
++
++ size = sizeof(*cmd) + (num_clips - 1) * sizeof(cmd->cb) +
++ sizeof(*suffix);
++ cmd = malloc(size);
++ if (!cmd)
++ return -1;
++
++ cmd->header.id = SVGA_3D_CMD_SURFACE_DMA;
++ cmd->header.size = sizeof(cmd->body) + num_clips * sizeof(cmd->cb) +
++ sizeof(*suffix);
++ cb = &cmd->cb;
++
++ suffix = (SVGA3dCmdSurfaceDMASuffix *) &cb[num_clips];
++ suffix->suffixSize = sizeof(*suffix);
++ suffix->maximumOffset = (uint32_t) -1;
++ suffix->flags.discard = 0;
++ suffix->flags.unsynchronized = 0;
++ suffix->flags.reserved = 0;
++
++ body = &cmd->body;
++ body->guest.ptr.gmrId = buf->gmr_id;
++ body->guest.ptr.offset = buf->gmr_offset;
++ body->guest.pitch = buf_pitch;
++ body->host.sid = surface_handle;
++ body->host.face = 0;
++ body->host.mipmap = 0;
++
++ body->transfer = (to_surface ? SVGA3D_WRITE_HOST_VRAM :
++ SVGA3D_READ_HOST_VRAM);
++
++
++ for (i=0; i < num_clips; i++, cb++, clips++) {
++ cb->x = (uint16_t) clips->x1 + host_x;
++ cb->y = (uint16_t) clips->y1 + host_y;
++ cb->z = 0;
++ cb->srcx = (uint16_t) clips->x1;
++ cb->srcy = (uint16_t) clips->y1;
++ cb->srcz = 0;
++ cb->w = (uint16_t) (clips->x2 - clips->x1);
++ cb->h = (uint16_t) (clips->y2 - clips->y1);
++ cb->d = 1;
++#if 0
++ LogMessage(X_INFO, "DMA! x: %u y: %u srcx: %u srcy: %u w: %u h: %u %s\n",
++ cb->x, cb->y, cb->srcx, cb->srcy, cb->w, cb->h,
++ to_surface ? "to" : "from");
++#endif
++
++ }
++
++ memset(&arg, 0, sizeof(arg));
++ memset(&rep, 0, sizeof(rep));
++
++ rep.error = -EFAULT;
++ arg.fence_rep = ((to_surface) ? 0UL : (unsigned long)&rep);
++ arg.commands = (unsigned long)cmd;
++ arg.command_size = size;
++ arg.throttle_us = 0;
++ arg.version = DRM_VMW_EXECBUF_VERSION;
++
++ ret = drmCommandWrite(ibuf->drm_fd, DRM_VMW_EXECBUF, &arg, sizeof(arg));
++ if (ret) {
++ LogMessage(X_ERROR, "DMA error %s.\n", strerror(-ret));
++ }
++
++ free(cmd);
++
++ if (rep.error == 0) {
++ ret = vmwgfx_fence_wait(ibuf->drm_fd, rep.handle, TRUE);
++ if (ret) {
++ LogMessage(X_ERROR, "DMA from host fence wait error %s.\n",
++ strerror(-ret));
++ vmwgfx_fence_unref(ibuf->drm_fd, rep.handle);
++ }
++ }
++
++ return 0;
++}
++
++int
+ vmwgfx_get_param(int drm_fd, uint32_t param, uint64_t *out)
+ {
+ struct drm_vmw_getparam_arg gp_arg;
+diff --git a/vmwgfx/vmwgfx_drmi.h b/vmwgfx/vmwgfx_drmi.h
+index fff728a..2435009 100644
+--- a/vmwgfx/vmwgfx_drmi.h
++++ b/vmwgfx/vmwgfx_drmi.h
+@@ -60,6 +60,11 @@ extern void
+ vmwgfx_dmabuf_unmap(struct vmwgfx_dmabuf *buf);
+
+ extern int
++vmwgfx_dma(unsigned int host_x, unsigned int host_y,
++ RegionPtr region, struct vmwgfx_dmabuf *buf,
++ uint32_t buf_pitch, uint32_t surface_handle, int to_surface);
++
++extern int
+ vmwgfx_num_streams(int drm_fd, uint32_t *ntot, uint32_t *nfree);
+
+ extern int
+diff --git a/vmwgfx/vmwgfx_saa.c b/vmwgfx/vmwgfx_saa.c
+index 28819c1..96275a5 100644
+--- a/vmwgfx/vmwgfx_saa.c
++++ b/vmwgfx/vmwgfx_saa.c
+@@ -285,40 +285,40 @@ vmwgfx_saa_dma(struct vmwgfx_saa *vsaa,
+ Bool to_hw)
+ {
+ struct vmwgfx_saa_pixmap *vpix = vmwgfx_saa_pixmap(pixmap);
+- void *data = vpix->malloc;
+- int ret;
+
+ if (!vpix->hw || (!vpix->gmr && !vpix->malloc))
+ return TRUE;
+
++ if (vpix->gmr && vsaa->can_optimize_dma) {
++ uint32_t handle, dummy;
+
+- if (vpix->gmr) {
+- data = vmwgfx_dmabuf_map(vpix->gmr);
+- if (!data)
++ if (xa_surface_handle(vpix->hw, xa_handle_type_shared,
++ &handle, &dummy) != 0)
+ goto out_err;
+- }
+-
+- ret = xa_surface_dma(vsaa->xa_ctx, vpix->hw, data, pixmap->devKind,
+- (int) to_hw,
+- (struct xa_box *) REGION_RECTS(reg),
+- REGION_NUM_RECTS(reg));
+- if (vpix->gmr)
+- vmwgfx_dmabuf_unmap(vpix->gmr);
+-
+- if (ret)
+- goto out_err;
++ if (vmwgfx_dma(0, 0, reg, vpix->gmr, pixmap->devKind, handle,
++ to_hw) != 0)
++ goto out_err;
++ } else {
++ void *data = vpix->malloc;
++ int ret;
+
+- ret = xa_surface_dma(vsaa->xa_ctx, vpix->hw, data, pixmap->devKind,
+- (int) to_hw,
+- (struct xa_box *) REGION_RECTS(reg),
+- REGION_NUM_RECTS(reg));
+- if (to_hw)
+- xa_context_flush(vsaa->xa_ctx);
+- if (vpix->gmr)
+- vmwgfx_dmabuf_unmap(vpix->gmr);
+- if (ret)
+- goto out_err;
++ if (vpix->gmr) {
++ data = vmwgfx_dmabuf_map(vpix->gmr);
++ if (!data)
++ goto out_err;
++ }
+
++ ret = xa_surface_dma(vsaa->xa_ctx, vpix->hw, data, pixmap->devKind,
++ (int) to_hw,
++ (struct xa_box *) REGION_RECTS(reg),
++ REGION_NUM_RECTS(reg));
++ if (to_hw)
++ xa_context_flush(vsaa->xa_ctx);
++ if (vpix->gmr)
++ vmwgfx_dmabuf_unmap(vpix->gmr);
++ if (ret)
++ goto out_err;
++ }
+ return TRUE;
+ out_err:
+ LogMessage(X_ERROR, "DMA %s surface failed.\n",
+@@ -1377,6 +1377,7 @@ vmwgfx_saa_init(ScreenPtr pScreen, int drm_fd, struct xa_tracker *xat,
+ vsaa->xa_ctx = xa_context_default(xat);
+ vsaa->drm_fd = drm_fd;
+ vsaa->present_flush = present_flush;
++ vsaa->can_optimize_dma = FALSE;
+ vsaa->use_present_opt = direct_presents;
+ vsaa->only_hw_presents = only_hw_presents;
+ vsaa->rendercheck = rendercheck;
+diff --git a/vmwgfx/vmwgfx_saa_priv.h b/vmwgfx/vmwgfx_saa_priv.h
+index f5f45ba..16583b0 100644
+--- a/vmwgfx/vmwgfx_saa_priv.h
++++ b/vmwgfx/vmwgfx_saa_priv.h
+@@ -50,6 +50,7 @@ struct vmwgfx_saa {
+ int ydiff;
+ RegionRec present_region;
+ uint32_t src_handle;
++ Bool can_optimize_dma;
+ Bool use_present_opt;
+ Bool only_hw_presents;
+ Bool rendercheck;
+--
+1.8.5.1
+
+
+From 93228f3dd3355a25583d22dbb96791678b93be3e Mon Sep 17 00:00:00 2001
+From: Thomas Hellstrom <thellstrom@vmware.com>
+Date: Wed, 11 Dec 2013 06:54:02 -0800
+Subject: [PATCH 10/11] vmwgfx: Really allow XA version 2.
+
+When XA starts to correctly advertise version 2, we didn't allow it.
+Fix this.
+
+Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com>
+Reviewed-by: Jakob Bornecrantz <jakob@vmware.com>
+---
+ vmwgfx/vmwgfx_driver.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/vmwgfx/vmwgfx_driver.c b/vmwgfx/vmwgfx_driver.c
+index 6301c29..4e28097 100644
+--- a/vmwgfx/vmwgfx_driver.c
++++ b/vmwgfx/vmwgfx_driver.c
+@@ -79,7 +79,7 @@ typedef uint8_t uint8;
+
+ #define XA_VERSION_MINOR_REQUIRED 0
+ #define XA_VERSION_MAJOR_REQUIRED 1
+-#define XA_VERSION_MAJOR_COMPAT 1
++#define XA_VERSION_MAJOR_COMPAT 2
+
+ #define DRM_VERSION_MAJOR_REQUIRED 2
+ #define DRM_VERSION_MINOR_REQUIRED 3
+--
+1.8.5.1
+
+
+From f45a551e9b70ccec8f92df02747d4e2af299cf8c Mon Sep 17 00:00:00 2001
+From: Thomas Hellstrom <thellstrom@vmware.com>
+Date: Mon, 16 Dec 2013 10:38:21 +0100
+Subject: [PATCH 11/11] vmwgfx: Fix compile breakage on XA version 1.
+
+A recent revert brought back code that assumed XA version 2.
+
+Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com>
+Reviewed-by: trivial
+---
+ vmwgfx/vmwgfx_saa.c | 3 +--
+ 1 file changed, 1 insertion(+), 2 deletions(-)
+
+diff --git a/vmwgfx/vmwgfx_saa.c b/vmwgfx/vmwgfx_saa.c
+index 96275a5..e76bd09 100644
+--- a/vmwgfx/vmwgfx_saa.c
++++ b/vmwgfx/vmwgfx_saa.c
+@@ -292,8 +292,7 @@ vmwgfx_saa_dma(struct vmwgfx_saa *vsaa,
+ if (vpix->gmr && vsaa->can_optimize_dma) {
+ uint32_t handle, dummy;
+
+- if (xa_surface_handle(vpix->hw, xa_handle_type_shared,
+- &handle, &dummy) != 0)
++ if (_xa_surface_handle(vpix->hw, &handle, &dummy) != 0)
+ goto out_err;
+ if (vmwgfx_dma(0, 0, reg, vpix->gmr, pixmap->devKind, handle,
+ to_hw) != 0)
+--
+1.8.5.1
+