From patchwork Fri Dec 15 12:10:47 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 122080 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp386230qgn; Fri, 15 Dec 2017 04:12:16 -0800 (PST) X-Google-Smtp-Source: ACJfBosXfn2p2jczeiL/ySlM5rOB080Wheva/egxdXUHPs5lEH3eghtFOWQFndzO6MZOuYnOfC7S X-Received: by 10.159.205.139 with SMTP id v11mr13402472plo.233.1513339936510; Fri, 15 Dec 2017 04:12:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1513339936; cv=none; d=google.com; s=arc-20160816; b=jcyYTLnOWObefOH2ML4YHH289mOqv/On4vMUGx7ydpPi+r0UoRE19LaycUaLLmE57P xAA4Wsz+gt3HmQ4m0drFxjVHTt1whM8+GwEkQ/Iik1Zvx24EeGGFDALuRToGgDuvcxXT OY9p5Kn4Y00J8A8Z5NrbGe+zewv9dejp+oKuVEMj/uAUWerb4tnwz9irSWD/I58HhJMR 7wZ0nCZ5YCHcsn1jBosQrg+D82Ijar2XAWdZpPI2FvH4CuPzpjqJ+KLu12ufx/9VLcQW yHI3aj1/zrg2NWB/zkhnfdrDbyC+OQJiOuHacZTyAV7GALzQ8eCoCmWrFCYLfSHz5Cld FHTw== 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 :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:cc:references:in-reply-to:message-id:date :subject:to:from:dkim-signature:delivered-to :arc-authentication-results; bh=Fz7VKvZf2T2de4/Jh8AfsGDsTzPS6lzMZKiXqpBdA94=; b=SAsd56BCtJvTTGsrFWKhM8J2X10zGh5WouQciuYy4NLeQn2gNG0ohcg7IyTPbJZX2r ICeKr+F0JIBnz2hEphRBDMokiVCmcxRcArsmoEfgbeVpmtxyk3QZwxvOegSnQBxnrfgb kRKiuAkVLpOEM0BWJcz0WEwjAuBakPvympgWvZFKJUluE/V46/N/GAxdegrPDkOnvSLN B2/FnLMY9zE4HorpAJXC0AoL2e1O8sf8HCDeQKeJRLiqbEEw+zI8j0iF4unrXP7ZBvTn yXJn2jSk7+FK6fyBZQzx2PN7Sj7Zqo9gy4OFgAcBsf+xAww+VkiFYGD7hHGTsbbqQxBN ykgw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=LmcF7Ycc; 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 k185si4495060pge.131.2017.12.15.04.12.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 15 Dec 2017 04:12: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=LmcF7Ycc; 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 85A536E7E7; Fri, 15 Dec 2017 12:11:45 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-lf0-x244.google.com (mail-lf0-x244.google.com [IPv6:2a00:1450:4010:c07::244]) by gabe.freedesktop.org (Postfix) with ESMTPS id DE9CB6E7E7 for ; Fri, 15 Dec 2017 12:11:43 +0000 (UTC) Received: by mail-lf0-x244.google.com with SMTP id j124so10238726lfg.2 for ; Fri, 15 Dec 2017 04:11:43 -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=E3LbcZrWs1F/3W5h91Nx2QsW58Glj1jmJ6padzI36Do=; b=LmcF7YccXKdfklMt71XDrPgv5a5ObWygUpELKdAGyZLIZ/0SeuUqnDt4T/sb1Hm5OK 64OF6Tr6YCj3mch4p/hODSns9Yxd4HWl1dfucuQYRDIUA4Ivdp/GfX4JLHyjn5Ufwo8L liXreVxw1TMeboBPluZZJiAZs8fg4NsuDTYho= 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=E3LbcZrWs1F/3W5h91Nx2QsW58Glj1jmJ6padzI36Do=; b=hyYTTUVCL1jmLC7izevCsdcEh7Nr5eHo97tN2WvVdVMwUuU2dqBlxDcTn0+y9e5KUJ 8EPKh+U69z1bf0fUpvgPTf4oknNrRjdaRq0RcD0GHkhPRgUDyCUdBb6OOkS9isbhI+Fm aB6o2eAZUjg+A/TXevcMlQWIJy9MRos8HQHxQhVpAQU8g/jZoVLMvuyeAuxaAjjFW5Fs nLbk18emArT3A1boUrGi3q4dwqacpxLy+5juwVR/+a5pOFal3sL8dnKTaw7r96RmZZHQ SWSqYkULNuKzDV+cOO2kuZaYnvJzFtGSctyxa6UhKFa5TSxWTT+gBV08J5oq/d1f1hKw wx7w== X-Gm-Message-State: AKGB3mLjtr0k38sSaSzrM+9g/uQphzLaU6B9OMp7bIo9kl2TTQWGYdhc P01ubJ9jgNeZ7awmJrzMQnJBnA== X-Received: by 10.25.233.142 with SMTP id j14mr5534265lfk.101.1513339902270; Fri, 15 Dec 2017 04:11:42 -0800 (PST) Received: from localhost.localdomain ([90.229.2.39]) by smtp.gmail.com with ESMTPSA id z81sm1289345lff.80.2017.12.15.04.11.39 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 15 Dec 2017 04:11:41 -0800 (PST) From: Linus Walleij To: Archit Taneja , Andrzej Hajda , Laurent Pinchart Subject: [PATCH 4/4 v5] drm/pl111: Support handling bridge timings Date: Fri, 15 Dec 2017 13:10:47 +0100 Message-Id: <20171215121047.3650-5-linus.walleij@linaro.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20171215121047.3650-1-linus.walleij@linaro.org> References: <20171215121047.3650-1-linus.walleij@linaro.org> Cc: linux-arm-kernel@lists.infradead.org, dri-devel@lists.freedesktop.org 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" If the bridge has a too strict setup time for the incoming signals, we may not be fast enough and then we need to compensate by outputting the signal on the inverse clock edge so it is for sure stable when the bridge samples it. Since bridges in difference to panels does not expose their connectors, make the connector optional in the display setup code. Signed-off-by: Linus Walleij Acked-by: Laurent Pinchart --- ChangeLog v4->v5: - Use the new bridge timings setup method. --- drivers/gpu/drm/pl111/Kconfig | 1 + drivers/gpu/drm/pl111/pl111_display.c | 35 +++++++++++++++++++++++++++++++---- drivers/gpu/drm/pl111/pl111_drv.c | 20 +++++++++++--------- 3 files changed, 43 insertions(+), 13 deletions(-) diff --git a/drivers/gpu/drm/pl111/Kconfig b/drivers/gpu/drm/pl111/Kconfig index e5e2abd66491..82cb3e60ddc8 100644 --- a/drivers/gpu/drm/pl111/Kconfig +++ b/drivers/gpu/drm/pl111/Kconfig @@ -8,6 +8,7 @@ config DRM_PL111 select DRM_GEM_CMA_HELPER select DRM_BRIDGE select DRM_PANEL_BRIDGE + select DRM_DUMB_VGA_DAC select VT_HW_CONSOLE_BINDING if FRAMEBUFFER_CONSOLE help Choose this option for DRM support for the PL111 CLCD controller. diff --git a/drivers/gpu/drm/pl111/pl111_display.c b/drivers/gpu/drm/pl111/pl111_display.c index 06c4bf756b69..7fe4040aea46 100644 --- a/drivers/gpu/drm/pl111/pl111_display.c +++ b/drivers/gpu/drm/pl111/pl111_display.c @@ -94,6 +94,7 @@ static void pl111_display_enable(struct drm_simple_display_pipe *pipe, const struct drm_display_mode *mode = &cstate->mode; struct drm_framebuffer *fb = plane->state->fb; struct drm_connector *connector = priv->connector; + struct drm_bridge *bridge = priv->bridge; u32 cntl; u32 ppl, hsw, hfp, hbp; u32 lpp, vsw, vfp, vbp; @@ -143,11 +144,37 @@ static void pl111_display_enable(struct drm_simple_display_pipe *pipe, if (mode->flags & DRM_MODE_FLAG_NVSYNC) tim2 |= TIM2_IVS; - if (connector->display_info.bus_flags & DRM_BUS_FLAG_DE_LOW) - tim2 |= TIM2_IOE; + if (connector) { + if (connector->display_info.bus_flags & DRM_BUS_FLAG_DE_LOW) + tim2 |= TIM2_IOE; - if (connector->display_info.bus_flags & DRM_BUS_FLAG_PIXDATA_NEGEDGE) - tim2 |= TIM2_IPC; + if (connector->display_info.bus_flags & + DRM_BUS_FLAG_PIXDATA_NEGEDGE) + tim2 |= TIM2_IPC; + } + + if (bridge) { + const struct drm_bridge_timings *btimings = bridge->timings; + + /* + * Here is when things get really fun. Sometimes the bridge + * timings are such that the signal out from PL11x is not + * stable before the receiving bridge (such as a dumb VGA DAC + * or similar) samples it. If that happens, we compensate by + * the only method we have: output the data on the opposite + * edge of the clock so it is for sure stable when it gets + * sampled. + * + * The PL111 manual does not contain proper timining diagrams + * or data for these details, but we know from experiments + * that the setup time is more than 3000 picoseconds (3 ns). + * If we have a bridge that requires the signal to be stable + * earlier than 3000 ps before the clock pulse, we have to + * output the data on the opposite edge to avoid flicker. + */ + if (btimings && btimings->setup_time_ps >= 3000) + tim2 ^= TIM2_IPC; + } tim2 |= cpl << 16; writel(tim2, priv->regs + CLCD_TIM2); diff --git a/drivers/gpu/drm/pl111/pl111_drv.c b/drivers/gpu/drm/pl111/pl111_drv.c index 201d57d5cb54..101a9c7db6ff 100644 --- a/drivers/gpu/drm/pl111/pl111_drv.c +++ b/drivers/gpu/drm/pl111/pl111_drv.c @@ -107,11 +107,17 @@ static int pl111_modeset_init(struct drm_device *dev) ret = PTR_ERR(bridge); goto out_config; } - /* - * TODO: when we are using a different bridge than a panel - * (such as a dumb VGA connector) we need to devise a different - * method to get the connector out of the bridge. - */ + } else if (bridge) { + dev_info(dev->dev, "Using non-panel bridge\n"); + } else { + dev_err(dev->dev, "No bridge, exiting\n"); + return -ENODEV; + } + + priv->bridge = bridge; + if (panel) { + priv->panel = panel; + priv->connector = panel->connector; } ret = pl111_display_init(dev); @@ -125,10 +131,6 @@ static int pl111_modeset_init(struct drm_device *dev) if (ret) return ret; - priv->bridge = bridge; - priv->panel = panel; - priv->connector = panel->connector; - ret = drm_vblank_init(dev, 1); if (ret != 0) { dev_err(dev->dev, "Failed to init vblank\n");