xf86-video-intel: src/i830_common.h src/i830_display.c src/i830_dri.c src/i830_driver.c

Jesse Barnes jbarnes at kemper.freedesktop.org
Mon Sep 10 23:31:30 PDT 2007


 src/i830_common.h  |   19 +++++++++++--------
 src/i830_display.c |   20 ++++++++++----------
 src/i830_dri.c     |   24 ++++++++++++------------
 src/i830_driver.c  |   29 ++++++++++++++++++++++++++++-
 4 files changed, 61 insertions(+), 31 deletions(-)

New commits:
diff-tree 4c7542ef43a5267e470ca1608a2ae57abf9783ec (from 286f5df0b62f571cbb4dbf120679d3af029b8775)
Author: Jesse Barnes <jesse.barnes at intel.com>
Date:   Mon Sep 10 23:30:50 2007 -0700

    Only swap planes and pipes if DRM supports it
    
    We want to associate plane A with pipe B on pre-965 mobile chips, since that's
    the only way to get framebuffer compression on the builtin LVDS on those
    platforms.  However, if we do this swapping and DRM isn't aware of it, we may
    end up requesting vblank events for the wrong pipe, or setting up SAREA buffer
    swap state incorrectly.
    
    This mod checks whether DRM supports the new plane->pipe swapping behavior, and
    only enables the swapping if so.  This should fix the bugs Lukas found and
    debugged.  Reviewed by Michel Danzer.

diff --git a/src/i830_common.h b/src/i830_common.h
index 9c8616c..a652428 100644
--- a/src/i830_common.h
+++ b/src/i830_common.h
@@ -124,14 +124,17 @@ typedef struct {
         unsigned int rotated_tiled;
         unsigned int rotated2_tiled;
 
-	int pipeA_x;
-	int pipeA_y;
-	int pipeA_w;
-	int pipeA_h;
-	int pipeB_x;
-	int pipeB_y;
-	int pipeB_w;
-	int pipeB_h;
+	int planeA_x;
+	int planeA_y;
+	int planeA_w;
+	int planeA_h;
+	int planeB_x;
+	int planeB_y;
+	int planeB_w;
+	int planeB_h;
+
+	int planeA_pipe;
+	int planeB_pipe;
 
 	/* Triple buffering */
 	drm_handle_t third_handle;
diff --git a/src/i830_display.c b/src/i830_display.c
index d8be8d9..92e52ed 100644
--- a/src/i830_display.c
+++ b/src/i830_display.c
@@ -414,14 +414,14 @@ i830PipeSetBase(xf86CrtcPtr crtc, int x,
 	if (!sPriv)
 	    return;
 
-	switch (pipe) {
+	switch (plane) {
 	case 0:
-	    sPriv->pipeA_x = x;
-	    sPriv->pipeA_y = y;
+	    sPriv->planeA_x = x;
+	    sPriv->planeA_y = y;
 	    break;
 	case 1:
-	    sPriv->pipeB_x = x;
-	    sPriv->pipeB_y = y;
+	    sPriv->planeB_x = x;
+	    sPriv->planeB_y = y;
 	    break;
 	default:
 	    xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
@@ -763,14 +763,14 @@ i830_crtc_dpms(xf86CrtcPtr crtc, int mod
 	if (!sPriv)
 	    return;
 
-	switch (pipe) {
+	switch (plane) {
 	case 0:
-	    sPriv->pipeA_w = enabled ? crtc->mode.HDisplay : 0;
-	    sPriv->pipeA_h = enabled ? crtc->mode.VDisplay : 0;
+	    sPriv->planeA_w = enabled ? crtc->mode.HDisplay : 0;
+	    sPriv->planeA_h = enabled ? crtc->mode.VDisplay : 0;
 	    break;
 	case 1:
-	    sPriv->pipeB_w = enabled ? crtc->mode.HDisplay : 0;
-	    sPriv->pipeB_h = enabled ? crtc->mode.VDisplay : 0;
+	    sPriv->planeB_w = enabled ? crtc->mode.HDisplay : 0;
+	    sPriv->planeB_h = enabled ? crtc->mode.VDisplay : 0;
 	    break;
 	default:
 	    xf86DrvMsg(pScrn->scrnIndex, X_ERROR,
diff --git a/src/i830_dri.c b/src/i830_dri.c
index 32f6510..2654ae6 100644
--- a/src/i830_dri.c
+++ b/src/i830_dri.c
@@ -91,7 +91,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 #define DRM_VBLANK_FLIP 0x8000000
 
 typedef struct drm_i915_flip {
-   int pipes;
+   int planes;
 } drm_i915_flip_t;
 
 #undef DRM_IOCTL_I915_FLIP
@@ -1288,20 +1288,20 @@ I830DRISwapContext(ScreenPtr pScreen, DR
 #ifdef DAMAGE
       /* Try flipping back to the front page if necessary */
       if (sPriv && !sPriv->pf_enabled && sPriv->pf_current_page != 0) {
-	 drm_i915_flip_t flip = { .pipes = 0 };
+	 drm_i915_flip_t flip = { .planes = 0 };
 
 	 if (sPriv->pf_current_page & (0x3 << 2)) {
 	    sPriv->pf_current_page = sPriv->pf_current_page & 0x3;
 	    sPriv->pf_current_page |= (sPriv->third_handle ? 2 : 1) << 2;
 
-	    flip.pipes |= 0x2;
+	    flip.planes |= 0x2;
 	 }
 
 	 if (sPriv->pf_current_page & 0x3) {
 	    sPriv->pf_current_page = sPriv->pf_current_page & (0x3 << 2);
 	    sPriv->pf_current_page |= sPriv->third_handle ? 2 : 1;
 
-	    flip.pipes |= 0x1;
+	    flip.planes |= 0x1;
 	 }
 
 	 drmCommandWrite(pI830->drmSubFD, DRM_I915_FLIP, &flip, sizeof(flip));
@@ -1634,14 +1634,14 @@ I830DRIClipNotify(ScreenPtr pScreen, Win
       unsigned numvisible[2] = { 0, 0 };
       int i, j;
 
-      crtcBox[0].x1 = sPriv->pipeA_x;
-      crtcBox[0].y1 = sPriv->pipeA_y;
-      crtcBox[0].x2 = crtcBox[0].x1 + sPriv->pipeA_w;
-      crtcBox[0].y2 = crtcBox[0].y1 + sPriv->pipeA_h;
-      crtcBox[1].x1 = sPriv->pipeB_x;
-      crtcBox[1].y1 = sPriv->pipeB_y;
-      crtcBox[1].x2 = crtcBox[1].x1 + sPriv->pipeB_w;
-      crtcBox[1].y2 = crtcBox[1].y1 + sPriv->pipeB_h;
+      crtcBox[0].x1 = sPriv->planeA_x;
+      crtcBox[0].y1 = sPriv->planeA_y;
+      crtcBox[0].x2 = crtcBox[0].x1 + sPriv->planeA_w;
+      crtcBox[0].y2 = crtcBox[0].y1 + sPriv->planeA_h;
+      crtcBox[1].x1 = sPriv->planeB_x;
+      crtcBox[1].y1 = sPriv->planeB_y;
+      crtcBox[1].x2 = crtcBox[1].x1 + sPriv->planeB_w;
+      crtcBox[1].y2 = crtcBox[1].y1 + sPriv->planeB_h;
 
       for (i = 0; i < 2; i++) {
 	 for (j = 0; j < num; j++) {
diff --git a/src/i830_driver.c b/src/i830_driver.c
index b168fd4..ea22855 100644
--- a/src/i830_driver.c
+++ b/src/i830_driver.c
@@ -851,6 +851,10 @@ I830SetupOutputs(ScrnInfoPtr pScrn)
       output->possible_clones = i830_output_clones (pScrn, intel_output->clone_mask);
    }
 
+   /* Only recent DRM drivers can support plane<->pipe reversal */
+   if (pI830->directRenderingEnabled && pI830->drmMinor < 10)
+       goto out;
+
    /*
     * If an LVDS display is present, swap the plane/pipe mappings so we can
     * use FBC on the builtin display.
@@ -858,6 +862,8 @@ I830SetupOutputs(ScrnInfoPtr pScrn)
     *       alone in that case.
     */
    if (lvds_detected && !IS_I965GM(pI830)) {
+       xf86DrvMsg(pScrn->scrnIndex, X_INFO, "adjusting plane->pipe mappings "
+		  "to allow for framebuffer compression\n");
        for (c = 0; c < config->num_crtc; c++) {
 	   xf86CrtcPtr	      crtc = config->crtc[c];
 	   I830CrtcPrivatePtr   intel_crtc = crtc->driver_private;
@@ -868,6 +874,9 @@ I830SetupOutputs(ScrnInfoPtr pScrn)
 	       intel_crtc->plane = 0;
       }
    }
+
+out:
+   return;
 }
 
 /**
@@ -2249,11 +2258,13 @@ I830ScreenInit(int scrnIndex, ScreenPtr 
    VisualPtr visual;
    I830Ptr pI8301 = NULL;
    unsigned long sys_mem;
-   int i;
+   int i, c;
    Bool allocation_done = FALSE;
    MessageType from;
 #ifdef XF86DRI
    Bool driDisabled;
+   drmI830Sarea *sPriv;
+   xf86CrtcConfigPtr config;
 #ifdef XF86DRI_MM
    unsigned long savedMMSize;
 #endif
@@ -2706,6 +2717,22 @@ I830ScreenInit(int scrnIndex, ScreenPtr 
       i830_free_3d_memory(pScrn);
    }
 
+   config = XF86_CRTC_CONFIG_PTR(pScrn);
+   sPriv = DRIGetSAREAPrivate(pScrn->pScreen);
+   /* Setup pipe->plane mappings for DRI & DRM */
+   for (c = 0; c < config->num_crtc; c++) {
+       xf86CrtcPtr crtc = config->crtc[c];
+       I830CrtcPrivatePtr intel_crtc = crtc->driver_private;
+
+       if (intel_crtc->plane == 0)
+	   sPriv->planeA_pipe = intel_crtc->pipe;
+       else if (intel_crtc->plane == 1)
+	   sPriv->planeB_pipe = intel_crtc->pipe;
+   }
+
+   xf86DrvMsg(pScrn->scrnIndex, X_INFO, "drm planeA pipe: %d, "
+	      "planeB pipe: %d\n", sPriv->planeA_pipe, sPriv->planeB_pipe);
+
 #else
    pI830->directRenderingEnabled = FALSE;
 #endif


More information about the xorg-commit mailing list