From patchwork Mon Nov 30 13:53:28 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 57465 Delivered-To: patch@linaro.org Received: by 10.112.155.196 with SMTP id vy4csp1489622lbb; Mon, 30 Nov 2015 05:59:49 -0800 (PST) X-Received: by 10.66.124.135 with SMTP id mi7mr91240165pab.102.1448891646004; Mon, 30 Nov 2015 05:54:06 -0800 (PST) Return-Path: Received: from gabe.freedesktop.org (gabe.freedesktop.org. [131.252.210.177]) by mx.google.com with ESMTP id u81si2528861pfa.147.2015.11.30.05.54.04; Mon, 30 Nov 2015 05:54:05 -0800 (PST) Received-SPF: pass (google.com: domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) client-ip=131.252.210.177; Authentication-Results: mx.google.com; spf=pass (google.com: domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id CFE0D6E5CA; Mon, 30 Nov 2015 05:54:02 -0800 (PST) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mailout3.w1.samsung.com (mailout3.w1.samsung.com [210.118.77.13]) by gabe.freedesktop.org (Postfix) with ESMTPS id E4BA46E5C6 for ; Mon, 30 Nov 2015 05:53:55 -0800 (PST) Received: from eucpsbgm2.samsung.com (unknown [203.254.199.245]) by mailout3.w1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0NYM009XQRXRQFB0@mailout3.w1.samsung.com> for dri-devel@lists.freedesktop.org; Mon, 30 Nov 2015 13:53:51 +0000 (GMT) X-AuditID: cbfec7f5-f79b16d000005389-e6-565c54ef53e3 Received: from eusync2.samsung.com ( [203.254.199.212]) by eucpsbgm2.samsung.com (EUCPMTA) with SMTP id 4F.68.21385.FE45C565; Mon, 30 Nov 2015 13:53:51 +0000 (GMT) Received: from amdc1339.digital.local ([106.116.147.30]) by eusync2.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0NYM007NRRXFE700@eusync2.samsung.com>; Mon, 30 Nov 2015 13:53:51 +0000 (GMT) From: Marek Szyprowski To: dri-devel@lists.freedesktop.org, linux-samsung-soc@vger.kernel.org Subject: [PATCH v2 13/22] drm/exynos: fix clipping when scaling is enabled Date: Mon, 30 Nov 2015 14:53:28 +0100 Message-id: <1448891617-18830-14-git-send-email-m.szyprowski@samsung.com> X-Mailer: git-send-email 1.9.2 In-reply-to: <1448891617-18830-1-git-send-email-m.szyprowski@samsung.com> References: <1448891617-18830-1-git-send-email-m.szyprowski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrBLMWRmVeSWpSXmKPExsVy+t/xK7rvQ2LCDHo+y1jcWneO1WLjjPWs Fle+vmez2PlgF7vFpPsTWCzevF3DZPHi3kUWi9cvDC1mnN/HZLH2yF12ixmTX7JZtK3+wGqx atcfRgdej52z7rJ73O8+zuTx7xi7x5Z+IG/npL1MHn1bVjF6fN4kF8AexWWTkpqTWZZapG+X wJXR+mI7a8FsnooV32ezNzB+5Oxi5OSQEDCR2HG8hQ3CFpO4cG89kM3FISSwlFHi/JYXrBBO E5PEkb+TWEGq2AQMJbredoF1iAi4STQdngkWZxY4zCxxeGpdFyMHh7CAl8T0MxIgYRYBVYnj F/cygYR5BTwlzkzWhtglJ/H/5QomEJsTKPzk7Gl2EFtIwENiw4xjTBMYeRcwMqxiFE0tTS4o TkrPNdIrTswtLs1L10vOz93ECAnPrzsYlx6zOsQowMGoxMMrYRYdJsSaWFZcmXuIUYKDWUmE N9A0JkyINyWxsiq1KD++qDQntfgQozQHi5I478xd70OEBNITS1KzU1MLUotgskwcnFINjHPC N9xh3FN0qlHA7NqeSo3Ca/xndqzyqpikfXzy9B8BgUZGL8VUFr11erF6jnLNutrTCzzu73U7 +O5w/qkHvYK823ple8taD+75dKryQO0/qRrxKxX1Dqt3GK/gefmwQ96xMGCuf4rtiu2nVu3t fChdNZ/7moGmgPhWtoi51p+FSlkXL5w+64oSS3FGoqEWc1FxIgCYseqsSwIAAA== Cc: Javier Martinez Canillas , Krzysztof Kozlowski , Bartlomiej Zolnierkiewicz , Seung-Woo Kim , Andrzej Hajda , Tobias Jakobi , Marek Szyprowski 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" This patch fixes calculation of src x/y offset for negative crtc x/y values when scaling is enabled. This fixes possible IOMMU fault when scaling is enabled. Signed-off-by: Marek Szyprowski --- drivers/gpu/drm/exynos/exynos_drm_plane.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/exynos/exynos_drm_plane.c b/drivers/gpu/drm/exynos/exynos_drm_plane.c index 9eaa8627175f..427aeec78a28 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_plane.c +++ b/drivers/gpu/drm/exynos/exynos_drm_plane.c @@ -85,25 +85,26 @@ static void exynos_plane_mode_set(struct exynos_drm_plane_state *exynos_state) src_w = state->src_w >> 16; src_h = state->src_h >> 16; + /* set ratio */ + exynos_state->h_ratio = (src_w << 16) / crtc_w; + exynos_state->v_ratio = (src_h << 16) / crtc_h; + + /* clip to visible area */ actual_w = exynos_plane_get_size(crtc_x, crtc_w, mode->hdisplay); actual_h = exynos_plane_get_size(crtc_y, crtc_h, mode->vdisplay); if (crtc_x < 0) { if (actual_w) - src_x -= crtc_x; + src_x += ((-crtc_x) * exynos_state->h_ratio) >> 16; crtc_x = 0; } if (crtc_y < 0) { if (actual_h) - src_y -= crtc_y; + src_y += ((-crtc_y) * exynos_state->v_ratio) >> 16; crtc_y = 0; } - /* set ratio */ - exynos_state->h_ratio = (src_w << 16) / crtc_w; - exynos_state->v_ratio = (src_h << 16) / crtc_h; - /* set drm framebuffer data. */ exynos_state->src.x = src_x; exynos_state->src.y = src_y;