From patchwork Tue Nov 21 14:15:09 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Juha-Pekka Heikkila X-Patchwork-Id: 10068255 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 028BA602B7 for ; Tue, 21 Nov 2017 14:15:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E8F98285A4 for ; Tue, 21 Nov 2017 14:15:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DD7D02966C; Tue, 21 Nov 2017 14:15:29 +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=-4.1 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID 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 8AC7F285A4 for ; Tue, 21 Nov 2017 14:15:29 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 441C188A28; Tue, 21 Nov 2017 14:15:29 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-pg0-x243.google.com (mail-pg0-x243.google.com [IPv6:2607:f8b0:400e:c05::243]) by gabe.freedesktop.org (Postfix) with ESMTPS id BBF836E42D for ; Tue, 21 Nov 2017 14:15:26 +0000 (UTC) Received: by mail-pg0-x243.google.com with SMTP id r12so10245724pgu.10 for ; Tue, 21 Nov 2017 06:15:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=SSk9EFqljkq3q3pKgCR39xJpVijJWWs6OehfYtN7TYk=; b=Rli9gz/djcIXef+72qpzKgdUBUwkFQOl9boxDA3k4r10ytWFsFNc+650XI+o4lMsj4 w+PuhzLYk4Zi/YHd1z2aeAlcwhvqU+zogEEo5oOchvPn/TT4ev/qCPwTOI1BOmlRYUZt qhUuZBB4QQRYQsxQ755HnCiasPt9VItjnB5/Mj4xrB7+PbEy/Di+l90Sf7ZkqVp0yOj2 QLMv697MzltyKohEiJsMn/osg7lug06Oj6sxWRgmhkGKMybZq4xkwXuNYodrHoz/v0h6 EQZt0KF8VVj7f/TGZqTnGqZMMtiib3myovQ1RaJr+6pB1LwjSJTitx1p9KJfoSZeSFPv A7lg== 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=SSk9EFqljkq3q3pKgCR39xJpVijJWWs6OehfYtN7TYk=; b=jvnlRCp7bc+iFkIRd2wEA/q+bb3h6NnT5oxKmx7JlABSkl6liwujgVuv5Uq16vP0X9 0Pnueg6QxWob3uGvRThCfFKAsVw2Y5akFggV4yCS+MFRxdOcWuQ2lTcuHkDLIujbuzxn 7+V+XRLKnhdIXdHVYEctC6VGbvE5rL0U6RYnEw1o6ylEOGpeWYrXcJ1B/ic3oEZNtWU/ TiPdYexgi56S+7R5kq5RTsGlZgbYq2GV3wnOEQ4p2KZ3vv7HdfdAniLreU8qt4h3Y8nd rTtk230T4gOVHzfYEDe7atK+Kd008cDzvxp0opP3ZlaWQM2ICb2ZYqt457nsKsj9Z4Fu 2bSQ== X-Gm-Message-State: AJaThX4C7lfsJANkyd0xw6tLNkNmjOQAmDRNDEf5Tr3RfAknRNC9Wgmc PDZMLwKaHNYCzzlb077O1yf0YQ== X-Google-Smtp-Source: AGs4zMbh2mVgZm8rbAye1l+F8aeA4slUgOGbOs17dr57pKypJ9dLd4d5qAxMgrwBXBXmW+of7sSixA== X-Received: by 10.99.126.11 with SMTP id z11mr17405563pgc.281.1511273725824; Tue, 21 Nov 2017 06:15:25 -0800 (PST) Received: from jheikkil-mobl.fi.intel.com (fmdmzpr03-ext.fm.intel.com. [192.55.54.38]) by smtp.gmail.com with ESMTPSA id p21sm33487812pfk.185.2017.11.21.06.15.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 21 Nov 2017 06:15:25 -0800 (PST) From: Juha-Pekka Heikkila To: intel-gfx@lists.freedesktop.org Date: Tue, 21 Nov 2017 16:15:09 +0200 Message-Id: <1511273710-3553-2-git-send-email-juhapekka.heikkila@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1511273710-3553-1-git-send-email-juhapekka.heikkila@gmail.com> References: <1511273710-3553-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.18 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ä) rebase and small detail changes. Signed-off-by: Juha-Pekka Heikkila --- drivers/gpu/drm/i915/intel_atomic_plane.c | 78 ++++++++++++++++++------------- 1 file changed, 45 insertions(+), 33 deletions(-) diff --git a/drivers/gpu/drm/i915/intel_atomic_plane.c b/drivers/gpu/drm/i915/intel_atomic_plane.c index 8e6dc15..8be50309 100644 --- a/drivers/gpu/drm/i915/intel_atomic_plane.c +++ b/drivers/gpu/drm/i915/intel_atomic_plane.c @@ -107,6 +107,50 @@ intel_plane_destroy_state(struct drm_plane *plane, drm_atomic_helper_plane_destroy_state(plane, state); } +static bool intel_plane_valid_rotation(const struct drm_plane_state *plane_state) +{ + struct intel_plane *plane = to_intel_plane(plane_state->plane); + struct drm_i915_private *dev_priv = to_i915(plane->base.dev); + + if (plane_state->fb && + drm_rotation_90_or_270(plane_state->rotation)) { + struct drm_format_name_buf format_name; + + 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 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. + */ + 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(plane_state->fb->format->format, + &format_name)); + return false; + default: + break; + } + } + + /* CHV ignores the mirror bit when the rotate bit is set :( */ + if (IS_CHERRYVIEW(dev_priv) && + 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 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, @@ -137,40 +181,8 @@ int intel_plane_atomic_check_with_state(const struct intel_crtc_state *old_crtc_ intel_state->clip.y2 = crtc_state->base.enable ? crtc_state->pipe_src_h : 0; - if (state->fb && drm_rotation_90_or_270(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) { - DRM_DEBUG_KMS("Y/Yf tiling required for 90/270!\n"); - return -EINVAL; - } - - /* - * 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. - */ - switch (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; - - default: - break; - } - } - - /* 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) { - DRM_DEBUG_KMS("Cannot rotate and reflect at the same time\n"); + if (!intel_plane_valid_rotation(state)) return -EINVAL; - } intel_state->base.visible = false; ret = intel_plane->check_plane(intel_plane, crtc_state, intel_state);