File copy-fb.patch 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.8.0/src/drmmode_display.c
===================================================================
--- xf86-video-intel-2.8.0.orig/src/drmmode_display.c
+++ xf86-video-intel-2.8.0/src/drmmode_display.c
@@ -31,6 +31,8 @@
#include <errno.h>
+#include <sys/ioctl.h>
+
#include "xorgVersion.h"
#include "i830.h"
@@ -724,6 +726,13 @@ drmmode_output_dpms(xf86OutputPtr output
drmmode_ptr drmmode = drmmode_output->drmmode;
int i;
drmModePropertyPtr props;
+ I830Ptr pI830 = I830PTR(output->scrn);
+
+ /* xf86Crtc.c calls dpms off in set desired modes, so ignore
+ * the request if we're starting up. */
+
+ if (pI830->starting)
+ return;
for (i = 0; i < koutput->count_props; i++) {
props = drmModeGetProperty(drmmode->fd, koutput->props[i]);
@@ -1124,6 +1133,8 @@ Bool drmmode_pre_init(ScrnInfoPtr pScrn,
xf86InitialConfiguration(pScrn, TRUE);
+ pScrn->canDoBGNoneRoot = TRUE;
+
return TRUE;
}
@@ -1134,3 +1145,97 @@ 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;
+ I830Ptr pI830 = I830PTR(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(pI830->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];
+ I830Ptr pI830 = I830PTR(pScrn);
+ PixmapPtr src, dst;
+ unsigned int pitch = pScrn->displayWidth * pI830->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, pI830->front_buffer->bo);
+
+ pI830->uxa_driver->prepare_copy(src, dst, -1, -1, GXcopy, FB_ALLONES);
+
+ pI830->uxa_driver->copy(dst, 0, 0, 0, 0,
+ pScrn->virtualX, pScrn->virtualY);
+
+ pI830->uxa_driver->done_copy(dst);
+
+ I830EmitFlush(pScrn);
+ intel_batch_flush(pScrn, TRUE);
+
+ (*pScreen->DestroyPixmap)(src);
+ (*pScreen->DestroyPixmap)(dst);
+}
Index: xf86-video-intel-2.8.0/src/i830.h
===================================================================
--- xf86-video-intel-2.8.0.orig/src/i830.h
+++ xf86-video-intel-2.8.0/src/i830.h
@@ -691,6 +691,7 @@ void I830DRI2CloseScreen(ScreenPtr pScre
extern Bool drmmode_pre_init(ScrnInfoPtr pScrn, int fd, int cpp);
extern int drmmode_get_pipe_from_crtc_id(drm_intel_bufmgr *bufmgr, xf86CrtcPtr crtc);
extern int drmmode_output_dpms_status(xf86OutputPtr output);
+extern void drmmode_copy_fb(ScrnInfoPtr pScrn);
void
drmmode_crtc_set_cursor_bo(xf86CrtcPtr crtc, dri_bo *cursor);
Index: xf86-video-intel-2.8.0/src/i830_driver.c
===================================================================
--- xf86-video-intel-2.8.0.orig/src/i830_driver.c
+++ xf86-video-intel-2.8.0/src/i830_driver.c
@@ -3059,6 +3059,8 @@ I830EnterVT(int scrnIndex, int flags)
/* Clear the framebuffer */
memset(pI830->FbBase + pScrn->fbOffset, 0,
pScrn->virtualY * pScrn->displayWidth * pI830->cpp);
+ } else {
+ drmmode_copy_fb(pScrn);
}
if (!xf86SetDesiredModes (pScrn))