Skip to content

Commit cf77d79

Browse files
jernejskmripard
authored andcommitted
drm/sun4i: tcon: Add another way for matching mixers with tcon
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 <wens@csie.org> Signed-off-by: Jernej Skrabec <jernej.skrabec@siol.net> Signed-off-by: Maxime Ripard <maxime.ripard@bootlin.com> Link: https://patchwork.freedesktop.org/patch/msgid/20180710203511.18454-13-jernej.skrabec@siol.net
1 parent 2aafafa commit cf77d79

File tree

1 file changed

+49
-2
lines changed

1 file changed

+49
-2
lines changed

drivers/gpu/drm/sun4i/sun4i_tcon.c

Lines changed: 49 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
#include "sun4i_rgb.h"
3737
#include "sun4i_tcon.h"
3838
#include "sun6i_mipi_dsi.h"
39+
#include "sun8i_tcon_top.h"
3940
#include "sunxi_engine.h"
4041

4142
static struct drm_connector *sun4i_tcon_get_connector(const struct drm_encoder *encoder)
@@ -908,6 +909,36 @@ static struct sunxi_engine *sun4i_tcon_get_engine_by_id(struct sun4i_drv *drv,
908909
return ERR_PTR(-EINVAL);
909910
}
910911

912+
static bool sun4i_tcon_connected_to_tcon_top(struct device_node *node)
913+
{
914+
struct device_node *remote;
915+
bool ret = false;
916+
917+
remote = of_graph_get_remote_node(node, 0, -1);
918+
if (remote) {
919+
ret = !!of_match_node(sun8i_tcon_top_of_table, remote);
920+
of_node_put(remote);
921+
}
922+
923+
return ret;
924+
}
925+
926+
static int sun4i_tcon_get_index(struct sun4i_drv *drv)
927+
{
928+
struct list_head *pos;
929+
int size = 0;
930+
931+
/*
932+
* Because TCON is added to the list at the end of the probe
933+
* (after this function is called), index of the current TCON
934+
* will be same as current TCON list size.
935+
*/
936+
list_for_each(pos, &drv->tcon_list)
937+
++size;
938+
939+
return size;
940+
}
941+
911942
/*
912943
* On SoCs with the old display pipeline design (Display Engine 1.0),
913944
* we assumed the TCON was always tied to just one backend. However
@@ -956,8 +987,24 @@ static struct sunxi_engine *sun4i_tcon_find_engine(struct sun4i_drv *drv,
956987
* connections between the backend and TCON?
957988
*/
958989
if (of_get_child_count(port) > 1) {
959-
/* Get our ID directly from an upstream endpoint */
960-
int id = sun4i_tcon_of_get_id_from_port(port);
990+
int id;
991+
992+
/*
993+
* When pipeline has the same number of TCONs and engines which
994+
* are represented by frontends/backends (DE1) or mixers (DE2),
995+
* we match them by their respective IDs. However, if pipeline
996+
* contains TCON TOP, chances are that there are either more
997+
* TCONs than engines (R40) or TCONs with non-consecutive ids.
998+
* (H6). In that case it's easier just use TCON index in list
999+
* as an id. That means that on R40, any 2 TCONs can be enabled
1000+
* in DT out of 4 (there are 2 mixers). Due to the design of
1001+
* TCON TOP, remaining 2 TCONs can't be connected to anything
1002+
* anyway.
1003+
*/
1004+
if (sun4i_tcon_connected_to_tcon_top(node))
1005+
id = sun4i_tcon_get_index(drv);
1006+
else
1007+
id = sun4i_tcon_of_get_id_from_port(port);
9611008

9621009
/* Get our engine by matching our ID */
9631010
engine = sun4i_tcon_get_engine_by_id(drv, id);

0 commit comments

Comments
 (0)