File xf86-video-intel-copy-fb.diff of Package xorg-x11-driver-video

commit b209cbc72f8d524b2c4c6d0e6e6acf8385e96062
Author: Kristian Høgsberg <krh@redhat.com>
Date:   Tue Feb 24 10:49:45 2009 -0500

    Copy initial framebuffer contents when starting with -br.

Index: xf86-video-intel-2.11.0/src/drmmode_display.c
===================================================================
--- xf86-video-intel-2.11.0.orig/src/drmmode_display.c
+++ xf86-video-intel-2.11.0/src/drmmode_display.c
@@ -36,6 +36,8 @@
 #include <errno.h>
 #include <poll.h>
 
+#include <sys/ioctl.h>
+
 #include "xorgVersion.h"
 
 #include "i830.h"
@@ -856,7 +858,14 @@ drmmode_output_dpms(xf86OutputPtr output
 	drmmode_ptr drmmode = drmmode_output->drmmode;
 	int i;
 	drmModePropertyPtr props;
+	intel_screen_private *intel = intel_get_screen_private(output->scrn);
+#if 0
+	/* xf86Crtc.c calls dpms off in set desired modes, so ignore
+	 * the request if we're starting up. */
 
+	if (intel->starting)
+		return;
+#endif
 	for (i = 0; i < koutput->count_props; i++) {
 		props = drmModeGetProperty(drmmode->fd, koutput->props[i]);
 		if (!props)
@@ -1308,6 +1317,8 @@ drmmode_xf86crtc_resize (ScrnInfoPtr scr
 	if (old_front)
 		drm_intel_bo_unreference(old_front);
 
+	scrn->canDoBGNoneRoot = TRUE;
+
 	return TRUE;
 
  fail:
@@ -1486,6 +1497,99 @@ drmmode_get_pipe_from_crtc_id(drm_intel_
 	return drm_intel_get_pipe_from_crtc_id (bufmgr, drmmode_crtc->mode_crtc->crtc_id);
 }
 
+static PixmapPtr
+drmmode_create_pixmap_for_fbcon(ScrnInfoPtr pScrn)
+{
+	xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(pScrn);
+	drmmode_crtc_private_ptr drmmode_crtc = xf86_config->crtc[0]->driver_private;
+	ScreenPtr pScreen = screenInfo.screens[pScrn->scrnIndex];
+	drmmode_ptr drmmode = drmmode_crtc->drmmode;
+	intel_screen_private *intel = intel_get_screen_private(pScrn);
+	drmModeFBPtr fbcon;
+	struct drm_gem_flink flink;
+	drm_intel_bo *bo;
+	PixmapPtr pixmap = NULL;
+	int i;
+
+	for (i = 0; i < drmmode->mode_res->count_crtcs; i++) {
+		drmmode_crtc = xf86_config->crtc[i]->driver_private;
+		if (drmmode_crtc->mode_crtc->buffer_id == 0)
+			continue;
+		fbcon = drmModeGetFB(drmmode->fd,
+				     drmmode_crtc->mode_crtc->buffer_id);
+		if (fbcon != NULL)
+			break;
+	}
+	if (i == drmmode->mode_res->count_crtcs)
+		return NULL;
+
+	flink.handle = fbcon->handle;
+	if (ioctl(drmmode->fd, DRM_IOCTL_GEM_FLINK, &flink) < 0) {
+		xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+			   "Couldn't flink fbcon handle\n");
+		return NULL;
+	}
+
+	bo = drm_intel_bo_gem_create_from_name(intel->bufmgr,
+					       "fbcon", flink.name);
+	if (bo == NULL) {
+		xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+			   "Couldn't allocate bo for fbcon handle\n");
+		return NULL;
+	}
+
+	pixmap = GetScratchPixmapHeader(pScreen,
+					fbcon->width, fbcon->height,
+					fbcon->depth, fbcon->bpp,
+					fbcon->pitch, NULL);
+
+	if (pixmap == NULL) {
+		xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+			   "Couldn't allocate pixmap fbcon contents\n");
+		return NULL;
+	}
+
+	i830_set_pixmap_bo(pixmap, bo);
+	drm_intel_bo_unreference(bo);
+	drmModeFreeFB(fbcon);
+
+	return pixmap;
+}
+void drmmode_copy_fb(ScrnInfoPtr pScrn)
+{
+	ScreenPtr pScreen = screenInfo.screens[pScrn->scrnIndex];
+	intel_screen_private *intel = intel_get_screen_private(pScrn);
+	PixmapPtr src, dst;
+	unsigned int pitch = pScrn->displayWidth * intel->cpp;
+
+	src = drmmode_create_pixmap_for_fbcon(pScrn);
+	if (src == NULL) {
+		xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
+			   "Couldn't create pixmap for fbcon\n");
+		return;
+	}
+
+	/* We dont have a screen Pixmap yet */
+	dst = GetScratchPixmapHeader(pScreen,
+				     pScrn->virtualX, pScrn->virtualY,
+				     pScrn->depth, pScrn->bitsPerPixel,
+				     pitch,
+				     NULL);
+	i830_set_pixmap_bo(dst, intel->front_buffer);
+
+	intel->uxa_driver->prepare_copy(src, dst, -1, -1, GXcopy, FB_ALLONES);
+
+	intel->uxa_driver->copy(dst, 0, 0, 0, 0,
+				pScrn->virtualX, pScrn->virtualY);
+
+	intel->uxa_driver->done_copy(dst);
+
+	intel_batch_submit(pScrn, TRUE);
+
+	(*pScreen->DestroyPixmap)(src);
+	(*pScreen->DestroyPixmap)(dst);
+}
+
 /* for the drmmode overlay */
 int
 drmmode_crtc_id(xf86CrtcPtr crtc)
Index: xf86-video-intel-2.11.0/src/i830.h
===================================================================
--- xf86-video-intel-2.11.0.orig/src/i830.h
+++ xf86-video-intel-2.11.0/src/i830.h
@@ -420,6 +420,8 @@ extern int drmmode_get_pipe_from_crtc_id
 extern int drmmode_output_dpms_status(xf86OutputPtr output);
 extern int drmmode_crtc_id(xf86CrtcPtr crtc);
 
+extern void drmmode_copy_fb(ScrnInfoPtr pScrn);
+
 extern Bool i830_crtc_on(xf86CrtcPtr crtc);
 extern int i830_crtc_to_pipe(xf86CrtcPtr crtc);
 extern Bool I830AccelInit(ScreenPtr pScreen);
Index: xf86-video-intel-2.11.0/src/i830_driver.c
===================================================================
--- xf86-video-intel-2.11.0.orig/src/i830_driver.c
+++ xf86-video-intel-2.11.0/src/i830_driver.c
@@ -1391,6 +1391,8 @@ static Bool I830EnterVT(int scrnIndex, i
 
 	i830_set_gem_max_sizes(scrn);
 
+	drmmode_copy_fb(scrn);
+
 	if (!xf86SetDesiredModes(scrn))
 		return FALSE;
 
openSUSE Build Service is sponsored by