[Intel-gfx] [PATCH 07/13] drm/i915: Replace intel_set_property() with transitional helper

Matt Roper matthew.d.roper at intel.com
Mon Jan 19 19:57:40 PST 2015


This switch allows us to exercise the .atomic_set_property() that will
be used by atomic.  The only real changes we need to make here are:
 * extract the property validation from our old set_property handler and
   stick it in intel_plane_atomic_check().
 * make intel_check_*_plane() functions capable of handling a NULL crtc
   (which will happen if userspace tries to set a property value on a
   disabled plane).

Signed-off-by: Matt Roper <matthew.d.roper at intel.com>
---
 drivers/gpu/drm/i915/intel_atomic_plane.c | 24 +++++++++++++++++++-----
 drivers/gpu/drm/i915/intel_display.c      | 10 +++++++++-
 drivers/gpu/drm/i915/intel_drv.h          |  3 ---
 drivers/gpu/drm/i915/intel_sprite.c       | 31 ++++---------------------------
 4 files changed, 32 insertions(+), 36 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_atomic_plane.c b/drivers/gpu/drm/i915/intel_atomic_plane.c
index 0b07b90..966c908 100644
--- a/drivers/gpu/drm/i915/intel_atomic_plane.c
+++ b/drivers/gpu/drm/i915/intel_atomic_plane.c
@@ -104,13 +104,20 @@ static int intel_plane_atomic_check(struct drm_plane *plane,
 	intel_state->dst.x2 = state->crtc_x + state->crtc_w;
 	intel_state->dst.y2 = state->crtc_y + state->crtc_h;
 
-	/* Clip all planes to CRTC size, or 0x0 if CRTC is disabled */
+	/*
+	 * Clip all planes to CRTC size, or 0x0 if CRTC unset or disabled.
+	 * Note that CRTC may be unset if we're setting a property of a
+	 * disabled plane.
+	 */
 	intel_state->clip.x1 = 0;
 	intel_state->clip.y1 = 0;
-	intel_state->clip.x2 =
-		intel_crtc->active ? intel_crtc->config->pipe_src_w : 0;
-	intel_state->clip.y2 =
-		intel_crtc->active ? intel_crtc->config->pipe_src_h : 0;
+	if (crtc && intel_crtc->active) {
+		intel_state->clip.x2 = intel_crtc->config->pipe_src_w;
+		intel_state->clip.y2 = intel_crtc->config->pipe_src_h;
+	} else {
+		intel_state->clip.x2 = 0;
+		intel_state->clip.y2 = 0;
+	}
 
 	/*
 	 * Disabling a plane is always okay; we just need to update
@@ -118,6 +125,9 @@ static int intel_plane_atomic_check(struct drm_plane *plane,
 	 * get called by the plane helpers.
 	 */
 	if (state->fb == NULL && plane->state->fb != NULL) {
+		if (WARN_ON(!crtc))
+			return -EINVAL;
+
 		/*
 		 * 'prepare' is never called when plane is being disabled, so
 		 * we need to handle frontbuffer tracking as a special case
@@ -126,6 +136,10 @@ static int intel_plane_atomic_check(struct drm_plane *plane,
 			(1 << drm_plane_index(plane));
 	}
 
+	/* Rotation property should contain only a single rotation bit */
+	if (hweight32(intel_state->rotation & 0xf) != 1)
+		return -EINVAL;
+
 	return intel_plane->check_plane(plane, intel_state);
 }
 
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index 90008b8..50ae3b1 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -11774,6 +11774,10 @@ intel_check_primary_plane(struct drm_plane *plane,
 	crtc = crtc ? crtc : plane->crtc;
 	intel_crtc = to_intel_crtc(crtc);
 
+	/* CRTC may be unset if we're updating a property of a disabled plane */
+	if (!crtc)
+		return 0;
+
 	ret = drm_plane_helper_check_update(plane, crtc, fb,
 					    src, dest, clip,
 					    DRM_PLANE_HELPER_NO_SCALING,
@@ -11972,7 +11976,7 @@ const struct drm_plane_funcs intel_plane_funcs = {
 	.update_plane = drm_plane_helper_update,
 	.disable_plane = drm_plane_helper_disable,
 	.destroy = intel_plane_destroy,
-	.set_property = intel_plane_set_property,
+	.set_property = drm_plane_helper_set_property,
 	.atomic_get_property = intel_plane_atomic_get_property,
 	.atomic_set_property = intel_plane_atomic_set_property,
 	.atomic_duplicate_state = intel_plane_duplicate_state,
@@ -12057,6 +12061,10 @@ intel_check_cursor_plane(struct drm_plane *plane,
 	crtc = crtc ? crtc : plane->crtc;
 	intel_crtc = to_intel_crtc(crtc);
 
+	/* CRTC may be unset if we're updating a property of a disabled plane */
+	if (!crtc)
+		return 0;
+
 	ret = drm_plane_helper_check_update(plane, crtc, fb,
 					    src, dest, clip,
 					    DRM_PLANE_HELPER_NO_SCALING,
diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
index 97c3ace..2d9e9a4 100644
--- a/drivers/gpu/drm/i915/intel_drv.h
+++ b/drivers/gpu/drm/i915/intel_drv.h
@@ -1246,9 +1246,6 @@ bool intel_sdvo_init(struct drm_device *dev, uint32_t sdvo_reg, bool is_sdvob);
 int intel_plane_init(struct drm_device *dev, enum pipe pipe, int plane);
 void intel_flush_primary_plane(struct drm_i915_private *dev_priv,
 			       enum plane plane);
-int intel_plane_set_property(struct drm_plane *plane,
-			     struct drm_property *prop,
-			     uint64_t val);
 int intel_plane_restore(struct drm_plane *plane);
 int intel_sprite_set_colorkey(struct drm_device *dev, void *data,
 			      struct drm_file *file_priv);
diff --git a/drivers/gpu/drm/i915/intel_sprite.c b/drivers/gpu/drm/i915/intel_sprite.c
index 8af4c69..c62f263 100644
--- a/drivers/gpu/drm/i915/intel_sprite.c
+++ b/drivers/gpu/drm/i915/intel_sprite.c
@@ -1094,6 +1094,10 @@ intel_check_sprite_plane(struct drm_plane *plane,
 
 	intel_crtc = intel_crtc ? intel_crtc : to_intel_crtc(plane->crtc);
 
+	/* CRTC may be unset if we're updating a property of a disabled plane */
+	if (!intel_crtc)
+		return 0;
+
 	if (!fb) {
 		state->visible = false;
 		goto finish;
@@ -1367,33 +1371,6 @@ out_unlock:
 	return ret;
 }
 
-int intel_plane_set_property(struct drm_plane *plane,
-			     struct drm_property *prop,
-			     uint64_t val)
-{
-	struct drm_device *dev = plane->dev;
-	struct intel_plane_state *state = to_intel_plane_state(plane->state);
-	uint64_t old_val;
-	int ret = -ENOENT;
-
-	if (prop == dev->mode_config.rotation_property) {
-		/* exactly one rotation angle please */
-		if (hweight32(val & 0xf) != 1)
-			return -EINVAL;
-
-		if (state->rotation == val)
-			return 0;
-
-		old_val = state->rotation;
-		state->rotation = val;
-		ret = intel_plane_restore(plane);
-		if (ret)
-			state->rotation = old_val;
-	}
-
-	return ret;
-}
-
 int intel_plane_restore(struct drm_plane *plane)
 {
 	if (!plane->crtc || !plane->fb)
-- 
1.8.5.1



More information about the Intel-gfx mailing list