Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp2117118imm; Tue, 10 Jul 2018 13:37:47 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfJ3aRNhxFy2YcI1BtbT9vs73ori6F5EnaknVS0/4C0EH7pMeH4OFHPlsK1k1GaPDK8/ZDt X-Received: by 2002:a17:902:9883:: with SMTP id s3-v6mr26004039plp.194.1531255067756; Tue, 10 Jul 2018 13:37:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531255067; cv=none; d=google.com; s=arc-20160816; b=wESMPyLCR8eTovXybi8XS7EkEKVw1UNJrZrMB4pf+P3tds4TtDk6+vlit8RnsxFPd2 KkY8j2xb8U3sZHCea7mpcz3h6k3ONWz0BxnK0sR+F+yqyXvdmE4I/NrzEOrjehe4FaMX 6f4rNwrYdF8qEy/8ql25/deScoDGMf3DaUKKR0D7s2LsA80lJorheGTLuvrCiMmHoenI EIvQIPySI3NSDawArcgt0TayqMS4ZzOa3WQxsWMtra+OyLWgbPhoE2Di+72PSXjrlSkY ZmbiLWMvEIgLayxvj6MDyn702WCeUSCHBd7/YnIBQAKt/hIqBNCtXHV8MsmaLYWrg81G Bo1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=BiIZyFGbQl75s+bxt6M+R0Wt2nXIp9hIWDKNO36Hg34=; b=1F3oQuSo4YStVqXK0RDyH0lUpa0eDMYw14nPrLDWz2d08HbhkKmE46suST+LQ91qWa Z8Gz/ZZOp0BgYjQWok3OLSbEBg+fAqnmGZMrML8b9NGrNVKZ7r8z1t4uAKNvGDggrL2G GxRE0lzFouiYFRRHzXU+214giIwt32hYoKTSnv5zx5fZNGoebWtekK0mz6sdLcMF59s2 7MQ54ZvagGHjPdQsbb+4y1CAn9dk88bepzq+mOpMP1VWIY5ldMZvcQnrLAvkS+7F6Ibp DIpEmc91TuEGK6AdKFlAUb5GdoRNTrMXyXXWl/t9TyhOtvHWAtQnaFvLZ5I2XLL4V6Nv dNuw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v2-v6si17448983plg.12.2018.07.10.13.37.33; Tue, 10 Jul 2018 13:37:47 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733024AbeGJUgf (ORCPT + 99 others); Tue, 10 Jul 2018 16:36:35 -0400 Received: from mailoutvs31.siol.net ([185.57.226.222]:47502 "EHLO mail.siol.net" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1733011AbeGJUge (ORCPT ); Tue, 10 Jul 2018 16:36:34 -0400 Received: from localhost (localhost [127.0.0.1]) by mail.siol.net (Zimbra) with ESMTP id 21F2B522726; Tue, 10 Jul 2018 22:35:51 +0200 (CEST) X-Virus-Scanned: amavisd-new at psrvmta12.zcs-production.pri Received: from mail.siol.net ([127.0.0.1]) by localhost (psrvmta12.zcs-production.pri [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id s1w6S5KH5rLJ; Tue, 10 Jul 2018 22:35:50 +0200 (CEST) Received: from mail.siol.net (localhost [127.0.0.1]) by mail.siol.net (Zimbra) with ESMTPS id 8A231520AA8; Tue, 10 Jul 2018 22:35:50 +0200 (CEST) Received: from localhost.localdomain (unknown [194.152.15.144]) (Authenticated sender: 031275009) by mail.siol.net (Zimbra) with ESMTPSA id 1FC6252272D; Tue, 10 Jul 2018 22:35:48 +0200 (CEST) From: Jernej Skrabec To: maxime.ripard@bootlin.com, wens@csie.org, robh+dt@kernel.org Cc: airlied@linux.ie, mark.rutland@arm.com, dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-sunxi@googlegroups.com Subject: [PATCH v2 12/18] drm/sun4i: tcon: Add another way for matching mixers with tcon Date: Tue, 10 Jul 2018 22:35:05 +0200 Message-Id: <20180710203511.18454-13-jernej.skrabec@siol.net> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180710203511.18454-1-jernej.skrabec@siol.net> References: <20180710203511.18454-1-jernej.skrabec@siol.net> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Till now, new way of matching engines with TCONs was reading their respective ids and match them by those ids. However, with introduction of TCON TOP, that might not be so straightforward anymore. - there might be more TCONs that engines (mixers) - TCON ids might have non-consecutive ids Workaround that by matching mixer id with TCON index from TCON list. For example, R40 has 2 mixers and 4 TCONs. Board designer can choose 2 outputs, which are connected to any of those 4 TCONs. As long as there are only 2 TCONs enabled in DT, using index in list as alternative id, will allow to match them with mixer 0 and 1. Reviewed-by: Chen-Yu Tsai Signed-off-by: Jernej Skrabec --- drivers/gpu/drm/sun4i/sun4i_tcon.c | 51 ++++++++++++++++++++++++++++-- 1 file changed, 49 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/sun4i/sun4i_tcon.c b/drivers/gpu/drm/sun4i/sun4i_tcon.c index 3fb084f802e2..44ec3a3d4d64 100644 --- a/drivers/gpu/drm/sun4i/sun4i_tcon.c +++ b/drivers/gpu/drm/sun4i/sun4i_tcon.c @@ -35,6 +35,7 @@ #include "sun4i_rgb.h" #include "sun4i_tcon.h" #include "sun6i_mipi_dsi.h" +#include "sun8i_tcon_top.h" #include "sunxi_engine.h" static struct drm_connector *sun4i_tcon_get_connector(const struct drm_encoder *encoder) @@ -880,6 +881,36 @@ static struct sunxi_engine *sun4i_tcon_get_engine_by_id(struct sun4i_drv *drv, return ERR_PTR(-EINVAL); } +static bool sun4i_tcon_connected_to_tcon_top(struct device_node *node) +{ + struct device_node *remote; + bool ret = false; + + remote = of_graph_get_remote_node(node, 0, -1); + if (remote) { + ret = !!of_match_node(sun8i_tcon_top_of_table, remote); + of_node_put(remote); + } + + return ret; +} + +static int sun4i_tcon_get_index(struct sun4i_drv *drv) +{ + struct list_head *pos; + int size = 0; + + /* + * Because TCON is added to the list at the end of the probe + * (after this function is called), index of the current TCON + * will be same as current TCON list size. + */ + list_for_each(pos, &drv->tcon_list) + ++size; + + return size; +} + /* * On SoCs with the old display pipeline design (Display Engine 1.0), * we assumed the TCON was always tied to just one backend. However @@ -928,8 +959,24 @@ static struct sunxi_engine *sun4i_tcon_find_engine(struct sun4i_drv *drv, * connections between the backend and TCON? */ if (of_get_child_count(port) > 1) { - /* Get our ID directly from an upstream endpoint */ - int id = sun4i_tcon_of_get_id_from_port(port); + int id; + + /* + * When pipeline has the same number of TCONs and engines which + * are represented by frontends/backends (DE1) or mixers (DE2), + * we match them by their respective IDs. However, if pipeline + * contains TCON TOP, chances are that there are either more + * TCONs than engines (R40) or TCONs with non-consecutive ids. + * (H6). In that case it's easier just use TCON index in list + * as an id. That means that on R40, any 2 TCONs can be enabled + * in DT out of 4 (there are 2 mixers). Due to the design of + * TCON TOP, remaining 2 TCONs can't be connected to anything + * anyway. + */ + if (sun4i_tcon_connected_to_tcon_top(node)) + id = sun4i_tcon_get_index(drv); + else + id = sun4i_tcon_of_get_id_from_port(port); /* Get our engine by matching our ID */ engine = sun4i_tcon_get_engine_by_id(drv, id); -- 2.18.0