[PATCH xf86-video-nv] Fix shadow framebuffer implementation.

Matthieu Herrb matthieu at herrb.eu
Mon Nov 18 12:14:42 PST 2013


Makes it possible to run the nv driver without XAA on cards where
EXA is not supported.

Signed-off-by: Matthieu Herrb <matthieu at herrb.eu>
---
 src/nv_driver.c | 44 +++++++++++++++++++++++++++++++++++++++++---
 src/nv_local.h  |  1 +
 src/nv_proto.h  |  1 +
 src/nv_shadow.c | 11 +++++++++++
 src/nv_type.h   |  2 ++
 5 files changed, 56 insertions(+), 3 deletions(-)

diff --git src/nv_driver.c src/nv_driver.c
index 8f35334..3a74038 100644
--- src/nv_driver.c
+++ src/nv_driver.c
@@ -2066,7 +2066,7 @@ NVPreInit(ScrnInfoPtr pScrn, int flags)
 
     /* Load shadowfb if needed */
     if (pNv->ShadowFB) {
-	if (!xf86LoadSubModule(pScrn, "shadowfb")) {
+	if (!xf86LoadSubModule(pScrn, "shadow")) {
 	    xf86FreeInt10(pNv->pInt);
 	    NVFreeRec(pScrn);
 	    return FALSE;
@@ -2374,6 +2374,44 @@ NVDPMSSet(ScrnInfoPtr pScrn, int PowerManagementMode, int flags)
   hwp->writeCrtc(hwp, 0x1A, crtc1A);
 }
 
+static Bool
+NVCreateScreenResources(ScreenPtr pScreen)
+{
+	ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
+	NVPtr pNv = NVPTR(pScrn);
+	PixmapPtr pPixmap;
+	Bool ret;
+
+	pScreen->CreateScreenResources = pNv->CreateScreenResources;
+	ret = pScreen->CreateScreenResources(pScreen);
+	pScreen->CreateScreenResources = NVCreateScreenResources;
+
+	if (!ret)
+		return FALSE;
+
+	pPixmap = pScreen->GetScreenPixmap(pScreen);
+
+	if (!shadowAdd(pScreen, pPixmap, NVShadowUpdate,
+		NULL, 0, NULL)) {
+		return FALSE;
+	}
+	return TRUE;
+}
+
+static Bool
+NVShadowInit(ScreenPtr pScreen)
+{
+	ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen);
+	NVPtr pNv = NVPTR(pScrn);
+
+	if (!shadowSetup(pScreen))
+		return FALSE;
+	pNv->CreateScreenResources = pScreen->CreateScreenResources;
+	pScreen->CreateScreenResources = NVCreateScreenResources;
+
+	return TRUE;
+}
+
 
 /* Mandatory */
 
@@ -2595,8 +2633,8 @@ NVScreenInit(SCREEN_INIT_ARGS_DECL)
                           "Driver rotation enabled, RandR disabled\n");
            }
 	}
-
-	ShadowFBInit(pScreen, refreshArea);
+        pNv->refreshArea = refreshArea;
+	NVShadowInit(pScreen);
     }
 
     if(pNv->FlatPanel)
diff --git src/nv_local.h src/nv_local.h
index a0b5e41..8ff8aa1 100644
--- src/nv_local.h
+++ src/nv_local.h
@@ -32,6 +32,7 @@
 #include "compiler.h"
 #include "xf86_OSproc.h"
 
+#include "shadow.h"
 /*
  * Typedefs to force certain sized values.
  */
diff --git src/nv_proto.h src/nv_proto.h
index 0e9fdcc..ff764cf 100644
--- src/nv_proto.h
+++ src/nv_proto.h
@@ -49,6 +49,7 @@ int  NVShowHideCursor(NVPtr,int);
 void NVLockUnlock(NVPtr,int);
 
 /* in nv_shadow.c */
+void NVShadowUpdate (ScreenPtr pScreen, shadowBufPtr pBuf);
 void NVRefreshArea(ScrnInfoPtr pScrn, int num, BoxPtr pbox);
 void NVRefreshArea8(ScrnInfoPtr pScrn, int num, BoxPtr pbox);
 void NVRefreshArea16(ScrnInfoPtr pScrn, int num, BoxPtr pbox);
diff --git src/nv_shadow.c src/nv_shadow.c
index 3946448..58db331 100644
--- src/nv_shadow.c
+++ src/nv_shadow.c
@@ -13,6 +13,17 @@
 #include "shadowfb.h"
 #include "servermd.h"
 
+void
+NVShadowUpdate (ScreenPtr pScreen, shadowBufPtr pBuf)
+{
+    RegionPtr damage = DamageRegion(pBuf->pDamage);
+    ScrnInfoPtr pScrn;
+    pScrn = xf86ScreenToScrn(pScreen);
+
+    (NVPTR(pScrn))->refreshArea (pScrn, REGION_NUM_RECTS(damage),
+	REGION_RECTS(damage));
+}
+
 
 void
 NVRefreshArea(ScrnInfoPtr pScrn, int num, BoxPtr pbox)
diff --git src/nv_type.h src/nv_type.h
index 65a6a55..e705d4c 100644
--- src/nv_type.h
+++ src/nv_type.h
@@ -133,6 +133,8 @@ typedef struct {
     int                 numDGAModes;
     Bool                DGAactive;
     int                 DGAViewportStatus;
+    CreateScreenResourcesProcPtr CreateScreenResources;
+    RefreshAreaFuncPtr refreshArea;
     void		(*PointerMoved)(SCRN_ARG_TYPE arg, int x, int y);
     ScreenBlockHandlerProcPtr BlockHandler;
     CloseScreenProcPtr  CloseScreen;
-- 
1.8.4.2



More information about the xorg-devel mailing list