From patchwork Wed Jan 14 05:40:54 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: sonika.jindal@intel.com X-Patchwork-Id: 5625871 Return-Path: X-Original-To: patchwork-dri-devel@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 EB912C058E for ; Wed, 14 Jan 2015 05:47:56 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1452C2039E for ; Wed, 14 Jan 2015 05:47:56 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 28DBE20395 for ; Wed, 14 Jan 2015 05:47:55 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id F261D6E70E; Tue, 13 Jan 2015 21:47:52 -0800 (PST) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by gabe.freedesktop.org (Postfix) with ESMTP id CC50D6E70D; Tue, 13 Jan 2015 21:47:51 -0800 (PST) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga101.jf.intel.com with ESMTP; 13 Jan 2015 21:47:51 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.07,754,1413270000"; d="scan'208";a="661534917" Received: from sonikaji-desktop.iind.intel.com ([10.223.25.81]) by fmsmga002.fm.intel.com with ESMTP; 13 Jan 2015 21:47:49 -0800 From: Sonika Jindal To: intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Subject: [PATCH] drm: Adding rotation to drm_plane_helper_check_update Date: Wed, 14 Jan 2015 11:10:54 +0530 Message-Id: <1421214054-30393-1-git-send-email-sonika.jindal@intel.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <20150113133245.GK10649@intel.com> References: <20150113133245.GK10649@intel.com> X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" 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 Taking rotation into account while checking the plane and adjusting the sizes accordingly. v2: Adding parameter in the callers in the same patch(Matt) Removing unnecessary code and allowing scaling(Ville) Signed-off-by: Sonika Jindal --- drivers/gpu/drm/drm_plane_helper.c | 44 ++++++++++++++++++++++++--- drivers/gpu/drm/i915/intel_display.c | 6 ++-- drivers/gpu/drm/rockchip/rockchip_drm_vop.c | 3 +- include/drm/drm_plane_helper.h | 3 +- 4 files changed, 48 insertions(+), 8 deletions(-) diff --git a/drivers/gpu/drm/drm_plane_helper.c b/drivers/gpu/drm/drm_plane_helper.c index f24c4cf..d6916af 100644 --- a/drivers/gpu/drm/drm_plane_helper.c +++ b/drivers/gpu/drm/drm_plane_helper.c @@ -138,7 +138,8 @@ int drm_plane_helper_check_update(struct drm_plane *plane, int max_scale, bool can_position, bool can_update_disabled, - bool *visible) + bool *visible, + unsigned int rotation) { int hscale, vscale; @@ -158,9 +159,13 @@ int drm_plane_helper_check_update(struct drm_plane *plane, return -EINVAL; } + if (fb) + drm_rect_rotate(src, fb->width << 16, fb->height << 16, + rotation); + /* Check scaling */ - hscale = drm_rect_calc_hscale(src, dest, min_scale, max_scale); - vscale = drm_rect_calc_vscale(src, dest, min_scale, max_scale); + hscale = drm_rect_calc_hscale_relaxed(src, dest, min_scale, max_scale); + vscale = drm_rect_calc_vscale_relaxed(src, dest, min_scale, max_scale); if (hscale < 0 || vscale < 0) { DRM_DEBUG_KMS("Invalid scaling of plane\n"); return -ERANGE; @@ -182,6 +187,36 @@ int drm_plane_helper_check_update(struct drm_plane *plane, return -EINVAL; } + if (*visible) { + /* check again in case clipping clamped the results */ + hscale = drm_rect_calc_hscale(src, dest, min_scale, max_scale); + if (hscale < 0) { + DRM_DEBUG_KMS("Horizontal scaling factor out of limits\n"); + drm_rect_debug_print(src, true); + drm_rect_debug_print(dest, false); + + return hscale; + } + + vscale = drm_rect_calc_vscale(src, dest, min_scale, max_scale); + if (vscale < 0) { + DRM_DEBUG_KMS("Vertical scaling factor out of limits\n"); + drm_rect_debug_print(src, true); + drm_rect_debug_print(dest, false); + + return vscale; + } + + /* Make the source viewport size an exact multiple of the scaling factors. */ + drm_rect_adjust_size(src, + drm_rect_width(dest) * hscale - drm_rect_width(src), + drm_rect_height(dest) * vscale - drm_rect_height(src)); + + drm_rect_rotate_inv(src, fb->width << 16, fb->height << 16, + rotation); + + } + return 0; } EXPORT_SYMBOL(drm_plane_helper_check_update); @@ -258,7 +293,8 @@ int drm_primary_helper_update(struct drm_plane *plane, struct drm_crtc *crtc, &src, &dest, &clip, DRM_PLANE_HELPER_NO_SCALING, DRM_PLANE_HELPER_NO_SCALING, - false, false, &visible); + false, false, &visible, + DRM_ROTATE_0); if (ret) return ret; diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c index f40288f..d19ed4b 100644 --- a/drivers/gpu/drm/i915/intel_display.c +++ b/drivers/gpu/drm/i915/intel_display.c @@ -12155,7 +12155,8 @@ intel_check_primary_plane(struct drm_plane *plane, src, dest, clip, DRM_PLANE_HELPER_NO_SCALING, DRM_PLANE_HELPER_NO_SCALING, - false, true, &state->visible); + false, true, &state->visible, + to_intel_plane(plane)->rotation); if (ret) return ret; @@ -12429,7 +12430,8 @@ intel_check_cursor_plane(struct drm_plane *plane, src, dest, clip, DRM_PLANE_HELPER_NO_SCALING, DRM_PLANE_HELPER_NO_SCALING, - true, true, &state->visible); + true, true, &state->visible, + to_intel_plane(plane)->rotation); if (ret) return ret; diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c index e7ca25b..4813a53 100644 --- a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c +++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c @@ -551,7 +551,8 @@ static int vop_update_plane_event(struct drm_plane *plane, &src, &dest, &clip, DRM_PLANE_HELPER_NO_SCALING, DRM_PLANE_HELPER_NO_SCALING, - can_position, false, &visible); + can_position, false, &visible, + DRM_ROTATE_0); if (ret) return ret; diff --git a/include/drm/drm_plane_helper.h b/include/drm/drm_plane_helper.h index a185392..ef9eb04 100644 --- a/include/drm/drm_plane_helper.h +++ b/include/drm/drm_plane_helper.h @@ -84,7 +84,8 @@ extern int drm_plane_helper_check_update(struct drm_plane *plane, int max_scale, bool can_position, bool can_update_disabled, - bool *visible); + bool *visible, + unsigned int rotation); extern int drm_primary_helper_update(struct drm_plane *plane, struct drm_crtc *crtc, struct drm_framebuffer *fb,