From patchwork Sun Jun 14 17:22:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 11604061 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 50F1F1392 for ; Mon, 15 Jun 2020 07:28:38 +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 29A7520707 for ; Mon, 15 Jun 2020 07:28:38 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="EuuwpiMk" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 29A7520707 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.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 6DDA46E2B6; Mon, 15 Jun 2020 07:27:26 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-lf1-x143.google.com (mail-lf1-x143.google.com [IPv6:2a00:1450:4864:20::143]) by gabe.freedesktop.org (Postfix) with ESMTPS id 36CEC89E0D for ; Sun, 14 Jun 2020 17:23:21 +0000 (UTC) Received: by mail-lf1-x143.google.com with SMTP id c12so8130731lfc.10 for ; Sun, 14 Jun 2020 10:23:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=AU8aHNXSJicC/3mJ6DI0lDrv2zkNv1iB0kltJtsuQAw=; b=EuuwpiMkbbMKMls8xVM/R+dW4jTSovpLjRK+sPtMRrFMpHoHw/kpM0xivjB5l+3Wu3 XcUOjOxZDNoxCm9oFseCYWGMQ4vKztSVSKaiiekr0ZHPjmq71USjRbt3J8TPe3Km7Gqj 86xW1PapknQ65as28VSKdVfcrouIaRfG8tcHkG1XO8H0q1TQP2ev6QgYkXmf6yzttsN1 3+Qt1QJ4OnQcEEPRzCq/I/qpa7toX5wmOqFyYeMQJA8iqB8HECwkI+b4byv4eW8aSFdx DUVNa2qUVBn5Ue4ihyiX2OKpG5BslNmisbchP8GEm4WR8NFbkSb1bIk8yMxj4seYeMQ+ BnOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=AU8aHNXSJicC/3mJ6DI0lDrv2zkNv1iB0kltJtsuQAw=; b=OvMSxD0toNIiWtqUfjxlhu0QRo9STebClyjpJsyrlyU58csxTiByXsFxYJUmu+fnX0 Wm2HjYZy6YBgMfc1bO7/dxpjWIwMedypQ9jFybr92hmxIgIxl+zKeLawcAa28TtyXLzp uBanfSvhh+AxLCAndTs+eUM+rmMOUFP5Wmz9byWR7+sw7o4Hn0DX5s94oavFsxhwQJSm NAgWMN4toQrVLbmYRIPtjIE+Rguu+Ywvju7YB/wIoaKB/0JrqcS0dKHoIYK808i8Lo1x N8+899b1XdkdZF003IlJzjnhRU9B2rVTET2nzoPiZBdStfTKA/87SgOy4vXVAC+GDcbN N00Q== X-Gm-Message-State: AOAM532oQSbtE49HygCE9/ZZwLnDvfkfXOYSse5QXqXIrnyUHGuxYfv4 W4DLc8MYpKblphNWP2EavBI= X-Google-Smtp-Source: ABdhPJzCKQtPD6hDheFX6eXjxf0eeSg/hLqj0WyObz6WVWCknsTBezAKbLQH2/+sU3UDZqxB0Q3JGg== X-Received: by 2002:a19:356:: with SMTP id 83mr11724834lfd.179.1592155399430; Sun, 14 Jun 2020 10:23:19 -0700 (PDT) Received: from localhost.localdomain (79-139-237-54.dynamic.spd-mgts.ru. [79.139.237.54]) by smtp.gmail.com with ESMTPSA id m14sm55144lfp.18.2020.06.14.10.23.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 14 Jun 2020 10:23:18 -0700 (PDT) From: Dmitry Osipenko To: Thierry Reding , Sam Ravnborg , Laurent Pinchart , Rob Herring , Frank Rowand Subject: [PATCH v7 1/6] of_graph: add of_graph_get_local_port() Date: Sun, 14 Jun 2020 20:22:29 +0300 Message-Id: <20200614172234.8856-2-digetx@gmail.com> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200614172234.8856-1-digetx@gmail.com> References: <20200614172234.8856-1-digetx@gmail.com> MIME-Version: 1.0 X-Mailman-Approved-At: Mon, 15 Jun 2020 07:27:17 +0000 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: linux-tegra@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" In some case, like a DRM display code for example, it's useful to silently check whether port node exists at all in a device-tree before proceeding with parsing the graph. This patch adds of_graph_get_local_port() which returns pointer to a local port node, or NULL if graph isn't specified in a device-tree for a given device node. Reviewed-by: Rob Herring Reviewed-by: Sam Ravnborg Signed-off-by: Dmitry Osipenko --- drivers/of/property.c | 32 +++++++++++++++++++++++--------- include/linux/of_graph.h | 7 +++++++ 2 files changed, 30 insertions(+), 9 deletions(-) diff --git a/drivers/of/property.c b/drivers/of/property.c index 1f2086f4e7ce..05c5f619b8bb 100644 --- a/drivers/of/property.c +++ b/drivers/of/property.c @@ -608,15 +608,7 @@ struct device_node *of_graph_get_next_endpoint(const struct device_node *parent, * parent port node. */ if (!prev) { - struct device_node *node; - - node = of_get_child_by_name(parent, "ports"); - if (node) - parent = node; - - port = of_get_child_by_name(parent, "port"); - of_node_put(node); - + port = of_graph_get_local_port(parent); if (!port) { pr_err("graph: no port node found in %pOF\n", parent); return NULL; @@ -765,6 +757,28 @@ struct device_node *of_graph_get_remote_port(const struct device_node *node) } EXPORT_SYMBOL(of_graph_get_remote_port); +/** + * of_graph_get_local_port() - get local port node + * @node: pointer to a local endpoint device_node + * + * Return: First local port node associated with local endpoint node linked + * to @node. Use of_node_put() on it when done. + */ +struct device_node *of_graph_get_local_port(const struct device_node *node) +{ + struct device_node *ports, *port; + + ports = of_get_child_by_name(node, "ports"); + if (ports) + node = ports; + + port = of_get_child_by_name(node, "port"); + of_node_put(ports); + + return port; +} +EXPORT_SYMBOL(of_graph_get_local_port); + int of_graph_get_endpoint_count(const struct device_node *np) { struct device_node *endpoint; diff --git a/include/linux/of_graph.h b/include/linux/of_graph.h index 01038a6aade0..1fdeb72c7765 100644 --- a/include/linux/of_graph.h +++ b/include/linux/of_graph.h @@ -54,6 +54,7 @@ struct device_node *of_graph_get_remote_port_parent( struct device_node *of_graph_get_remote_port(const struct device_node *node); struct device_node *of_graph_get_remote_node(const struct device_node *node, u32 port, u32 endpoint); +struct device_node *of_graph_get_local_port(const struct device_node *node); #else static inline int of_graph_parse_endpoint(const struct device_node *node, @@ -116,6 +117,12 @@ static inline struct device_node *of_graph_get_remote_node( return NULL; } +static inline struct device_node *of_graph_get_local_port( + const struct device_node *node) +{ + return NULL; +} + #endif /* CONFIG_OF */ #endif /* __LINUX_OF_GRAPH_H */ From patchwork Sun Jun 14 17:22:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 11604099 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 290E7913 for ; Mon, 15 Jun 2020 07:29:18 +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 0765B2068E for ; Mon, 15 Jun 2020 07:29:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="E7gvBJJi" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0765B2068E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.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 A7C1D6E2B0; Mon, 15 Jun 2020 07:28:34 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-lj1-x241.google.com (mail-lj1-x241.google.com [IPv6:2a00:1450:4864:20::241]) by gabe.freedesktop.org (Postfix) with ESMTPS id 110C889E0D for ; Sun, 14 Jun 2020 17:23:22 +0000 (UTC) Received: by mail-lj1-x241.google.com with SMTP id c17so16383036lji.11 for ; Sun, 14 Jun 2020 10:23:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=VyQqkmAqCRmhebVrr7VbOeFm0zvD99iAEoTluAvbJX0=; b=E7gvBJJiMDzQ/hN1Q+zOkceklOE1WVsx+l7Iy9oVFXo5YdbJGaqXM1qt5YZ3j3zBoY 2JmV6Ixn9GR6yhMc8rvT1dcmt//FSyhkSfcqF1GebqLgCpUiZLapr6jsTRYRJTRq5d/C Z/HR33BZUAVEKxTTJs0RdooZEqN7qmnRgfJngaqFt6eEzh0F4qaKRJPSp61zuzhwCF0J 1OwGlGBGStNgq2Qh39E0tSs83Jmil03qwcc6RJpD1uus/SQSm4UVPvfisEahbNDFaOp+ HbW5eowMmTX36XcBG7Wdqhz0kOdKepyD3Rznmh9qZzafTkX2MVWIr6GcWMoclqep168B +EvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=VyQqkmAqCRmhebVrr7VbOeFm0zvD99iAEoTluAvbJX0=; b=KQNVpnxlwgkOK2EzDebRfqiNrfY8Y8FrkaUcKqTt0KogY/J6wz0B6pXJMV1VRzwct3 uLR9fUB/5rQPbjgvlyzOdIMZVjo6ZUkQJ4lB5fw0gLDlymTFayEUkzhZ3d+kNSRkiN0U SmjdE+n7vFG+uNjjy5Jv7aKcDgKY5uzQMXd4rkDYKe/4xTM5dfguyHXJkTAp1GBzQL9n uJeLOjHI562Nh153G1VxYr2qweIM3k+q9Gh0UAJGf1ZwB8XDtfHpsDJHZZTqbvIKOdm8 KdbWeDTDkXlcuajVJUXsONIjuMxjKuS5V6xJr40SLQ4sMHdYzIAwg0TjopZdoplIpQ8p 2ucQ== X-Gm-Message-State: AOAM530YHib5QtH9zr5jdTCHSIHXSEepqAgou+WBupp5QnwvvwVMZVjK 7wcSN/cB1bJKiZDNUa1/HYH67784 X-Google-Smtp-Source: ABdhPJxjKu9bib2Y/FR5d++QXjDAXCBR7MA6OqR8H3NBmnRWIAqCA7uBRZPeT0pH9/ki30A+N3Wr1A== X-Received: by 2002:a2e:954c:: with SMTP id t12mr6303730ljh.287.1592155400529; Sun, 14 Jun 2020 10:23:20 -0700 (PDT) Received: from localhost.localdomain (79-139-237-54.dynamic.spd-mgts.ru. [79.139.237.54]) by smtp.gmail.com with ESMTPSA id m14sm55144lfp.18.2020.06.14.10.23.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 14 Jun 2020 10:23:20 -0700 (PDT) From: Dmitry Osipenko To: Thierry Reding , Sam Ravnborg , Laurent Pinchart , Rob Herring , Frank Rowand Subject: [PATCH v7 2/6] drm/of: Make drm_of_find_panel_or_bridge() to check graph's presence Date: Sun, 14 Jun 2020 20:22:30 +0300 Message-Id: <20200614172234.8856-3-digetx@gmail.com> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200614172234.8856-1-digetx@gmail.com> References: <20200614172234.8856-1-digetx@gmail.com> MIME-Version: 1.0 X-Mailman-Approved-At: Mon, 15 Jun 2020 07:27:17 +0000 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: linux-tegra@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" When graph isn't defined in a device-tree, the of_graph_get_remote_node() prints a noisy error message, telling that port node is not found. This is undesirable behaviour in our case because absence of a panel/bridge graph is a valid case. Let's check presence of the local port in a device-tree before proceeding with parsing the graph. Reviewed-by: Sam Ravnborg Signed-off-by: Dmitry Osipenko --- drivers/gpu/drm/drm_of.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/drm_of.c b/drivers/gpu/drm/drm_of.c index b50b44e76279..e0652c38f357 100644 --- a/drivers/gpu/drm/drm_of.c +++ b/drivers/gpu/drm/drm_of.c @@ -239,13 +239,24 @@ int drm_of_find_panel_or_bridge(const struct device_node *np, struct drm_bridge **bridge) { int ret = -EPROBE_DEFER; - struct device_node *remote; + struct device_node *local, *remote; if (!panel && !bridge) return -EINVAL; if (panel) *panel = NULL; + /* + * of_graph_get_remote_node() produces a noisy error message if port + * node isn't found and the absence of the port is a legit case here, + * so at first we silently check presence of the local port. + */ + local = of_graph_get_local_port(np); + if (!local) + return -ENODEV; + + of_node_put(local); + remote = of_graph_get_remote_node(np, port, endpoint); if (!remote) return -ENODEV; From patchwork Sun Jun 14 17:22:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 11604055 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 7E8921392 for ; Mon, 15 Jun 2020 07:28:30 +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 5D22620738 for ; Mon, 15 Jun 2020 07:28:30 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="jX7MFaOw" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5D22620738 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.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 3C4166E2A8; Mon, 15 Jun 2020 07:27:25 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-lj1-x243.google.com (mail-lj1-x243.google.com [IPv6:2a00:1450:4864:20::243]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1BBDE89E0D for ; Sun, 14 Jun 2020 17:23:23 +0000 (UTC) Received: by mail-lj1-x243.google.com with SMTP id c17so16383067lji.11 for ; Sun, 14 Jun 2020 10:23:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=h/buGMp+Ss9uiUTlhYkjRB/SevbvsV7Suq67TOhl6lM=; b=jX7MFaOw3cExCgSaekXMQiFMv/ykxYaiV4t1aMfdM6ABkfwSen/ZrGgy+12hgi+r7Q q+72FwMZe4K1nHuX9cdGrxxAOywfo8z7x4qIC1IpLu8fm4i/7d98M309qR5nj2AD+5FY OJNX+EyWKohGRt8WNLBY+ePLkjZD6EGLjYoMwqm24LfowY2b8D5cJIpl7ubwIlhBuL5H unENs4NsWiU+Sz7EO0Kn+F6lk94UD7aK7VHGbD8SPepdrJGm16z2biCZYTFZNLASoiAc iP4BWAQujyinZ7D6PEBtv6fUC2PuWmSFqcLCTD6vP2aUXv4CUIw2fy+mDQgW5HWzbLHK yP3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=h/buGMp+Ss9uiUTlhYkjRB/SevbvsV7Suq67TOhl6lM=; b=ricilcD6uKqhJGglcO2N5AwgO/dfQT0zt3gqZRoq00IUoittMaOEnuz0X++reIuSaS Cxpho4b6q3oiukjhR/G+ga87dD2tyDq2eiP4DPAjq5dp47cnRfLsJO3grBSniYPsaBZ0 2qgrQlb0Qaq2QBMKdKw/hBKCaUMIXTTrUNO7iSYLp/7gQKd6nGGqsaDJGkkqehJ0GUIN 0wv4CYll27cpAlK3D3juE07Tb/e/+KK2NOuXrgBVwIVXatyJcRxgzxDS81iVv11cFeBq EsQilvsT77fuRxlH+PiD3apSTaih5Vy1FZEmht4JDVuWpCZcJdEV1ezB/urpBA4o0Z5j tEXw== X-Gm-Message-State: AOAM532fG3eecZODlD1whmwlJZq/WUobGjPIP81sr7joURJQ/sFzxRNQ jXH5MFynmGuKCkAyM2bacV8= X-Google-Smtp-Source: ABdhPJwSMAH7jtbReoRcuYHV06Fh8WgMrqBhXiLq3LLTXowtYAwZwDpcHXi+//vFWQlT9aXjggdY3Q== X-Received: by 2002:a2e:b0e3:: with SMTP id h3mr11925153ljl.16.1592155401538; Sun, 14 Jun 2020 10:23:21 -0700 (PDT) Received: from localhost.localdomain (79-139-237-54.dynamic.spd-mgts.ru. [79.139.237.54]) by smtp.gmail.com with ESMTPSA id m14sm55144lfp.18.2020.06.14.10.23.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 14 Jun 2020 10:23:21 -0700 (PDT) From: Dmitry Osipenko To: Thierry Reding , Sam Ravnborg , Laurent Pinchart , Rob Herring , Frank Rowand Subject: [PATCH v7 3/6] drm/tegra: output: Don't leak OF node on error Date: Sun, 14 Jun 2020 20:22:31 +0300 Message-Id: <20200614172234.8856-4-digetx@gmail.com> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200614172234.8856-1-digetx@gmail.com> References: <20200614172234.8856-1-digetx@gmail.com> MIME-Version: 1.0 X-Mailman-Approved-At: Mon, 15 Jun 2020 07:27:17 +0000 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: linux-tegra@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" The OF node should be put before returning error in tegra_output_probe(), otherwise node's refcount will be leaked. Reviewed-by: Laurent Pinchart Reviewed-by: Sam Ravnborg Signed-off-by: Dmitry Osipenko --- drivers/gpu/drm/tegra/output.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/tegra/output.c b/drivers/gpu/drm/tegra/output.c index e36e5e7c2f69..a6a711d54e88 100644 --- a/drivers/gpu/drm/tegra/output.c +++ b/drivers/gpu/drm/tegra/output.c @@ -102,10 +102,10 @@ int tegra_output_probe(struct tegra_output *output) panel = of_parse_phandle(output->of_node, "nvidia,panel", 0); if (panel) { output->panel = of_drm_find_panel(panel); + of_node_put(panel); + if (IS_ERR(output->panel)) return PTR_ERR(output->panel); - - of_node_put(panel); } output->edid = of_get_property(output->of_node, "nvidia,edid", &size); @@ -113,13 +113,12 @@ int tegra_output_probe(struct tegra_output *output) ddc = of_parse_phandle(output->of_node, "nvidia,ddc-i2c-bus", 0); if (ddc) { output->ddc = of_find_i2c_adapter_by_node(ddc); + of_node_put(ddc); + if (!output->ddc) { err = -EPROBE_DEFER; - of_node_put(ddc); return err; } - - of_node_put(ddc); } output->hpd_gpio = devm_gpiod_get_from_of_node(output->dev, From patchwork Sun Jun 14 17:22:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 11604027 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 A59EA913 for ; Mon, 15 Jun 2020 07:28:06 +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 83AB32068E for ; Mon, 15 Jun 2020 07:28:06 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Dqy6XNyL" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 83AB32068E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.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 5476E6E0DC; Mon, 15 Jun 2020 07:27:20 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-lj1-x244.google.com (mail-lj1-x244.google.com [IPv6:2a00:1450:4864:20::244]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0CBDE89E47 for ; Sun, 14 Jun 2020 17:23:24 +0000 (UTC) Received: by mail-lj1-x244.google.com with SMTP id 9so16393282ljv.5 for ; Sun, 14 Jun 2020 10:23:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=a5nZg8KheWIS8ObVaNA2RcCFchGpMXgRR/HHGM1BHBw=; b=Dqy6XNyLSpGzRAK8Mx2BZJwy8mQMfw9cJ4gG2HCuEejoyhoX1igZul80ku4k+6hGxl 8UF0ySu37m0omKHX5t0FvsIIflDE1n/SKPlGJyePW22HIzv4iRDLOJPyFfvXBKyjvujP k25eoAezusd38q28urO4RjKuVQX4Rrq0O2LTvI1w/y2EqQ6lXH/S4fguB998BNVhV7Gn dNaOJLhcTmc02Yd91VMo+aIWNUCE6lZ/2duOTdyDWNcS0/HTHIwTcSs+44upBtVIsGOh J37RR8mTcgyTZwF4xdNgqOPk7TPmxB1VvDskyB7acYlPP/eU9hvDbylanZbqTO3PQX/K vQ2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=a5nZg8KheWIS8ObVaNA2RcCFchGpMXgRR/HHGM1BHBw=; b=tFHp3Ff6txfgcpX51QY/bDBZtfxMeunMP9Bdwm/QNHmvTZaULD5wqTVFjCxfRSC/fu uC4GhZM8FG2PZU2PsoKcS9gNRVXK/siGIvHQhA5U/3AgvLlqtXMsMXKEa+bYI0VjY5U1 3triCreZVTZB1nJJT6Qll720aewGS/Hx45p7KU1obuexsGyjCW4ZD9ix28hXm8rCH292 g3enkPUS5dlGgqtw1T1FCPDsf8wQ5EzEGu7U6gYKRbwIaIlfFgMK+ARBj+BxBqcYKbUU +MAox8gdT79CXWX3H7pmnmGYuFBg9ThNKBbEVgoTT40pSx/nUVnwMy44V9YkIOh3VOx7 +d0w== X-Gm-Message-State: AOAM532ovwlNojyNA1Wbh7N2TqBBLzEPBl35W//G/zlU7X+vuJtupLjh CQXP4ThNqcIloNd/LYh0o5w= X-Google-Smtp-Source: ABdhPJwSz84D2Xlury2MH6eG3RCGtfat5pMgNh5ZeZ8BdFrpPl/5TrBUHqMqWjoU3cTBnLJPEyUmcw== X-Received: by 2002:a2e:b88c:: with SMTP id r12mr11057370ljp.266.1592155402510; Sun, 14 Jun 2020 10:23:22 -0700 (PDT) Received: from localhost.localdomain (79-139-237-54.dynamic.spd-mgts.ru. [79.139.237.54]) by smtp.gmail.com with ESMTPSA id m14sm55144lfp.18.2020.06.14.10.23.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 14 Jun 2020 10:23:22 -0700 (PDT) From: Dmitry Osipenko To: Thierry Reding , Sam Ravnborg , Laurent Pinchart , Rob Herring , Frank Rowand Subject: [PATCH v7 4/6] drm/tegra: output: Support DRM bridges Date: Sun, 14 Jun 2020 20:22:32 +0300 Message-Id: <20200614172234.8856-5-digetx@gmail.com> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200614172234.8856-1-digetx@gmail.com> References: <20200614172234.8856-1-digetx@gmail.com> MIME-Version: 1.0 X-Mailman-Approved-At: Mon, 15 Jun 2020 07:27:17 +0000 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: linux-tegra@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Newer Tegra device-trees will specify a video output graph which involves a bridge. This patch adds initial support for the DRM bridges to the Tegra DRM output. Acked-by: Sam Ravnborg Signed-off-by: Dmitry Osipenko --- drivers/gpu/drm/tegra/drm.h | 2 ++ drivers/gpu/drm/tegra/output.c | 12 ++++++++++++ 2 files changed, 14 insertions(+) diff --git a/drivers/gpu/drm/tegra/drm.h b/drivers/gpu/drm/tegra/drm.h index b25443255be6..f38de08e0c95 100644 --- a/drivers/gpu/drm/tegra/drm.h +++ b/drivers/gpu/drm/tegra/drm.h @@ -12,6 +12,7 @@ #include #include +#include #include #include #include @@ -116,6 +117,7 @@ struct tegra_output { struct device_node *of_node; struct device *dev; + struct drm_bridge *bridge; struct drm_panel *panel; struct i2c_adapter *ddc; const struct edid *edid; diff --git a/drivers/gpu/drm/tegra/output.c b/drivers/gpu/drm/tegra/output.c index a6a711d54e88..ccd1421f1b24 100644 --- a/drivers/gpu/drm/tegra/output.c +++ b/drivers/gpu/drm/tegra/output.c @@ -5,6 +5,7 @@ */ #include +#include #include #include @@ -99,8 +100,19 @@ int tegra_output_probe(struct tegra_output *output) if (!output->of_node) output->of_node = output->dev->of_node; + err = drm_of_find_panel_or_bridge(output->of_node, -1, -1, + &output->panel, &output->bridge); + if (err && err != -ENODEV) + return err; + panel = of_parse_phandle(output->of_node, "nvidia,panel", 0); if (panel) { + /* + * Don't mix nvidia,panel phandle with the graph in a + * device-tree. + */ + WARN_ON(output->panel || output->bridge); + output->panel = of_drm_find_panel(panel); of_node_put(panel); From patchwork Sun Jun 14 17:22:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 11604057 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 014EA913 for ; Mon, 15 Jun 2020 07:28:34 +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 D3C252068E for ; Mon, 15 Jun 2020 07:28:33 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="HQDJDQZC" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D3C252068E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.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 D32366E2DC; Mon, 15 Jun 2020 07:27:28 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-lj1-x243.google.com (mail-lj1-x243.google.com [IPv6:2a00:1450:4864:20::243]) by gabe.freedesktop.org (Postfix) with ESMTPS id 10E9789E9E for ; Sun, 14 Jun 2020 17:23:25 +0000 (UTC) Received: by mail-lj1-x243.google.com with SMTP id y11so16427286ljm.9 for ; Sun, 14 Jun 2020 10:23:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=bfaJuFdXozXDPR9zng+hgfPKlX3mT8FyISD1FTQ25bo=; b=HQDJDQZCB/xOQVZo2t6Fc/k3bSs8SMgo0QWAfN4dQfoQ1LINb2Kyzl2YimVdQPXszj P7IJoLJq4mexh79Re8BDkeoEFzFIWdI3AKivBUBAasbS8jAKLm3URdeMvc46FoxNRTYP 8g+Ffm3qJToMdpFD3NxmcptMbqbFl+dbNe1XK0ITwvLTxOfbRQIka36OtSIURZ9OB2dw +1eZkJmqZbzGyeotAvl56hp0QsS25Dk4REsJ9wgfS816WTDjmtxbr81CGfvsskpYwANx SNhUXfdvt7LDWSTNTSjejIOULBYtIRL5BeDuY2lxFxqyVU2w5wR3WLDiyq48MEBHsSIv XJHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=bfaJuFdXozXDPR9zng+hgfPKlX3mT8FyISD1FTQ25bo=; b=KBtUEKEHpkMlDNmgJhXPJdkGJR+gnWfslbw+sWvWfSpMIR9XDwmMhcICY/Gvlrzpn+ CPqiHMlxpZrCG54De4SzCbEYeA+d6kLYu1wXhNBxE95MHVnINmvB31ROIQ0QZdXenTAG V9Lua44wisNARv3PDPZlWwuOcVEjue5aKDBMs8+k7i7rDoYQrNnOUNfiV1GaiIol10D+ ATOoDHh+6cpx++rZm0fxb9nl74LjIioF+CCb4z1RhZ6y8hnJR3fPqfQVdtLPlzlcbGiD C1yff7eMZZHJA73L9sk/WnxknoPtitYuftNyoatR+l/p9SQE77lAc3JkRuj5fxSbsTM2 fkgQ== X-Gm-Message-State: AOAM531Bw/VGaEGaVSVqHNuHQoqrjrJMXBLitcW6jdgNcgBQ2+125txS MUj6oHds19r789Go5sH+JC6Goy5p X-Google-Smtp-Source: ABdhPJydsb3itiYMRywNC5ifF4Kc/5EdonKXAtEm8tYm6mo/Q8ZftpEz4mh0PXzhyD+30VDVunJPtQ== X-Received: by 2002:a2e:b4a5:: with SMTP id q5mr10853627ljm.186.1592155403476; Sun, 14 Jun 2020 10:23:23 -0700 (PDT) Received: from localhost.localdomain (79-139-237-54.dynamic.spd-mgts.ru. [79.139.237.54]) by smtp.gmail.com with ESMTPSA id m14sm55144lfp.18.2020.06.14.10.23.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 14 Jun 2020 10:23:23 -0700 (PDT) From: Dmitry Osipenko To: Thierry Reding , Sam Ravnborg , Laurent Pinchart , Rob Herring , Frank Rowand Subject: [PATCH v7 5/6] drm/tegra: output: rgb: Support LVDS encoder bridge Date: Sun, 14 Jun 2020 20:22:33 +0300 Message-Id: <20200614172234.8856-6-digetx@gmail.com> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200614172234.8856-1-digetx@gmail.com> References: <20200614172234.8856-1-digetx@gmail.com> MIME-Version: 1.0 X-Mailman-Approved-At: Mon, 15 Jun 2020 07:27:17 +0000 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: linux-tegra@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Newer Tegra device-trees will specify a video output graph, which involves LVDS encoder bridge. This patch adds support for the LVDS encoder bridge to the RGB output, allowing us to model the display hardware properly. Reviewed-by: Laurent Pinchart Acked-by: Sam Ravnborg Signed-off-by: Dmitry Osipenko --- drivers/gpu/drm/tegra/rgb.c | 58 +++++++++++++++++++++++++++++++------ 1 file changed, 49 insertions(+), 9 deletions(-) diff --git a/drivers/gpu/drm/tegra/rgb.c b/drivers/gpu/drm/tegra/rgb.c index 0562a7eb793f..9a7024ec96bc 100644 --- a/drivers/gpu/drm/tegra/rgb.c +++ b/drivers/gpu/drm/tegra/rgb.c @@ -7,6 +7,7 @@ #include #include +#include #include #include @@ -267,24 +268,63 @@ int tegra_dc_rgb_remove(struct tegra_dc *dc) int tegra_dc_rgb_init(struct drm_device *drm, struct tegra_dc *dc) { struct tegra_output *output = dc->rgb; + struct drm_connector *connector; int err; if (!dc->rgb) return -ENODEV; - drm_connector_init(drm, &output->connector, &tegra_rgb_connector_funcs, - DRM_MODE_CONNECTOR_LVDS); - drm_connector_helper_add(&output->connector, - &tegra_rgb_connector_helper_funcs); - output->connector.dpms = DRM_MODE_DPMS_OFF; - drm_simple_encoder_init(drm, &output->encoder, DRM_MODE_ENCODER_LVDS); drm_encoder_helper_add(&output->encoder, &tegra_rgb_encoder_helper_funcs); - drm_connector_attach_encoder(&output->connector, - &output->encoder); - drm_connector_register(&output->connector); + /* + * Tegra devices that have LVDS panel utilize LVDS encoder bridge + * for converting up to 28 LCD LVTTL lanes into 5/4 LVDS lanes that + * go to display panel's receiver. + * + * Encoder usually have a power-down control which needs to be enabled + * in order to transmit data to the panel. Historically devices that + * use an older device-tree version didn't model the bridge, assuming + * that encoder is turned ON by default, while today's DRM allows us + * to model LVDS encoder properly. + * + * Newer device-trees utilize LVDS encoder bridge, which provides + * us with a connector and handles the display panel. + * + * For older device-trees we fall back to our own connector and use + * nvidia,panel phandle. + */ + if (output->bridge) { + err = drm_bridge_attach(&output->encoder, output->bridge, + NULL, DRM_BRIDGE_ATTACH_NO_CONNECTOR); + if (err) { + dev_err(output->dev, "failed to attach bridge: %d\n", + err); + return err; + } + + connector = drm_bridge_connector_init(drm, &output->encoder); + if (IS_ERR(connector)) { + dev_err(output->dev, + "failed to initialize bridge connector: %pe\n", + connector); + return PTR_ERR(connector); + } + + drm_connector_attach_encoder(connector, &output->encoder); + } else { + drm_connector_init(drm, &output->connector, + &tegra_rgb_connector_funcs, + DRM_MODE_CONNECTOR_LVDS); + drm_connector_helper_add(&output->connector, + &tegra_rgb_connector_helper_funcs); + output->connector.dpms = DRM_MODE_DPMS_OFF; + + drm_connector_attach_encoder(&output->connector, + &output->encoder); + drm_connector_register(&output->connector); + } err = tegra_output_init(drm, output); if (err < 0) { From patchwork Sun Jun 14 17:22:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 11604047 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 DFE73913 for ; Mon, 15 Jun 2020 07:28:22 +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 BE2372068E for ; Mon, 15 Jun 2020 07:28:22 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="sUM+61bH" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BE2372068E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.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 540DD6E13D; Mon, 15 Jun 2020 07:27:21 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-lj1-x244.google.com (mail-lj1-x244.google.com [IPv6:2a00:1450:4864:20::244]) by gabe.freedesktop.org (Postfix) with ESMTPS id 2039C89EB1 for ; Sun, 14 Jun 2020 17:23:26 +0000 (UTC) Received: by mail-lj1-x244.google.com with SMTP id c17so16383148lji.11 for ; Sun, 14 Jun 2020 10:23:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=37Z3HYJxY12m2q1zLLMVAo9a4Krobq6zohBrdzALyVQ=; b=sUM+61bHMTQwyYxyYmN3fSPDw7/38uK50F0zfc7/YI9dEkVzyM9NDOvp2JksQFxlp5 +XXYcNtE6bwKD1ZtEgCTqYbjoKGJUk9bFlSM7g7PCqKJLuNbskX9LlACSXwTrgLzq+zK nIIkNqncpoEs6GazHlCOxHv9tVrGbnBki3ob+PiT9cP4TBBmfSfBZKtE5K6Y9vT3iaw9 YyDnfQ6O/jedLLqaOUACuoh7l6pXCyG/CGAupZ4k8xPzrjheB0PwD97CVU9RSxwek/tN K0CsnhRxmA4w6XasvfzFQ7yqEOfRH8CLbhoPum1rJly1ylZ7qxjWtnH0seb1nKRGI2SQ wY0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=37Z3HYJxY12m2q1zLLMVAo9a4Krobq6zohBrdzALyVQ=; b=RgDuajWzhmbrW/gfPvKDC09tuBYlYUbfJWmZNb4S5sN1RpvS1Q0X7uJ0B/uDz6TmYI aHssf6CciLwHKa6KJQikpfnBdVx0Nh/D7zf00RWcS/aFJ7MRrtowaNWF9PUAAWCMUba4 bZmGts510PbO3IiXvdB+ICWnOr/vr33E+r3iNyY3MOwInL1j73otLmvdb3/Lpvax8dH1 s5RkbB7bEVT7d8MCKQL3P+9+PoT19mEtqtOXTf83Qg6Lx8wmOAxMmgWjNAwpXxnUw2e6 7ONYaErJw97xJFqzKZJUGDXsWRGy/OgKXhYCqo/6R7a/LM9/QKshx6MsjW3yLj3zl9f3 C0mw== X-Gm-Message-State: AOAM532d6IqaCfC99Rwizvo+HXkFpB3xYIGY5bAhfbBDT+W0XNbM4VUC 516xm2LBLb6XONGV/QV8at4= X-Google-Smtp-Source: ABdhPJwJkmicC3yQWMn1EaHLj6NqgXGyVJXWs5uV2d/dqFdB4aC3XCOIC1NQbPfRIz+w9Luv9PWQ2w== X-Received: by 2002:a2e:82ce:: with SMTP id n14mr12022057ljh.9.1592155404533; Sun, 14 Jun 2020 10:23:24 -0700 (PDT) Received: from localhost.localdomain (79-139-237-54.dynamic.spd-mgts.ru. [79.139.237.54]) by smtp.gmail.com with ESMTPSA id m14sm55144lfp.18.2020.06.14.10.23.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 14 Jun 2020 10:23:24 -0700 (PDT) From: Dmitry Osipenko To: Thierry Reding , Sam Ravnborg , Laurent Pinchart , Rob Herring , Frank Rowand Subject: [PATCH v7 6/6] drm/tegra: output: rgb: Wrap directly-connected panel into DRM bridge Date: Sun, 14 Jun 2020 20:22:34 +0300 Message-Id: <20200614172234.8856-7-digetx@gmail.com> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200614172234.8856-1-digetx@gmail.com> References: <20200614172234.8856-1-digetx@gmail.com> MIME-Version: 1.0 X-Mailman-Approved-At: Mon, 15 Jun 2020 07:27:17 +0000 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: linux-tegra@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Currently Tegra DRM driver manually manages display panel, but this management could be moved out into DRM core if we'll wrap panel into DRM bridge. This patch wraps RGB panel into a DRM bridge and removes manual handling of the panel from the RGB output code. Suggested-by: Laurent Pinchart Acked-by: Sam Ravnborg Signed-off-by: Dmitry Osipenko --- drivers/gpu/drm/tegra/rgb.c | 70 ++++++++++--------------------------- 1 file changed, 18 insertions(+), 52 deletions(-) diff --git a/drivers/gpu/drm/tegra/rgb.c b/drivers/gpu/drm/tegra/rgb.c index 9a7024ec96bc..4142a56ca764 100644 --- a/drivers/gpu/drm/tegra/rgb.c +++ b/drivers/gpu/drm/tegra/rgb.c @@ -8,7 +8,6 @@ #include #include -#include #include #include "drm.h" @@ -86,45 +85,13 @@ static void tegra_dc_write_regs(struct tegra_dc *dc, tegra_dc_writel(dc, table[i].value, table[i].offset); } -static const struct drm_connector_funcs tegra_rgb_connector_funcs = { - .reset = drm_atomic_helper_connector_reset, - .detect = tegra_output_connector_detect, - .fill_modes = drm_helper_probe_single_connector_modes, - .destroy = tegra_output_connector_destroy, - .atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state, - .atomic_destroy_state = drm_atomic_helper_connector_destroy_state, -}; - -static enum drm_mode_status -tegra_rgb_connector_mode_valid(struct drm_connector *connector, - struct drm_display_mode *mode) -{ - /* - * FIXME: For now, always assume that the mode is okay. There are - * unresolved issues with clk_round_rate(), which doesn't always - * reliably report whether a frequency can be set or not. - */ - return MODE_OK; -} - -static const struct drm_connector_helper_funcs tegra_rgb_connector_helper_funcs = { - .get_modes = tegra_output_connector_get_modes, - .mode_valid = tegra_rgb_connector_mode_valid, -}; - static void tegra_rgb_encoder_disable(struct drm_encoder *encoder) { struct tegra_output *output = encoder_to_output(encoder); struct tegra_rgb *rgb = to_rgb(output); - if (output->panel) - drm_panel_disable(output->panel); - tegra_dc_write_regs(rgb->dc, rgb_disable, ARRAY_SIZE(rgb_disable)); tegra_dc_commit(rgb->dc); - - if (output->panel) - drm_panel_unprepare(output->panel); } static void tegra_rgb_encoder_enable(struct drm_encoder *encoder) @@ -133,9 +100,6 @@ static void tegra_rgb_encoder_enable(struct drm_encoder *encoder) struct tegra_rgb *rgb = to_rgb(output); u32 value; - if (output->panel) - drm_panel_prepare(output->panel); - tegra_dc_write_regs(rgb->dc, rgb_enable, ARRAY_SIZE(rgb_enable)); value = DE_SELECT_ACTIVE | DE_CONTROL_NORMAL; @@ -157,9 +121,6 @@ static void tegra_rgb_encoder_enable(struct drm_encoder *encoder) tegra_dc_writel(rgb->dc, value, DC_DISP_SHIFT_CLOCK_OPTIONS); tegra_dc_commit(rgb->dc); - - if (output->panel) - drm_panel_enable(output->panel); } static int @@ -278,6 +239,23 @@ int tegra_dc_rgb_init(struct drm_device *drm, struct tegra_dc *dc) drm_encoder_helper_add(&output->encoder, &tegra_rgb_encoder_helper_funcs); + /* + * Wrap directly-connected panel into DRM bridge in order to let + * DRM core to handle panel for us. + */ + if (output->panel) { + output->bridge = devm_drm_panel_bridge_add(output->dev, + output->panel); + if (IS_ERR(output->bridge)) { + dev_err(output->dev, + "failed to wrap panel into bridge: %pe\n", + output->bridge); + return PTR_ERR(output->bridge); + } + + output->panel = NULL; + } + /* * Tegra devices that have LVDS panel utilize LVDS encoder bridge * for converting up to 28 LCD LVTTL lanes into 5/4 LVDS lanes that @@ -292,8 +270,7 @@ int tegra_dc_rgb_init(struct drm_device *drm, struct tegra_dc *dc) * Newer device-trees utilize LVDS encoder bridge, which provides * us with a connector and handles the display panel. * - * For older device-trees we fall back to our own connector and use - * nvidia,panel phandle. + * For older device-trees we wrapped panel into the panel-bridge. */ if (output->bridge) { err = drm_bridge_attach(&output->encoder, output->bridge, @@ -313,17 +290,6 @@ int tegra_dc_rgb_init(struct drm_device *drm, struct tegra_dc *dc) } drm_connector_attach_encoder(connector, &output->encoder); - } else { - drm_connector_init(drm, &output->connector, - &tegra_rgb_connector_funcs, - DRM_MODE_CONNECTOR_LVDS); - drm_connector_helper_add(&output->connector, - &tegra_rgb_connector_helper_funcs); - output->connector.dpms = DRM_MODE_DPMS_OFF; - - drm_connector_attach_encoder(&output->connector, - &output->encoder); - drm_connector_register(&output->connector); } err = tegra_output_init(drm, output);