From patchwork Wed Feb 28 11:26:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomi Valkeinen X-Patchwork-Id: 129964 Delivered-To: patch@linaro.org Received: by 10.46.66.2 with SMTP id p2csp909455lja; Wed, 28 Feb 2018 03:28:45 -0800 (PST) X-Google-Smtp-Source: AH8x226Slcyhksd8JLN5w/oxrATQmAGMdmGITmRAAmiYxOa0E0KeS9L+AOjKgXNWPVltEqtUPN7g X-Received: by 10.167.131.135 with SMTP id u7mr17405172pfm.50.1519817325226; Wed, 28 Feb 2018 03:28:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519817325; cv=none; d=google.com; s=arc-20160816; b=w4KojVEOYrb3QPuZ4L/GnIONh9LL7o5PguEjl3BlFZFO7RpZ4umGMGgQ+vWGbVA0U1 7oRaueUTJPVJT9B2qWziO5dYFFw76Hx+Z22eshTPw5HfNu+fioCExqL8Q/DyE2o/V1vF B+g7rcwkQ7QzBaKiSYh0URQYqggCy4gVg68/mR4Y0vH2jc/4MIibYtQXU+oNJNCx+R5w j8ddLqeQVmTdFrrhVETxbLKMnWmRvCOSH81ERCbpGavg7T4xBOeKwGDGQPsaN6UajTbs F7OK4O7RWT+PdnKrMf4dnc6NPnPIGw+4+WRlu5jhV14gv9072alDPi8qjv6bbqIbNUeJ 3gDg== 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=tJZOk0rqHNPFAGX/azY+xH/w+qvjy5YwTU1dYzgHXD8=; b=iJFjScHvMeVwtS1DypDPJ/Eh5vFp9Dw4j9Eb191GGtxO+kaFV2oCJGaeHrLbPO2wDm w02dFo6KigLDJab8H+lMKDUgNEAJHl/2FhCm5dE2+C9g5FveVf6+UU5uA05LJRatxLfu 5un2GzLWtiDNTF9BUfMkzRTjJmjXMCCPEhITj+H9w+RUFSwUPQtX5uASxpAM0ZsiK6Gv VPUAYjvhXxlKuQC/GeGzIX6ss5/ugtMunvHrIzBBjhhQ41y6sxXpOYen8ZIL/+0WApDW CPLM/JTKsUmmXZVylaA7TSampGklQD/PrH6BQjLGBkmQOmp6ngIijccYEJG1XeDzQQHn GhHw== 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=y7uOmGHj; 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 h127si378192pgc.308.2018.02.28.03.28.44 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 28 Feb 2018 03:28: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=y7uOmGHj; 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 13EF96E971; Wed, 28 Feb 2018 11:27:43 +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 B3D3A6E96B for ; Wed, 28 Feb 2018 11:27:39 +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 w1SBRbkA008407; Wed, 28 Feb 2018 05:27:37 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ti.com; s=ti-com-17Q1; t=1519817257; bh=IEoS6G2/z37MVXRNRckKaH1pOh5R/yW0Vn3j6zuTQQI=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=y7uOmGHj+xJqqvCX09fHaxDzbS7krBasLnsA/gViXShIIhyrDLmepkCJkGLnsJPsw T8EY8DJxW8PRU0Pis7I0aEOmbX/icXsDmvK2QrS6fJ3ugnxp9BPi78YjNpFVEh+EyW 1emI4SurR2qA5eC6+9Hxb726w80n8QneAK3z9Sks= Received: from DLEE100.ent.ti.com (dlee100.ent.ti.com [157.170.170.30]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id w1SBRbwN031559; Wed, 28 Feb 2018 05:27:37 -0600 Received: from DLEE104.ent.ti.com (157.170.170.34) by DLEE100.ent.ti.com (157.170.170.30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1261.35; Wed, 28 Feb 2018 05:27:37 -0600 Received: from dflp32.itg.ti.com (10.64.6.15) by DLEE104.ent.ti.com (157.170.170.34) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1261.35 via Frontend Transport; Wed, 28 Feb 2018 05:27:36 -0600 Received: from deskari.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by dflp32.itg.ti.com (8.14.3/8.13.8) with ESMTP id w1SBRAfW024563; Wed, 28 Feb 2018 05:27:35 -0600 From: Tomi Valkeinen To: , Laurent Pinchart Subject: [PATCHv2 13/17] drm/omap: fix scaling limits for WB Date: Wed, 28 Feb 2018 13:26:10 +0200 Message-ID: <1519817174-20714-14-git-send-email-tomi.valkeinen@ti.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1519817174-20714-1-git-send-email-tomi.valkeinen@ti.com> References: <1519817174-20714-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: Peter Ujfalusi , Tomi Valkeinen , Jyri Sarha 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 | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/omapdrm/dss/dispc.c b/drivers/gpu/drm/omapdrm/dss/dispc.c index 72f00e8a1329..2aa72845f819 100644 --- a/drivers/gpu/drm/omapdrm/dss/dispc.c +++ b/drivers/gpu/drm/omapdrm/dss/dispc.c @@ -2475,6 +2475,7 @@ static int dispc_ovl_calc_scaling_44xx(struct dispc_device *dispc, ((dividend) * 100 / (divisor) - ((dividend) / (divisor) * 100)) static int dispc_ovl_calc_scaling(struct dispc_device *dispc, + enum omap_plane_id plane, unsigned long pclk, unsigned long lclk, enum omap_overlay_caps caps, const struct videomode *vm, @@ -2485,7 +2486,8 @@ static int dispc_ovl_calc_scaling(struct dispc_device *dispc, 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; @@ -2493,6 +2495,20 @@ static int dispc_ovl_calc_scaling(struct dispc_device *dispc, 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; @@ -2510,8 +2526,8 @@ static int dispc_ovl_calc_scaling(struct dispc_device *dispc, 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; @@ -2615,7 +2631,7 @@ static int dispc_ovl_setup_common(struct dispc_device *dispc, if (!dispc_ovl_color_mode_supported(dispc, plane, fourcc)) return -EINVAL; - r = dispc_ovl_calc_scaling(dispc, pclk, lclk, caps, vm, in_width, + r = dispc_ovl_calc_scaling(dispc, 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);