From patchwork Mon Jun 11 13:35:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Heiko_St=C3=BCbner?= X-Patchwork-Id: 10457825 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 9D9AC6020F for ; Mon, 11 Jun 2018 13:35:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8DF0926E79 for ; Mon, 11 Jun 2018 13:35:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 828F028459; Mon, 11 Jun 2018 13:35:53 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 34C6D26E79 for ; Mon, 11 Jun 2018 13:35:53 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2F4676E329; Mon, 11 Jun 2018 13:35:26 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from gloria.sntech.de (gloria.sntech.de [95.129.55.99]) by gabe.freedesktop.org (Postfix) with ESMTPS id 87C6E89F27 for ; Mon, 11 Jun 2018 13:35:19 +0000 (UTC) Received: from wd0341.dip.tu-dresden.de ([141.76.109.85] helo=phil.dip.tu-dresden.de) by gloria.sntech.de with esmtpsa (TLS1.1:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.80) (envelope-from ) id 1fSMya-0001rB-Om; Mon, 11 Jun 2018 15:35:16 +0200 From: Heiko Stuebner To: dri-devel@lists.freedesktop.org Subject: [PATCH 6/8] drm/dsi: add helper function to find the second host in a dual-dsi setup Date: Mon, 11 Jun 2018 15:35:00 +0200 Message-Id: <20180611133502.1292-7-heiko@sntech.de> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180611133502.1292-1-heiko@sntech.de> References: <20180611133502.1292-1-heiko@sntech.de> 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: mark.rutland@arm.com, devicetree@vger.kernel.org, briannorris@chromium.org, hoegsberg@gmail.com, philippe.cornu@st.com, yannick.fertre@st.com, linux-rockchip@lists.infradead.org, nickey.yang@rock-chips.com, robh+dt@kernel.org, thierry.reding@gmail.com, laurent.pinchart@ideasonboard.com, mka@chromium.org MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP From a specified output port of one dsi controller this function allows to iterate over the list of registered dsi controllers trying to find a second instance connected to the same display, like it is used in dual-dsi setups. Signed-off-by: Heiko Stuebner --- drivers/gpu/drm/drm_mipi_dsi.c | 56 ++++++++++++++++++++++++++++++++++ include/drm/drm_mipi_dsi.h | 2 ++ 2 files changed, 58 insertions(+) diff --git a/drivers/gpu/drm/drm_mipi_dsi.c b/drivers/gpu/drm/drm_mipi_dsi.c index bc73b7f5b9fc..ac457d02389c 100644 --- a/drivers/gpu/drm/drm_mipi_dsi.c +++ b/drivers/gpu/drm/drm_mipi_dsi.c @@ -30,6 +30,7 @@ #include #include #include +#include #include #include @@ -282,6 +283,61 @@ struct mipi_dsi_host *of_find_mipi_dsi_host_by_node(struct device_node *node) } EXPORT_SYMBOL(of_find_mipi_dsi_host_by_node); +struct device_node *of_mipi_dsi_find_second_host(struct device_node *first_np, + int port, int endpoint) +{ + struct mipi_dsi_host *first, *host; + struct device_node *remote, *np, *second_np = NULL; + int num = 0; + + first = of_find_mipi_dsi_host_by_node(first_np); + if (!first) { + pr_err("no dsi-host for node %s\n", first_np->full_name); + return ERR_PTR(-ENODEV); + } + + /* output-node of the known dsi-host */ + remote = of_graph_get_remote_node(first_np, port, endpoint); + if (!remote) { + dev_err(first->dev, "no output node found\n"); + return ERR_PTR(-ENODEV); + } + + mutex_lock(&host_lock); + + list_for_each_entry(host, &host_list, list) { + np = of_graph_get_remote_node(host->dev->of_node, + port, endpoint); + + /* found a host connected to this panel */ + if (np == remote) + num++; + + /* found one second host */ + if (host->dev->of_node != first_np) + second_np = host->dev->of_node; + + of_node_put(np); + } + + /* of_node_get the node under host_lock */ + if (num == 2) + of_node_get(second_np); + + mutex_unlock(&host_lock); + + of_node_put(remote); + + if (num > 2) { + dev_err(first->dev, + "too many DSI links for output: %d links\n", num); + return ERR_PTR(-EINVAL); + } + + return second_np; +} +EXPORT_SYMBOL(of_mipi_dsi_find_second_host); + int mipi_dsi_host_register(struct mipi_dsi_host *host) { struct device_node *node; diff --git a/include/drm/drm_mipi_dsi.h b/include/drm/drm_mipi_dsi.h index 4fef19064b0f..89532ae69c91 100644 --- a/include/drm/drm_mipi_dsi.h +++ b/include/drm/drm_mipi_dsi.h @@ -107,6 +107,8 @@ struct mipi_dsi_host { int mipi_dsi_host_register(struct mipi_dsi_host *host); void mipi_dsi_host_unregister(struct mipi_dsi_host *host); struct mipi_dsi_host *of_find_mipi_dsi_host_by_node(struct device_node *node); +struct device_node *of_mipi_dsi_find_second_host(struct device_node *first_np, + int port, int endpoint); /* DSI mode flags */