From patchwork Thu Sep 27 10:25:21 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joonyoung Shim X-Patchwork-Id: 1512771 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by patchwork2.kernel.org (Postfix) with ESMTP id 50F12DFE80 for ; Thu, 27 Sep 2012 10:25:35 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2F4079ED98 for ; Thu, 27 Sep 2012 03:25:35 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mailout4.samsung.com (mailout4.samsung.com [203.254.224.34]) by gabe.freedesktop.org (Postfix) with ESMTP id D52B29E753 for ; Thu, 27 Sep 2012 03:25:23 -0700 (PDT) Received: from epcpsbgm2.samsung.com (epcpsbgm2 [203.254.230.27]) by mailout4.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MB0006BR7M1ZLE0@mailout4.samsung.com> for dri-devel@lists.freedesktop.org; Thu, 27 Sep 2012 19:25:22 +0900 (KST) X-AuditID: cbfee61b-b7f2b6d000000f14-66-506429927ea1 Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id 37.F5.03860.29924605; Thu, 27 Sep 2012 19:25:22 +0900 (KST) Received: from localhost.localdomain ([10.90.51.60]) by mmp2.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0MB000L557M9CG80@mmp2.samsung.com> for dri-devel@lists.freedesktop.org; Thu, 27 Sep 2012 19:25:22 +0900 (KST) From: Joonyoung Shim To: dri-devel@lists.freedesktop.org Subject: [PATCH] drm/exynos: fix to calculate CRTC shown via screen Date: Thu, 27 Sep 2012 19:25:21 +0900 Message-id: <1348741521-15707-1-git-send-email-jy0922.shim@samsung.com> X-Mailer: git-send-email 1.7.9.5 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrGJMWRmVeSWpSXmKPExsVy+t9jQd1JmikBBm13eCyufH3P5sDocb/7 OFMAYxSXTUpqTmZZapG+XQJXxu5H55gKDohUbPxR3MC4mb+LkZNDQsBE4vOySywQtpjEhXvr 2UBsIYHpjBIT33BC2CuYJNofRoPYbAJ6Ene2HWcCsUUElCX+TlzFCGIzCxhLdMz/wgpiCws4 Szzeew1oJgcHi4CqxNKN5SBhXgF3if3bz7KDhCUEFCTmTLKZwMi9gJFhFaNoakFyQXFSeq6R XnFibnFpXrpecn7uJkaw755J72Bc1WBxiFGAg1GJhzfAPTlAiDWxrLgy9xCjBAezkghvlGpK gBBvSmJlVWpRfnxRaU5q8SFGaQ4WJXFe4U+BAUIC6YklqdmpqQWpRTBZJg5OqQbGuJ3hXx7O 5Zt2N7Dm7q/bTJ8tLH0EXEP0rl733zrh2U8FVgG+VU+uGP7/vN/ozFJlzug/5ySEjn2+Oenl e262q1wf1Z255y3+8klqc7qLRevTN9sFYxKN+5tEnT+uPjzl0c+rnXueRoWcEYh1fjht3zO5 e5Z5phkbl8T9uXJJgadJaPd6dcMDOUosxRmJhlrMRcWJAO+/YmnZAQAA Cc: kyungmin.park@samsung.com X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org Errors-To: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org This patch is to exactly calculate CRTC shown via screen for all cases. Refer exynos_plane_get_size() function for this. Also source position of fb is fixed when start position of CRTC is negative number. Signed-off-by: Joonyoung Shim Signed-off-by: Kyungmin Park --- drivers/gpu/drm/exynos/exynos_drm_plane.c | 56 +++++++++++++++++++++++++++-- 1 file changed, 54 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/exynos/exynos_drm_plane.c b/drivers/gpu/drm/exynos/exynos_drm_plane.c index 777e142..4a03d1c 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_plane.c +++ b/drivers/gpu/drm/exynos/exynos_drm_plane.c @@ -33,6 +33,42 @@ static const uint32_t formats[] = { DRM_FORMAT_NV12MT, }; +/* + * This function is to get X or Y size shown via screen. This needs length and + * start position of CRTC. + * + * <--- length ---> + * CRTC ---------------- + * ^ start ^ end + * + * There are six cases from a to b. + * + * <----- SCREEN -----> + * 0 last + * ----------|------------------|---------- + * CRTCs + * a ------- + * b ------- + * c -------------------------- + * d -------- + * e ------- + * f ------- + */ +static int exynos_plane_get_size(int start, unsigned length, unsigned last) +{ + int end = start + length; + int size = 0; + + if (start <= 0) { + if (end > 0) + size = min_t(unsigned, end, last); + } else if (start <= last) { + size = min_t(unsigned, last - start, length); + } + + return size; +} + int exynos_plane_mode_set(struct drm_plane *plane, struct drm_crtc *crtc, struct drm_framebuffer *fb, int crtc_x, int crtc_y, unsigned int crtc_w, unsigned int crtc_h, @@ -65,8 +101,24 @@ int exynos_plane_mode_set(struct drm_plane *plane, struct drm_crtc *crtc, (unsigned long)overlay->dma_addr[i]); } - actual_w = min((unsigned)(crtc->mode.hdisplay - crtc_x), crtc_w); - actual_h = min((unsigned)(crtc->mode.vdisplay - crtc_y), crtc_h); + actual_w = exynos_plane_get_size(crtc_x, crtc_w, crtc->mode.hdisplay); + actual_h = exynos_plane_get_size(crtc_y, crtc_h, crtc->mode.vdisplay); + + if (crtc_x < 0) { + if (actual_w) + src_x -= crtc_x; + else + src_x += crtc_w; + crtc_x = 0; + } + + if (crtc_y < 0) { + if (actual_h) + src_y -= crtc_y; + else + src_y += crtc_h; + crtc_y = 0; + } /* set drm framebuffer data. */ overlay->fb_x = src_x;