All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrzej Hajda <a.hajda@samsung.com>
To: Inki Dae <inki.dae@samsung.com>
Cc: linux-samsung-soc@vger.kernel.org,
	Marek Szyprowski <m.szyprowski@samsung.com>,
	dri-devel@lists.freedesktop.org,
	Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
Subject: [PATCH 05/23] drm/exynos/decon5433: embed exynos_drm_crtc directly into context
Date: Fri, 01 Mar 2019 13:20:37 +0100	[thread overview]
Message-ID: <20190301122055.7135-6-a.hajda@samsung.com> (raw)
In-Reply-To: <20190301122055.7135-1-a.hajda@samsung.com>

Since crtc maps 1:1 to the device there is no point in allocating it
separately, another benefit is possibility of direct initialisation
of its fields which is more readable and allows further expansion.

Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
---
 drivers/gpu/drm/exynos/exynos5433_drm_decon.c | 52 +++++++++----------
 1 file changed, 26 insertions(+), 26 deletions(-)

diff --git a/drivers/gpu/drm/exynos/exynos5433_drm_decon.c b/drivers/gpu/drm/exynos/exynos5433_drm_decon.c
index ae0f475eb633..0d409f453923 100644
--- a/drivers/gpu/drm/exynos/exynos5433_drm_decon.c
+++ b/drivers/gpu/drm/exynos/exynos5433_drm_decon.c
@@ -54,7 +54,7 @@ static const char * const decon_clks_name[] = {
 struct decon_context {
 	struct device			*dev;
 	struct drm_device		*drm_dev;
-	struct exynos_drm_crtc		*crtc;
+	struct exynos_drm_crtc		crtc;
 	struct exynos_drm_plane		planes[WINDOWS_NR];
 	void __iomem			*addr;
 	struct regmap			*sysreg;
@@ -69,6 +69,8 @@ struct decon_context {
 	u32				frame_id;
 };
 
+#define to_decon(ptr) container_of(ptr, struct decon_context, ptr)
+
 static const uint32_t decon_formats[] = {
 	DRM_FORMAT_XRGB1555,
 	DRM_FORMAT_RGB565,
@@ -90,7 +92,7 @@ static inline void decon_set_bits(struct decon_context *ctx, u32 reg, u32 mask,
 
 static int decon_enable_vblank(struct exynos_drm_crtc *crtc)
 {
-	struct decon_context *ctx = crtc->ctx;
+	struct decon_context *ctx = to_decon(crtc);
 	u32 val;
 
 	val = VIDINTCON0_INTEN;
@@ -110,7 +112,7 @@ static int decon_enable_vblank(struct exynos_drm_crtc *crtc)
 
 static void decon_disable_vblank(struct exynos_drm_crtc *crtc)
 {
-	struct decon_context *ctx = crtc->ctx;
+	struct decon_context *ctx = to_decon(crtc);
 
 	if (!(ctx->out_type & I80_HW_TRG))
 		disable_irq_nosync(ctx->te_irq);
@@ -143,7 +145,7 @@ static u32 decon_get_frame_count(struct decon_context *ctx, bool end)
 
 	switch (status & (VIDCON1_VSTATUS_MASK | VIDCON1_I80_ACTIVE)) {
 	case VIDCON1_VSTATUS_VS:
-		if (!(ctx->crtc->i80_mode))
+		if (!(ctx->crtc.i80_mode))
 			--frm;
 		break;
 	case VIDCON1_VSTATUS_BP:
@@ -163,7 +165,7 @@ static u32 decon_get_frame_count(struct decon_context *ctx, bool end)
 
 static void decon_setup_trigger(struct decon_context *ctx)
 {
-	if (!ctx->crtc->i80_mode && !(ctx->out_type & I80_HW_TRG))
+	if (!ctx->crtc.i80_mode && !(ctx->out_type & I80_HW_TRG))
 		return;
 
 	if (!(ctx->out_type & I80_HW_TRG)) {
@@ -183,7 +185,7 @@ static void decon_setup_trigger(struct decon_context *ctx)
 
 static void decon_commit(struct exynos_drm_crtc *crtc)
 {
-	struct decon_context *ctx = crtc->ctx;
+	struct decon_context *ctx = to_decon(crtc);
 	struct drm_display_mode *m = &crtc->base.mode;
 	bool interlaced = false;
 	u32 val;
@@ -377,7 +379,7 @@ static void decon_shadow_protect(struct decon_context *ctx, bool protect)
 
 static void decon_atomic_begin(struct exynos_drm_crtc *crtc)
 {
-	struct decon_context *ctx = crtc->ctx;
+	struct decon_context *ctx = to_decon(crtc);
 
 	decon_shadow_protect(ctx, true);
 }
@@ -391,7 +393,7 @@ static void decon_update_plane(struct exynos_drm_crtc *crtc,
 {
 	struct exynos_drm_plane_state *state =
 				to_exynos_plane_state(plane->base.state);
-	struct decon_context *ctx = crtc->ctx;
+	struct decon_context *ctx = to_decon(crtc);
 	struct drm_framebuffer *fb = state->base.fb;
 	unsigned int win = state->base.normalized_zpos + ctx->first_win;
 	unsigned int cpp = fb->format->cpp[0];
@@ -445,7 +447,7 @@ static void decon_update_plane(struct exynos_drm_crtc *crtc,
 
 static void decon_atomic_flush(struct exynos_drm_crtc *crtc)
 {
-	struct decon_context *ctx = crtc->ctx;
+	struct decon_context *ctx = to_decon(crtc);
 	unsigned long flags;
 	int win = hweight32(crtc->base.state->plane_mask) + ctx->first_win;
 
@@ -502,7 +504,7 @@ static void decon_swreset(struct decon_context *ctx)
 
 static void decon_enable(struct exynos_drm_crtc *crtc)
 {
-	struct decon_context *ctx = crtc->ctx;
+	struct decon_context *ctx = to_decon(crtc);
 
 	pm_runtime_get_sync(ctx->dev);
 
@@ -510,12 +512,12 @@ static void decon_enable(struct exynos_drm_crtc *crtc)
 
 	decon_swreset(ctx);
 
-	decon_commit(ctx->crtc);
+	decon_commit(&ctx->crtc);
 }
 
 static void decon_disable(struct exynos_drm_crtc *crtc)
 {
-	struct decon_context *ctx = crtc->ctx;
+	struct decon_context *ctx = to_decon(crtc);
 	int i;
 
 	if (!(ctx->out_type & I80_HW_TRG))
@@ -548,7 +550,7 @@ static irqreturn_t decon_te_irq_handler(int irq, void *dev_id)
 
 static void decon_clear_channels(struct exynos_drm_crtc *crtc)
 {
-	struct decon_context *ctx = crtc->ctx;
+	struct decon_context *ctx = to_decon(crtc);
 	int win, i, ret;
 
 	DRM_DEBUG_KMS("%s\n", __FILE__);
@@ -577,7 +579,7 @@ static void decon_clear_channels(struct exynos_drm_crtc *crtc)
 static enum drm_mode_status decon_mode_valid(struct exynos_drm_crtc *crtc,
 		const struct drm_display_mode *mode)
 {
-	struct decon_context *ctx = crtc->ctx;
+	struct decon_context *ctx = to_decon(crtc);
 
 	ctx->irq = crtc->i80_mode ? ctx->irq_lcd_sys : ctx->irq_vsync;
 
@@ -605,8 +607,6 @@ static int decon_bind(struct device *dev, struct device *master, void *data)
 {
 	struct decon_context *ctx = dev_get_drvdata(dev);
 	struct drm_device *drm_dev = data;
-	struct exynos_drm_plane *exynos_plane;
-	enum exynos_drm_output_type out_type;
 	unsigned int i;
 	int ret;
 
@@ -624,15 +624,15 @@ static int decon_bind(struct device *dev, struct device *master, void *data)
 			return ret;
 	}
 
-	exynos_plane = &ctx->planes[PRIMARY_WIN];
-	out_type = (ctx->out_type & IFTYPE_HDMI) ? EXYNOS_DISPLAY_TYPE_HDMI
-						  : EXYNOS_DISPLAY_TYPE_LCD;
-	ctx->crtc = exynos_drm_crtc_create(drm_dev, &exynos_plane->base,
-			out_type, &decon_crtc_ops, ctx);
-	if (IS_ERR(ctx->crtc))
-		return PTR_ERR(ctx->crtc);
+	ctx->crtc.type = (ctx->out_type & IFTYPE_HDMI)
+		       ? EXYNOS_DISPLAY_TYPE_HDMI : EXYNOS_DISPLAY_TYPE_LCD;
+	ctx->crtc.ops = &decon_crtc_ops;
+	ret = exynos_drm_crtc_init(&ctx->crtc, drm_dev);
+	if (ret)
+		return ret;
+	ctx->crtc.base.primary = &ctx->planes[PRIMARY_WIN].base;
 
-	decon_clear_channels(ctx->crtc);
+	decon_clear_channels(&ctx->crtc);
 
 	return exynos_drm_register_dma(drm_dev, dev);
 }
@@ -641,7 +641,7 @@ static void decon_unbind(struct device *dev, struct device *master, void *data)
 {
 	struct decon_context *ctx = dev_get_drvdata(dev);
 
-	decon_disable(ctx->crtc);
+	decon_disable(&ctx->crtc);
 
 	/* detach this sub driver from iommu mapping if supported. */
 	exynos_drm_unregister_dma(ctx->drm_dev, ctx->dev);
@@ -663,7 +663,7 @@ static void decon_handle_vblank(struct decon_context *ctx)
 	if (frm != ctx->frame_id) {
 		/* handle only if incremented, take care of wrap-around */
 		if ((s32)(frm - ctx->frame_id) > 0)
-			drm_crtc_handle_vblank(&ctx->crtc->base);
+			drm_crtc_handle_vblank(&ctx->crtc.base);
 		ctx->frame_id = frm;
 	}
 
-- 
2.17.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  parent reply	other threads:[~2019-03-01 12:20 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20190301122106eucas1p2dc9cbc6d822965bfa3cd2de83f3a7812@eucas1p2.samsung.com>
2019-03-01 12:20 ` [PATCH 00/23] drm/exynos: add support for GSCALER planes on Exynos5433 Andrzej Hajda
     [not found]   ` <CGME20190301122106eucas1p2abe70ca71f4cab803c0edd88ea46996e@eucas1p2.samsung.com>
2019-03-01 12:20     ` [PATCH 01/23] drm/exynos: remove exynos_drm_plane.h header Andrzej Hajda
     [not found]   ` <CGME20190301122107eucas1p2a284b545b5b379e61dd960ab66ae2bdb@eucas1p2.samsung.com>
2019-03-01 12:20     ` [PATCH 02/23] drm/exynos: remove spare macro Andrzej Hajda
     [not found]   ` <CGME20190301122107eucas1p2d2defd88a0375c1a2dc00860d43aa7fd@eucas1p2.samsung.com>
2019-03-01 12:20     ` [PATCH 03/23] drm/exynos: drop exynos_drm_plane_config structure Andrzej Hajda
     [not found]   ` <CGME20190301122107eucas1p2b546a8f156d54c45669bfa9724c4b8c2@eucas1p2.samsung.com>
2019-03-01 12:20     ` [PATCH 04/23] drm/exynos: add exynos_drm_crtc_init function Andrzej Hajda
     [not found]   ` <CGME20190301122107eucas1p21e887d2025b970939cabe52ee215b9fe@eucas1p2.samsung.com>
2019-03-01 12:20     ` Andrzej Hajda [this message]
     [not found]   ` <CGME20190301122108eucas1p2b52e33f1799eefb8ac68d7c4063bb2b9@eucas1p2.samsung.com>
2019-03-01 12:20     ` [PATCH 06/23] drm/exynos/decon7: embed exynos_drm_crtc directly into context Andrzej Hajda
     [not found]   ` <CGME20190301122108eucas1p25f8fcb147e5dd0be0d877c55effa7e7e@eucas1p2.samsung.com>
2019-03-01 12:20     ` [PATCH 07/23] drm/exynos/fimd: " Andrzej Hajda
     [not found]   ` <CGME20190301122108eucas1p2ef7114bd5e714ce38ff070e404fd51a2@eucas1p2.samsung.com>
2019-03-01 12:20     ` [PATCH 08/23] drm/exynos/mixer: " Andrzej Hajda
     [not found]   ` <CGME20190301122109eucas1p22f304f014932064d4b02caa01b4583ac@eucas1p2.samsung.com>
2019-03-01 12:20     ` [PATCH 09/23] drm/exynos/vidi: " Andrzej Hajda
     [not found]   ` <CGME20190301122109eucas1p28ae2e947e12d640d1932895fc4d3c14a@eucas1p2.samsung.com>
2019-03-01 12:20     ` [PATCH 10/23] drm/exynos: remove standalone exynos_drm_crtc leftovers Andrzej Hajda
     [not found]   ` <CGME20190301122110eucas1p2506e2cc528823cb2276d757ad49cc396@eucas1p2.samsung.com>
2019-03-01 12:20     ` [PATCH 11/23] drm/exynos/vidi: remove encoder_to_vidi helper Andrzej Hajda
     [not found]   ` <CGME20190301122110eucas1p2e11aa4aac815820d1bcfc5dae485f060@eucas1p2.samsung.com>
2019-03-01 12:20     ` [PATCH 12/23] drm/exynos: unify plane type assignment Andrzej Hajda
     [not found]   ` <CGME20190301122110eucas1p2107b2c2837e9bad58bf21b7869b7e0eb@eucas1p2.samsung.com>
2019-03-01 12:20     ` [PATCH 13/23] drm/exynos: set primary and cursor planes in exynos_drm_crtc_init Andrzej Hajda
     [not found]   ` <CGME20190301122111eucas1p2cb70cdfa7e8c1ad6e32af695a2f88b10@eucas1p2.samsung.com>
2019-03-01 12:20     ` [PATCH 14/23] drm/exynos: add plane update/disable callbacks for planes Andrzej Hajda
     [not found]   ` <CGME20190301122111eucas1p2c0184ad8117054056ac10e6afd949a9f@eucas1p2.samsung.com>
2019-03-01 12:20     ` [PATCH 15/23] drm/exynos: add GSCALER plane capability Andrzej Hajda
     [not found]   ` <CGME20190301122112eucas1p2c0099b31af68e2c72c07640ab994123a@eucas1p2.samsung.com>
2019-03-01 12:20     ` [PATCH 16/23] drm/exynos/gscaler: fix id assignement Andrzej Hajda
     [not found]   ` <CGME20190301122112eucas1p2fe4f1ab4dfc3026f1a64bb07c649a590@eucas1p2.samsung.com>
2019-03-01 12:20     ` [PATCH 17/23] arm64: dts: exynos: configure GSCALER related clocks Andrzej Hajda
     [not found]   ` <CGME20190301122112eucas1p2d389c3d94c691507d5ac2c3d224e2e32@eucas1p2.samsung.com>
2019-03-01 12:20     ` [PATCH 18/23] arm64: dts: exynos: add DSD/GSD clocks to DECONs and GSCALERs Andrzej Hajda
2019-03-05  9:28       ` Krzysztof Kozlowski
2019-03-05  9:36         ` Andrzej Hajda
2019-03-05  9:37           ` Krzysztof Kozlowski
     [not found]   ` <CGME20190301122113eucas1p2c3cce6f8651859bdef9785e3c7042efc@eucas1p2.samsung.com>
2019-03-01 12:20     ` [PATCH 19/23] drm/exynos/gscaler: add local path support Andrzej Hajda
     [not found]   ` <CGME20190301122113eucas1p2bd3c00441025c99aa20e933441bd3f21@eucas1p2.samsung.com>
2019-03-01 12:20     ` [PATCH 20/23] drm/exynos/decon5433: " Andrzej Hajda
     [not found]   ` <CGME20190301122113eucas1p25f441847f19e4d1a355bffd7633dcd5d@eucas1p2.samsung.com>
2019-03-01 12:20     ` [PATCH 21/23] drm/exynos/decon5433: wait for finish previous update Andrzej Hajda
     [not found]   ` <CGME20190301122114eucas1p2f8722a93496077bfa60c7865781763b9@eucas1p2.samsung.com>
2019-03-01 12:20     ` [PATCH 22/23] drm/exynos/gscaler: change supported color format BGRX8888 to XBGR8888 Andrzej Hajda
     [not found]   ` <CGME20190301122114eucas1p2c257303e00546f399ee3e5f97962c28c@eucas1p2.samsung.com>
2019-03-01 12:20     ` [PATCH 23/23] drm/exynos/gscaler: fix handling YVU420 pixel format Andrzej Hajda

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=20190301122055.7135-6-a.hajda@samsung.com \
    --to=a.hajda@samsung.com \
    --cc=b.zolnierkie@samsung.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=inki.dae@samsung.com \
    --cc=linux-samsung-soc@vger.kernel.org \
    --cc=m.szyprowski@samsung.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.