From patchwork Wed Mar 29 13:16:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 13192410 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 E6161C761A6 for ; Wed, 29 Mar 2023 13:19:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=cuErzsF5lsC0gtlXGYDRKjBjL5TE+QDCxVvZTs+vFYY=; b=NdUbm3FsAuf6Dj QZDnXS/evxghBP57X5vdOZ7ncGwYg+8mqvN6iC25BzZ6DJCq/zqkC4xwmRD80Epmjv/kVI468tkFN Z6F9z6f5gcGoewZELhLYt6myYQCwSF9RQmqDKtRR5m3i7lj55WMm1uYyTWaP/Qsr5EKBx8kSxL6ou 7fZ8hJH2PLeq4a5af1ab8bsuHifGiNFCPPfGdUVbh05ktaEoSYk7sgm+GhF8uuNDMRcVHllk57kHa DaTvkoV5HCWdupM+Je1j1HG3bWq3Rwvw4vcJdJwYKIIwFCheH9IY374H0Y1VeUk1IKFHxhxOzr/i8 rq4CdHyY+UhP0tjVU2VA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1phVh3-000Jm5-1C; Wed, 29 Mar 2023 13:18:25 +0000 Received: from mail-pj1-x1032.google.com ([2607:f8b0:4864:20::1032]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1phVgg-000JS3-1r for linux-arm-kernel@lists.infradead.org; Wed, 29 Mar 2023 13:18:04 +0000 Received: by mail-pj1-x1032.google.com with SMTP id x15so14021501pjk.2 for ; Wed, 29 Mar 2023 06:17:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; t=1680095879; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=0wNTb2LrxaKFlmHgalrnrr3A4EG008KaVwysZvYEb6Q=; b=cqidfaD69QRlixQGDaMVrdpnuW4E/ueB+ta+aoaLu75jvjPTb6X8dXWmHB4iaw1Puf sA0xW5rf44dDAy0wFnUg6Z94f+i5ihDnYHtGWrSMB79e2IKvSUSnAty8f9XTn8263x+E rjUs3uFYzgM1UOkgvbYUPtQBmF6OKzdBEe78o= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680095879; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=0wNTb2LrxaKFlmHgalrnrr3A4EG008KaVwysZvYEb6Q=; b=eToK6LPFOFMuewau9Ro7OFBZMeETGmVzQJh83+oapkhf88fES/EmAQkEHxGxm8jzhV twEnBopcummdu0nU42m7dSSe67TE1og72LvKAztd2XjwM9bSGLTFo0oi8NFaO5yv2TAg 1m9t+5lYmCIKxLIneFXUMKSL5CQeveZ+pZoi6LEjd7oPESfRgEqohVVNjVIIKgtdv2Vj 5q4/B4wPqqOVxH2pcrGsTVuIMyf/REezKBT9VEaRKo1rQObtnJEOEcSMKW7gMJ/oL+U7 +Nw3gwSqXkLa+PjMUtQ5VHLSj8KoAuDyQGBTmAhrTn8C2mNEkUrdLcCNdP70z4+3vY7s E1Qg== X-Gm-Message-State: AAQBX9foF/ven698rywJ4t1U5TdL3L31UkORNWwe8FSDdxzOwuXJ+qL/ TmgrZRMqRfOAwIFagGBoMguDdQ== X-Google-Smtp-Source: AKy350Z0nRebQpUhm57vPD2Fu3xEl648nRwouk5XbwzGKAmjhBeobsc7CNU/OD8nrZMuYEE8Qi5lQA== X-Received: by 2002:a17:90b:3511:b0:23f:a4da:1208 with SMTP id ls17-20020a17090b351100b0023fa4da1208mr21913619pjb.39.1680095879378; Wed, 29 Mar 2023 06:17:59 -0700 (PDT) Received: from localhost.localdomain ([2405:201:c00a:a047:206d:4722:c4fa:e845]) by smtp.gmail.com with ESMTPSA id s16-20020a17090b071000b0023f5c867f82sm1400192pjz.41.2023.03.29.06.17.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Mar 2023 06:17:58 -0700 (PDT) From: Jagan Teki To: Dave Stevenson , Maxime Ripard , Maarten Lankhorst , Thomas Zimmermann , David Airlie , Daniel Vetter , Andrzej Hajda , Neil Armstrong , Robert Foss , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Sam Ravnborg , Rob Herring , Krzysztof Kozlowski Cc: linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, devicetree@vger.kernel.org, dri-devel@lists.freedesktop.org, Marek Vasut , linux-amarula , Jagan Teki Subject: [PATCH v7 02/12] drm: bridge: panel: Implement drmm_of_dsi_get_bridge helper Date: Wed, 29 Mar 2023 18:46:08 +0530 Message-Id: <20230329131615.1328366-3-jagan@amarulasolutions.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230329131615.1328366-1-jagan@amarulasolutions.com> References: <20230329131615.1328366-1-jagan@amarulasolutions.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230329_061802_615231_9AFCBBB3 X-CRM114-Status: GOOD ( 15.91 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Implement a DRM-managed action helper that returns the next DSI bridge in the chain. Unlike general bridge return helper drmm_of_get_bridge, this helper uses the dsi specific panel_or_bridge helper to find the next DSI device in the pipeline. Helper lookup a given downstream DSI device that has been added via child or OF-graph port or ports node. Upstream DSI looks for downstream devices using drm pointer, port and endpoint number. Downstream devices added via child node don't affect the port and endpoint number arguments. Signed-off-by: Jagan Teki --- Changes for v7: - new patch drivers/gpu/drm/bridge/panel.c | 34 ++++++++++++++++++++++++++++++++++ include/drm/drm_bridge.h | 10 ++++++++++ 2 files changed, 44 insertions(+) diff --git a/drivers/gpu/drm/bridge/panel.c b/drivers/gpu/drm/bridge/panel.c index d4b112911a99..d047c7d9551d 100644 --- a/drivers/gpu/drm/bridge/panel.c +++ b/drivers/gpu/drm/bridge/panel.c @@ -501,4 +501,38 @@ struct drm_bridge *drmm_of_get_bridge(struct drm_device *drm, } EXPORT_SYMBOL(drmm_of_get_bridge); +/** + * drmm_of_dsi_get_bridge - Return next DSI bridge in the chain + * @drm: device to tie the bridge lifetime to + * @np: device tree node containing DSI output ports + * @port: port in the device tree node + * @endpoint: endpoint in the device tree node + * + * Given a DT node's port and endpoint number, finds the connected node + * and returns the associated DSI bridge if any, or creates and returns + * a DSI panel bridge instance if a panel is connected. + * + * Returns a drmm managed pointer to the DSI bridge if successful, or + * an error pointer otherwise. + */ +struct drm_bridge *drmm_of_dsi_get_bridge(struct drm_device *drm, + struct device_node *np, + u32 port, u32 endpoint) +{ + struct drm_bridge *bridge; + struct drm_panel *panel; + int ret; + + ret = drm_of_dsi_find_panel_or_bridge(np, port, endpoint, + &panel, &bridge); + if (ret) + return ERR_PTR(ret); + + if (panel) + bridge = drmm_panel_bridge_add(drm, panel); + + return bridge; +} +EXPORT_SYMBOL(drmm_of_dsi_get_bridge); + #endif diff --git a/include/drm/drm_bridge.h b/include/drm/drm_bridge.h index 42f86327b40a..a1a31704b917 100644 --- a/include/drm/drm_bridge.h +++ b/include/drm/drm_bridge.h @@ -931,6 +931,9 @@ struct drm_bridge *devm_drm_of_get_bridge(struct device *dev, struct device_node u32 port, u32 endpoint); struct drm_bridge *drmm_of_get_bridge(struct drm_device *drm, struct device_node *node, u32 port, u32 endpoint); +struct drm_bridge *drmm_of_dsi_get_bridge(struct drm_device *drm, + struct device_node *node, + u32 port, u32 endpoint); #else static inline struct drm_bridge *devm_drm_of_get_bridge(struct device *dev, struct device_node *node, @@ -947,6 +950,13 @@ static inline struct drm_bridge *drmm_of_get_bridge(struct drm_device *drm, { return ERR_PTR(-ENODEV); } + +static inline struct drm_bridge *drmm_of_dsi_get_bridge(struct drm_device *drm, + struct device_node *node, + u32 port, u32 endpoint) +{ + return ERR_PTR(-ENODEV); +} #endif #endif