From patchwork Wed Dec 7 10:22:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 13066945 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 817A0C352A1 for ; Wed, 7 Dec 2022 10:27:33 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4DF1910E391; Wed, 7 Dec 2022 10:27:22 +0000 (UTC) Received: from out3-smtp.messagingengine.com (out3-smtp.messagingengine.com [66.111.4.27]) by gabe.freedesktop.org (Postfix) with ESMTPS id 2547010E391 for ; Wed, 7 Dec 2022 10:27:18 +0000 (UTC) Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id 54F395C00FB; Wed, 7 Dec 2022 05:27:17 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Wed, 07 Dec 2022 05:27:17 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cerno.tech; h=cc :cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm2; t=1670408837; x= 1670495237; bh=w+Gci/EdEyZNlgJIQDZMLgz1QP+F+UJkjKPeee30W70=; b=U AYeWgpcWyxgCAxvZ1hru12ZbMWrdG9xQohWAecVtnS+nx9IBPRrAeO4sicwqKzIJ +aSVdO+KS+KvI3USr+E2Duon9qjMM3IvPsaFm2LNFVwU73SfXqEcFgsz10FgUnaP XpppQWggX1ldVmBrD19otOF66G4yhWXLMWmAm+F/zXUKPRVVgUNg92kbmttAodTR U25vmaHselY4wJHJmOdOCpEu0cXlDVtr+NLKRZSb4JvyTH43pOlV55d4I8RdN2Q4 CAec3afr2lgfJv9mcI4wwr4fbV5e4He/oCuXXDOUUeC9jPoL+g3PgXQuWt8JkAuP z5o0DJyfzKDwzsqp8B5zQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1670408837; x= 1670495237; bh=w+Gci/EdEyZNlgJIQDZMLgz1QP+F+UJkjKPeee30W70=; b=P mkYLiEHUCM0QSX+4fjK7X0bBS/tkXzNPFqBkmy/Ij8JXmECOtUderHWxq4LIGo8h 13phtE2wX4y6CSATS9u+shqja0KOk879oe5h4g7iv6/HDekhd/+bC1vW96fCZqHe vkjFQ8EXPB9ra4Hky026tHHHmgEW4lbk+QZ41JikhrOm3z/nhEme6bZWPxR+Z4UZ 5FBtJLo+LWoY1wQ/TxpQjKg5CcQEm0DrGHiIpY1NnQYUi7DDuwZQEV/f87tmWel4 yuI0F1wqW0NwOJDFv7DIvrfBk+9tW6oET4+bwaCYxA34Hs1vEm5JChV58zslu13E 9H9V6vWjCJ1TBUJDvVPcQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrudekgddugecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhfffugggtgffkfhgjvfevofesthejredtredtjeenucfhrhhomhepofgrgihi mhgvucftihhprghrugcuoehmrgigihhmvgestggvrhhnohdrthgvtghhqeenucggtffrrg htthgvrhhnpeevvdelieejgedvkeffheekheeilefhgefgffehteekueelvddtueffheet ledtffenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpe hmrgigihhmvgestggvrhhnohdrthgvtghh X-ME-Proxy: Feedback-ID: i8771445c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 7 Dec 2022 05:27:16 -0500 (EST) From: Maxime Ripard Date: Wed, 07 Dec 2022 11:22:44 +0100 Subject: [PATCH 1/6] drm/vc4: dsi: Rename bridge to out_bridge MIME-Version: 1.0 Message-Id: <20221207-rpi-dsi-bridge-v1-1-8f68ee0b0adb@cerno.tech> References: <20221207-rpi-dsi-bridge-v1-0-8f68ee0b0adb@cerno.tech> In-Reply-To: <20221207-rpi-dsi-bridge-v1-0-8f68ee0b0adb@cerno.tech> To: Emma Anholt , Maxime Ripard , David Airlie , Daniel Vetter X-Mailer: b4 0.11.0-dev-8c583 X-Developer-Signature: v=1; a=openpgp-sha256; l=1888; i=maxime@cerno.tech; h=from:subject:message-id; bh=tWzFKQ0hN8LGVeDx6bqlvMlhZjCI3ajfljD5sQbs6zo=; b=owGbwMvMwCX2+D1vfrpE4FHG02pJDMkTMkuSLHUVNkTy8qzJ6/ZtfDL/bI3wgSxm5d07I48t8Qrd OjG2o5SFQYyLQVZMkSVG2HxJ3KlZrzvZ+ObBzGFlAhnCwMUpABNZOouR4anCW8PTFstMbwZNUr4j0m nX27/tUdofr4cSPJ+qD+9ZdIXhr8jf8zO+yKj8FJ4xNz9VWNjvhLSp4v2NP2VfrTx77NNfFUYA X-Developer-Key: i=maxime@cerno.tech; a=openpgp; fpr=BE5675C37E818C8B5764241C254BCFC56BF6CE8D X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Maxime Ripard , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Dave Stevenson Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Dave Stevenson In preparation for converting the encoder to being a bridge, rename the variable holding the next bridge in the chain to out_bridge, so that our bridge can be called bridge. Signed-off-by: Dave Stevenson Signed-off-by: Maxime Ripard --- drivers/gpu/drm/vc4/vc4_dsi.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/vc4/vc4_dsi.c b/drivers/gpu/drm/vc4/vc4_dsi.c index 878e05d79e81..d9d951e9ab7c 100644 --- a/drivers/gpu/drm/vc4/vc4_dsi.c +++ b/drivers/gpu/drm/vc4/vc4_dsi.c @@ -556,7 +556,7 @@ struct vc4_dsi { struct platform_device *pdev; - struct drm_bridge *bridge; + struct drm_bridge *out_bridge; struct list_head bridge_chain; void __iomem *regs; @@ -800,7 +800,7 @@ static void vc4_dsi_encoder_disable(struct drm_encoder *encoder) if (iter->funcs->disable) iter->funcs->disable(iter); - if (iter == dsi->bridge) + if (iter == dsi->out_bridge) break; } @@ -1723,9 +1723,9 @@ static int vc4_dsi_bind(struct device *dev, struct device *master, void *data) return ret; } - dsi->bridge = drmm_of_get_bridge(drm, dev->of_node, 0, 0); - if (IS_ERR(dsi->bridge)) - return PTR_ERR(dsi->bridge); + dsi->out_bridge = drmm_of_get_bridge(drm, dev->of_node, 0, 0); + if (IS_ERR(dsi->out_bridge)) + return PTR_ERR(dsi->out_bridge); /* The esc clock rate is supposed to always be 100Mhz. */ ret = clk_set_rate(dsi->escape_clock, 100 * 1000000); @@ -1751,7 +1751,7 @@ static int vc4_dsi_bind(struct device *dev, struct device *master, void *data) if (ret) return ret; - ret = drm_bridge_attach(encoder, dsi->bridge, NULL, 0); + ret = drm_bridge_attach(encoder, dsi->out_bridge, NULL, 0); if (ret) return ret; /* Disable the atomic helper calls into the bridge. We From patchwork Wed Dec 7 10:22:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 13066946 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C503DC352A1 for ; Wed, 7 Dec 2022 10:27:38 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 64CCD10E392; Wed, 7 Dec 2022 10:27:26 +0000 (UTC) Received: from out3-smtp.messagingengine.com (out3-smtp.messagingengine.com [66.111.4.27]) by gabe.freedesktop.org (Postfix) with ESMTPS id B500910E38F for ; Wed, 7 Dec 2022 10:27:19 +0000 (UTC) Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id 1B31D5C01C6; Wed, 7 Dec 2022 05:27:19 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Wed, 07 Dec 2022 05:27:19 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cerno.tech; h=cc :cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm2; t=1670408839; x= 1670495239; bh=Zn5jcj0nU0NQg/fB7GJUuCXybzPA29EmtUUxU6l8Xro=; b=E wuHCkoD5BEswQC9qUuPfaaqVKsMliy8vHaeLW61fXj/q8yKZCL5IvVJpI4alxzdV 3gvWCzgR59199Zb9qSHkvTWzEYsinVkjSGrrpK3B66WKkgFDYGPJYehdcoU0HoVt uQZIb/1hdRf7wMSQnKEHzI6kYh+8lumue2V36gAP6DLZoEhWBMLlXeV/Tx1O3JOo G3+FeGOXbvJHIrmGU1KK8tsMenMODr9mCuZxviw9L1tE/+wTeRkl74XCJtXAMHvw nyznme2vhKyAc4J2RrUdFMDouDfffxusMkU4iG3UYCjrsUiNSOf8+zF+gZ2SOJ+Q IAT6ANuaUvC/P2gNZ+SOg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1670408839; x= 1670495239; bh=Zn5jcj0nU0NQg/fB7GJUuCXybzPA29EmtUUxU6l8Xro=; b=O Em7LebaaCIxXob7HuXAjoWNVUY9POi5Tpz7ddMXAxbL2X9EXwy56scD6DRJgeK/1 ktJrzah4EKNRzd15gaCm6EtLAAKcK29psDPEXACESTZqRDAa66fmLmzsiE0Mew5w nWbRnECnSov4WgHpZ6r5xG934CNfFsMLwF6CDV+oNfBlHG7SgWH0nmrjvIU61l3O ZDIUhJmKFenPO9vhcz78QFu99FWe2XDf0f1bSivJwHOpr7fzaotHXSKOybLoZQ3u eI5Pt/bXDoNKWvhc4V8RX6fRHVlSR3LKLtCEPS22UFvvXBhfyKkQq2wXIVeqpgu5 Up6ikjU3AFwbj1cLzKssg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrudekgddugecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhfffugggtgffkfhgjvfevofesthejredtredtjeenucfhrhhomhepofgrgihi mhgvucftihhprghrugcuoehmrgigihhmvgestggvrhhnohdrthgvtghhqeenucggtffrrg htthgvrhhnpeevvdelieejgedvkeffheekheeilefhgefgffehteekueelvddtueffheet ledtffenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpe hmrgigihhmvgestggvrhhnohdrthgvtghh X-ME-Proxy: Feedback-ID: i8771445c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 7 Dec 2022 05:27:18 -0500 (EST) From: Maxime Ripard Date: Wed, 07 Dec 2022 11:22:45 +0100 Subject: [PATCH 2/6] drm/vc4: dsi: Move initialisation to encoder_mode_set MIME-Version: 1.0 Message-Id: <20221207-rpi-dsi-bridge-v1-2-8f68ee0b0adb@cerno.tech> References: <20221207-rpi-dsi-bridge-v1-0-8f68ee0b0adb@cerno.tech> In-Reply-To: <20221207-rpi-dsi-bridge-v1-0-8f68ee0b0adb@cerno.tech> To: Emma Anholt , Maxime Ripard , David Airlie , Daniel Vetter X-Mailer: b4 0.11.0-dev-8c583 X-Developer-Signature: v=1; a=openpgp-sha256; l=2358; i=maxime@cerno.tech; h=from:subject:message-id; bh=3tiWtws48aAKGnXcNHWpHDYHrtyX9rE7+J92kYYHF9A=; b=owGbwMvMwCX2+D1vfrpE4FHG02pJDMkTMkslXzLeKGBUO2H0unniv7QQ8z7lXy/O3b53qfvphBWp r8/xdZSyMIhxMciKKbLECJsviTs163UnG988mDmsTCBDGLg4BWAieiWMDN8+yBe1KEZtrjT42aOgsv fWNJs1WapSE1mNlALXfuQ+Is/IsOGY+TXVhZbcwVp3zpck1erx8t+JLt+6hS3kyIRDyz+8YwEA X-Developer-Key: i=maxime@cerno.tech; a=openpgp; fpr=BE5675C37E818C8B5764241C254BCFC56BF6CE8D X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Maxime Ripard , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Dave Stevenson Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Dave Stevenson Breaking the bridge chain does not work for atomic bridges/panels and generally causes issues. We need to initialise the DSI host before the bridge pre_enables are called, so move that to encoder_mode_set in the same way that dw-mipi-dsi does. Signed-off-by: Dave Stevenson Signed-off-by: Maxime Ripard --- drivers/gpu/drm/vc4/vc4_dsi.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/vc4/vc4_dsi.c b/drivers/gpu/drm/vc4/vc4_dsi.c index d9d951e9ab7c..607ebe368409 100644 --- a/drivers/gpu/drm/vc4/vc4_dsi.c +++ b/drivers/gpu/drm/vc4/vc4_dsi.c @@ -867,18 +867,18 @@ static bool vc4_dsi_encoder_mode_fixup(struct drm_encoder *encoder, return true; } -static void vc4_dsi_encoder_enable(struct drm_encoder *encoder) +static void vc4_dsi_encoder_mode_set(struct drm_encoder *encoder, + struct drm_display_mode *mode, + struct drm_display_mode *adjusted_mode) { - struct drm_display_mode *mode = &encoder->crtc->state->adjusted_mode; struct vc4_dsi *dsi = to_vc4_dsi(encoder); struct device *dev = &dsi->pdev->dev; bool debug_dump_regs = false; - struct drm_bridge *iter; unsigned long hs_clock; u32 ui_ns; /* Minimum LP state duration in escape clock cycles. */ u32 lpx = dsi_esc_timing(60); - unsigned long pixel_clock_hz = mode->clock * 1000; + unsigned long pixel_clock_hz = adjusted_mode->clock * 1000; unsigned long dsip_clock; unsigned long phy_clock; int ret; @@ -1105,6 +1105,13 @@ static void vc4_dsi_encoder_enable(struct drm_encoder *encoder) ~DSI_PORT_BIT(PHY_AFEC0_RESET)); vc4_dsi_ulps(dsi, false); +} + +static void vc4_dsi_encoder_enable(struct drm_encoder *encoder) +{ + struct vc4_dsi *dsi = to_vc4_dsi(encoder); + bool debug_dump_regs = false; + struct drm_bridge *iter; list_for_each_entry_reverse(iter, &dsi->bridge_chain, chain_node) { if (iter->funcs->pre_enable) @@ -1370,6 +1377,7 @@ static const struct drm_encoder_helper_funcs vc4_dsi_encoder_helper_funcs = { .disable = vc4_dsi_encoder_disable, .enable = vc4_dsi_encoder_enable, .mode_fixup = vc4_dsi_encoder_mode_fixup, + .mode_set = vc4_dsi_encoder_mode_set, }; static int vc4_dsi_late_register(struct drm_encoder *encoder) From patchwork Wed Dec 7 10:22:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 13066947 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A0AA5C4708E for ; Wed, 7 Dec 2022 10:27:43 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E44C510E394; Wed, 7 Dec 2022 10:27:29 +0000 (UTC) Received: from out3-smtp.messagingengine.com (out3-smtp.messagingengine.com [66.111.4.27]) by gabe.freedesktop.org (Postfix) with ESMTPS id 712FD10E38F for ; Wed, 7 Dec 2022 10:27:21 +0000 (UTC) Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id CBA4C5C00EF; Wed, 7 Dec 2022 05:27:20 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Wed, 07 Dec 2022 05:27:20 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cerno.tech; h=cc :cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm2; t=1670408840; x= 1670495240; bh=vNQF1/ogN8Vz4W9wc5Vdm2dmWdFNZe2M9hI8eB4AV7k=; b=c nzeVVUrYhQk13y3TM3HBfdFuSpIPRHA1368XMXBWBmUPMRDh+YI9qanbC25gMnqY WE5Hw2ChpviqJZdaiJZD/NvKoWj2b46WmyBfWG4OKr6T3ZC4On1o9LUFjotot//F R1k5MUSxfHFXemNl80LSywaoY+ZtRzz1D+LxhT/iS8LQE+t3WaT25pEri2aVfuZt CiCgY5w/G6bnCILjhvL125JtfiZ4aNv34myphBIKtKSLvgy6iErXINu01fVSk5Jh xBP48i378Pv9C1s/lPxUWdu2Dyi9OAJxOd77SSDq4lPqVKPgwBBeipiLg57f5fR/ PdoGyyFssfDaK7nFRItuw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1670408840; x= 1670495240; bh=vNQF1/ogN8Vz4W9wc5Vdm2dmWdFNZe2M9hI8eB4AV7k=; b=E FufSSqgZoWX6Pd+/luN134DPgN3z/qNfQnCWOQI2lvYqrIjqUv+8TT3YALtyWKSf jElqh+U/1V9DS2K50CnmSDOqBHugZfhdRk5NilVjCaFrV1m/7H2Rfo3St3Qn4gNX mCOCTDevOaTnOvr7PdUdBGnA06lV8vh+Emz9Uw1ph714wlG614UeNatMWWkrYnrU 2aNilyoJUX1e8ydEHS27/MOlhTxFP+mTmTe/xK8x8uHsy10Sn44sfv/7DRhDHLS5 WA01iGYlQN6ePVgPmU6/0mYlC9/tFc/IkStGPKOgpUI/QKixt8H2ag5K1ABeSfis oey9a00iy/U1rWmj//JfA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrudekgdduhecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhfffugggtgffkfhgjvfevofesthejredtredtjeenucfhrhhomhepofgrgihi mhgvucftihhprghrugcuoehmrgigihhmvgestggvrhhnohdrthgvtghhqeenucggtffrrg htthgvrhhnpeevvdelieejgedvkeffheekheeilefhgefgffehteekueelvddtueffheet ledtffenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpe hmrgigihhmvgestggvrhhnohdrthgvtghh X-ME-Proxy: Feedback-ID: i8771445c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 7 Dec 2022 05:27:20 -0500 (EST) From: Maxime Ripard Date: Wed, 07 Dec 2022 11:22:46 +0100 Subject: [PATCH 3/6] drm/vc4: dsi: Remove splitting the bridge chain from the driver MIME-Version: 1.0 Message-Id: <20221207-rpi-dsi-bridge-v1-3-8f68ee0b0adb@cerno.tech> References: <20221207-rpi-dsi-bridge-v1-0-8f68ee0b0adb@cerno.tech> In-Reply-To: <20221207-rpi-dsi-bridge-v1-0-8f68ee0b0adb@cerno.tech> To: Emma Anholt , Maxime Ripard , David Airlie , Daniel Vetter X-Mailer: b4 0.11.0-dev-8c583 X-Developer-Signature: v=1; a=openpgp-sha256; l=3801; i=maxime@cerno.tech; h=from:subject:message-id; bh=DYzIKgF8O4vqIwwivxAS+tyuqAfWzIHA7ueve8x9kVE=; b=owGbwMvMwCX2+D1vfrpE4FHG02pJDMkTMkuXJv61PHzMoUbqyYyZDfeSDkSGJ3/U9bE5sHbTI69d ueGbO0pZGMS4GGTFFFlihM2XxJ2a9bqTjW8ezBxWJpAhDFycAjCRTfEM/z3iOP1vvvabl1Bd65nJkz 0nTV9AdpdsnbeP2HenPcxdGxkZHhzR/jtDr1a5/azIqcd7FpQuOfKo7IP9LeO+ZwoqTGs3cwMA X-Developer-Key: i=maxime@cerno.tech; a=openpgp; fpr=BE5675C37E818C8B5764241C254BCFC56BF6CE8D X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Maxime Ripard , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Dave Stevenson Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Dave Stevenson Splitting the bridge chain fails for atomic bridges as the framework can't add the relevant state in drm_atomic_add_encoder_bridges. The chain was split because we needed to power up before calling pre_enable, but that is now done in mode_set, and will move into the framework. Signed-off-by: Dave Stevenson Signed-off-by: Maxime Ripard --- drivers/gpu/drm/vc4/vc4_dsi.c | 47 ------------------------------------------- 1 file changed, 47 deletions(-) diff --git a/drivers/gpu/drm/vc4/vc4_dsi.c b/drivers/gpu/drm/vc4/vc4_dsi.c index 607ebe368409..53d73a6590b7 100644 --- a/drivers/gpu/drm/vc4/vc4_dsi.c +++ b/drivers/gpu/drm/vc4/vc4_dsi.c @@ -557,7 +557,6 @@ struct vc4_dsi { struct platform_device *pdev; struct drm_bridge *out_bridge; - struct list_head bridge_chain; void __iomem *regs; @@ -794,23 +793,9 @@ static void vc4_dsi_encoder_disable(struct drm_encoder *encoder) { struct vc4_dsi *dsi = to_vc4_dsi(encoder); struct device *dev = &dsi->pdev->dev; - struct drm_bridge *iter; - - list_for_each_entry_reverse(iter, &dsi->bridge_chain, chain_node) { - if (iter->funcs->disable) - iter->funcs->disable(iter); - - if (iter == dsi->out_bridge) - break; - } vc4_dsi_ulps(dsi, true); - list_for_each_entry_from(iter, &dsi->bridge_chain, chain_node) { - if (iter->funcs->post_disable) - iter->funcs->post_disable(iter); - } - clk_disable_unprepare(dsi->pll_phy_clock); clk_disable_unprepare(dsi->escape_clock); clk_disable_unprepare(dsi->pixel_clock); @@ -1111,12 +1096,6 @@ static void vc4_dsi_encoder_enable(struct drm_encoder *encoder) { struct vc4_dsi *dsi = to_vc4_dsi(encoder); bool debug_dump_regs = false; - struct drm_bridge *iter; - - list_for_each_entry_reverse(iter, &dsi->bridge_chain, chain_node) { - if (iter->funcs->pre_enable) - iter->funcs->pre_enable(iter); - } if (dsi->mode_flags & MIPI_DSI_MODE_VIDEO) { DSI_PORT_WRITE(DISP0_CTRL, @@ -1133,11 +1112,6 @@ static void vc4_dsi_encoder_enable(struct drm_encoder *encoder) DSI_DISP0_ENABLE); } - list_for_each_entry(iter, &dsi->bridge_chain, chain_node) { - if (iter->funcs->enable) - iter->funcs->enable(iter); - } - if (debug_dump_regs) { struct drm_printer p = drm_info_printer(&dsi->pdev->dev); dev_info(&dsi->pdev->dev, "DSI regs after:\n"); @@ -1625,7 +1599,6 @@ static int vc4_dsi_bind(struct device *dev, struct device *master, void *data) dsi->variant = of_device_get_match_data(dev); - INIT_LIST_HEAD(&dsi->bridge_chain); dsi->encoder.type = dsi->variant->port ? VC4_ENCODER_TYPE_DSI1 : VC4_ENCODER_TYPE_DSI0; @@ -1762,32 +1735,12 @@ static int vc4_dsi_bind(struct device *dev, struct device *master, void *data) ret = drm_bridge_attach(encoder, dsi->out_bridge, NULL, 0); if (ret) return ret; - /* Disable the atomic helper calls into the bridge. We - * manually call the bridge pre_enable / enable / etc. calls - * from our driver, since we need to sequence them within the - * encoder's enable/disable paths. - */ - list_splice_init(&encoder->bridge_chain, &dsi->bridge_chain); return 0; } -static void vc4_dsi_unbind(struct device *dev, struct device *master, - void *data) -{ - struct vc4_dsi *dsi = dev_get_drvdata(dev); - struct drm_encoder *encoder = &dsi->encoder.base; - - /* - * Restore the bridge_chain so the bridge detach procedure can happen - * normally. - */ - list_splice_init(&dsi->bridge_chain, &encoder->bridge_chain); -} - static const struct component_ops vc4_dsi_ops = { .bind = vc4_dsi_bind, - .unbind = vc4_dsi_unbind, }; static int vc4_dsi_dev_probe(struct platform_device *pdev) From patchwork Wed Dec 7 10:22:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 13066948 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5B1A6C4708E for ; Wed, 7 Dec 2022 10:27:47 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3EDD710E396; Wed, 7 Dec 2022 10:27:31 +0000 (UTC) Received: from out3-smtp.messagingengine.com (out3-smtp.messagingengine.com [66.111.4.27]) by gabe.freedesktop.org (Postfix) with ESMTPS id 35A1910E392 for ; Wed, 7 Dec 2022 10:27:23 +0000 (UTC) Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id 9044B5C0113; Wed, 7 Dec 2022 05:27:22 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Wed, 07 Dec 2022 05:27:22 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cerno.tech; h=cc :cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm2; t=1670408842; x= 1670495242; bh=j72BaHFyaTxFOjEUAha4RtUDZFCZoWNUBdI79nsXaTQ=; b=R TxHcrcOJG43IWsUGKtFeTz45rZzwmVW1r2KFSQXX1Xf4tFxpC14QNFMLp5HJkYzF mV7gJaH1rU5YIxMFkHac+XJQPosI6Lf2/WVc5u9Uf/34zUCa47UE32MF5AoCI+nm otQQ2pRvyeWAwbK5SyzqTrrPPWI5gG/Ueud9IlicdoSQyZ5WKy5YQbdPNT0lM8wx D31yBK4ziALKFMmMDLOHmg3j5RDrN3Xq/dd1W21p5Jf+iJL91+ozIdexDB5F7tki flSV8aC7k6EiVVtEtCVlQnKAG+ybWVGb5DJicr6y8y2lRVLPklDtOQVvhR4YHBAv G5o9llUwDedG/PbLK/Ipw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1670408842; x= 1670495242; bh=j72BaHFyaTxFOjEUAha4RtUDZFCZoWNUBdI79nsXaTQ=; b=s 0Xs//yopxl2aiiorM0laR64MDvfw0i7gJIRWRfrXyK0Ni8GnzRcJ1CoPaDS3A/te OL4oMVD5UgHunRLSSyrMy2q4z2xd8kDtC9VqkwXtKupMIR/W0d797CshUJTiG2vN MZLzI9UuOC3IV1g4A7PQOm+u0pxWUJ3vIuCqbjCM7n2D5icW+LU7IqSaLqdboR7/ fR3p7DbEy7PTPvFijvbeyvkoRiBVmVu2zObPrCggyAshLP+Dmkv/orJ+se3/jXxA GKmPgl/ptRjAWsz4yt8qNtiAzPRdh+NHPrHUQlWZK2jfN+nAWOAZzDIVRwu3nL4l B9i/btWB7m7hvA8MGD60Q== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrudekgdduhecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhfffugggtgffkfhgjvfevofesthejredtredtjeenucfhrhhomhepofgrgihi mhgvucftihhprghrugcuoehmrgigihhmvgestggvrhhnohdrthgvtghhqeenucggtffrrg htthgvrhhnpeevvdelieejgedvkeffheekheeilefhgefgffehteekueelvddtueffheet ledtffenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpe hmrgigihhmvgestggvrhhnohdrthgvtghh X-ME-Proxy: Feedback-ID: i8771445c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 7 Dec 2022 05:27:21 -0500 (EST) From: Maxime Ripard Date: Wed, 07 Dec 2022 11:22:47 +0100 Subject: [PATCH 4/6] drm/vc4: dsi: Convert to use atomic operations MIME-Version: 1.0 Message-Id: <20221207-rpi-dsi-bridge-v1-4-8f68ee0b0adb@cerno.tech> References: <20221207-rpi-dsi-bridge-v1-0-8f68ee0b0adb@cerno.tech> In-Reply-To: <20221207-rpi-dsi-bridge-v1-0-8f68ee0b0adb@cerno.tech> To: Emma Anholt , Maxime Ripard , David Airlie , Daniel Vetter X-Mailer: b4 0.11.0-dev-8c583 X-Developer-Signature: v=1; a=openpgp-sha256; l=3055; i=maxime@cerno.tech; h=from:subject:message-id; bh=CXisU7c7qlb5YkMujGkhm32rlKYH8x7P9zn1D9smdLI=; b=owGbwMvMwCX2+D1vfrpE4FHG02pJDMkTMkulWlkX6qxZeGDyZBmP1WLT60yuaa2Wc3DoZVouFyx0 JUKno5SFQYyLQVZMkSVG2HxJ3KlZrzvZ+ObBzGFlAhnCwMUpABPpqGf4p8l4XMD6u0TzO2a1Xytnzv K+aX5l8U+LkoiVoWem/VT+2MLwz/Tzf94Foa0lnfpPT5dduqr2K+TF4TMmr9fdbNl/b/VeRS4A X-Developer-Key: i=maxime@cerno.tech; a=openpgp; fpr=BE5675C37E818C8B5764241C254BCFC56BF6CE8D X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Maxime Ripard , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Dave Stevenson Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Dave Stevenson The atomic calls are preferred as the non-atomic ones are deprecated. In preparation for conversion to a bridge, switch to the atomic calls. Signed-off-by: Dave Stevenson Signed-off-by: Maxime Ripard --- drivers/gpu/drm/vc4/vc4_dsi.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/drivers/gpu/drm/vc4/vc4_dsi.c b/drivers/gpu/drm/vc4/vc4_dsi.c index 53d73a6590b7..b90186f38749 100644 --- a/drivers/gpu/drm/vc4/vc4_dsi.c +++ b/drivers/gpu/drm/vc4/vc4_dsi.c @@ -789,7 +789,8 @@ dsi_esc_timing(u32 ns) return DIV_ROUND_UP(ns, ESC_TIME_NS); } -static void vc4_dsi_encoder_disable(struct drm_encoder *encoder) +static void vc4_dsi_encoder_disable(struct drm_encoder *encoder, + struct drm_atomic_state *state) { struct vc4_dsi *dsi = to_vc4_dsi(encoder); struct device *dev = &dsi->pdev->dev; @@ -853,17 +854,18 @@ static bool vc4_dsi_encoder_mode_fixup(struct drm_encoder *encoder, } static void vc4_dsi_encoder_mode_set(struct drm_encoder *encoder, - struct drm_display_mode *mode, - struct drm_display_mode *adjusted_mode) + struct drm_crtc_state *crtc_state, + struct drm_connector_state *conn_state) { struct vc4_dsi *dsi = to_vc4_dsi(encoder); struct device *dev = &dsi->pdev->dev; + const struct drm_display_mode *mode; bool debug_dump_regs = false; unsigned long hs_clock; u32 ui_ns; /* Minimum LP state duration in escape clock cycles. */ u32 lpx = dsi_esc_timing(60); - unsigned long pixel_clock_hz = adjusted_mode->clock * 1000; + unsigned long pixel_clock_hz; unsigned long dsip_clock; unsigned long phy_clock; int ret; @@ -880,6 +882,10 @@ static void vc4_dsi_encoder_mode_set(struct drm_encoder *encoder, drm_print_regset32(&p, &dsi->regset); } + mode = &crtc_state->adjusted_mode; + + pixel_clock_hz = mode->clock * 1000; + /* Round up the clk_set_rate() request slightly, since * PLLD_DSI1 is an integer divider and its rate selection will * never round up. @@ -1092,7 +1098,8 @@ static void vc4_dsi_encoder_mode_set(struct drm_encoder *encoder, vc4_dsi_ulps(dsi, false); } -static void vc4_dsi_encoder_enable(struct drm_encoder *encoder) +static void vc4_dsi_encoder_enable(struct drm_encoder *encoder, + struct drm_atomic_state *state) { struct vc4_dsi *dsi = to_vc4_dsi(encoder); bool debug_dump_regs = false; @@ -1348,10 +1355,10 @@ static const struct mipi_dsi_host_ops vc4_dsi_host_ops = { }; static const struct drm_encoder_helper_funcs vc4_dsi_encoder_helper_funcs = { - .disable = vc4_dsi_encoder_disable, - .enable = vc4_dsi_encoder_enable, + .atomic_disable = vc4_dsi_encoder_disable, + .atomic_enable = vc4_dsi_encoder_enable, .mode_fixup = vc4_dsi_encoder_mode_fixup, - .mode_set = vc4_dsi_encoder_mode_set, + .atomic_mode_set = vc4_dsi_encoder_mode_set, }; static int vc4_dsi_late_register(struct drm_encoder *encoder) From patchwork Wed Dec 7 10:22:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 13066950 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 42766C4708E for ; Wed, 7 Dec 2022 10:27:54 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D8AE110E398; Wed, 7 Dec 2022 10:27:41 +0000 (UTC) Received: from out3-smtp.messagingengine.com (out3-smtp.messagingengine.com [66.111.4.27]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1ECCA10E392 for ; Wed, 7 Dec 2022 10:27:25 +0000 (UTC) Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id 7830D5C00EF; Wed, 7 Dec 2022 05:27:24 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Wed, 07 Dec 2022 05:27:24 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cerno.tech; h=cc :cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm2; t=1670408844; x= 1670495244; bh=+wYLphAQDm0Qe9AV/NNK/4x7FAZwLgHWOx+tfp6bL30=; b=h FBRFs3+RDobnRgfUGch5JiYRWBqvHSiSTjcciv0Yum0NGqXJqPyP6Gv5ySdppQMt rwcjTk5dhsirA9ppK1OgVGqMkVlmW+9Gl/dzwNT2L9iFG96wPjTzYR7KWgdetPRM zDY1klfxuAa3IjceqtbWfE9xfQuGSwOa9iMTNsMd0+Y3PNCaw82TbnwouwesEiTg eMs/bces5MRlWR/lBtnsjveep/7yOOLlBHN+NNsEKYzMp5TXE5K+SSCGwWR/hz7e VpvWQV/TznMEkq93Y9rRShhPVIl10OhPIeuZC36CXJn4sFbQr0hE1IIg4vw7+62+ sEo6ycnHOPqIIeOeP7LHw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1670408844; x= 1670495244; bh=+wYLphAQDm0Qe9AV/NNK/4x7FAZwLgHWOx+tfp6bL30=; b=N ZNPQZOfNvlI+nArPW2oO6GQWl6FRZz98nAjQkrZJr6b3tJcHdrLLS7zM+3DbgEpS I+jMPTouALnc2LFjF2Bt/VpxWi1sINXwYv5HWFn4rDqb1h71/VRE3hBsJpoKN4ib eQn0NgkWSMshE/8G7jzL9VPC8v0MJ3YLl9u3YqbJxTYKJzfviG1/+unYbyFVcd0W H2T2hO56lsUOIAqCCC3AP5rDmBpeG8DQAhjG82zyZVA6bb0S8GEtQafsSJYTud9t fkKXKyde3ee+uRO8K0PefqObbs1M269uxcZA9eULCW/+8vQ1oWNzD+WV3mCz2Ef3 tTiMuBjAEF8jOvZOxbTnA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrudekgdduhecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhfffugggtgffkfhgjvfevofesthejredtredtjeenucfhrhhomhepofgrgihi mhgvucftihhprghrugcuoehmrgigihhmvgestggvrhhnohdrthgvtghhqeenucggtffrrg htthgvrhhnpeevvdelieejgedvkeffheekheeilefhgefgffehteekueelvddtueffheet ledtffenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpe hmrgigihhmvgestggvrhhnohdrthgvtghh X-ME-Proxy: Feedback-ID: i8771445c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 7 Dec 2022 05:27:23 -0500 (EST) From: Maxime Ripard Date: Wed, 07 Dec 2022 11:22:48 +0100 Subject: [PATCH 5/6] drm/vc4: dsi: Convert to using a bridge instead of encoder MIME-Version: 1.0 Message-Id: <20221207-rpi-dsi-bridge-v1-5-8f68ee0b0adb@cerno.tech> References: <20221207-rpi-dsi-bridge-v1-0-8f68ee0b0adb@cerno.tech> In-Reply-To: <20221207-rpi-dsi-bridge-v1-0-8f68ee0b0adb@cerno.tech> To: Emma Anholt , Maxime Ripard , David Airlie , Daniel Vetter X-Mailer: b4 0.11.0-dev-8c583 X-Developer-Signature: v=1; a=openpgp-sha256; l=9201; i=maxime@cerno.tech; h=from:subject:message-id; bh=sS0nffUEMdzevHmlYA6fk8WS+z9I0/zZLGW2+XZSbos=; b=owGbwMvMwCX2+D1vfrpE4FHG02pJDMkTMksPp3GJvHv16nLAl7VhC/672LSq/Z+rLigwP0JEs+/D +474jlIWBjEuBlkxRZYYYfMlcadmve5k45sHM4eVCWQIAxenAExk62lGhu2/32zlSr7kvP7cyhCXpY FGQk7mFocfx3qzLlqd9q965zKG/441qToeHbPmSXtom9wS+LBay8Lhr+S5R7ZxdtWF+66LswIA X-Developer-Key: i=maxime@cerno.tech; a=openpgp; fpr=BE5675C37E818C8B5764241C254BCFC56BF6CE8D X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Maxime Ripard , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Dave Stevenson Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Dave Stevenson Remove the encoder functions, and create a bridge attached to this dumb encoder which implements the same functionality. As a bridge has state which an encoder doesn't, we need to add the state management functions as well. As there is no bridge atomic_mode_set, move the initialisation code that was in mode_set into _pre_enable. The code to actually enable and disable sending video are split from the general control into _enable and _disable. Signed-off-by: Dave Stevenson Signed-off-by: Maxime Ripard --- drivers/gpu/drm/vc4/vc4_dsi.c | 121 +++++++++++++++++++++++++++++++----------- 1 file changed, 90 insertions(+), 31 deletions(-) diff --git a/drivers/gpu/drm/vc4/vc4_dsi.c b/drivers/gpu/drm/vc4/vc4_dsi.c index b90186f38749..a7b8ffd995b0 100644 --- a/drivers/gpu/drm/vc4/vc4_dsi.c +++ b/drivers/gpu/drm/vc4/vc4_dsi.c @@ -557,6 +557,7 @@ struct vc4_dsi { struct platform_device *pdev; struct drm_bridge *out_bridge; + struct drm_bridge bridge; void __iomem *regs; @@ -608,6 +609,12 @@ to_vc4_dsi(struct drm_encoder *encoder) return container_of(encoder, struct vc4_dsi, encoder.base); } +static inline struct vc4_dsi * +bridge_to_vc4_dsi(struct drm_bridge *bridge) +{ + return container_of(bridge, struct vc4_dsi, bridge); +} + static inline void dsi_dma_workaround_write(struct vc4_dsi *dsi, u32 offset, u32 val) { @@ -789,10 +796,21 @@ dsi_esc_timing(u32 ns) return DIV_ROUND_UP(ns, ESC_TIME_NS); } -static void vc4_dsi_encoder_disable(struct drm_encoder *encoder, - struct drm_atomic_state *state) +static void vc4_dsi_bridge_disable(struct drm_bridge *bridge, + struct drm_bridge_state *state) { - struct vc4_dsi *dsi = to_vc4_dsi(encoder); + struct vc4_dsi *dsi = bridge_to_vc4_dsi(bridge); + u32 disp0_ctrl; + + disp0_ctrl = DSI_PORT_READ(DISP0_CTRL); + disp0_ctrl &= ~DSI_DISP0_ENABLE; + DSI_PORT_WRITE(DISP0_CTRL, disp0_ctrl); +} + +static void vc4_dsi_bridge_post_disable(struct drm_bridge *bridge, + struct drm_bridge_state *state) +{ + struct vc4_dsi *dsi = bridge_to_vc4_dsi(bridge); struct device *dev = &dsi->pdev->dev; vc4_dsi_ulps(dsi, true); @@ -817,11 +835,11 @@ static void vc4_dsi_encoder_disable(struct drm_encoder *encoder, * higher-than-expected clock rate to the panel, but that's what the * firmware does too. */ -static bool vc4_dsi_encoder_mode_fixup(struct drm_encoder *encoder, - const struct drm_display_mode *mode, - struct drm_display_mode *adjusted_mode) +static bool vc4_dsi_bridge_mode_fixup(struct drm_bridge *bridge, + const struct drm_display_mode *mode, + struct drm_display_mode *adjusted_mode) { - struct vc4_dsi *dsi = to_vc4_dsi(encoder); + struct vc4_dsi *dsi = bridge_to_vc4_dsi(bridge); struct clk *phy_parent = clk_get_parent(dsi->pll_phy_clock); unsigned long parent_rate = clk_get_rate(phy_parent); unsigned long pixel_clock_hz = mode->clock * 1000; @@ -853,15 +871,18 @@ static bool vc4_dsi_encoder_mode_fixup(struct drm_encoder *encoder, return true; } -static void vc4_dsi_encoder_mode_set(struct drm_encoder *encoder, - struct drm_crtc_state *crtc_state, - struct drm_connector_state *conn_state) +static void vc4_dsi_bridge_pre_enable(struct drm_bridge *bridge, + struct drm_bridge_state *old_state) { - struct vc4_dsi *dsi = to_vc4_dsi(encoder); + struct drm_atomic_state *state = old_state->base.state; + struct vc4_dsi *dsi = bridge_to_vc4_dsi(bridge); + const struct drm_crtc_state *crtc_state; struct device *dev = &dsi->pdev->dev; const struct drm_display_mode *mode; + struct drm_connector *connector; bool debug_dump_regs = false; unsigned long hs_clock; + struct drm_crtc *crtc; u32 ui_ns; /* Minimum LP state duration in escape clock cycles. */ u32 lpx = dsi_esc_timing(60); @@ -882,6 +903,14 @@ static void vc4_dsi_encoder_mode_set(struct drm_encoder *encoder, drm_print_regset32(&p, &dsi->regset); } + /* + * Retrieve the CRTC adjusted mode. This requires a little dance to go + * from the bridge to the encoder, to the connector and to the CRTC. + */ + connector = drm_atomic_get_new_connector_for_encoder(state, + bridge->encoder); + crtc = drm_atomic_get_new_connector_state(state, connector)->crtc; + crtc_state = drm_atomic_get_new_crtc_state(state, crtc); mode = &crtc_state->adjusted_mode; pixel_clock_hz = mode->clock * 1000; @@ -1096,13 +1125,6 @@ static void vc4_dsi_encoder_mode_set(struct drm_encoder *encoder, ~DSI_PORT_BIT(PHY_AFEC0_RESET)); vc4_dsi_ulps(dsi, false); -} - -static void vc4_dsi_encoder_enable(struct drm_encoder *encoder, - struct drm_atomic_state *state) -{ - struct vc4_dsi *dsi = to_vc4_dsi(encoder); - bool debug_dump_regs = false; if (dsi->mode_flags & MIPI_DSI_MODE_VIDEO) { DSI_PORT_WRITE(DISP0_CTRL, @@ -1111,13 +1133,23 @@ static void vc4_dsi_encoder_enable(struct drm_encoder *encoder, VC4_SET_FIELD(dsi->format, DSI_DISP0_PFORMAT) | VC4_SET_FIELD(DSI_DISP0_LP_STOP_PERFRAME, DSI_DISP0_LP_STOP_CTRL) | - DSI_DISP0_ST_END | - DSI_DISP0_ENABLE); + DSI_DISP0_ST_END); } else { DSI_PORT_WRITE(DISP0_CTRL, - DSI_DISP0_COMMAND_MODE | - DSI_DISP0_ENABLE); + DSI_DISP0_COMMAND_MODE); } +} + +static void vc4_dsi_bridge_enable(struct drm_bridge *bridge, + struct drm_bridge_state *old_state) +{ + struct vc4_dsi *dsi = bridge_to_vc4_dsi(bridge); + bool debug_dump_regs = false; + u32 disp0_ctrl; + + disp0_ctrl = DSI_PORT_READ(DISP0_CTRL); + disp0_ctrl |= DSI_DISP0_ENABLE; + DSI_PORT_WRITE(DISP0_CTRL, disp0_ctrl); if (debug_dump_regs) { struct drm_printer p = drm_info_printer(&dsi->pdev->dev); @@ -1126,6 +1158,16 @@ static void vc4_dsi_encoder_enable(struct drm_encoder *encoder, } } +static int vc4_dsi_bridge_attach(struct drm_bridge *bridge, + enum drm_bridge_attach_flags flags) +{ + struct vc4_dsi *dsi = bridge_to_vc4_dsi(bridge); + + /* Attach the panel or bridge to the dsi bridge */ + return drm_bridge_attach(bridge->encoder, dsi->out_bridge, + &dsi->bridge, flags); +} + static ssize_t vc4_dsi_host_transfer(struct mipi_dsi_host *host, const struct mipi_dsi_msg *msg) { @@ -1302,6 +1344,7 @@ static int vc4_dsi_host_attach(struct mipi_dsi_host *host, struct mipi_dsi_device *device) { struct vc4_dsi *dsi = host_to_dsi(host); + int ret; dsi->lanes = device->lanes; dsi->channel = device->channel; @@ -1336,7 +1379,15 @@ static int vc4_dsi_host_attach(struct mipi_dsi_host *host, return 0; } - return component_add(&dsi->pdev->dev, &vc4_dsi_ops); + drm_bridge_add(&dsi->bridge); + + ret = component_add(&dsi->pdev->dev, &vc4_dsi_ops); + if (ret) { + drm_bridge_remove(&dsi->bridge); + return ret; + } + + return 0; } static int vc4_dsi_host_detach(struct mipi_dsi_host *host, @@ -1345,6 +1396,7 @@ static int vc4_dsi_host_detach(struct mipi_dsi_host *host, struct vc4_dsi *dsi = host_to_dsi(host); component_del(&dsi->pdev->dev, &vc4_dsi_ops); + drm_bridge_remove(&dsi->bridge); return 0; } @@ -1354,11 +1406,16 @@ static const struct mipi_dsi_host_ops vc4_dsi_host_ops = { .transfer = vc4_dsi_host_transfer, }; -static const struct drm_encoder_helper_funcs vc4_dsi_encoder_helper_funcs = { - .atomic_disable = vc4_dsi_encoder_disable, - .atomic_enable = vc4_dsi_encoder_enable, - .mode_fixup = vc4_dsi_encoder_mode_fixup, - .atomic_mode_set = vc4_dsi_encoder_mode_set, +static const struct drm_bridge_funcs vc4_dsi_bridge_funcs = { + .atomic_duplicate_state = drm_atomic_helper_bridge_duplicate_state, + .atomic_destroy_state = drm_atomic_helper_bridge_destroy_state, + .atomic_reset = drm_atomic_helper_bridge_reset, + .atomic_pre_enable = vc4_dsi_bridge_pre_enable, + .atomic_enable = vc4_dsi_bridge_enable, + .atomic_disable = vc4_dsi_bridge_disable, + .atomic_post_disable = vc4_dsi_bridge_post_disable, + .attach = vc4_dsi_bridge_attach, + .mode_fixup = vc4_dsi_bridge_mode_fixup, }; static int vc4_dsi_late_register(struct drm_encoder *encoder) @@ -1733,13 +1790,11 @@ static int vc4_dsi_bind(struct device *dev, struct device *master, void *data) if (ret) return ret; - drm_encoder_helper_add(encoder, &vc4_dsi_encoder_helper_funcs); - ret = devm_pm_runtime_enable(dev); if (ret) return ret; - ret = drm_bridge_attach(encoder, dsi->out_bridge, NULL, 0); + ret = drm_bridge_attach(encoder, &dsi->bridge, NULL, 0); if (ret) return ret; @@ -1761,7 +1816,11 @@ static int vc4_dsi_dev_probe(struct platform_device *pdev) dev_set_drvdata(dev, dsi); kref_init(&dsi->kref); + dsi->pdev = pdev; + dsi->bridge.funcs = &vc4_dsi_bridge_funcs; + dsi->bridge.of_node = dev->of_node; + dsi->bridge.type = DRM_MODE_CONNECTOR_DSI; dsi->dsi_host.ops = &vc4_dsi_host_ops; dsi->dsi_host.dev = dev; mipi_dsi_host_register(&dsi->dsi_host); From patchwork Wed Dec 7 10:22:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 13066949 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E75A3C352A1 for ; Wed, 7 Dec 2022 10:27:50 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 65CE010E395; Wed, 7 Dec 2022 10:27:35 +0000 (UTC) Received: from out3-smtp.messagingengine.com (out3-smtp.messagingengine.com [66.111.4.27]) by gabe.freedesktop.org (Postfix) with ESMTPS id BC56710E393 for ; Wed, 7 Dec 2022 10:27:26 +0000 (UTC) Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id 20A395C01D5; Wed, 7 Dec 2022 05:27:26 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Wed, 07 Dec 2022 05:27:26 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cerno.tech; h=cc :cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm2; t=1670408846; x= 1670495246; bh=h5h97StYzAEu+yy4ghlHT2x7MeSqftaELyUUevoLQM0=; b=D 73OOanYGO2UWsfZrhE9zGdhqwFvGx4FmLgwO/J77HyamhCE+Gs80PkL2hiRjGDrK /mE8qPVF/PELLh0PjbiZ310kQi+MGOUz07iJbQ1DtybENJhYUnoBewNIJ5n3W097 cmd6fz9BFsDHbpIZHUj46AFc8K4ia4WG1PKnUsylK/aUx2MkURyzpufy/ms2qhSr cON6ZFr274Xp/ONPQv/OMXJT1F7KHMj0xivqM1Kj0oOxiOlqrRaxjEEpzqHToWSl CWuk0xeHLn+N2a1eOQP6i/b6sbo/30b8IQxiOwpMJzLGHZi4JT5pIqdQaONwG3zn g0ffE5z1IdkuiJ9eUmRXg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1670408846; x= 1670495246; bh=h5h97StYzAEu+yy4ghlHT2x7MeSqftaELyUUevoLQM0=; b=I Jns9dICqpr3zOv31VUmjTqzDQxbqqlac2wTRVoEL4yJg8xOrB7hL9J36NjBx6c7r dwqudNa+ENc1h5gmmigvBcgiu4MMGu3kazia9IBTAzX3MWxnn/DjSCV65BSi7c7U E9hHAE7wzxIWl4CXXIrtM20faW6pDYYvlR6/PmFVlv0/fikXVb2Yt6jvMAcB26ru 4XCFbhjVJRvhhPI4RrHLmHh8rFdITNiq+9ZJ9f+aKwMqsKFpcpZ+NG9bUAgUZpgy nLBQHOwemRwqsc0xgy+Qe+N2D2mcu3Opnyua1FacRepO99NbZdjIeogNMIHmK5Ld +oteCm9v8Z5PKCADuzqjw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrudekgdduhecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhfffugggtgffkfhgjvfevofesthejredtredtjeenucfhrhhomhepofgrgihi mhgvucftihhprghrugcuoehmrgigihhmvgestggvrhhnohdrthgvtghhqeenucggtffrrg htthgvrhhnpeevvdelieejgedvkeffheekheeilefhgefgffehteekueelvddtueffheet ledtffenucevlhhushhtvghrufhiiigvpedunecurfgrrhgrmhepmhgrihhlfhhrohhmpe hmrgigihhmvgestggvrhhnohdrthgvtghh X-ME-Proxy: Feedback-ID: i8771445c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 7 Dec 2022 05:27:25 -0500 (EST) From: Maxime Ripard Date: Wed, 07 Dec 2022 11:22:49 +0100 Subject: [PATCH 6/6] drm/vc4: dsi: Remove entry to ULPS from vc4_dsi post_disable MIME-Version: 1.0 Message-Id: <20221207-rpi-dsi-bridge-v1-6-8f68ee0b0adb@cerno.tech> References: <20221207-rpi-dsi-bridge-v1-0-8f68ee0b0adb@cerno.tech> In-Reply-To: <20221207-rpi-dsi-bridge-v1-0-8f68ee0b0adb@cerno.tech> To: Emma Anholt , Maxime Ripard , David Airlie , Daniel Vetter X-Mailer: b4 0.11.0-dev-8c583 X-Developer-Signature: v=1; a=openpgp-sha256; l=1249; i=maxime@cerno.tech; h=from:subject:message-id; bh=cJvbEvZA5k2IhWWlGKDtOHgsecBa2Doxm4Mts5DYRUc=; b=owGbwMvMwCX2+D1vfrpE4FHG02pJDMkTMkvvMpjYH9y0vulQ/kYji2NzPKdOYs+brJxR8Saxeu+L qGrHjlIWBjEuBlkxRZYYYfMlcadmve5k45sHM4eVCWQIAxenAExk51+G/07nIrUtPrr6T1LgfWzldC HwUtxWqUuf3zk4mGvsO787YjfDP33DE+5dT3tO1uQF5gXrZ0tYlnkevjLN8Sv/Re2b855YMAMA X-Developer-Key: i=maxime@cerno.tech; a=openpgp; fpr=BE5675C37E818C8B5764241C254BCFC56BF6CE8D X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Maxime Ripard , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Dave Stevenson Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Dave Stevenson Post_disable was sending the D-PHY sequence to put any device into ULPS suspend mode, and then cutting power to the DSI block. The power-on reset state of the DSI block is for DSI to be in an operational state, not ULPS, so it then never sent the sequence for exiting ULPS. Any attached device that didn't have an external reset therefore remained in ULPS / standby, and didn't function. Use of ULPS isn't well specified in DRM, therefore remove entering it to avoid the above situation. Signed-off-by: Dave Stevenson Signed-off-by: Maxime Ripard --- drivers/gpu/drm/vc4/vc4_dsi.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/gpu/drm/vc4/vc4_dsi.c b/drivers/gpu/drm/vc4/vc4_dsi.c index a7b8ffd995b0..4f3805528aa1 100644 --- a/drivers/gpu/drm/vc4/vc4_dsi.c +++ b/drivers/gpu/drm/vc4/vc4_dsi.c @@ -813,8 +813,6 @@ static void vc4_dsi_bridge_post_disable(struct drm_bridge *bridge, struct vc4_dsi *dsi = bridge_to_vc4_dsi(bridge); struct device *dev = &dsi->pdev->dev; - vc4_dsi_ulps(dsi, true); - clk_disable_unprepare(dsi->pll_phy_clock); clk_disable_unprepare(dsi->escape_clock); clk_disable_unprepare(dsi->pixel_clock);