From patchwork Mon Feb 12 09:44:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomi Valkeinen X-Patchwork-Id: 127971 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp3040859ljc; Mon, 12 Feb 2018 01:46:45 -0800 (PST) X-Google-Smtp-Source: AH8x22727VFvc+DwZgvS9bH5AtLIMnAfImhuGKNQx5GicHPpbbwAZXO80gWcS5n/hx7C0zGLFbnw X-Received: by 10.98.189.8 with SMTP id a8mr11101046pff.125.1518428805328; Mon, 12 Feb 2018 01:46:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518428805; cv=none; d=google.com; s=arc-20160816; b=HkWJ9H01Hp6AfwNs99+j9sFXuTmoP+HEzdtvL9VnhOORANmdpvr0nBExtDVgi8ec6P DffDmg5w5mBWHmkjva56b1lzJnfxVoE01m+1tHNLIjRCOtZCUrJBs9FmuPtP/gJ00pbf HYhkyII8Ln30qmzQpo4nwRaGr0UJCQOt8VcpDJOJFt9hzTQPEQkkc+y38uAc96rEtCOD CcBiy04ULWHkgconKtWbfGYsFl79hCKTCK+pF4GFxd+e6Rrr9G+o+PijRwCKGqi+JQUQ zKmJ/mLp9NadEmrlageySw1m932nOUMVFXixN0tLHLP5WL5XpWgCYI4ttv/W3y6MUrj8 goIQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:mime-version:references:in-reply-to:message-id:date :subject:to:from:dkim-signature:delivered-to :arc-authentication-results; bh=ljzK5k/vZkortrs/WFqPQoU6xp5Q5OmfEq4rrL4udpo=; b=Neyz13Akf9pnHz3KPlW0AHhhVbO32X/7P/GAw57YXa9JBxT+qP5J9SdacO5XBXHaMF +PTUHqIynKBASe6ZlgZwRmUr00ZDPvk8GVSMAN160qQtPgvDJgxJ+3iKGA3JMnYSs0Oo j7ha8ApIPPKSykINGcxXGiVA2Lepz9MH2U/S7aFgib8yFrTAb2I8jWOy+2vBai+qN9yO H4XCchMlJtU6T+btxNfH5h+hPZVCoSFp+zuTCfdTCZbQrFeKELFFyyQI/IwRdXMOLR/m MDBoblcNH78hn5Bfhw0JuaeVeBFuL4Lco7AAz6MzDIGdm62lqECEDglKxwsNS/B3aGcD NhYA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@ti.com header.s=ti-com-17Q1 header.b=LIYznCpJ; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=fail (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from gabe.freedesktop.org (gabe.freedesktop.org. [131.252.210.177]) by mx.google.com with ESMTPS id a5-v6si5562893plp.416.2018.02.12.01.46.45 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 12 Feb 2018 01:46:45 -0800 (PST) Received-SPF: pass (google.com: best guess record for 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; dkim=neutral (body hash did not verify) header.i=@ti.com header.s=ti-com-17Q1 header.b=LIYznCpJ; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=fail (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 06BF66E1AB; Mon, 12 Feb 2018 09:45:45 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from lelnx193.ext.ti.com (lelnx193.ext.ti.com [198.47.27.77]) by gabe.freedesktop.org (Postfix) with ESMTPS id 7395B6E1AB for ; Mon, 12 Feb 2018 09:45:42 +0000 (UTC) Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by lelnx193.ext.ti.com (8.15.1/8.15.1) with ESMTP id w1C9jeos016067; Mon, 12 Feb 2018 03:45:40 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ti.com; s=ti-com-17Q1; t=1518428740; bh=JpCtcF637omENBV7BGnu4+UenB6FtPDkJ118RWeO+8w=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=LIYznCpJLdzimdkmgy/UQ9raKI+2VH9O9h2zkNZJ+FW/gYH8BVXnXWaRAgm/nh5Uf warK8QQ4dXQUtjed78NQsF9pP8nRrPwKXPzyycaCFZK1iXvUZpq4RcBVyoHeNA+i07 KoJg2Xq4buiMBcXUzZEBtVlDtLB+CD9JlRUc+1QI= Received: from DFLE103.ent.ti.com (dfle103.ent.ti.com [10.64.6.24]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id w1C9jeLo019568; Mon, 12 Feb 2018 03:45:40 -0600 Received: from DFLE107.ent.ti.com (10.64.6.28) by DFLE103.ent.ti.com (10.64.6.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1261.35; Mon, 12 Feb 2018 03:45:39 -0600 Received: from dflp33.itg.ti.com (10.64.6.16) by DFLE107.ent.ti.com (10.64.6.28) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1261.35 via Frontend Transport; Mon, 12 Feb 2018 03:45:39 -0600 Received: from deskari.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by dflp33.itg.ti.com (8.14.3/8.13.8) with ESMTP id w1C9j0NH003439; Mon, 12 Feb 2018 03:45:38 -0600 From: Tomi Valkeinen To: , Laurent Pinchart , Peter Ujfalusi , Jyri Sarha , Benoit Parrot Subject: [PATCH 20/24] drm/omap: fix scaling limits for WB Date: Mon, 12 Feb 2018 11:44:50 +0200 Message-ID: <1518428694-18018-21-git-send-email-tomi.valkeinen@ti.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1518428694-18018-1-git-send-email-tomi.valkeinen@ti.com> References: <1518428694-18018-1-git-send-email-tomi.valkeinen@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Tomi Valkeinen Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" WB has additional scaling limits when the output color format is one of the YUV formats. These limits are not handled at the moment, causing bad scaling and/or NULL dereference crash. This patchs adds the check so that dispc returns an error for bad scaling request. Signed-off-by: Tomi Valkeinen --- drivers/gpu/drm/omapdrm/dss/dispc.c | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/omapdrm/dss/dispc.c b/drivers/gpu/drm/omapdrm/dss/dispc.c index 3d804187df13..2d19852553f5 100644 --- a/drivers/gpu/drm/omapdrm/dss/dispc.c +++ b/drivers/gpu/drm/omapdrm/dss/dispc.c @@ -2381,7 +2381,8 @@ static int dispc_ovl_calc_scaling_44xx(unsigned long pclk, unsigned long lclk, #define DIV_FRAC(dividend, divisor) \ ((dividend) * 100 / (divisor) - ((dividend) / (divisor) * 100)) -static int dispc_ovl_calc_scaling(unsigned long pclk, unsigned long lclk, +static int dispc_ovl_calc_scaling(enum omap_plane_id plane, + unsigned long pclk, unsigned long lclk, enum omap_overlay_caps caps, const struct videomode *vm, u16 width, u16 height, u16 out_width, u16 out_height, @@ -2389,7 +2390,8 @@ static int dispc_ovl_calc_scaling(unsigned long pclk, unsigned long lclk, int *x_predecim, int *y_predecim, u16 pos_x, enum omap_dss_rotation_type rotation_type, bool mem_to_mem) { - const int maxdownscale = dispc.feat->max_downscale; + int maxhdownscale = dispc.feat->max_downscale; + int maxvdownscale = dispc.feat->max_downscale; const int max_decim_limit = 16; unsigned long core_clk = 0; int decim_x, decim_y, ret; @@ -2397,6 +2399,20 @@ static int dispc_ovl_calc_scaling(unsigned long pclk, unsigned long lclk, if (width == out_width && height == out_height) return 0; + if (plane == OMAP_DSS_WB) { + switch (fourcc) { + case DRM_FORMAT_NV12: + maxhdownscale = maxvdownscale = 2; + break; + case DRM_FORMAT_YUYV: + case DRM_FORMAT_UYVY: + maxhdownscale = 2; + maxvdownscale = 4; + break; + default: + break; + } + } if (!mem_to_mem && (pclk == 0 || vm->pixelclock == 0)) { DSSERR("cannot calculate scaling settings: pclk is zero\n"); return -EINVAL; @@ -2414,8 +2430,8 @@ static int dispc_ovl_calc_scaling(unsigned long pclk, unsigned long lclk, 2 : max_decim_limit; } - decim_x = DIV_ROUND_UP(DIV_ROUND_UP(width, out_width), maxdownscale); - decim_y = DIV_ROUND_UP(DIV_ROUND_UP(height, out_height), maxdownscale); + decim_x = DIV_ROUND_UP(DIV_ROUND_UP(width, out_width), maxhdownscale); + decim_y = DIV_ROUND_UP(DIV_ROUND_UP(height, out_height), maxvdownscale); if (decim_x > *x_predecim || out_width > width * 8) return -EINVAL; @@ -2514,7 +2530,7 @@ static int dispc_ovl_setup_common(enum omap_plane_id plane, if (!dispc_ovl_color_mode_supported(plane, fourcc)) return -EINVAL; - r = dispc_ovl_calc_scaling(pclk, lclk, caps, vm, in_width, + r = dispc_ovl_calc_scaling(plane, pclk, lclk, caps, vm, in_width, in_height, out_width, out_height, fourcc, &five_taps, &x_predecim, &y_predecim, pos_x, rotation_type, mem_to_mem);