xf86-video-intel: 2 commits - src/sna/sna_display.c

Chris Wilson ickle at kemper.freedesktop.org
Tue Aug 12 02:57:17 PDT 2014


 src/sna/sna_display.c |   87 +++++++++++++++++++++++++++-----------------------
 1 file changed, 47 insertions(+), 40 deletions(-)

New commits:
commit ec10cef592b7a3d1dc3c4949778e72e8cd156245
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Tue Aug 12 10:52:12 2014 +0100

    sna: Only apply a DPMS change for an enabled CRTC
    
    Mostly paranoia, but we need to validate that the stored mode is valid
    before applying the modeset.
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/sna/sna_display.c b/src/sna/sna_display.c
index f723481..04e9a41 100644
--- a/src/sna/sna_display.c
+++ b/src/sna/sna_display.c
@@ -2157,6 +2157,7 @@ sna_crtc_dpms(xf86CrtcPtr crtc, int mode)
 	priv->dpms_mode = mode;
 
 	if (mode == DPMSModeOn &&
+	    crtc->enabled &&
 	    priv->bo == NULL &&
 	    !__sna_crtc_set_mode(crtc))
 		mode = DPMSModeOff;
commit 9cc72c2dc7130d3d5731f7e75f35f10302389f08
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Tue Aug 12 10:49:20 2014 +0100

    sna: Suppress "switch to mode" messages for internal CRTC applies
    
    We only want to log a mode change when it is initiated by the user. For
    internal updates, such as changing the frame or restoring a mode from
    DPMS, we want to silently apply the current mode.
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/sna/sna_display.c b/src/sna/sna_display.c
index 4f69dac..f723481 100644
--- a/src/sna/sna_display.c
+++ b/src/sna/sna_display.c
@@ -2046,41 +2046,14 @@ static const char *reflection_to_str(Rotation rotation)
 }
 
 static Bool
-sna_crtc_set_mode_major(xf86CrtcPtr crtc, DisplayModePtr mode,
-			Rotation rotation, int x, int y)
+__sna_crtc_set_mode(xf86CrtcPtr crtc)
 {
-	ScrnInfoPtr scrn = crtc->scrn;
-	struct sna *sna = to_sna(scrn);
+	struct sna *sna = to_sna(crtc->scrn);
 	struct sna_crtc *sna_crtc = to_sna_crtc(crtc);
 	struct kgem_bo *saved_bo, *bo;
-	struct drm_mode_modeinfo saved_kmode;
 	uint32_t saved_offset;
 	bool saved_transform;
-	char outputs[256];
-
-	if (mode->HDisplay == 0 || mode->VDisplay == 0)
-		return FALSE;
-
-	assert(sna_crtc);
-
-	xf86DrvMsg(crtc->scrn->scrnIndex, X_INFO,
-		   "switch to mode %dx%d@%.1f on %s using pipe %d, position (%d, %d), rotation %s, reflection %s\n",
-		   mode->HDisplay, mode->VDisplay, xf86ModeVRefresh(mode),
-		   outputs_for_crtc(crtc, outputs, sizeof(outputs)), sna_crtc->pipe,
-		   x, y, rotation_to_str(rotation), reflection_to_str(rotation));
 
-	assert(mode->HDisplay <= sna->mode.max_crtc_width &&
-	       mode->VDisplay <= sna->mode.max_crtc_height);
-
-#if HAS_GAMMA
-	drmModeCrtcSetGamma(sna->kgem.fd, sna_crtc->id,
-			    crtc->gamma_size,
-			    crtc->gamma_red,
-			    crtc->gamma_green,
-			    crtc->gamma_blue);
-#endif
-
-	saved_kmode = sna_crtc->kmode;
 	saved_bo = sna_crtc->bo;
 	saved_transform = sna_crtc->transform;
 	saved_offset = sna_crtc->offset;
@@ -2094,7 +2067,6 @@ retry: /* Attach per-crtc pixmap or direct */
 	kgem_bo_submit(&sna->kgem, bo);
 
 	sna_crtc->bo = bo;
-	mode_to_kmode(&sna_crtc->kmode, mode);
 	if (!sna_crtc_apply(crtc)) {
 		int err = errno;
 
@@ -2111,9 +2083,9 @@ retry: /* Attach per-crtc pixmap or direct */
 		sna_crtc->offset = saved_offset;
 		sna_crtc->transform = saved_transform;
 		sna_crtc->bo = saved_bo;
-		sna_crtc->kmode = saved_kmode;
 		return FALSE;
 	}
+
 	bo->active_scanout++;
 	if (saved_bo) {
 		assert(saved_bo->active_scanout);
@@ -2131,6 +2103,46 @@ retry: /* Attach per-crtc pixmap or direct */
 	return TRUE;
 }
 
+static Bool
+sna_crtc_set_mode_major(xf86CrtcPtr crtc, DisplayModePtr mode,
+			Rotation rotation, int x, int y)
+{
+	struct sna *sna = to_sna(crtc->scrn);
+	struct sna_crtc *sna_crtc = to_sna_crtc(crtc);
+	struct drm_mode_modeinfo saved_kmode;
+	char outputs[256];
+
+	if (mode->HDisplay == 0 || mode->VDisplay == 0)
+		return FALSE;
+
+	assert(sna_crtc);
+
+	xf86DrvMsg(crtc->scrn->scrnIndex, X_INFO,
+		   "switch to mode %dx%d@%.1f on %s using pipe %d, position (%d, %d), rotation %s, reflection %s\n",
+		   mode->HDisplay, mode->VDisplay, xf86ModeVRefresh(mode),
+		   outputs_for_crtc(crtc, outputs, sizeof(outputs)), sna_crtc->pipe,
+		   x, y, rotation_to_str(rotation), reflection_to_str(rotation));
+
+	assert(mode->HDisplay <= sna->mode.max_crtc_width &&
+	       mode->VDisplay <= sna->mode.max_crtc_height);
+
+#if HAS_GAMMA
+	drmModeCrtcSetGamma(sna->kgem.fd, sna_crtc->id,
+			    crtc->gamma_size,
+			    crtc->gamma_red,
+			    crtc->gamma_green,
+			    crtc->gamma_blue);
+#endif
+
+	saved_kmode = sna_crtc->kmode;
+	mode_to_kmode(&sna_crtc->kmode, mode);
+	if (__sna_crtc_set_mode(crtc))
+		return TRUE;
+
+	sna_crtc->kmode = saved_kmode;
+	return FALSE;
+}
+
 static void
 sna_crtc_dpms(xf86CrtcPtr crtc, int mode)
 {
@@ -2146,9 +2158,7 @@ sna_crtc_dpms(xf86CrtcPtr crtc, int mode)
 
 	if (mode == DPMSModeOn &&
 	    priv->bo == NULL &&
-	    !sna_crtc_set_mode_major(crtc,
-				     &crtc->mode, crtc->rotation,
-				     crtc->x, crtc->y))
+	    !__sna_crtc_set_mode(crtc))
 		mode = DPMSModeOff;
 
 	if (mode != DPMSModeOn)
@@ -2176,9 +2186,7 @@ void sna_mode_adjust_frame(struct sna *sna, int x, int y)
 
 	crtc->x = x;
 	crtc->y = y;
-	if (to_sna_crtc(crtc) &&
-	    !sna_crtc_set_mode_major(crtc, &crtc->mode,
-				     crtc->rotation, x, y)) {
+	if (to_sna_crtc(crtc) && !__sna_crtc_set_mode(crtc)) {
 		crtc->x = saved_x;
 		crtc->y = saved_y;
 	}
@@ -4129,9 +4137,7 @@ sna_mode_resize(ScrnInfoPtr scrn, int width, int height)
 		if (!crtc->enabled)
 			continue;
 
-		if (!sna_crtc_set_mode_major(crtc,
-					     &crtc->mode, crtc->rotation,
-					     crtc->x, crtc->y))
+		if (!__sna_crtc_set_mode(crtc))
 			sna_crtc_disable(crtc);
 	}
 


More information about the xorg-commit mailing list