From patchwork Tue Dec 31 19:28:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 13923951 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 42080E7718B for ; Tue, 31 Dec 2024 19:30:32 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id BDF4510E477; Tue, 31 Dec 2024 19:30:31 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=denx.de header.i=@denx.de header.b="IUOEsjQZ"; dkim-atps=neutral Received: from mx.denx.de (mx.denx.de [89.58.32.78]) by gabe.freedesktop.org (Postfix) with ESMTPS id 487AF10E189 for ; Tue, 31 Dec 2024 19:30:25 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 822C810486D9F; Tue, 31 Dec 2024 20:29:51 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=mx-20241105; t=1735673393; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+zjnnI3iPrWwOE0R208z670xT6TwIYqYj6odvgiZrgw=; b=IUOEsjQZRLNPIjI7Ed+UsxthNvxR028jHVDEfiqfTA2JOEEImbpUOYkKZqo+9YbAIBcoBZ j/nPXfW4Fh3xsgX67siwVYtGzU9Cqx9QP9ei7eRbnnbsSzGPJjZ3VqcoTLK3QmBzE3ggRK l5eKR9CMQBJtn6Pkq+6SGSSUbd1QA+j9DNlhOKLdzUZCuBIr+1h3IfUg52QWEt1Y0m7aDv yCCeAg0zAiMf24ewR0qIfhu2/6ZWfPjFT9ZQmBYjIIshvSftPMK4BIKCt+VwsqZP0Vkb8x t8296MP6z5byvs5yqjWj/7ypJcpUxiloC1Sc2EBZJ8OSTTqMxWQUWa6LFzLhOQ== From: Marek Vasut To: dri-devel@lists.freedesktop.org Cc: Marek Vasut , Dmitry Baryshkov , Andrzej Hajda , David Airlie , Fabio Estevam , Jernej Skrabec , Jonas Karlman , Laurent Pinchart , Liu Ying , Maarten Lankhorst , Maxime Ripard , Neil Armstrong , Pengutronix Kernel Team , Robert Foss , Sascha Hauer , Shawn Guo , Simona Vetter , Stefan Agner , Thomas Zimmermann , imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org Subject: [PATCH v3 3/4] drm/lcdif: add DRM_BRIDGE_ATTACH_NO_CONNECTOR flag to drm_bridge_attach Date: Tue, 31 Dec 2024 20:28:50 +0100 Message-ID: <20241231192925.97614-3-marex@denx.de> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241231192925.97614-1-marex@denx.de> References: <20241231192925.97614-1-marex@denx.de> MIME-Version: 1.0 X-Last-TLS-Session-Version: TLSv1.3 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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Commit a25b988ff83f ("drm/bridge: Extend bridge API to disable connector creation") added DRM_BRIDGE_ATTACH_NO_CONNECTOR bridge flag and all bridges handle this flag in some way since then. Newly added bridge drivers must no longer contain the connector creation and will fail probing if this flag isn't set. In order to be able to connect to those newly added bridges as well, make use of drm_bridge_connector API and have the connector initialized by the display controller. Based on 2e87bf389e13 ("drm/rockchip: add DRM_BRIDGE_ATTACH_NO_CONNECTOR flag to drm_bridge_attach") This makes LT9611 work with i.MX8M Plus. Reviewed-by: Dmitry Baryshkov Signed-off-by: Marek Vasut --- Cc: Andrzej Hajda Cc: David Airlie Cc: Fabio Estevam Cc: Jernej Skrabec Cc: Jonas Karlman Cc: Laurent Pinchart Cc: Liu Ying Cc: Maarten Lankhorst Cc: Maxime Ripard Cc: Neil Armstrong Cc: Pengutronix Kernel Team Cc: Robert Foss Cc: Sascha Hauer Cc: Shawn Guo Cc: Simona Vetter Cc: Stefan Agner Cc: Thomas Zimmermann Cc: dri-devel@lists.freedesktop.org Cc: imx@lists.linux.dev Cc: linux-arm-kernel@lists.infradead.org --- V2: Add RB from Dmitry V3: - Select DRM_DISPLAY_HELPER - Use return dev_err_probe() directly - Add missing of_node_put(ep) - Add test using drm_bridge_get_next_bridge() to try and determine if the HDMI connector was missing in DT or not, and if it was missing, if it was created by the HDMI bridge driver. --- drivers/gpu/drm/mxsfb/Kconfig | 2 ++ drivers/gpu/drm/mxsfb/lcdif_drv.c | 30 ++++++++++++++++++++++++++++-- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/mxsfb/Kconfig b/drivers/gpu/drm/mxsfb/Kconfig index 264e74f455547..fe98674d5a298 100644 --- a/drivers/gpu/drm/mxsfb/Kconfig +++ b/drivers/gpu/drm/mxsfb/Kconfig @@ -12,6 +12,7 @@ config DRM_MXSFB select DRM_CLIENT_SELECTION select DRM_MXS select DRM_KMS_HELPER + select DRM_BRIDGE_CONNECTOR select DRM_GEM_DMA_HELPER select DRM_PANEL select DRM_PANEL_BRIDGE @@ -28,6 +29,7 @@ config DRM_IMX_LCDIF depends on COMMON_CLK depends on ARCH_MXC || COMPILE_TEST select DRM_CLIENT_SELECTION + select DRM_DISPLAY_HELPER select DRM_MXS select DRM_KMS_HELPER select DRM_GEM_DMA_HELPER diff --git a/drivers/gpu/drm/mxsfb/lcdif_drv.c b/drivers/gpu/drm/mxsfb/lcdif_drv.c index 8ee00f59ca821..dc39adabb3cd9 100644 --- a/drivers/gpu/drm/mxsfb/lcdif_drv.c +++ b/drivers/gpu/drm/mxsfb/lcdif_drv.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -48,8 +49,10 @@ static const struct drm_encoder_funcs lcdif_encoder_funcs = { static int lcdif_attach_bridge(struct lcdif_drm_private *lcdif) { struct device *dev = lcdif->drm->dev; + struct drm_device *drm = lcdif->drm; + struct drm_connector *connector; struct device_node *ep; - struct drm_bridge *bridge; + struct drm_bridge *bridge, *nextbridge; int ret; for_each_endpoint_of_node(dev->of_node, ep) { @@ -97,13 +100,36 @@ static int lcdif_attach_bridge(struct lcdif_drm_private *lcdif) return ret; } - ret = drm_bridge_attach(encoder, bridge, NULL, 0); + ret = drm_bridge_attach(encoder, bridge, NULL, + DRM_BRIDGE_ATTACH_NO_CONNECTOR); if (ret) { of_node_put(ep); return dev_err_probe(dev, ret, "Failed to attach bridge for endpoint%u\n", of_ep.id); } + + nextbridge = drm_bridge_get_next_bridge(bridge); + nextbridge = drm_bridge_get_next_bridge(nextbridge); + /* Test if connector node in DT, if not, it was created already */ + if (!nextbridge) + continue; + + connector = drm_bridge_connector_init(drm, encoder); + if (IS_ERR(connector)) { + of_node_put(ep); + return dev_err_probe(drm->dev, PTR_ERR(connector), + "Failed to initialize bridge connector: %pe\n", + connector); + } + + ret = drm_connector_attach_encoder(connector, encoder); + if (ret < 0) { + of_node_put(ep); + drm_connector_cleanup(connector); + return dev_err_probe(drm->dev, ret, + "Failed to attach encoder.\n"); + } } return 0;