File 0001-ddx-merged-commit-with-amended-nv30-fp-restore.patch of Package nouveau

# Needed for NV4x:
--- xf86-video-nouveau/src/nv30_shaders.c
+++ xf86-video-nouveau/src/nv30_shaders.c
@@ -133,6 +133,7 @@ NV40_LoadFragProg
 			xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
 				   "Couldn't map fragprog buffer!\n");
 		}
+		global_fp_mem = fp_mem;
 	}
 
 	if (!shader->hw_id) {

From e928d4836e85e5fa1448f6038af1c37fa82bc96d Mon Sep 17 00:00:00 2001
From: root <root@gdp.(none)>
Date: Tue, 6 May 2008 22:50:32 +0100
Subject: [PATCH] merged commit with amended nv30 fp restore

---
 src/nv30_shaders.c |    3 +++
 src/nv_driver.c    |   31 ++++++++++++++++++++++++++++++-
 2 files changed, 33 insertions(+), 1 deletions(-)

diff --git a/src/nv30_shaders.c b/src/nv30_shaders.c
index 989777e..ad80818 100644
--- xf86-video-nouveau/src/nv30_shaders.c
+++ xf86-video-nouveau/src/nv30_shaders.c
@@ -23,6 +23,8 @@
 
 #include "nv30_shaders.h"
 
+struct nouveau_bo *global_fp_mem = NULL;
+
 void
 NV30_LoadFragProg(ScrnInfoPtr pScrn, nv_shader_t *shader)
 {
@@ -42,6 +44,7 @@ NV30_LoadFragProg(ScrnInfoPtr pScrn, nv_shader_t *shader)
 			xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
 				   "Couldn't map fragprog buffer!\n");
 		}
+		global_fp_mem = fp_mem;
 	}
 
 	if (!shader->hw_id) {
diff --git a/src/nv_driver.c b/src/nv_driver.c
index 38c2908..0c534c5 100644
--- xf86-video-nouveau/src/nv_driver.c
+++ xf86-video-nouveau/src/nv_driver.c
@@ -28,6 +28,14 @@
 
 #include "xf86drm.h"
 
+/* the modesetting stuff is on crack and calls EnterVT at times other than when
+ * the X VT has been entered. bonged distinguishes this case
+ */
+static int bonged = 0;
+/* Uh, yeah */
+extern struct nouveau_bo *global_fp_mem;
+static uint32_t fp_backup[0x1000/4];
+
 extern DisplayModePtr xf86ModesAdd(DisplayModePtr Modes, DisplayModePtr Additions);
 
 /*
@@ -705,6 +713,16 @@ NVEnterVT(int scrnIndex, int flags)
 	NVPtr pNv = NVPTR(pScrn);
 
 	if (!pNv->kms_enable) {
+		if (!bonged) {
+			if (global_fp_mem) {
+				uint32_t i, *map = global_fp_mem->map;
+				for (i = 0; i < 0x1000/4; i++)
+					map[i] = fp_backup[i];
+			}
+
+			drmCommandNone(((struct nouveau_device_priv *)pNv->dev)->fd, DRM_NOUVEAU_RESUME);
+		}
+
 		if (pNv->randr12_enable) {
 			xf86DrvMsg(pScrn->scrnIndex, X_INFO, "NVEnterVT is called.\n");
 			xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(pScrn);
@@ -729,6 +747,8 @@ NVEnterVT(int scrnIndex, int flags)
 
 			if (!xf86SetDesiredModes(pScrn))
 				return FALSE;
+
+			NVAccelCommonInit(pScrn);
 		} else {
 			if (!NVModeInit(pScrn, pScrn->currentMode))
 				return FALSE;
@@ -2104,6 +2124,14 @@ NVRestore(ScrnInfoPtr pScrn)
 		NVWriteVgaCrtc(pNv, 0, NV_VGA_CRTCX_OWNER, pNv->vtOWNER);
 		NVLockVgaCrtc(pNv, 0, true);
 	}
+
+	drmCommandNone(((struct nouveau_device_priv *)pNv->dev)->fd, DRM_NOUVEAU_SUSPEND);
+
+	if (global_fp_mem) {
+		uint32_t i, *map = global_fp_mem->map;
+		for (i = 0; i < 0x1000/4; i++)
+			fp_backup[i] = map[i];
+	}
 }
 
 static void
@@ -2383,8 +2411,10 @@ NVScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
 			xf86DrvMsg(pScrn->scrnIndex, X_INFO, "CRTC 1 was enabled.\n");
 		}
 
+		bonged = 1;
 		if (!NVEnterVT(scrnIndex, 0))
 			return FALSE;
+		bonged = 0;
 		NVSaveScreen(pScreen, SCREEN_SAVER_ON);
 	}
 
@@ -2489,7 +2519,6 @@ NVScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
 	if (!pNv->NoAccel) {
 		if (!NVExaInit(pScreen))
 			return FALSE;
-		NVAccelCommonInit(pScrn);
 	} else if (pNv->VRAMPhysicalSize / 2 < NOUVEAU_ALIGN(pScrn->virtualX, 64) * NOUVEAU_ALIGN(pScrn->virtualY, 64) * (pScrn->bitsPerPixel >> 3)) {
 		xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "The virtual screen size's resolution is too big for the video RAM framebuffer at this colour depth.\n");
 		return FALSE;
-- 
1.5.4.4
openSUSE Build Service is sponsored by