From patchwork Mon Aug 26 15:26:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Boris Brezillon X-Patchwork-Id: 11114903 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EEA531395 for ; Mon, 26 Aug 2019 15:27:49 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id D6F0521881 for ; Mon, 26 Aug 2019 15:27:49 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D6F0521881 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=collabora.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2E6EB6E24E; Mon, 26 Aug 2019 15:27:38 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [46.235.227.227]) by gabe.freedesktop.org (Postfix) with ESMTPS id CBF286E229 for ; Mon, 26 Aug 2019 15:27:05 +0000 (UTC) Received: from localhost.localdomain (unknown [IPv6:2a01:e0a:2c:6930:5cf4:84a1:2763:fe0d]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: bbrezillon) by bhuna.collabora.co.uk (Postfix) with ESMTPSA id 1C34E28BD1B; Mon, 26 Aug 2019 16:27:04 +0100 (BST) From: Boris Brezillon To: dri-devel@lists.freedesktop.org Subject: [PATCH v2 15/21] drm/bridge: Add the drm_bridge_chain_get_prev_bridge() helper Date: Mon, 26 Aug 2019 17:26:43 +0200 Message-Id: <20190826152649.13820-16-boris.brezillon@collabora.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190826152649.13820-1-boris.brezillon@collabora.com> References: <20190826152649.13820-1-boris.brezillon@collabora.com> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Nikita Yushchenko , Jernej Skrabec , Laurent Pinchart , Neil Armstrong , Andrey Smirnov , Jonas Karlman , Seung-Woo Kim , Kyungmin Park , Thierry Reding , Chris Healy , Boris Brezillon , kernel@collabora.com, Sam Ravnborg Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Will be useful for bridge drivers that want to do bus format negotiation with their neighbours. Signed-off-by: Boris Brezillon Reviewed-by: Neil Armstrong --- Changes in v2: * Fix the kerneldoc * Drop the !bridge || !bridge->encoder check --- drivers/gpu/drm/drm_bridge.c | 17 +++++++++++++++++ include/drm/drm_bridge.h | 2 ++ 2 files changed, 19 insertions(+) diff --git a/drivers/gpu/drm/drm_bridge.c b/drivers/gpu/drm/drm_bridge.c index 7f7e0ea5b06c..9c74b285da9d 100644 --- a/drivers/gpu/drm/drm_bridge.c +++ b/drivers/gpu/drm/drm_bridge.c @@ -238,6 +238,23 @@ drm_bridge_chain_get_next_bridge(struct drm_bridge *bridge) } EXPORT_SYMBOL(drm_bridge_chain_get_next_bridge); +/** + * drm_bridge_chain_get_prev_bridge() - Get the previous bridge in the chain + * @bridge: bridge object + * + * RETURNS: + * the previous bridge in the chain, or NULL if @bridge is the last. + */ +struct drm_bridge * +drm_bridge_chain_get_prev_bridge(struct drm_bridge *bridge) +{ + if (list_is_first(&bridge->chain_node, &bridge->encoder->bridge_chain)) + return NULL; + + return list_prev_entry(bridge, chain_node); +} +EXPORT_SYMBOL(drm_bridge_chain_get_prev_bridge); + /** * DOC: bridge callbacks * diff --git a/include/drm/drm_bridge.h b/include/drm/drm_bridge.h index 7fdce6dc5f26..95dc58c3a4e8 100644 --- a/include/drm/drm_bridge.h +++ b/include/drm/drm_bridge.h @@ -521,6 +521,8 @@ int drm_bridge_attach(struct drm_encoder *encoder, struct drm_bridge *bridge, struct drm_bridge * drm_bridge_chain_get_next_bridge(struct drm_bridge *bridge); +struct drm_bridge * +drm_bridge_chain_get_prev_bridge(struct drm_bridge *bridge); bool drm_bridge_chain_mode_fixup(struct drm_bridge *bridge, const struct drm_display_mode *mode, struct drm_display_mode *adjusted_mode);