From patchwork Tue Jan 13 12:33:39 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: 5620361 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 96DE99F3A0 for ; Tue, 13 Jan 2015 12:40:52 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 87BEB20614 for ; Tue, 13 Jan 2015 12:40:51 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 82E3620608 for ; Tue, 13 Jan 2015 12:40:50 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8468A6E604; Tue, 13 Jan 2015 04:40:49 -0800 (PST) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by gabe.freedesktop.org (Postfix) with ESMTP id 5C2926E606; Tue, 13 Jan 2015 04:40:48 -0800 (PST) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga101.jf.intel.com with ESMTP; 13 Jan 2015 04:40:42 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.07,750,1413270000"; d="scan'208";a="669060070" Received: from sonikaji-desktop.iind.intel.com ([10.223.25.81]) by orsmga002.jf.intel.com with ESMTP; 13 Jan 2015 04:40:40 -0800 From: Sonika Jindal To: intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Date: Tue, 13 Jan 2015 18:03:39 +0530 Message-Id: <1421152420-20375-2-git-send-email-sonika.jindal@intel.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1421152420-20375-1-git-send-email-sonika.jindal@intel.com> References: <1421152420-20375-1-git-send-email-sonika.jindal@intel.com> Subject: [Intel-gfx] [PATCH 1/2] drm: Adding rotation to drm_plane_helper_check_update 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 Taking rotation into account while checking the plane and adjusting the sizes accordingly. Signed-off-by: Sonika Jindal --- drivers/gpu/drm/drm_plane_helper.c | 79 ++++++++++++++++++++++++++++++++++-- include/drm/drm_plane_helper.h | 3 +- 2 files changed, 77 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/drm_plane_helper.c b/drivers/gpu/drm/drm_plane_helper.c index f24c4cf..4badd69 100644 --- a/drivers/gpu/drm/drm_plane_helper.c +++ b/drivers/gpu/drm/drm_plane_helper.c @@ -138,9 +138,13 @@ 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; + int crtc_x, crtc_y; + unsigned int crtc_w, crtc_h; + uint32_t src_x, src_y, src_w, src_h; if (!fb) { *visible = false; @@ -158,9 +162,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 +190,68 @@ int drm_plane_helper_check_update(struct drm_plane *plane, return -EINVAL; } + crtc_x = dest->x1; + crtc_y = dest->y1; + crtc_w = drm_rect_width(dest); + crtc_h = drm_rect_height(dest); + + if (*visible) { + /* check again in case clipping clamped the results */ + hscale = drm_rect_calc_hscale(src, dest, + DRM_PLANE_HELPER_NO_SCALING, + DRM_PLANE_HELPER_NO_SCALING); + 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, + DRM_PLANE_HELPER_NO_SCALING, + DRM_PLANE_HELPER_NO_SCALING); + 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); + + /* + * Hardware doesn't handle subpixel coordinates. + * Adjust to (macro)pixel boundary, but be careful not to + * increase the source viewport size, because that could + * push the downscaling factor out of bounds. + */ + src_x = src->x1 >> 16; + src_w = drm_rect_width(src) >> 16; + src_y = src->y1 >> 16; + src_h = drm_rect_height(src) >> 16; + } + + if (*visible) { + src->x1 = src_x; + src->x2 = src_x + src_w; + src->y1 = src_y; + src->y2 = src_y + src_h; + } + + dest->x1 = crtc_x; + dest->x2 = crtc_x + crtc_w; + dest->y1 = crtc_y; + dest->y2 = crtc_y + crtc_h; + + return 0; } EXPORT_SYMBOL(drm_plane_helper_check_update); @@ -258,7 +328,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/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,