File 0001-merge-nv40fp.patch of Package nouveau

From 0debf95c81748626321b8ef004e03ba0b4e5cfd7 Mon Sep 17 00:00:00 2001
From: root <root@gdp.(none)>
Date: Tue, 6 May 2008 22:50:32 +0100
Subject: [PATCH] merge-nv40fp

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

diff --git a/src/nv30_shaders.c b/src/nv30_shaders.c
index 735b454..effec7b 100644
--- a/src/nv30_shaders.c
+++ b/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)
 {
@@ -44,6 +46,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) {
@@ -133,6 +136,7 @@ NV40_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 837527d..95b19d8 100644
--- a/src/nv_driver.c
+++ b/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];
+
 /*
  * Forward definitions for the functions that make up the driver.
  */
@@ -702,6 +710,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);
@@ -726,6 +744,8 @@ NVEnterVT(int scrnIndex, int flags)
 
 			if (!xf86SetDesiredModes(pScrn))
 				return FALSE;
+
+			NVAccelCommonInit(pScrn);
 		} else {
 			if (!NVModeInit(pScrn, pScrn->currentMode))
 				return FALSE;
@@ -1865,6 +1885,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
@@ -2086,8 +2114,10 @@ NVScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
 		pScrn->memPhysBase = pNv->VRAMPhysical;
 		pScrn->fbOffset = 0;
 
+		bonged = 1;
 		if (!NVEnterVT(scrnIndex, 0))
 			return FALSE;
+		bonged = 0;
 		NVSaveScreen(pScreen, SCREEN_SAVER_ON);
 	}
 
@@ -2189,7 +2219,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