From patchwork Tue Feb 6 12:18:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 126991 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp2864116ljc; Tue, 6 Feb 2018 04:19:12 -0800 (PST) X-Google-Smtp-Source: AH8x224x3AgznDaXby2yJ0vBUmcoyVmLBonPRtO0l5PcPrzkYsMMNw+VrB8n6PZCwjK9uygZJfvi X-Received: by 10.98.100.139 with SMTP id y133mr2275086pfb.68.1517919552470; Tue, 06 Feb 2018 04:19:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517919552; cv=none; d=google.com; s=arc-20160816; b=L5ItYHGubO6i0MI+mVoSmeDxIddVdvJ09G60sLcNKwOiOCwvSFqPR3keWrNkxIjuRh 7d4UIuoxnzSeMQGDHT/k2krUuyrzcpHo2wnwIL+2LTkSWcafd/UH8zbwUQ6/Nr530wep Jun8Bxc8Bm6T2tZa957I0QV/eFs2M2HHXLZ9Qc8YeTVI7dRmLueiX6L+BHuzB8gDMpkt lUemqn0xqNhmuZYSIo31NGwoebwu10zkZ0FuVxpLwfv20qtBWt/o+m19ZLciEbhxG06F BqMjEk/REXTxA7nobf1Vs4fVS9ibuQIuqlk3WAw9UYAcd4NU73lekB+ZPpvI3JhlkVOu Of4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:references:in-reply-to:message-id:date:subject :to:from:dkim-signature:delivered-to:arc-authentication-results; bh=F78BrQl/JY/oSpFTjE14Ao9luDbmjnHxLL39eUYoqTg=; b=OHhVCEoZAz0JszxNaL1gtziLmkNZ1EImBh1YWPOsCUzbUj7BfaznNowkzVekSQzxTo MLfVqumnUkACDYYZotiPiSrtTJWwRSLZB/L6HnQnoMCmZWhNWiugIcmvihXGak85hdqM PL8fLP5EuvMg9b5EWOy7A0afSUFihWwf3n8MWIBPFsYj/pi9YSpQSrSHHubkqH/unEJH bt5oOSvBq3pXD9NwealQzb52BfhGpOX66AbuXGzdz6+DpMyt7G2ApzTrAKxFb/gbeWu1 PnZVagbPNj1hjPI+KdZ8EBK3GVz66vggEGHkt5adaTCbGGAicoUJUizGq6HSPcVTXc1i BUhA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=I6RyMnDu; 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=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from gabe.freedesktop.org (gabe.freedesktop.org. [131.252.210.177]) by mx.google.com with ESMTPS id s19-v6si1403741plp.116.2018.02.06.04.19.12 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 06 Feb 2018 04:19:12 -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=@linaro.org header.s=google header.b=I6RyMnDu; 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=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 056446E059; Tue, 6 Feb 2018 12:19:10 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-lf0-x242.google.com (mail-lf0-x242.google.com [IPv6:2a00:1450:4010:c07::242]) by gabe.freedesktop.org (Postfix) with ESMTPS id 621986E3ED for ; Tue, 6 Feb 2018 12:19:08 +0000 (UTC) Received: by mail-lf0-x242.google.com with SMTP id v188so2407153lfa.11 for ; Tue, 06 Feb 2018 04:19:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=vbK6vqrT2y6vISmcZ0Vtb1+wEYChM77hizI0k+gQWhs=; b=I6RyMnDu1JlD7FH2PgENUcbcoKetv3M3rZVF9J0nM2pnKVIMmurZQE+Z8NKQz1AK8Y W+quOCxDBLlClgIC/xwdCmk0hxbxqwq0gl3vhx0ROJRFnuHVQxb1iPHUO+Jed641fZY5 Xw8y9HUHE61t3IyacMvddD1hvhglBwsECDRmc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=vbK6vqrT2y6vISmcZ0Vtb1+wEYChM77hizI0k+gQWhs=; b=acaQlgbw+drf13ZVxjOsr5priLEhYxIQiXXFTBP7vqdTdQpZBlAPf75REAOU6DRTaJ r6/yFELarf676VCuBmiO/AWBzyZ1yGPNYKqJAFMWpJL0ZB0hRqF0IbZZ1WHnzFur6VI8 SKRaVS4mlYTm9kw4t9GKj9BEdb8k1VU6aC0RZlMw/AylKC2R99bknqLhuQMG3rZs20y9 4XKgAfE2s/p3MG8uQUIIhObFUeQojolRf28zhbk0VqsQj3nMMLyBnExg9kAYWYqjHMZY hjDGcanCsUpNctPe1Vr7/JqkIGr9yqwU8yODlBMCWZUAPR5LJUYTzuOT10I8YsKtw3ai uKeA== X-Gm-Message-State: APf1xPBKqzm2ybtpLgNG+4lQqwXcm9WxCBWi8sJ89FgTAg4AysHGEMXt ulx4OixGCHWjwZAj4k0Jdyf+7Q== X-Received: by 10.46.118.20 with SMTP id r20mr1493914ljc.11.1517919546847; Tue, 06 Feb 2018 04:19:06 -0800 (PST) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id f11sm598631lja.63.2018.02.06.04.19.05 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 06 Feb 2018 04:19:06 -0800 (PST) From: Linus Walleij To: Daniel Vetter , Jani Nikula , Sean Paul , Eric Anholt , Peter Ujfalusi , Tomi Valkeinen Subject: [PATCH 1/3] drm: simple_kms_helper: Add mode_valid() callback support Date: Tue, 6 Feb 2018 13:18:52 +0100 Message-Id: <20180206121854.4407-2-linus.walleij@linaro.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180206121854.4407-1-linus.walleij@linaro.org> References: <20180206121854.4407-1-linus.walleij@linaro.org> 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: linux-arm-kernel@lists.infradead.org, dri-devel@lists.freedesktop.org MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" The PL111 needs to filter valid modes based on memory bandwidth. I guess it is a pretty simple operation, so we can still claim the DRM KMS helper pipeline is simple after adding this (optional) vtable callback. Signed-off-by: Linus Walleij Reviewed-by: Eric Anholt Reviewed-by: Daniel Vetter --- drivers/gpu/drm/drm_simple_kms_helper.c | 15 +++++++++++++++ include/drm/drm_simple_kms_helper.h | 15 +++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/drivers/gpu/drm/drm_simple_kms_helper.c b/drivers/gpu/drm/drm_simple_kms_helper.c index dc9fd109de14..b7840cf34808 100644 --- a/drivers/gpu/drm/drm_simple_kms_helper.c +++ b/drivers/gpu/drm/drm_simple_kms_helper.c @@ -34,6 +34,20 @@ static const struct drm_encoder_funcs drm_simple_kms_encoder_funcs = { .destroy = drm_encoder_cleanup, }; +static enum drm_mode_status +drm_simple_kms_crtc_mode_valid(struct drm_crtc *crtc, + const struct drm_display_mode *mode) +{ + struct drm_simple_display_pipe *pipe; + + pipe = container_of(crtc, struct drm_simple_display_pipe, crtc); + if (!pipe->funcs || !pipe->funcs->mode_valid) + /* Anything goes */ + return MODE_OK; + + return pipe->funcs->mode_valid(crtc, mode); +} + static int drm_simple_kms_crtc_check(struct drm_crtc *crtc, struct drm_crtc_state *state) { @@ -72,6 +86,7 @@ static void drm_simple_kms_crtc_disable(struct drm_crtc *crtc, } static const struct drm_crtc_helper_funcs drm_simple_kms_crtc_helper_funcs = { + .mode_valid = drm_simple_kms_crtc_mode_valid, .atomic_check = drm_simple_kms_crtc_check, .atomic_enable = drm_simple_kms_crtc_enable, .atomic_disable = drm_simple_kms_crtc_disable, diff --git a/include/drm/drm_simple_kms_helper.h b/include/drm/drm_simple_kms_helper.h index 6d9adbb46293..ad74cb33c539 100644 --- a/include/drm/drm_simple_kms_helper.h +++ b/include/drm/drm_simple_kms_helper.h @@ -21,6 +21,21 @@ struct drm_simple_display_pipe; * display pipeline */ struct drm_simple_display_pipe_funcs { + /** + * @mode_valid: + * + * This function is called to filter out valid modes from the + * suggestions suggested by the bridge or display. This optional + * hook is passed in when initializing the pipeline. + * + * RETURNS: + * + * MODE_OK if the mode is acceptable. + * MODE_BAD if we need to try something else. + */ + enum drm_mode_status (*mode_valid)(struct drm_crtc *crtc, + const struct drm_display_mode *mode); + /** * @enable: * From patchwork Tue Feb 6 12:18:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 126994 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp2864488ljc; Tue, 6 Feb 2018 04:19:44 -0800 (PST) X-Google-Smtp-Source: AH8x227iA9GHcNfVZIs2iEczFq9Vf1Hq4PSTdEW9FtGOevuNm5qcEDyxjmTlrrmZ/1Si7DVtsHNS X-Received: by 2002:a17:902:b496:: with SMTP id y22-v6mr2211880plr.206.1517919584400; Tue, 06 Feb 2018 04:19:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517919584; cv=none; d=google.com; s=arc-20160816; b=AQSlOTWe3oI51HfRpaF0aqEjMO1Oe2/DUqby7IOKu78XzoMxzaeBK1xNgYnrC6NAOZ M5Jt36PFB2QL/WJzgFDrRS48vx2YgrB93+os2pdz7AWz0cvVUUJU0DQFMQ1p2rcMXDpH B5kJWRvlEopLzPtq1ho7pq/7cSE/BMJN6w4wOPGIJUMVKxRPP8fXowbiWaKwqceh8uXC JjAOlr6k1LHwYzMSIiieJBY4XUMYtDdtOLuZw4zJVIZWPZ56ppUtDsLqrycp3Qsl48OJ A/4UdvbTAejMBzQ1bXlvtjgdIzEzqvvKjTYtNyy95NhD8NB2BQqQ9WUoeiAkoPeTduxI 0+/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:references:in-reply-to:message-id:date:subject :to:from:dkim-signature:delivered-to:arc-authentication-results; bh=2Q0TBUnnnWOR/dmfkG0MGc5XYSAS+rc+383Ol+HRqXk=; b=EThRw5K1r1WT8zPRBEEaPwFC0Ne0NwAiGFsDs5M5+hgn57oajLJHHAmzUdR8HsU1Se TAZnTNLXZ+55m6nPYhkVizTDVE23H/Yir8RtuxnpznZEFgat5FbUxvAcW+lYhMyu3jxo JpSbDI5lQw/BGBGDgSmQ30CaAGnJqnUQNuvcrrtrtzDoqkKsaDV+oMLxp+DI09ZSfFZL 8CzETypVWG7PTRLIcGppDM9TgdMONCcCTyZCygwbH4LNz4Q7l/27pslhRgdZIhqTMStb zcUywbvTyX3ASTNfBz/enU2Amr7mRLF9/f8QXw56uDxL2rLWL/EAQvn60Hyw0gV/f4aF ic2A== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=HAafFOoi; 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=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from gabe.freedesktop.org (gabe.freedesktop.org. [131.252.210.177]) by mx.google.com with ESMTPS id g16si2777053pfh.248.2018.02.06.04.19.44 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 06 Feb 2018 04:19:44 -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=@linaro.org header.s=google header.b=HAafFOoi; 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=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C36ED6E3C7; Tue, 6 Feb 2018 12:19:11 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-lf0-x242.google.com (mail-lf0-x242.google.com [IPv6:2a00:1450:4010:c07::242]) by gabe.freedesktop.org (Postfix) with ESMTPS id 603A46E3C7 for ; Tue, 6 Feb 2018 12:19:10 +0000 (UTC) Received: by mail-lf0-x242.google.com with SMTP id t139so2450796lff.0 for ; Tue, 06 Feb 2018 04:19:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=f7JnaHsjAjqOXqK52gFDjiX1ejLP7oS1DOQ3Qkp2poU=; b=HAafFOoif1iXLzWwQpe16ypliwomRIkwq49ktjDvN7599fvCE/IR+UfN06iTwgOUL7 ualVklQEVwxVN8Q5rvOym7lbb7JXiNKM9BYyWL//RdWJJ6qX7yPskE7hPiO7PkixR+w6 qGtvfnVI45viCTHQJD3tBuSnjYADWLKhQV5g0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=f7JnaHsjAjqOXqK52gFDjiX1ejLP7oS1DOQ3Qkp2poU=; b=tH1U7aHStbUz2sCaWIy+YraI+qNXdm0ioezDvpagZ4162syiK+Pd6E03TKyEPb2XhV uBp9zTOrmsUusVL8NYhKf/Oqf5Ptx0/bQNEn6mMgrJiz2jImbEc3EhgQodjOQ8/thJeT yDaqoOWgFwXNY4yRV34XTmqlh7wa2Cf8E/QiiWimZ/zfZn01ltf/kRgBv1z1LO8cE6xW PwWNxGAdVvDpPJMkg+dFYrO2kNLsm8Hulz9D8Bv25CD3tzMUAVq4F/NvhUFudluah9u3 RF8RU5pZiM32Iryd4AaGA0Z1zvYWCURfDbzU5756JnPyamVNTYZcAPUA8y30+BOxNX2D e0EA== X-Gm-Message-State: APf1xPCEZGW/gWNV49HXde4xmjTuZU7fZAylG8GNUhi30bRc38VuTrcT M1mqZ2xlUYeQjOs/x3pS71WXng== X-Received: by 10.46.36.21 with SMTP id k21mr1549325ljk.14.1517919548758; Tue, 06 Feb 2018 04:19:08 -0800 (PST) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id f11sm598631lja.63.2018.02.06.04.19.07 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 06 Feb 2018 04:19:08 -0800 (PST) From: Linus Walleij To: Daniel Vetter , Jani Nikula , Sean Paul , Eric Anholt , Peter Ujfalusi , Tomi Valkeinen Subject: [PATCH 2/3] drm/pl111: Make the default BPP a per-variant variable Date: Tue, 6 Feb 2018 13:18:53 +0100 Message-Id: <20180206121854.4407-3-linus.walleij@linaro.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180206121854.4407-1-linus.walleij@linaro.org> References: <20180206121854.4407-1-linus.walleij@linaro.org> 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: linux-arm-kernel@lists.infradead.org, dri-devel@lists.freedesktop.org MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" The PL110, Integrator and Versatile boards strongly prefer to use 16 BPP even if other modes are supported, both to keep down memory consumption and also to easier find a good match to supported resolutions with consideration taken to the memory bandwidth of the platforms. Signed-off-by: Linus Walleij Reviewed-by: Eric Anholt --- drivers/gpu/drm/pl111/pl111_drm.h | 2 ++ drivers/gpu/drm/pl111/pl111_drv.c | 4 +++- drivers/gpu/drm/pl111/pl111_versatile.c | 2 ++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/pl111/pl111_drm.h b/drivers/gpu/drm/pl111/pl111_drm.h index d74076c6b7ef..9f2d30b52e7a 100644 --- a/drivers/gpu/drm/pl111/pl111_drm.h +++ b/drivers/gpu/drm/pl111/pl111_drm.h @@ -43,6 +43,7 @@ struct drm_minor; * @broken_vblank: the vblank IRQ is broken on this variant * @formats: array of supported pixel formats on this variant * @nformats: the length of the array of supported pixel formats + * @fb_bpp: desired bits per pixel on the default framebuffer */ struct pl111_variant_data { const char *name; @@ -52,6 +53,7 @@ struct pl111_variant_data { bool broken_vblank; const u32 *formats; unsigned int nformats; + unsigned int fb_bpp; }; struct pl111_drm_dev_private { diff --git a/drivers/gpu/drm/pl111/pl111_drv.c b/drivers/gpu/drm/pl111/pl111_drv.c index 221f3af02fb4..f5d5aa464ae2 100644 --- a/drivers/gpu/drm/pl111/pl111_drv.c +++ b/drivers/gpu/drm/pl111/pl111_drv.c @@ -191,7 +191,7 @@ static int pl111_modeset_init(struct drm_device *dev) drm_mode_config_reset(dev); - priv->fbdev = drm_fbdev_cma_init(dev, 32, + priv->fbdev = drm_fbdev_cma_init(dev, priv->variant->fb_bpp, dev->mode_config.num_connector); if (IS_ERR(priv->fbdev)) { dev_err(dev->dev, "Failed to initialize CMA framebuffer\n"); @@ -354,6 +354,7 @@ static const struct pl111_variant_data pl110_variant = { .is_pl110 = true, .formats = pl110_pixel_formats, .nformats = ARRAY_SIZE(pl110_pixel_formats), + .fb_bpp = 16, }; /* RealView, Versatile Express etc use this modern variant */ @@ -378,6 +379,7 @@ static const struct pl111_variant_data pl111_variant = { .name = "PL111", .formats = pl111_pixel_formats, .nformats = ARRAY_SIZE(pl111_pixel_formats), + .fb_bpp = 32, }; static const struct amba_id pl111_id_table[] = { diff --git a/drivers/gpu/drm/pl111/pl111_versatile.c b/drivers/gpu/drm/pl111/pl111_versatile.c index 11024ad64181..9825f6d52788 100644 --- a/drivers/gpu/drm/pl111/pl111_versatile.c +++ b/drivers/gpu/drm/pl111/pl111_versatile.c @@ -241,6 +241,7 @@ static const struct pl111_variant_data pl110_integrator = { .broken_vblank = true, .formats = pl110_integrator_pixel_formats, .nformats = ARRAY_SIZE(pl110_integrator_pixel_formats), + .fb_bpp = 16, }; /* @@ -253,6 +254,7 @@ static const struct pl111_variant_data pl110_versatile = { .external_bgr = true, .formats = pl110_versatile_pixel_formats, .nformats = ARRAY_SIZE(pl110_versatile_pixel_formats), + .fb_bpp = 16, }; int pl111_versatile_init(struct device *dev, struct pl111_drm_dev_private *priv) From patchwork Tue Feb 6 12:18:54 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 126992 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp2864167ljc; Tue, 6 Feb 2018 04:19:16 -0800 (PST) X-Google-Smtp-Source: AH8x2260oL96Tkko8GpgPjueOUM5h0FYnhlLQ3KMYjX1vTEdVGVFdUTBD0bIatz+3h4vi7r2qG2v X-Received: by 10.99.63.11 with SMTP id m11mr1877381pga.422.1517919556212; Tue, 06 Feb 2018 04:19:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517919556; cv=none; d=google.com; s=arc-20160816; b=sr8jrjB/3LZoQKoJuOFKGkrFVOZOS37zJwgVM15frAEWCl3s1S4U6ykv2mlx8pbcNO ZyLEBaijfGEdVB92C18fECHe3X90ruhBKS/SQmH4Z8hzi/cjYPXekc1DcbvuqCYBULFE 5MJDKkRwhkkV4XU/c/A5UcXvb8JeaXskr25CG6eqPLzZM/GtOMHnt9ve0yF1ka2wqP9t JlwQQzz0oE0Bx/c2GXCJqmWtbg2OB7GzcC/9BClgqPHo0qjD9tGiepyzlqGhbk3mhBQm yBKA16DUbq7214ujSOaGIrlJl0UuVaqckWbLGfyQcF1ppIGoT4OcChERX5mju/X42nZ/ 7CnA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:references:in-reply-to:message-id:date:subject :to:from:dkim-signature:delivered-to:arc-authentication-results; bh=96GJo1QZDEWLX/LkVeYAitqtDVY9YOIF8bnaw3fT4cQ=; b=YnzbUb45xHa9AG7rxeN/szzRMLSxY81JsSIY5QG6xrdvrEx1ArdhdSlbiG1okWDeqq szoYOUgci2HuN+O6myJ9tgctnjMX8lSXP79o1MBCLvawsT14NoF7KUVGJpkAt6ngWAhG yO+dFX0dbhX0loHQ04CkD19l8USWBvC6XoKVCRbs35wwMovSDfFldHqfBxkTujiBl9Pl JpnhMnC/qWl+9dXjt+MjFQdWZ1COO5uVkH3RaKSBjo3FOv5zDVWlxw+K4Hx8jpPUwgH7 sa92L/Fpjgo4UCs2kWbyu0uphhjGx8usF7OUXGmQDnbAu/A5iYRSf6BaV/WV247sxDt1 JF6Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=hvpN1gc7; 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=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from gabe.freedesktop.org (gabe.freedesktop.org. [131.252.210.177]) by mx.google.com with ESMTPS id i127si1810377pgc.565.2018.02.06.04.19.15 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 06 Feb 2018 04:19:16 -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=@linaro.org header.s=google header.b=hvpN1gc7; 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=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5A73D6E3ED; Tue, 6 Feb 2018 12:19:14 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-lf0-x243.google.com (mail-lf0-x243.google.com [IPv6:2a00:1450:4010:c07::243]) by gabe.freedesktop.org (Postfix) with ESMTPS id E83586E3F9 for ; Tue, 6 Feb 2018 12:19:12 +0000 (UTC) Received: by mail-lf0-x243.google.com with SMTP id 63so2429712lfv.4 for ; Tue, 06 Feb 2018 04:19:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=2VHmLoYn2o4vLNG/yaV/loxHsUJ8DNKpUHjTbiLoYXI=; b=hvpN1gc73Im7DpOrm+ti0+yVyFUPbeMqSeXxR8ww3euZOgjEHnZ8YxDMpUKwXHT6r8 G7VrveXEGnwAIq1kY2Y377+DsbKax7AqQcwuSGiNDr/a1cVHotU5rElmsYSZD6icW3sz 4flA4xGIlkIRmIMrUPO8pBRJUBSr9u3YEHiYU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=2VHmLoYn2o4vLNG/yaV/loxHsUJ8DNKpUHjTbiLoYXI=; b=PRPrxC9d3MDcZNz7BvzteYCwZSjfbwln54/mFZN7q/YkBFH3t345HMXiFeymlR3h3s ffIJz4NSwQvGA/eqXhZX+e88ut20x6hn7BxaLVyoSDOxZ5iOnuVfQEJ1Bb30R0NvuPeM 4EA6J5mJMAqLf4kyX+blPBLUK+PynUKEIv0L324386BhsAduf23y2V0PzVU2/vHCSYHp 4/HfWD8zhT2qW0ubwQXMkpsGN3CQFhu4OZ/fZT9gZCRzA/QGr7V2anxaaQ0+OZFcs7EQ dbBHwldgOXrmgOZeVecJ/pb/QOBPhj4TvWX+lXKBIhELMVEq3ZBsJmasCgfQ8p5lha7D rXmw== X-Gm-Message-State: APf1xPAva/Uc1qeWmg6eCwrpQLMGWGRZG8pleG7zcnhbfV+/GwoNqqkF 5HCylifo73D+wn8aQxmo+U1g6A== X-Received: by 10.46.29.83 with SMTP id d80mr1646386ljd.95.1517919550886; Tue, 06 Feb 2018 04:19:10 -0800 (PST) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id f11sm598631lja.63.2018.02.06.04.19.09 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 06 Feb 2018 04:19:09 -0800 (PST) From: Linus Walleij To: Daniel Vetter , Jani Nikula , Sean Paul , Eric Anholt , Peter Ujfalusi , Tomi Valkeinen Subject: [PATCH 3/3] drm/pl111: Use max memory bandwidth for resolution Date: Tue, 6 Feb 2018 13:18:54 +0100 Message-Id: <20180206121854.4407-4-linus.walleij@linaro.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180206121854.4407-1-linus.walleij@linaro.org> References: <20180206121854.4407-1-linus.walleij@linaro.org> 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: linux-arm-kernel@lists.infradead.org, dri-devel@lists.freedesktop.org MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" We were previously selecting 1024x768 and 32BPP as the default set-up for the PL111 consumers. This does not work on elder systems: the device tree bindings support a property "max-memory-bandwidth" in bytes/second that states that if you exceed this the memory bus will saturate. The result is flickering and unstable images. Parse the "max-memory-bandwidth" and respect it when intializing the driver. On the RealView PB11MP, Versatile and Integrator/CP we get a nice console as default with this code. Signed-off-by: Linus Walleij --- ChangeLog v1->v2: - Exploit the new .mode_valid() callback we added to the simple KMS helper. - Use the hardcoded bits per pixel per variant instead of trying to be heuristic about this setting for now. --- drivers/gpu/drm/pl111/pl111_display.c | 30 ++++++++++++++++++++++++++++++ drivers/gpu/drm/pl111/pl111_drm.h | 1 + drivers/gpu/drm/pl111/pl111_drv.c | 6 ++++++ 3 files changed, 37 insertions(+) diff --git a/drivers/gpu/drm/pl111/pl111_display.c b/drivers/gpu/drm/pl111/pl111_display.c index d75923896609..a1ca9e1ffe15 100644 --- a/drivers/gpu/drm/pl111/pl111_display.c +++ b/drivers/gpu/drm/pl111/pl111_display.c @@ -50,6 +50,35 @@ irqreturn_t pl111_irq(int irq, void *data) return status; } +static enum drm_mode_status +pl111_mode_valid(struct drm_crtc *crtc, + const struct drm_display_mode *mode) +{ + struct drm_device *drm = crtc->dev; + struct pl111_drm_dev_private *priv = drm->dev_private; + u32 cpp = priv->variant->fb_bpp / 8; + u64 bw; + + /* + * We use the pixelclock to also account for interlaced modes, the + * resulting bandwidth is in bytes per second. + */ + bw = mode->clock * 1000; /* In Hz */ + bw = bw * mode->hdisplay * mode->vdisplay * cpp; + bw = div_u64(bw, mode->htotal * mode->vtotal); + + if (bw > priv->memory_bw) { + DRM_DEBUG("%d x %d @ %d Hz, %d cpp, bw %llu too fast\n", + mode->hdisplay, mode->vdisplay, mode->clock, cpp, bw); + + return MODE_BAD; + } + DRM_DEBUG("%d x %d @ %d Hz, %d cpp, bw %llu bytes/s OK\n", + mode->hdisplay, mode->vdisplay, mode->clock, cpp, bw); + + return MODE_OK; +} + static int pl111_display_check(struct drm_simple_display_pipe *pipe, struct drm_plane_state *pstate, struct drm_crtc_state *cstate) @@ -344,6 +373,7 @@ static int pl111_display_prepare_fb(struct drm_simple_display_pipe *pipe, } static const struct drm_simple_display_pipe_funcs pl111_display_funcs = { + .mode_valid = pl111_mode_valid, .check = pl111_display_check, .enable = pl111_display_enable, .disable = pl111_display_disable, diff --git a/drivers/gpu/drm/pl111/pl111_drm.h b/drivers/gpu/drm/pl111/pl111_drm.h index 9f2d30b52e7a..7a3d7af1c8cf 100644 --- a/drivers/gpu/drm/pl111/pl111_drm.h +++ b/drivers/gpu/drm/pl111/pl111_drm.h @@ -66,6 +66,7 @@ struct pl111_drm_dev_private { struct drm_fbdev_cma *fbdev; void *regs; + u32 memory_bw; u32 ienb; u32 ctrl; /* The pixel clock (a reference to our clock divider off of CLCDCLK). */ diff --git a/drivers/gpu/drm/pl111/pl111_drv.c b/drivers/gpu/drm/pl111/pl111_drv.c index f5d5aa464ae2..0077059c897f 100644 --- a/drivers/gpu/drm/pl111/pl111_drv.c +++ b/drivers/gpu/drm/pl111/pl111_drv.c @@ -274,6 +274,12 @@ static int pl111_amba_probe(struct amba_device *amba_dev, drm->dev_private = priv; priv->variant = variant; + if (of_property_read_u32(dev->of_node, "max-memory-bandwidth", + &priv->memory_bw)) { + dev_info(dev, "no max memory bandwidth specified, assume unlimited\n"); + priv->memory_bw = 0; + } + /* The two variants swap this register */ if (variant->is_pl110) { priv->ienb = CLCD_PL110_IENB;