[PATCH 1/3] video: add option to include disabled CRTCs in best CRTC search

Ilija Hadzic ilijahadzic at gmail.com
Thu Dec 13 11:46:31 PST 2012


From: Ilija Hadzic <ihadzic at research.bell-labs.com>

This patch adds an option called consider_disabled to
radeon_pick_best_crtc function. If this option is set
and searching for best-fit CRTC yields nothing, the search
will be widened to include CRTCs in DPMS "off" state that
have usable refresh rate. The new option is not used yet;
it will be in the patches to follow.

Signed-off-by: Ilija Hadzic <ihadzic at research.bell-labs.com>
---
 src/evergreen_textured_videofuncs.c |  2 +-
 src/r600_textured_videofuncs.c      |  2 +-
 src/radeon.h                        |  1 +
 src/radeon_dri2.c                   |  2 +-
 src/radeon_exa_funcs.c              |  4 ++--
 src/radeon_exa_render.c             |  2 +-
 src/radeon_exa_shared.c             |  3 ++-
 src/radeon_textured_videofuncs.c    |  8 ++++----
 src/radeon_video.c                  | 34 +++++++++++++++++++++++++++++++++-
 9 files changed, 46 insertions(+), 12 deletions(-)

diff --git a/src/evergreen_textured_videofuncs.c b/src/evergreen_textured_videofuncs.c
index 6daf30e..2568731 100644
--- a/src/evergreen_textured_videofuncs.c
+++ b/src/evergreen_textured_videofuncs.c
@@ -464,7 +464,7 @@ EVERGREENDisplayTexturedVideo(ScrnInfoPtr pScrn, RADEONPortPrivPtr pPriv)
 	if (pPriv->desired_crtc)
 	    crtc = pPriv->desired_crtc;
 	else
-	    crtc = radeon_pick_best_crtc(pScrn,
+	    crtc = radeon_pick_best_crtc(pScrn, FALSE,
 					 pPriv->drw_x,
 					 pPriv->drw_x + pPriv->dst_w,
 					 pPriv->drw_y,
diff --git a/src/r600_textured_videofuncs.c b/src/r600_textured_videofuncs.c
index 970ab8e..a831558 100644
--- a/src/r600_textured_videofuncs.c
+++ b/src/r600_textured_videofuncs.c
@@ -447,7 +447,7 @@ R600DisplayTexturedVideo(ScrnInfoPtr pScrn, RADEONPortPrivPtr pPriv)
 	if (pPriv->desired_crtc)
 	    crtc = pPriv->desired_crtc;
 	else
-	    crtc = radeon_pick_best_crtc(pScrn,
+	    crtc = radeon_pick_best_crtc(pScrn, FALSE,
 					 pPriv->drw_x,
 					 pPriv->drw_x + pPriv->dst_w,
 					 pPriv->drw_y,
diff --git a/src/radeon.h b/src/radeon.h
index 9c2073f..aeb1de0 100644
--- a/src/radeon.h
+++ b/src/radeon.h
@@ -520,6 +520,7 @@ extern void RADEONInitVideo(ScreenPtr pScreen);
 extern void RADEONResetVideo(ScrnInfoPtr pScrn);
 extern Bool radeon_load_bicubic_texture(ScrnInfoPtr pScrn);
 extern xf86CrtcPtr radeon_pick_best_crtc(ScrnInfoPtr pScrn,
+					 Bool consider_disabled,
 					 int x1, int x2, int y1, int y2);
 
 extern void radeon_cs_flush_indirect(ScrnInfoPtr pScrn);
diff --git a/src/radeon_dri2.c b/src/radeon_dri2.c
index 919f1f6..83bc2d2 100644
--- a/src/radeon_dri2.c
+++ b/src/radeon_dri2.c
@@ -781,7 +781,7 @@ static int radeon_dri2_drawable_crtc(DrawablePtr pDraw)
     xf86CrtcPtr crtc;
     int crtc_id = -1;
 
-    crtc = radeon_pick_best_crtc(pScrn,
+    crtc = radeon_pick_best_crtc(pScrn, FALSE,
 				 pDraw->x,
 				 pDraw->x + pDraw->width,
 				 pDraw->y,
diff --git a/src/radeon_exa_funcs.c b/src/radeon_exa_funcs.c
index 2533d78..ce6186d 100644
--- a/src/radeon_exa_funcs.c
+++ b/src/radeon_exa_funcs.c
@@ -190,7 +190,7 @@ RADEONSolid(PixmapPtr pPix, int x1, int y1, int x2, int y2)
 
     if (info->accel_state->vsync)
 	RADEONWaitForVLine(pScrn, pPix,
-			   radeon_pick_best_crtc(pScrn, x1, x2, y1, y2),
+			   radeon_pick_best_crtc(pScrn, FALSE, x1, x2, y1, y2),
 			   y1, y2);
 
     BEGIN_RING(2*2);
@@ -304,7 +304,7 @@ RADEONCopy(PixmapPtr pDst,
 
     if (info->accel_state->vsync)
 	RADEONWaitForVLine(pScrn, pDst,
-			   radeon_pick_best_crtc(pScrn, dstX, dstX + w, dstY, dstY + h),
+			   radeon_pick_best_crtc(pScrn, FALSE, dstX, dstX + w, dstY, dstY + h),
 			   dstY, dstY + h);
 
     BEGIN_RING(2*3);
diff --git a/src/radeon_exa_render.c b/src/radeon_exa_render.c
index c673f2c..1a35742 100644
--- a/src/radeon_exa_render.c
+++ b/src/radeon_exa_render.c
@@ -2261,7 +2261,7 @@ static void RadeonCompositeTile(ScrnInfoPtr pScrn,
 
     if (info->accel_state->vsync)
         RADEONWaitForVLine(pScrn, pDst,
-			   radeon_pick_best_crtc(pScrn, dstX, dstX + w, dstY, dstY + h),
+			   radeon_pick_best_crtc(pScrn, FALSE, dstX, dstX + w, dstY, dstY + h),
 			   dstY, dstY + h);
 
     if (info->ChipFamily < CHIP_FAMILY_R200) {
diff --git a/src/radeon_exa_shared.c b/src/radeon_exa_shared.c
index 1218efb..cca1c67 100644
--- a/src/radeon_exa_shared.c
+++ b/src/radeon_exa_shared.c
@@ -63,7 +63,8 @@ void RADEONVlineHelperSet(ScrnInfoPtr pScrn, int x1, int y1, int x2, int y2)
     RADEONInfoPtr info = RADEONPTR(pScrn);
     struct radeon_accel_state *accel_state = info->accel_state;
 
-    accel_state->vline_crtc = radeon_pick_best_crtc(pScrn, x1, x2, y1, y2);
+    accel_state->vline_crtc =
+	radeon_pick_best_crtc(pScrn, FALSE, x1, x2, y1, y2);
     if (accel_state->vline_y1 == -1)
 	accel_state->vline_y1 = y1;
     if (y1 < accel_state->vline_y1)
diff --git a/src/radeon_textured_videofuncs.c b/src/radeon_textured_videofuncs.c
index c1bdc65..a67f2a4 100644
--- a/src/radeon_textured_videofuncs.c
+++ b/src/radeon_textured_videofuncs.c
@@ -269,7 +269,7 @@ RADEONPrepareTexturedVideo(ScrnInfoPtr pScrn, RADEONPortPrivPtr pPriv)
 	if (pPriv->desired_crtc)
 	    crtc = pPriv->desired_crtc;
 	else
-	    crtc = radeon_pick_best_crtc(pScrn,
+	    crtc = radeon_pick_best_crtc(pScrn, FALSE,
 					 pPriv->drw_x,
 					 pPriv->drw_x + pPriv->dst_w,
 					 pPriv->drw_y,
@@ -813,7 +813,7 @@ R200PrepareTexturedVideo(ScrnInfoPtr pScrn, RADEONPortPrivPtr pPriv)
 	if (pPriv->desired_crtc)
 	    crtc = pPriv->desired_crtc;
 	else
-	    crtc = radeon_pick_best_crtc(pScrn,
+	    crtc = radeon_pick_best_crtc(pScrn, FALSE,
 					 pPriv->drw_x,
 					 pPriv->drw_x + pPriv->dst_w,
 					 pPriv->drw_y,
@@ -2165,7 +2165,7 @@ R300PrepareTexturedVideo(ScrnInfoPtr pScrn, RADEONPortPrivPtr pPriv)
 	if (pPriv->desired_crtc)
 	    crtc = pPriv->desired_crtc;
 	else
-	    crtc = radeon_pick_best_crtc(pScrn,
+	    crtc = radeon_pick_best_crtc(pScrn, FALSE,
 					 pPriv->drw_x,
 					 pPriv->drw_x + pPriv->dst_w,
 					 pPriv->drw_y,
@@ -3730,7 +3730,7 @@ R500PrepareTexturedVideo(ScrnInfoPtr pScrn, RADEONPortPrivPtr pPriv)
 	if (pPriv->desired_crtc)
 	    crtc = pPriv->desired_crtc;
 	else
-	    crtc = radeon_pick_best_crtc(pScrn,
+	    crtc = radeon_pick_best_crtc(pScrn, FALSE,
 					 pPriv->drw_x,
 					 pPriv->drw_x + pPriv->dst_w,
 					 pPriv->drw_y,
diff --git a/src/radeon_video.c b/src/radeon_video.c
index 8073081..63b4844 100644
--- a/src/radeon_video.c
+++ b/src/radeon_video.c
@@ -74,8 +74,15 @@ radeon_crtc_is_enabled(xf86CrtcPtr crtc)
     return drmmode_crtc->dpms_mode == DPMSModeOn;
 }
 
+static Bool
+radeon_crtc_refresh_rate_usable(xf86CrtcPtr crtc)
+{
+    return (crtc->mode.Clock != 0) &&
+	(crtc->mode.HTotal != 0) && (crtc->mode.VTotal != 0);
+}
+
 xf86CrtcPtr
-radeon_pick_best_crtc(ScrnInfoPtr pScrn,
+radeon_pick_best_crtc(ScrnInfoPtr pScrn, Bool consider_disabled,
 		      int x1, int x2, int y1, int y2)
 {
     xf86CrtcConfigPtr   xf86_config = XF86_CRTC_CONFIG_PTR(pScrn);
@@ -103,6 +110,7 @@ radeon_pick_best_crtc(ScrnInfoPtr pScrn,
     if (primary_output && primary_output->crtc)
 	primary_crtc = primary_output->crtc->devPrivate;
 
+    /* first consider only enabled CRTCs */
     for (c = 0; c < xf86_config->num_crtc; c++) {
 	xf86CrtcPtr crtc = xf86_config->crtc[c];
 
@@ -118,6 +126,30 @@ radeon_pick_best_crtc(ScrnInfoPtr pScrn,
 	    best_coverage = coverage;
 	}
     }
+    if (best_crtc || !consider_disabled)
+	return best_crtc;
+
+    /* if we found nothing, repeat the search including disabled CRTCs */
+    for (c = 0; c < xf86_config->num_crtc; c++) {
+	xf86CrtcPtr crtc = xf86_config->crtc[c];
+
+	radeon_crtc_box(crtc, &crtc_box);
+	radeon_box_intersect(&cover_box, &crtc_box, &box);
+	coverage = radeon_box_area(&cover_box);
+	if (coverage > best_coverage ||
+	    (coverage == best_coverage && crtc == primary_crtc)) {
+	    best_crtc = crtc;
+	    best_coverage = coverage;
+	}
+    }
+
+    /*
+     * crtc in DPMS off state, it is still usable for us
+     * if it has a valid refresh rate set
+     */
+    if (best_crtc && !radeon_crtc_refresh_rate_usable(best_crtc))
+	best_crtc = NULL;
+
     return best_crtc;
 }
 
-- 
1.7.12.4



More information about the xorg-driver-ati mailing list