From patchwork Wed Jun 17 22:26:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 11611551 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 C47D8618 for ; Thu, 18 Jun 2020 07:18:32 +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 A31CB21532 for ; Thu, 18 Jun 2020 07:18:32 +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="dwdklXAy" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A31CB21532 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 3E7646EB19; Thu, 18 Jun 2020 07:17:37 +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 3A7676E190 for ; Wed, 17 Jun 2020 22:27:57 +0000 (UTC) Received: by mail-lj1-x243.google.com with SMTP id i3so4881141ljg.3 for ; Wed, 17 Jun 2020 15:27:56 -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=ctWQ9TZFDyYjy41m/bWYQmrPw1HpGYc8fpv1hjZ0KQo=; b=dwdklXAyAFHJ23dbH03q3jAUtq32OHCptiGtSVxoBCUYeso8+WqA8A3bizGuDPU+gv oHqGwfOcvTDr4l1aQqut40IA7a72w/rxkeB0xhQQt5NXh46g68JVMYBrhzcd9Cy1uS9x hV/RWVaPq9jgBivD97/qgxpKcTmnyfcz7zzrrlUQjjMe1G68EdaKfIpEs5OkLRaqNofe 1WqgUDWkrCdKh3s6VS5PLcUnEvzaCp+B9WC2ztT6UnRgusIhz7Y/KNhqeZt7EROiL3in b5DAcTGgpErJRuq5SUt1ohcAaLk6wNFXzx35XUedJ+z8PxdU7ouvHR2/htPkD/qlhLRl /Wfg== 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=ctWQ9TZFDyYjy41m/bWYQmrPw1HpGYc8fpv1hjZ0KQo=; b=RiEYW7w8xAVxrQqR6XQl9T9oJfkVa9YQtVwKvC8bjlmxjNxQqVmPSORHD8N12dIpcD Tw5FeELajK0hkqaE/WyC6X4YlNOWHlVgkPhe72EIUxjxc3Mo9zDhv08rZb2SvdJTSOJd NyNoRYpri0MXnifk5BweNFa68OP6e/RJe37RdTAWVpz6L8MMSTCJ6aCdwzP4y7WeYS4S Ybch3kYx6uVuZRuaNkuIZRoF/7+06QOm5ZrPjvwR83gmafmGQ2YlZ2z0yewNSFdGB/20 XQ2G+8fxPO3G1OkVKEf9Iji93nrb0M+il9AcVaZz2xwIoDN/oTEVqPBKm1O/TFPE48Us ks3A== X-Gm-Message-State: AOAM531J6RbPBpIxMmoOe8P8BeIAobPa9miAdgnWwWiXDRT5u1Y+X1i6 xdCThRc+R77Jzj0vrrUZu68= X-Google-Smtp-Source: ABdhPJwkoTaH4WuZGpqJFoZ45uqBFI0iXLbYRGzllThvZoBuBs9UOOEuxcDKPe9JyThvyYJ1kM5KiA== X-Received: by 2002:a2e:891a:: with SMTP id d26mr710439lji.384.1592432875401; Wed, 17 Jun 2020 15:27:55 -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 a1sm210378ljk.133.2020.06.17.15.27.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Jun 2020 15:27:54 -0700 (PDT) From: Dmitry Osipenko To: Thierry Reding , Sam Ravnborg , Laurent Pinchart , Rob Herring , Frank Rowand Subject: [PATCH v8 1/7] of_graph: add of_graph_presents() Date: Thu, 18 Jun 2020 01:26:57 +0300 Message-Id: <20200617222703.17080-2-digetx@gmail.com> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200617222703.17080-1-digetx@gmail.com> References: <20200617222703.17080-1-digetx@gmail.com> MIME-Version: 1.0 X-Mailman-Approved-At: Thu, 18 Jun 2020 07:17:31 +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 of the graph. This patch adds of_graph_presents() that returns true if given device-tree node contains OF graph port. Signed-off-by: Dmitry Osipenko Reviewed-by: Rob Herring --- drivers/of/property.c | 52 +++++++++++++++++++++++++++++++++------- include/linux/of_graph.h | 6 +++++ 2 files changed, 49 insertions(+), 9 deletions(-) diff --git a/drivers/of/property.c b/drivers/of/property.c index 1f2086f4e7ce..b84ed6a7cf50 100644 --- a/drivers/of/property.c +++ b/drivers/of/property.c @@ -29,6 +29,48 @@ #include "of_private.h" +/** + * of_graph_get_first_local_port() - get first 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. + */ +static struct device_node * +of_graph_get_first_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; +} + +/** + * of_graph_presents() - check graph's presence + * @node: pointer to a device_node checked for the graph's presence + * + * Return: True if @node has a port or ports sub-node, false otherwise. + */ +bool of_graph_presents(const struct device_node *node) +{ + struct device_node *local; + + local = of_graph_get_first_local_port(node); + if (!local) + return false; + + of_node_put(local); + + return true; +} +EXPORT_SYMBOL(of_graph_presents); + /** * of_property_count_elems_of_size - Count the number of elements in a property * @@ -608,15 +650,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_first_local_port(parent); if (!port) { pr_err("graph: no port node found in %pOF\n", parent); return NULL; diff --git a/include/linux/of_graph.h b/include/linux/of_graph.h index 01038a6aade0..cc3028a0659d 100644 --- a/include/linux/of_graph.h +++ b/include/linux/of_graph.h @@ -38,6 +38,7 @@ struct of_endpoint { child = of_graph_get_next_endpoint(parent, child)) #ifdef CONFIG_OF +bool of_graph_presents(const struct device_node *node); int of_graph_parse_endpoint(const struct device_node *node, struct of_endpoint *endpoint); int of_graph_get_endpoint_count(const struct device_node *np); @@ -56,6 +57,11 @@ struct device_node *of_graph_get_remote_node(const struct device_node *node, u32 port, u32 endpoint); #else +static inline bool of_graph_presents(const struct device_node *node) +{ + return false; +} + static inline int of_graph_parse_endpoint(const struct device_node *node, struct of_endpoint *endpoint) { From patchwork Wed Jun 17 22:26:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 11611553 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 CB6CB618 for ; Thu, 18 Jun 2020 07:18: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 AA89621532 for ; Thu, 18 Jun 2020 07:18: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="isbpr2Sx" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AA89621532 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 7A48B6EB1C; Thu, 18 Jun 2020 07:17:37 +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 19A446E190 for ; Wed, 17 Jun 2020 22:27:58 +0000 (UTC) Received: by mail-lj1-x243.google.com with SMTP id 9so4856554ljv.5 for ; Wed, 17 Jun 2020 15:27:58 -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=D2TQMn0dQ091Nqq+EmKWvf4EfULgSTe0SpqhYi3GcPk=; b=isbpr2SxlqW0J3J2CicBxq53fq28gMmg7YC/eQiXUTn9g8m1Gd6Or6C46Ub3yzaEPf BcvWGAqobcTCh3f4tPMWdWA5ME0RP5TJ/6+67rSMdNS5OTaIYhuE2RrZ5cFC8havF97R duxVfwbCfPK40vjgiyD7IodPZS4NJ0Ngbe4qBkzSovstySRusBj7BsUNLLw4my3yrnSu tc1sF0fwqJgDMlfwGql3o0WQmtsDmtjsXFFA2Yk3SzBQDfj21q4KL4adVx+IOSlLguQm FBeDVj8+86w0ZVNsJqIaJD7OTEhUItm7Zw3z94Bft5UE1kuH3XHlkDux1vIZr2AQJ3Gh Qxlg== 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=D2TQMn0dQ091Nqq+EmKWvf4EfULgSTe0SpqhYi3GcPk=; b=Bug03G/RB6e7Ma/D1Y5NoWRDkS+BeqVChzCCIhpnOIvVH886vig9neXHbFwRpVxs9a v5Ht0y25Kceg8dw4O7S/ezSmx9cQ5lc4RCBHbhJmpUf4khxqdsD0o009xJFv5VZrz0d9 nY0gB2KpcY+3XjlRpY9VQ8NungCGpbI8JYRqP94oiRlHlw2WXpLHMa1PpwkPfe030gJJ GcLvfCsjzUibCznml2ldDqTbznezlmdR7PFrHVHmYw2xgpdwSRKDSr8iv/MHrxiVp4sk VQ0v+0Ewzy3T6+c8YUIljs5v05R8IMja+cYygBQTtClM8kxouInjxDPCAIT89z2GE7mt A/3w== X-Gm-Message-State: AOAM530YfbZy5+DUTAKwc6JeNVW7gFkE6vNwrxKPfmw57o8FAJeEeTTj m/L8JIu3AxJokVy7CZf8Zz09C+MQ X-Google-Smtp-Source: ABdhPJxKn69Kc7DDNBEVuTIu09JjZKMVsMFj3derjbFs4KULA24ehv/AJiph5bFIewzvvXMssVFclA== X-Received: by 2002:a2e:b051:: with SMTP id d17mr674285ljl.254.1592432876539; Wed, 17 Jun 2020 15:27:56 -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 a1sm210378ljk.133.2020.06.17.15.27.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Jun 2020 15:27:56 -0700 (PDT) From: Dmitry Osipenko To: Thierry Reding , Sam Ravnborg , Laurent Pinchart , Rob Herring , Frank Rowand Subject: [PATCH v8 2/7] drm/of: Make drm_of_find_panel_or_bridge() to check graph's presence Date: Thu, 18 Jun 2020 01:26:58 +0300 Message-Id: <20200617222703.17080-3-digetx@gmail.com> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200617222703.17080-1-digetx@gmail.com> References: <20200617222703.17080-1-digetx@gmail.com> MIME-Version: 1.0 X-Mailman-Approved-At: Thu, 18 Jun 2020 07:17:31 +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 the graph's presence in a device-tree before proceeding with parsing of the graph. Reviewed-by: Sam Ravnborg Signed-off-by: Dmitry Osipenko --- drivers/gpu/drm/drm_of.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/gpu/drm/drm_of.c b/drivers/gpu/drm/drm_of.c index b50b44e76279..cbe65efdae39 100644 --- a/drivers/gpu/drm/drm_of.c +++ b/drivers/gpu/drm/drm_of.c @@ -246,6 +246,15 @@ int drm_of_find_panel_or_bridge(const struct device_node *np, 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 whether graph presents in the + * device-tree node. + */ + if (!of_graph_presents(np)) + return -ENODEV; + remote = of_graph_get_remote_node(np, port, endpoint); if (!remote) return -ENODEV; From patchwork Wed Jun 17 22:26:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 11611531 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 0D649618 for ; Thu, 18 Jun 2020 07:18:13 +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 E094421532 for ; Thu, 18 Jun 2020 07:18:12 +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="D/CVSkO2" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E094421532 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 277266EADF; Thu, 18 Jun 2020 07:17:35 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-lj1-x242.google.com (mail-lj1-x242.google.com [IPv6:2a00:1450:4864:20::242]) by gabe.freedesktop.org (Postfix) with ESMTPS id 2C17A882AF for ; Wed, 17 Jun 2020 22:27:59 +0000 (UTC) Received: by mail-lj1-x242.google.com with SMTP id z9so4820173ljh.13 for ; Wed, 17 Jun 2020 15:27:59 -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=D/CVSkO2CC++b8uBZgrP1E+qFdW4kJcztCNPpHH9x6AGt9kFw3c7ePV/phmO6Ng6ZB SOztQqoE/nYP7nhphM/Mt7GHf61uh37odiZzuIGY8uwlBYzqZjlMt5XxrcGjMndKN4rK qHPhSrd2y8guyLfFlejAen4aMP75xpwznOcKOZdsEXMK+GtsBkLGCSTKH6Ts+T6xYiKJ DFw/cvwh5lsHR7uNk7jt+ZKNjaHwPR6Pp6+mMxeSvFpW2C2IVh8BOX73d7CussyW7Ufk krsN2+lCDNs06zdNF5YvW4O53FVoAsjG+PHF/pi33iMXUUh/ys1cHePLnlpjE6vhuEem AHAQ== 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=HJYwIlNnjcSZ85+BoKZhvQjAvxtd+qBK6+CLMnm/QYNESvHy7wC06KUIZQz+yXo3FC VrtFK2qu4TrGpFk8iq+bX/6E2wD5lmA8onqK2QwB4OMBTracpAow7DI/YUswdAhlzsVr z+xvR9H8ud/yXzBmnlK62ZN5TUUUdkv8VgkMRPYvTsz3O1dQQDesXc9Onndg4uRr9UrB gH0e5NMnPiILIpBvQyIm5bFI7vkuSMSOzqeJZ9Yh7lZoR4FLoKk9MZzZmC5aSauUz6F8 KUq4GVyTCCAnIFn/GsutrEW3G0Ttb/JfG+TyLYLv0uCNuzPviUHWCtJl+ZM1wHwo23oP 5zPQ== X-Gm-Message-State: AOAM532PAfbtFn7lRRU11Cr8VNZzYuw3vwFIs2uyDoB9SapqL++YdQKX NzaHooNmkGxEjTgd2JEYbN7o4fE2 X-Google-Smtp-Source: ABdhPJz0MyoPM7RAlYae5zeKJonCtS9xXXa02ONOLAjERMK8yve0QEl8ro8GhLlHMxRQ43L058CrCg== X-Received: by 2002:a2e:8994:: with SMTP id c20mr719571lji.378.1592432877594; Wed, 17 Jun 2020 15:27:57 -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 a1sm210378ljk.133.2020.06.17.15.27.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Jun 2020 15:27:57 -0700 (PDT) From: Dmitry Osipenko To: Thierry Reding , Sam Ravnborg , Laurent Pinchart , Rob Herring , Frank Rowand Subject: [PATCH v8 3/7] drm/tegra: output: Don't leak OF node on error Date: Thu, 18 Jun 2020 01:26:59 +0300 Message-Id: <20200617222703.17080-4-digetx@gmail.com> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200617222703.17080-1-digetx@gmail.com> References: <20200617222703.17080-1-digetx@gmail.com> MIME-Version: 1.0 X-Mailman-Approved-At: Thu, 18 Jun 2020 07:17:31 +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 Wed Jun 17 22:27:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 11611543 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 EC9E614B7 for ; Thu, 18 Jun 2020 07:18: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 CB82F21548 for ; Thu, 18 Jun 2020 07:18: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="W6fRa05D" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CB82F21548 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 BD7456EB12; Thu, 18 Jun 2020 07:17:36 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-lj1-x242.google.com (mail-lj1-x242.google.com [IPv6:2a00:1450:4864:20::242]) by gabe.freedesktop.org (Postfix) with ESMTPS id 31932892A1 for ; Wed, 17 Jun 2020 22:28:00 +0000 (UTC) Received: by mail-lj1-x242.google.com with SMTP id n24so4827225lji.10 for ; Wed, 17 Jun 2020 15:28:00 -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=W6fRa05DMd5iUXT65xEWeMDU5c+C8e53g2PTD+NY5ci+/e7IuGGJJE2Bj/v1m+W38k yztIM0u+sakc6Wmhc05kLzSKqcP3TUvr+46f6vauwZ3zTeV9GYGfdeT+rDMsm4w6niW5 nDpZ7JKOIY/77pavIswi9UR4m/psn7lNTtNuJEruPntOzhjCMcrO4/IUdyGh2Xxs8GQl LftzTXaEvcSptQxasV8M9zrTN+kGfaAafeDMKPGMToKT/Fhrm12/x2XxGNpe4pBN3XmG wNIoeHixCOQURG3ashZTasqfIhNbVXFtqh6cRqGEO0OYo0PXPAcuxGWKqhP7itVVByag 3T7A== 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=iEt19ebcorLdWLr4gPJaP2pFN4A2Y6Cdj3duPIVJCv0EjXdKXL3hcS2THMgdtNao5l 91HqXOpmK6XaOzLlIq/hNotB0q9SrP3N1zZhwL4D1YCmIn1p83W+b6jYE+WXqIdBrKRz SqVgCFtTM1n5Rv1+iMpKKYrg+8QgxdFNUdYtr2AtqA+vjBbz6CmNFdW6bVPirqOl1RoY 8RxCjjI3YdTBXDpxtSnAitwkeyD4EaUzVCP4YsMW0Xr5q89cjm0lznR43T5i6mj3uKDp PaH5JRwZQynvXLSHtnEeo/eSW6y0dELjbSxzRw+buXs6XJKDf7Ee3itrV8DXrAEc3Tw5 Zd7g== X-Gm-Message-State: AOAM532i352NCmkx+Drm5XLQ7pznyaKzEzkqdqHgK69H1YBdMhGAzUhy whgRk15YWtwbrmi1DY830xs= X-Google-Smtp-Source: ABdhPJz09K4xYG7RHHMCEu95XlB0Ky4jivwqb/WBQsRuNgWFJrSXFINjMfowbCP5/Jy5ZCbJsdYnnQ== X-Received: by 2002:a2e:8690:: with SMTP id l16mr623699lji.462.1592432878644; Wed, 17 Jun 2020 15:27:58 -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 a1sm210378ljk.133.2020.06.17.15.27.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Jun 2020 15:27:58 -0700 (PDT) From: Dmitry Osipenko To: Thierry Reding , Sam Ravnborg , Laurent Pinchart , Rob Herring , Frank Rowand Subject: [PATCH v8 4/7] drm/tegra: output: Support DRM bridges Date: Thu, 18 Jun 2020 01:27:00 +0300 Message-Id: <20200617222703.17080-5-digetx@gmail.com> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200617222703.17080-1-digetx@gmail.com> References: <20200617222703.17080-1-digetx@gmail.com> MIME-Version: 1.0 X-Mailman-Approved-At: Thu, 18 Jun 2020 07:17:31 +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 Wed Jun 17 22:27:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 11611557 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 F31A914B7 for ; Thu, 18 Jun 2020 07:18:41 +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 D1A1821532 for ; Thu, 18 Jun 2020 07:18:41 +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="RB0qgOeu" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D1A1821532 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 0046D6EB1E; Thu, 18 Jun 2020 07:17:40 +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 4930D89B33 for ; Wed, 17 Jun 2020 22:28:01 +0000 (UTC) Received: by mail-lj1-x244.google.com with SMTP id 9so4852989ljc.8 for ; Wed, 17 Jun 2020 15:28:01 -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=RB0qgOeuHzO9YByplvGAQRyt/Yr043gU/Lo8HSOPsbx05BvHAqi2Y2x/jvJAhzFNRd DCjkwxcymDnKrF2Fyn38XzoCynZEFsV1VK0CZkvtQiSl4+p2aHD2iHEwlqjdOSsqL+I6 ECzpgzryGtPy76f0/J8Ri4mSwOzLnayi2X8VezIyGamfwxL+XzoXS6AswMJvayEFLMe/ QvvVTncEHvQ7TbTA3emK0r+nKtK7kFe+GgHNfY/EOOM9braDFKhBajccoOe+0hung4yt /IK5jQyIop9euyMmqXlndFogDeg2c6F7OjHmzBrueoNxJRp7I3fmirN4t1TQz2JmSslv iDgA== 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=SNOGBJbXn+6T8ReGoz0TQ7TXYkaw8/nVFQwZEcf7r/cHWmZi2dFcadyLD0z+lX6/5V 4FromEV09bbUq9eei9uRNYVOXP08z+qVUXrzDpWg/S4bezOi61MhGxbnckxYLc91+kZG uSEcJwRmjGiL8RzJCWU46TmTN60Cu/sgcgXR8D8tMP0X1YhvomvXd5/0xfKLqcoY7Lxu IAvOsLtI362rLzVvfI2V+QuRSLx3pyxc4DENcmUcvdpm2HfXTriAAuwBVbTYxMly8f/Y loegm/wIkJkCr0zbXzPvqN/rV5LrnmhWCgCt/5XHLdQK731Y7Hbc6vDcVtSrOOnzT+CJ iT7w== X-Gm-Message-State: AOAM532EQUuFMX7w4pLpF/dexgYsNgS6647PTXLiGOfnjRBQ/2t6xWaq DY20NgTHJiT5p+5LWwd1o8QGVkNU X-Google-Smtp-Source: ABdhPJwWkzHFO7/j4rrivw1CUW+9eVEX5WYFbeBzzjdhSDCwgE9Ovcs78pYKG8wa1gSIg7m+mT+i5Q== X-Received: by 2002:a2e:83c7:: with SMTP id s7mr758617ljh.68.1592432879661; Wed, 17 Jun 2020 15:27:59 -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 a1sm210378ljk.133.2020.06.17.15.27.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Jun 2020 15:27:59 -0700 (PDT) From: Dmitry Osipenko To: Thierry Reding , Sam Ravnborg , Laurent Pinchart , Rob Herring , Frank Rowand Subject: [PATCH v8 5/7] drm/tegra: output: rgb: Support LVDS encoder bridge Date: Thu, 18 Jun 2020 01:27:01 +0300 Message-Id: <20200617222703.17080-6-digetx@gmail.com> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200617222703.17080-1-digetx@gmail.com> References: <20200617222703.17080-1-digetx@gmail.com> MIME-Version: 1.0 X-Mailman-Approved-At: Thu, 18 Jun 2020 07:17:31 +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 Wed Jun 17 22:27:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 11611539 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 30351618 for ; Thu, 18 Jun 2020 07:18:20 +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 0F35121532 for ; Thu, 18 Jun 2020 07:18:20 +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="Y9tZxdA1" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0F35121532 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 5D45C6EB20; Thu, 18 Jun 2020 07:17:38 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-lf1-x141.google.com (mail-lf1-x141.google.com [IPv6:2a00:1450:4864:20::141]) by gabe.freedesktop.org (Postfix) with ESMTPS id 6A2A26E1CF for ; Wed, 17 Jun 2020 22:28:02 +0000 (UTC) Received: by mail-lf1-x141.google.com with SMTP id c11so2279670lfh.8 for ; Wed, 17 Jun 2020 15:28:02 -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=Y9tZxdA1rsUIIaZhvYLwCqWPTBb6phJr1GlFlLkZmkTyASjV5UDgh3qmcpfXJOG66b 6xnGvDC9A7qwm9zLOWBHW/anG5LKyRHK0Jps7F1yuVWYq2ep3TMgFixmGPknDWOkLhzI Itf3nzn2N8VqHIPa31vjW7HAJ+EpPpuNTidIrMkpryM3ivmGHVwt9DuXNiN6JFFlP7pa 6jZcNHu53Q10EMzElyIvK+XUPbsKfSDy+zSZkIg9LXjgKvpj9hIk+awSnvyDM6my/uz6 IKfz4sVl5VtGGQzULlzuC6cvmGc2JrDLAF/HuIHwGKvXVkJf93H8hyKMON3L1l9LmNyL 3+/Q== 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=MFS812v4qUUCB4s9ZlSY/zkzaNAzj/BUMCEM6gQKhkk3+j/mwmY2D8r1OyqZiX8E2H C6QUu6pPBHg6Ch2GrWfbnsbPgAuDJUEQgud6NNboCLhoRrvqMtNifFaShOkBUWOOGJog XyazMiJVdQjvvcQl7S8Lg1WUmGsRh0V7MtK+wMwR4+tIaNmp9GTBJB/QzkeMtd5N/A57 +MNrOSWu7PQuGzT3LrYixIajMmZeCvCuXHP1afEomxgrPBBfnH8DijiHNOlrKkI8/ppq SHN1IhgIqwDgUdjfp5db5N07K8gpDt3NDvnSTtnKjntHfTZccf+wVtjeBKdStLOJfPEq h0Eg== X-Gm-Message-State: AOAM530uQBhvAhHPCaX90cBnmQH5CTMnZ3utUrk5fuTvOmpZqwcKX0i6 BSpK+2O/EqXnVb0KVehb8MM= X-Google-Smtp-Source: ABdhPJx6IKZqruOfHC3cc6bguSK0xEBwL3JLuOkypb06GquTIdueKILcT/UJXg0dkgQ+3eEIFuf6dQ== X-Received: by 2002:a19:d44:: with SMTP id 65mr610935lfn.36.1592432880756; Wed, 17 Jun 2020 15:28:00 -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 a1sm210378ljk.133.2020.06.17.15.27.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Jun 2020 15:28:00 -0700 (PDT) From: Dmitry Osipenko To: Thierry Reding , Sam Ravnborg , Laurent Pinchart , Rob Herring , Frank Rowand Subject: [PATCH v8 6/7] drm/tegra: output: rgb: Wrap directly-connected panel into DRM bridge Date: Thu, 18 Jun 2020 01:27:02 +0300 Message-Id: <20200617222703.17080-7-digetx@gmail.com> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200617222703.17080-1-digetx@gmail.com> References: <20200617222703.17080-1-digetx@gmail.com> MIME-Version: 1.0 X-Mailman-Approved-At: Thu, 18 Jun 2020 07:17:31 +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); From patchwork Wed Jun 17 22:27:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 11611561 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 1DA5D14B7 for ; Thu, 18 Jun 2020 07:18:45 +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 F098521532 for ; Thu, 18 Jun 2020 07:18:44 +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="sogBx8KF" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F098521532 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 85B3A6EB2F; Thu, 18 Jun 2020 07:17:40 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-lj1-x242.google.com (mail-lj1-x242.google.com [IPv6:2a00:1450:4864:20::242]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4B3106E1F2 for ; Wed, 17 Jun 2020 22:28:03 +0000 (UTC) Received: by mail-lj1-x242.google.com with SMTP id a9so4855804ljn.6 for ; Wed, 17 Jun 2020 15:28:03 -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=IKFzNibCd7jzC+wKme/62sVxJsUZsrptVvulkctN6fc=; b=sogBx8KF5qXKU6uIzglmpLtOwdnq8arZ4/R7HdxFWl9vEyg25TbvzNbcUG5pA7PTxu +Y21qITF5l2IeoGbX8+uDtgy295BPargj9NdUoojpbkgn1HjN2SCkttS5sEeV73w6saM lQut9MIEPs+qRJyP3MahcOMs7ZdAGaGGGpixTEHQfzJoUjI8IPCu6T/6Apst2DmMOBy/ KUO8dzCcRhMPS2jxwmOYrUeLehzEENLkwHe15tzosdjPEL44iaqVVBabhJPAmHrJMz4M 83Q694VYVrE3UFGfqvgWshqUx5wEp6r2E6qeGiZ5eA67Iax9eZVlDzkJJ/iD0iL2vq96 QKyw== 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=IKFzNibCd7jzC+wKme/62sVxJsUZsrptVvulkctN6fc=; b=IaVy/mPidRXEXe7nVa13/BA1+ArZIXrJsrATgUTNnHs8dftfO2uELbbI3zepN0WLeE KrhmyQWMS9U3yNO8hwwHaROwryoUvj8ef/5+jlyUCL/NU5oX/sazN7Opzr5llLL3VUrr 9XhwkwuOw4Hs3IOIM7p9vStyULFbxNifqUFcfIAnDCqomMUaNtMwwlC8mXIx5tKaU28U nlUItBUYGLZCq377H9u/496iXmyFHzSDBTIdsvi/0Ng+3i3vUQ2BNDQ5ozzAVOtRAgCs YBnAogBC2KbQaob2sp1VXwgrC2Xigf8OsSMUP/4syF59/HCtBYjg+pYywM5OwyBtzXba ia/w== X-Gm-Message-State: AOAM530wCNE9PzM+TNRF+wPyZFLaSJX/Glyk8R8C5EXE5SVoX6Eub+lV SWvOewWlXtUJoeo4AZSwzZG12jUE X-Google-Smtp-Source: ABdhPJwcUfeogdH2fdQoZn2uStj+lMY3N6d4lTg2ozcjT5sN41K76ccpr8S5r0ZJF0Z0vAo7B1CP+A== X-Received: by 2002:a2e:9810:: with SMTP id a16mr648149ljj.157.1592432881697; Wed, 17 Jun 2020 15:28:01 -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 a1sm210378ljk.133.2020.06.17.15.28.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Jun 2020 15:28:01 -0700 (PDT) From: Dmitry Osipenko To: Thierry Reding , Sam Ravnborg , Laurent Pinchart , Rob Herring , Frank Rowand Subject: [PATCH v8 7/7] drm/panel-simple: Add missing connector type for some panels Date: Thu, 18 Jun 2020 01:27:03 +0300 Message-Id: <20200617222703.17080-8-digetx@gmail.com> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200617222703.17080-1-digetx@gmail.com> References: <20200617222703.17080-1-digetx@gmail.com> MIME-Version: 1.0 X-Mailman-Approved-At: Thu, 18 Jun 2020 07:17:31 +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 DRM panel bridge core requires connector type to be set up properly, otherwise it rejects the panel. The missing connector type problem popped up while I was trying to wrap CLAA070WP03XG panel into a DRM bridge in order to test whether panel's rotation property work properly using panel-simple driver on NVIDIA Tegra30 Nexus 7 tablet device, which uses CLAA070WP03XG display panel. The NVIDIA Tegra DRM driver recently gained DRM bridges support for the RGB output and now driver wraps directly-connected panels into DRM bridge. Hence all panels should have connector type set properly now, otherwise the panel's wrapping fails. This patch adds missing connector types for the LVDS panels that are found on NVIDIA Tegra devices: 1. AUO B101AW03 2. Chunghwa CLAA070WP03XG 3. Chunghwa CLAA101WA01A 4. Chunghwa CLAA101WB01 5. EDT ET057090DHU 6. Innolux N156BGE L21 7. Samsung LTN101NT05 Signed-off-by: Dmitry Osipenko --- drivers/gpu/drm/panel/panel-simple.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/gpu/drm/panel/panel-simple.c b/drivers/gpu/drm/panel/panel-simple.c index 6764ac630e22..9eb2dbb7bfa6 100644 --- a/drivers/gpu/drm/panel/panel-simple.c +++ b/drivers/gpu/drm/panel/panel-simple.c @@ -687,6 +687,7 @@ static const struct panel_desc auo_b101aw03 = { .width = 223, .height = 125, }, + .connector_type = DRM_MODE_CONNECTOR_LVDS, }; static const struct display_timing auo_b101ean01_timing = { @@ -1340,6 +1341,7 @@ static const struct panel_desc chunghwa_claa070wp03xg = { .width = 94, .height = 150, }, + .connector_type = DRM_MODE_CONNECTOR_LVDS, }; static const struct drm_display_mode chunghwa_claa101wa01a_mode = { @@ -1362,6 +1364,7 @@ static const struct panel_desc chunghwa_claa101wa01a = { .width = 220, .height = 120, }, + .connector_type = DRM_MODE_CONNECTOR_LVDS, }; static const struct drm_display_mode chunghwa_claa101wb01_mode = { @@ -1384,6 +1387,7 @@ static const struct panel_desc chunghwa_claa101wb01 = { .width = 223, .height = 125, }, + .connector_type = DRM_MODE_CONNECTOR_LVDS, }; static const struct drm_display_mode dataimage_scf0700c48ggu18_mode = { @@ -1573,6 +1577,7 @@ static const struct panel_desc edt_et057090dhu = { }, .bus_format = MEDIA_BUS_FMT_RGB666_1X18, .bus_flags = DRM_BUS_FLAG_DE_HIGH | DRM_BUS_FLAG_PIXDATA_DRIVE_NEGEDGE, + .connector_type = DRM_MODE_CONNECTOR_LVDS, }; static const struct drm_display_mode edt_etm0700g0dh6_mode = { @@ -2055,6 +2060,7 @@ static const struct panel_desc innolux_n156bge_l21 = { .width = 344, .height = 193, }, + .connector_type = DRM_MODE_CONNECTOR_LVDS, }; static const struct drm_display_mode innolux_p120zdg_bf1_mode = { @@ -3001,6 +3007,7 @@ static const struct panel_desc samsung_ltn101nt05 = { .width = 223, .height = 125, }, + .connector_type = DRM_MODE_CONNECTOR_LVDS, }; static const struct drm_display_mode samsung_ltn140at29_301_mode = {