From patchwork Mon Aug 27 12:37:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Juha-Pekka Heikkila X-Patchwork-Id: 10577055 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9374714BD for ; Mon, 27 Aug 2018 12:38:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7FAFB2941B for ; Mon, 27 Aug 2018 12:38:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 73F122941F; Mon, 27 Aug 2018 12:38:14 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 1E8E72941B for ; Mon, 27 Aug 2018 12:38:14 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 146256E232; Mon, 27 Aug 2018 12:38:13 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-pf1-x442.google.com (mail-pf1-x442.google.com [IPv6:2607:f8b0:4864:20::442]) by gabe.freedesktop.org (Postfix) with ESMTPS id F00DC6E232 for ; Mon, 27 Aug 2018 12:38:11 +0000 (UTC) Received: by mail-pf1-x442.google.com with SMTP id k21-v6so7681998pff.11 for ; Mon, 27 Aug 2018 05:38:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=9tFNBc5HKP1+otbM8DSvciTflmXrqTqKiBemDxqKyHc=; b=rkHdNbWG6a4+bfOzv8gWDdTvNbmpBKiitRLegFi9e03dGScQtq8GYfaJS8xpRrKFhj bvgo5gv8PL7OZ6ZltR7ark35/xAcdr9fsnMMotwXjzDKWtckVEKSWK4TlWSaV2G52G6C V2Oid8sxDteg6gL+1NydAX3jpBQadXJBCn0gPY7cCZFksZw0q/qNZ6cE/iG3VKyeby5l LjUYPmM5WlsrgHz8VmgO+yPmD9RBBDxhgUmR7B57r0x0hgc0hSrm+b4Xm1BPf0a7cLsO XUdKMgh9wc4MlMV8mlJkOqE+QgsijsV4b+AAYiqGZFkGvQmm1vwGvJVq8KSZ55JSdNQf hAcg== X-Gm-Message-State: APzg51CJ6Ue3byQqdG4OvWO+PqCmTi7xvAozs2RaXrurFN5Q3FX3xzag 2k1GYV+AGxBpftGeMzfLiFpHxozLCWo= X-Google-Smtp-Source: ANB0VdbWK8W00W+z+m2vp3K1kjIfHxSVfgf5+hRyQ17t2LitTynoW4zU3PXCOmPKc2fIF6BNtBNlAQ== X-Received: by 2002:a63:5126:: with SMTP id f38-v6mr12280641pgb.30.1535373491219; Mon, 27 Aug 2018 05:38:11 -0700 (PDT) Received: from jheikkil-mobl.fi.intel.com (fmdmzpr04-ext.fm.intel.com. [192.55.54.39]) by smtp.gmail.com with ESMTPSA id j5-v6sm19262476pff.139.2018.08.27.05.38.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 27 Aug 2018 05:38:10 -0700 (PDT) From: Juha-Pekka Heikkila To: intel-gfx@lists.freedesktop.org Date: Mon, 27 Aug 2018 15:37:52 +0300 Message-Id: <1535373473-3594-2-git-send-email-juhapekka.heikkila@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1535373473-3594-1-git-send-email-juhapekka.heikkila@gmail.com> References: <1535373473-3594-1-git-send-email-juhapekka.heikkila@gmail.com> MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH 1/2] drm/i915: Move 90/270 rotation validity check into its own function X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP This makes intel_plane_atomic_check_with_state() generally shorter. v2: (Ville Syrjälä) move all rotation related checks into new function and don't pass dev_priv pointer around. v3: (Ville Syljälä) rename new function. v4: rebase Signed-off-by: Juha-Pekka Heikkila --- drivers/gpu/drm/i915/intel_atomic_plane.c | 66 ++++++++++++++++++------------- 1 file changed, 39 insertions(+), 27 deletions(-) diff --git a/drivers/gpu/drm/i915/intel_atomic_plane.c b/drivers/gpu/drm/i915/intel_atomic_plane.c index dcba645..344a16b 100644 --- a/drivers/gpu/drm/i915/intel_atomic_plane.c +++ b/drivers/gpu/drm/i915/intel_atomic_plane.c @@ -107,44 +107,34 @@ intel_plane_destroy_state(struct drm_plane *plane, drm_atomic_helper_plane_destroy_state(plane, state); } -int intel_plane_atomic_check_with_state(const struct intel_crtc_state *old_crtc_state, - struct intel_crtc_state *crtc_state, - const struct intel_plane_state *old_plane_state, - struct intel_plane_state *intel_state) +static bool intel_plane_valid_rotation(const struct drm_plane_state *plane_state) { - struct drm_plane *plane = intel_state->base.plane; - struct drm_i915_private *dev_priv = to_i915(plane->dev); - struct drm_plane_state *state = &intel_state->base; - struct intel_plane *intel_plane = to_intel_plane(plane); - const struct drm_display_mode *adjusted_mode = - &crtc_state->base.adjusted_mode; - int ret; + struct intel_plane *plane = to_intel_plane(plane_state->plane); + struct drm_i915_private *dev_priv = to_i915(plane->base.dev); - if (!intel_state->base.crtc && !old_plane_state->base.crtc) - return 0; - - if (state->fb && drm_rotation_90_or_270(state->rotation)) { + if (plane_state->fb && + drm_rotation_90_or_270(plane_state->rotation)) { struct drm_format_name_buf format_name; - if (state->fb->modifier != I915_FORMAT_MOD_Y_TILED && - state->fb->modifier != I915_FORMAT_MOD_Yf_TILED) { + if (plane_state->fb->modifier != I915_FORMAT_MOD_Y_TILED && + plane_state->fb->modifier != I915_FORMAT_MOD_Yf_TILED) { DRM_DEBUG_KMS("Y/Yf tiling required for 90/270!\n"); - return -EINVAL; + return false; } /* * 90/270 is not allowed with RGB64 16:16:16:16, * RGB 16-bit 5:6:5, and Indexed 8-bit. - * TBD: Add RGB64 case once its added in supported format list. + * TBD: Add RGB64 case once its added in supported format + * list. */ - switch (state->fb->format->format) { + switch (plane_state->fb->format->format) { case DRM_FORMAT_C8: case DRM_FORMAT_RGB565: DRM_DEBUG_KMS("Unsupported pixel format %s for 90/270!\n", - drm_get_format_name(state->fb->format->format, - &format_name)); - return -EINVAL; - + drm_get_format_name(plane_state->fb->format->format, + &format_name)); + return false; default: break; } @@ -152,12 +142,34 @@ int intel_plane_atomic_check_with_state(const struct intel_crtc_state *old_crtc_ /* CHV ignores the mirror bit when the rotate bit is set :( */ if (IS_CHERRYVIEW(dev_priv) && - state->rotation & DRM_MODE_ROTATE_180 && - state->rotation & DRM_MODE_REFLECT_X) { + plane_state->rotation & DRM_MODE_ROTATE_180 && + plane_state->rotation & DRM_MODE_REFLECT_X) { DRM_DEBUG_KMS("Cannot rotate and reflect at the same time\n"); - return -EINVAL; + return false; } + return true; +} + +int intel_plane_atomic_check_with_state(const struct intel_crtc_state *old_crtc_state, + struct intel_crtc_state *crtc_state, + const struct intel_plane_state *old_plane_state, + struct intel_plane_state *intel_state) +{ + struct drm_plane *plane = intel_state->base.plane; + struct drm_i915_private *dev_priv = to_i915(plane->dev); + struct drm_plane_state *state = &intel_state->base; + struct intel_plane *intel_plane = to_intel_plane(plane); + const struct drm_display_mode *adjusted_mode = + &crtc_state->base.adjusted_mode; + int ret; + + if (!intel_state->base.crtc && !old_plane_state->base.crtc) + return 0; + + if (!intel_plane_valid_rotation(state)) + return -EINVAL; + intel_state->base.visible = false; ret = intel_plane->check_plane(intel_plane, crtc_state, intel_state); if (ret)