From patchwork Fri Jan 16 02:34:24 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matt Roper X-Patchwork-Id: 5643971 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 36AB0C058D for ; Fri, 16 Jan 2015 02:35:11 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 397CC201CE for ; Fri, 16 Jan 2015 02:35:10 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 2671A201CD for ; Fri, 16 Jan 2015 02:35:09 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 57F2D89C1E; Thu, 15 Jan 2015 18:35:08 -0800 (PST) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by gabe.freedesktop.org (Postfix) with ESMTP id 3C69F89A88 for ; Thu, 15 Jan 2015 18:35:03 -0800 (PST) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga103.jf.intel.com with ESMTP; 15 Jan 2015 18:31:19 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.09,407,1418112000"; d="scan'208";a="670800349" Received: from mdroper-hswdev.fm.intel.com (HELO mdroper-hswdev) ([10.1.134.215]) by orsmga002.jf.intel.com with ESMTP; 15 Jan 2015 18:35:02 -0800 Received: from mattrope by mdroper-hswdev with local (Exim 4.82) (envelope-from ) id 1YBwkY-0007yg-NE; Thu, 15 Jan 2015 18:35:02 -0800 From: Matt Roper To: intel-gfx@lists.freedesktop.org Date: Thu, 15 Jan 2015 18:34:24 -0800 Message-Id: <1421375664-30550-7-git-send-email-matthew.d.roper@intel.com> X-Mailer: git-send-email 1.8.5.1 In-Reply-To: <1421375664-30550-1-git-send-email-matthew.d.roper@intel.com> References: <1421375664-30550-1-git-send-email-matthew.d.roper@intel.com> Subject: [Intel-gfx] [PATCH 6/6] drm/i915: Replace intel_set_property() with transitional helper X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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 7db18d16..d34a8ca 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, @@ -11973,7 +11977,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, @@ -12058,6 +12062,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)