public inbox for devicetree@vger.kernel.org
 help / color / mirror / Atom feed
From: Jernej Skrabec <jernej.skrabec-gGgVlfcn5nU@public.gmane.org>
To: maxime.ripard-LDxbnhwyfcJBDgjK7y7TUQ@public.gmane.org,
	wens-jdAy2FN1RRM@public.gmane.org,
	robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org
Cc: airlied-cv59FeDIM0c@public.gmane.org,
	mark.rutland-5wv7dgnIgG8@public.gmane.org,
	dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org,
	devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-sunxi-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
Subject: [PATCH 11/17] drm/sun4i: tcon: Add another way for matching mixers with tcon
Date: Fri,  6 Jul 2018 19:51:07 +0200	[thread overview]
Message-ID: <20180706175113.26698-12-jernej.skrabec@siol.net> (raw)
In-Reply-To: <20180706175113.26698-1-jernej.skrabec-gGgVlfcn5nU@public.gmane.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.

Signed-off-by: Jernej Skrabec <jernej.skrabec-gGgVlfcn5nU@public.gmane.org>
---
 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

  parent reply	other threads:[~2018-07-06 17:51 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-06 17:50 [PATCH 00/17] Allwinner R40 HDMI refactoring Jernej Skrabec
     [not found] ` <20180706175113.26698-1-jernej.skrabec-gGgVlfcn5nU@public.gmane.org>
2018-07-06 17:50   ` [PATCH 01/17] dt-bindings: display: sun4i-drm: Add R40 display engine compatible Jernej Skrabec
     [not found]     ` <20180706175113.26698-2-jernej.skrabec-gGgVlfcn5nU@public.gmane.org>
2018-07-10 15:20       ` Chen-Yu Tsai
2018-07-06 17:50   ` [PATCH 02/17] drm/sun4i: " Jernej Skrabec
     [not found]     ` <20180706175113.26698-3-jernej.skrabec-gGgVlfcn5nU@public.gmane.org>
2018-07-10 15:20       ` Chen-Yu Tsai
2018-07-06 17:50   ` [PATCH 03/17] ARM: dts: sun8i: r40: Remove fallback " Jernej Skrabec
     [not found]     ` <20180706175113.26698-4-jernej.skrabec-gGgVlfcn5nU@public.gmane.org>
2018-07-10 15:21       ` Chen-Yu Tsai
2018-07-06 17:51   ` [PATCH 04/17] drm/sun4i: tcon-top: Cleanup clock handling Jernej Skrabec
     [not found]     ` <20180706175113.26698-5-jernej.skrabec-gGgVlfcn5nU@public.gmane.org>
2018-07-10 15:23       ` Chen-Yu Tsai
2018-07-06 17:51   ` [PATCH 05/17] drm/sun4i: tcon: Release node when traversing of graph Jernej Skrabec
     [not found]     ` <20180706175113.26698-6-jernej.skrabec-gGgVlfcn5nU@public.gmane.org>
2018-07-10 15:23       ` Chen-Yu Tsai
2018-07-06 17:51   ` [PATCH 06/17] dt-bindings: display: sun4i-drm: Add R40 TV TCON description Jernej Skrabec
     [not found]     ` <20180706175113.26698-7-jernej.skrabec-gGgVlfcn5nU@public.gmane.org>
2018-07-06 20:40       ` Rob Herring
2018-07-06 20:44         ` Jernej Škrabec
2018-07-09 14:16           ` Rob Herring
2018-07-10 15:26       ` Chen-Yu Tsai
2018-07-06 17:51   ` [PATCH 07/17] drm/sun4i: DW HDMI: Release nodes if error happens during CRTC search Jernej Skrabec
     [not found]     ` <20180706175113.26698-8-jernej.skrabec-gGgVlfcn5nU@public.gmane.org>
2018-07-10 15:31       ` Chen-Yu Tsai
2018-07-06 17:51   ` [PATCH 08/17] ARM: dts: sun8i: r40: Add mixer ids to TCON TOP Jernej Skrabec
     [not found]     ` <20180706175113.26698-9-jernej.skrabec-gGgVlfcn5nU@public.gmane.org>
2018-07-10 15:35       ` Chen-Yu Tsai
2018-07-06 17:51   ` [PATCH 09/17] drm/sun4i: mixer: Read id from DT Jernej Skrabec
2018-07-10 15:40     ` Chen-Yu Tsai
2018-07-06 17:51   ` [PATCH 10/17] drm/sun4i: tcon-top: Add helpers for switching mux Jernej Skrabec
     [not found]     ` <20180706175113.26698-11-jernej.skrabec-gGgVlfcn5nU@public.gmane.org>
2018-07-10 15:56       ` Chen-Yu Tsai
2018-07-06 17:51   ` Jernej Skrabec [this message]
     [not found]     ` <20180706175113.26698-12-jernej.skrabec-gGgVlfcn5nU@public.gmane.org>
2018-07-10 16:12       ` [PATCH 11/17] drm/sun4i: tcon: Add another way for matching mixers with tcon Chen-Yu Tsai
2018-07-06 17:51   ` [PATCH 12/17] drm/sun4i: tcon: Add support for R40 TCON Jernej Skrabec
     [not found]     ` <20180706175113.26698-13-jernej.skrabec-gGgVlfcn5nU@public.gmane.org>
2018-07-10 16:14       ` Chen-Yu Tsai
2018-07-06 17:51   ` [PATCH 13/17] ARM: dts: sun8i: r40: Remove fallback compatible for TCON TV Jernej Skrabec
     [not found]     ` <20180706175113.26698-14-jernej.skrabec-gGgVlfcn5nU@public.gmane.org>
2018-07-10 15:49       ` Chen-Yu Tsai
2018-07-06 17:51   ` [PATCH 14/17] ARM: dts: sun8i: r40: Add missing TCON-TOP - TCON connections Jernej Skrabec
     [not found]     ` <20180706175113.26698-15-jernej.skrabec-gGgVlfcn5nU@public.gmane.org>
2018-07-10 15:53       ` Chen-Yu Tsai
2018-07-06 17:51   ` [PATCH 15/17] ARM: dts: sun8i: r40: Disable TCONs by default Jernej Skrabec
2018-07-10 16:16     ` Chen-Yu Tsai
2018-07-06 17:51   ` [PATCH 16/17] drm/sun4i: tcon-top: Remove mux configuration at probe time Jernej Skrabec
     [not found]     ` <20180706175113.26698-17-jernej.skrabec-gGgVlfcn5nU@public.gmane.org>
2018-07-10 16:09       ` Chen-Yu Tsai
     [not found]         ` <CAGb2v64rjUnwnXbWxTSYJyhMyCV5QmV9YSr+Jryx3nEeMP8GJg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2018-07-10 16:18           ` Jernej Škrabec
2018-07-10 19:41             ` Jernej Škrabec
2018-07-06 17:51   ` [PATCH 17/17] dt-bindings: display: sun4i-drm: Fix order of DW HDMI PHY compatibles Jernej Skrabec
     [not found]     ` <20180706175113.26698-18-jernej.skrabec-gGgVlfcn5nU@public.gmane.org>
2018-07-10 16:09       ` Chen-Yu Tsai

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180706175113.26698-12-jernej.skrabec@siol.net \
    --to=jernej.skrabec-gggvlfcn5nu@public.gmane.org \
    --cc=airlied-cv59FeDIM0c@public.gmane.org \
    --cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org \
    --cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-sunxi-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org \
    --cc=mark.rutland-5wv7dgnIgG8@public.gmane.org \
    --cc=maxime.ripard-LDxbnhwyfcJBDgjK7y7TUQ@public.gmane.org \
    --cc=robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
    --cc=wens-jdAy2FN1RRM@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox