From patchwork Wed Jan 10 14:12:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 124100 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp5325346qgn; Wed, 10 Jan 2018 06:12:42 -0800 (PST) X-Google-Smtp-Source: ACJfBovac302PnfX0g7/tAd0Ep+nNIksvLnSAyWoOMBQoOG9Ekf743W7nZFooo9pK9Yn6D9hCnXo X-Received: by 10.84.238.197 with SMTP id l5mr12364544pln.443.1515593562892; Wed, 10 Jan 2018 06:12:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1515593562; cv=none; d=google.com; s=arc-20160816; b=Hg5xUIVvTaJVPivmMEszwytTnIDrLbEDDRZQqwpkpSLFGw57KGobyvuL0z3/Tsc898 WVzDBlB5BexKOQsg6BHg99SrE1LZ5whpJoxfATgD4Zsc8/DT3huih+KZqiXGU2cPeqpb v8XQrEt74ztUjr4bNz2/rGCtXCgCPVflEeeAtc6oFirSR5+FnA/uwh7aYAUFcOzPqSEJ s5SFFp4BibRPsITEFRlkbAuFhngn69voBAPhfflMFnGpT4OzTipZh87DC5iNVDYdPzmr I42JrzdQpOzkwhPsL6KH1CzUInWnJJMyntO3gg6J2LQ1YVySD4cMBQzxoV6hIWW04JPv ZQww== 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=RifRwkw/Mf2nlTAqFvlyLve5jzfgcNnM8FsSCxo+rT4=; b=hW7SK9dY+Qjw0GbhW46Psx9olG0qFcjmESrY4d8zUNOba5G1ek1h2oKXCp7W+EZRJB j3Wu/ZUL+GFz6qSPAwTbEfgXE0P+1T3yM/1Sd/joLi+DDFYYKyosUe2VoZjbsKE0mlfj vHSLaGqQwqjsixibXJqRt4irGBkiTKDgytedSWtbDgUmIpoXe+z1kvQt0FZKK2+1ifIH uKkyGVPB4pTqR1e14CTBIiWd7a5ATTpMg2MY11iQMGF8JN2iMcqT7c6ricmJ/X0oL+fS xFoqqhvL04u7BpSFMfZ/T/TNJkcZNHLNzHHHAfonMsEFvfLAl2V78gN8HvzHynwjB5Qc A0Gw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=d50GunxG; 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 v11si4947735plz.285.2018.01.10.06.12.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 10 Jan 2018 06:12:42 -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=d50GunxG; 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 B34C56E2D8; Wed, 10 Jan 2018 14:12:41 +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 9DB2D6E2D8 for ; Wed, 10 Jan 2018 14:12:40 +0000 (UTC) Received: by mail-lf0-x244.google.com with SMTP id m8so13930057lfc.6 for ; Wed, 10 Jan 2018 06:12:40 -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=/gBFTrI0KIXSs8pCWtsRDDOFrm0TSyo4lpBgEk5HEB8=; b=d50GunxG0Uc7yi4AAOOzReTtyfF6EM2H7w3PRri/y2Fyr2L/pt3oMjEvCVc2hQ7yaI i/F2fItEPt19fYjGan/jmz056bY89N4QPEmKtEZm/MPu5Luxb1H/WIUeFjA2chlfWPOj GovQxm12+iYzmXNiCISpnhgLJlclD8FCyjAyY= 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=/gBFTrI0KIXSs8pCWtsRDDOFrm0TSyo4lpBgEk5HEB8=; b=P8cNN2ZMT3hVD2eKNt9OY4LSMbTmO5PN1l8JLuuUeNduhoxkvmN3KQESTyQ5pkxyEA y+gN/e3seeCp30MB+sPt6gQCGxX/TTxJOrx4aAeP9qphdcpVzpDTQdsHvRYZ7IzEpC1s +BLlOWp3nNeWoxRFZWgACqi8v8vTM62Z/XL1obdYJkMB5zvZnMbiazHNK9ZhRnDhl6CE cEDCD8quL80R+IkzfbxccMsyAaOaXSKqz9FlIZzg7/KRuid8xtAlHW1KBkrDJ351RUHx vVPQFChxvyMzl5Z7vrYjKNNNdY+LFzEr8C/cfVYOMvLNwD8MhSIWYviWcJIq8tBwC1EJ fzRg== X-Gm-Message-State: AKwxytcjp7RuQpWHuDUWNRs8gGBxF5chjCYmnIGyGU+GqFaXJ3Jgni2g 1xLODDQL2hiBfc16jKngzY6lXA== X-Received: by 10.25.212.83 with SMTP id l80mr8683204lfg.83.1515593558862; Wed, 10 Jan 2018 06:12:38 -0800 (PST) Received: from genomnajs.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id u72sm1019258lfi.64.2018.01.10.06.12.37 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 10 Jan 2018 06:12:38 -0800 (PST) From: Linus Walleij To: Archit Taneja , Andrzej Hajda , Laurent Pinchart Subject: [PATCH 4/4 v6] drm/pl111: Support handling bridge timings Date: Wed, 10 Jan 2018 15:12:26 +0100 Message-Id: <20180110141226.27826-4-linus.walleij@linaro.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180110141226.27826-1-linus.walleij@linaro.org> References: <20180110141226.27826-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. Acked-by: Laurent Pinchart Signed-off-by: Linus Walleij Reviewed-by: Eric Anholt --- ChangeLog v5->v6: - Collect Laurent's ACK. 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");