public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
From: wens@csie.org (Chen-Yu Tsai)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 05/11] drm/sun4i: Initialize crtc from tcon bind function
Date: Thu, 23 Feb 2017 16:05:37 +0800	[thread overview]
Message-ID: <20170223080543.6659-6-wens@csie.org> (raw)
In-Reply-To: <20170223080543.6659-1-wens@csie.org>

The tcon provides part of the functionality of the crtc, and also
provides the device node for the output port of the crtc. To be able
to use drm_of_find_possible_crtcs(), all crtc must be initialized before
any downstream encoders. The other part of the crtc is the display
backend.

The Rockchip DRM driver does this by first binding all vops, which is
their crtc, and this step also creates the crtc objects. Then all
remaining hardware components are bound. With the Allwinner display
pipeline, we have multiple components comprising the crtc, and varying
depths of the display pipeline. Since components are added with a depth
first search of the of_graph, we can initialize the crtc object within
the tcon bind function. Since the backend precedes the tcon, and the
backends cannot be muxed or switched around, we can be sure that the
associated backend is already initialized.

This patch also moves the crtc pointer from the main drm_device data to
the tcon device data. Besides the crtc callbacks, the crtc structure is
only used within the tcon driver to signal vblank events from its
interrupt handler.

As the crtc and layer bits are now called from the tcon bits, we must
move them from the sun4i-drm module to the sun4i-tcon module to avoid
circular dependencies between the two modules. This is because sun4i-drm
also calls into sun4i-tcon.

Signed-off-by: Chen-Yu Tsai <wens@csie.org>
---
 drivers/gpu/drm/sun4i/Makefile     |  4 ++--
 drivers/gpu/drm/sun4i/sun4i_drv.c  |  8 --------
 drivers/gpu/drm/sun4i/sun4i_drv.h  |  1 -
 drivers/gpu/drm/sun4i/sun4i_tcon.c | 10 ++++++++--
 drivers/gpu/drm/sun4i/sun4i_tcon.h |  3 +++
 5 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/drivers/gpu/drm/sun4i/Makefile b/drivers/gpu/drm/sun4i/Makefile
index d625a82a6e5f..59b757350a1f 100644
--- a/drivers/gpu/drm/sun4i/Makefile
+++ b/drivers/gpu/drm/sun4i/Makefile
@@ -1,11 +1,11 @@
-sun4i-drm-y += sun4i_crtc.o
 sun4i-drm-y += sun4i_drv.o
 sun4i-drm-y += sun4i_framebuffer.o
-sun4i-drm-y += sun4i_layer.o
 
 sun4i-tcon-y += sun4i_tcon.o
 sun4i-tcon-y += sun4i_rgb.o
 sun4i-tcon-y += sun4i_dotclock.o
+sun4i-tcon-y += sun4i_crtc.o
+sun4i-tcon-y += sun4i_layer.o
 
 obj-$(CONFIG_DRM_SUN4I)		+= sun4i-drm.o sun4i-tcon.o
 obj-$(CONFIG_DRM_SUN4I)		+= sun4i_backend.o
diff --git a/drivers/gpu/drm/sun4i/sun4i_drv.c b/drivers/gpu/drm/sun4i/sun4i_drv.c
index 87bc0951eba8..4384c837baa8 100644
--- a/drivers/gpu/drm/sun4i/sun4i_drv.c
+++ b/drivers/gpu/drm/sun4i/sun4i_drv.c
@@ -20,7 +20,6 @@
 #include <drm/drm_fb_helper.h>
 #include <drm/drm_of.h>
 
-#include "sun4i_crtc.h"
 #include "sun4i_drv.h"
 #include "sun4i_framebuffer.h"
 #include "sun4i_tcon.h"
@@ -142,13 +141,6 @@ static int sun4i_drv_bind(struct device *dev)
 		goto cleanup_mode_config;
 	}
 
-	/* Create our CRTC */
-	drv->crtc = sun4i_crtc_init(drm);
-	if (IS_ERR(drv->crtc)) {
-		dev_err(drm->dev, "Couldn't create the CRTC\n");
-		ret = PTR_ERR(drv->crtc);
-		goto cleanup_mode_config;
-	}
 	drm->irq_enabled = true;
 
 	/* Remove early framebuffers (ie. simplefb) */
diff --git a/drivers/gpu/drm/sun4i/sun4i_drv.h b/drivers/gpu/drm/sun4i/sun4i_drv.h
index e22ee536677e..7a3345b7b6d1 100644
--- a/drivers/gpu/drm/sun4i/sun4i_drv.h
+++ b/drivers/gpu/drm/sun4i/sun4i_drv.h
@@ -18,7 +18,6 @@
 
 struct sun4i_drv {
 	struct sun4i_backend	*backend;
-	struct sun4i_crtc	*crtc;
 	struct sun4i_tcon	*tcon;
 
 	struct drm_plane	*primary;
diff --git a/drivers/gpu/drm/sun4i/sun4i_tcon.c b/drivers/gpu/drm/sun4i/sun4i_tcon.c
index ea2906f87cb9..3f3eb3f0b209 100644
--- a/drivers/gpu/drm/sun4i/sun4i_tcon.c
+++ b/drivers/gpu/drm/sun4i/sun4i_tcon.c
@@ -290,8 +290,7 @@ static irqreturn_t sun4i_tcon_handler(int irq, void *private)
 {
 	struct sun4i_tcon *tcon = private;
 	struct drm_device *drm = tcon->drm;
-	struct sun4i_drv *drv = drm->dev_private;
-	struct sun4i_crtc *scrtc = drv->crtc;
+	struct sun4i_crtc *scrtc = tcon->crtc;
 	unsigned int status;
 
 	regmap_read(tcon->regs, SUN4I_TCON_GINT0_REG, &status);
@@ -524,6 +523,13 @@ static int sun4i_tcon_bind(struct device *dev, struct device *master,
 		goto err_free_clocks;
 	}
 
+	tcon->crtc = sun4i_crtc_init(drm);
+	if (IS_ERR(tcon->crtc)) {
+		dev_err(dev, "Couldn't create our CRTC\n");
+		ret = PTR_ERR(tcon->crtc);
+		goto err_free_clocks;
+	}
+
 	ret = sun4i_rgb_init(drm);
 	if (ret < 0)
 		goto err_free_clocks;
diff --git a/drivers/gpu/drm/sun4i/sun4i_tcon.h b/drivers/gpu/drm/sun4i/sun4i_tcon.h
index 166064bafe2e..f636343a935d 100644
--- a/drivers/gpu/drm/sun4i/sun4i_tcon.h
+++ b/drivers/gpu/drm/sun4i/sun4i_tcon.h
@@ -169,6 +169,9 @@ struct sun4i_tcon {
 
 	/* Platform adjustments */
 	const struct sun4i_tcon_quirks	*quirks;
+
+	/* Associated crtc */
+	struct sun4i_crtc		*crtc;
 };
 
 struct drm_bridge *sun4i_tcon_find_bridge(struct device_node *node);
-- 
2.11.0

  parent reply	other threads:[~2017-02-23  8:05 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-23  8:05 [PATCH 00/11] drm/sun4i: Various fixes and cleanups part 2 Chen-Yu Tsai
2017-02-23  8:05 ` [PATCH 01/11] drm/sun4i: Make sunxi_rgb2yuv_coef constant Chen-Yu Tsai
2017-02-23 18:18   ` Maxime Ripard
2017-02-23  8:05 ` [PATCH 02/11] drm/sun4i: Set drm_crtc.port to the underlying TCON's output port node Chen-Yu Tsai
2017-02-23 18:20   ` Maxime Ripard
2017-02-23  8:05 ` [PATCH 03/11] drm/sun4i: Add end of list element for sun4i_layers_init's returned list Chen-Yu Tsai
2017-02-23 18:21   ` Maxime Ripard
2017-02-23  8:05 ` [PATCH 04/11] drm/sun4i: Move layers from sun4i_drv to sun4i_crtc Chen-Yu Tsai
2017-02-23 18:22   ` Maxime Ripard
2017-02-23  8:05 ` Chen-Yu Tsai [this message]
2017-02-23 18:24   ` [PATCH 05/11] drm/sun4i: Initialize crtc from tcon bind function Maxime Ripard
2017-02-23  8:05 ` [PATCH 06/11] drm/sun4i: Drop primary layer pointer from sun4i_drv Chen-Yu Tsai
2017-02-23 18:26   ` Maxime Ripard
2017-02-23  8:05 ` [PATCH 07/11] drm/sun4i: Drop hardcoded .possible_crtcs values from layers Chen-Yu Tsai
2017-02-23  8:05 ` [PATCH 08/11] drm/sun4i: tv: Switch to drm_of_find_possible_crtcs Chen-Yu Tsai
2017-02-23  8:05 ` [PATCH 09/11] drm/sun4i: rgb: Pass tcon pointer when initializing RGB encoder Chen-Yu Tsai
2017-02-23  8:05 ` [PATCH 10/11] drm/sun4i: Add backend pointer to sun4i_layer Chen-Yu Tsai
2017-02-23  8:05 ` [PATCH 11/11] drm/sun4i: Add backend and tcon pointers to sun4i_crtc Chen-Yu Tsai
2017-02-23 18:30   ` Maxime Ripard

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=20170223080543.6659-6-wens@csie.org \
    --to=wens@csie.org \
    --cc=linux-arm-kernel@lists.infradead.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