dri-devel.lists.freedesktop.org archive mirror
 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,
	Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>,
	Krzysztof Kozlowski <krzk@kernel.org>,
	dri-devel@lists.freedesktop.org,
	Marek Szyprowski <m.szyprowski@samsung.com>
Subject: [PATCH v2 RESEND 08/24] drm/exynos/mixer: embed exynos_drm_crtc directly into context
Date: Wed, 20 Mar 2019 14:06:51 +0100	[thread overview]
Message-ID: <20190320130707.25161-9-a.hajda@samsung.com> (raw)
In-Reply-To: <20190320130707.25161-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/exynos_mixer.c | 39 ++++++++++++++-------------
 1 file changed, 20 insertions(+), 19 deletions(-)

diff --git a/drivers/gpu/drm/exynos/exynos_mixer.c b/drivers/gpu/drm/exynos/exynos_mixer.c
index 750f682e9c31..946d62ae83e3 100644
--- a/drivers/gpu/drm/exynos/exynos_mixer.c
+++ b/drivers/gpu/drm/exynos/exynos_mixer.c
@@ -98,7 +98,7 @@ struct mixer_context {
 	struct platform_device *pdev;
 	struct device		*dev;
 	struct drm_device	*drm_dev;
-	struct exynos_drm_crtc	*crtc;
+	struct exynos_drm_crtc	crtc;
 	struct exynos_drm_plane	planes[MIXER_WIN_NR];
 	unsigned long		flags;
 
@@ -116,6 +116,8 @@ struct mixer_context {
 	int			scan_value;
 };
 
+#define to_mixer(ptr) container_of(ptr, struct mixer_context, ptr)
+
 struct mixer_drv_data {
 	enum mixer_version_id	version;
 	bool					is_vp_enabled;
@@ -426,7 +428,7 @@ static void mixer_stop(struct mixer_context *ctx)
 
 static void mixer_commit(struct mixer_context *ctx)
 {
-	struct drm_display_mode *mode = &ctx->crtc->base.state->adjusted_mode;
+	struct drm_display_mode *mode = &ctx->crtc.base.state->adjusted_mode;
 
 	mixer_cfg_scan(ctx, mode->hdisplay, mode->vdisplay);
 	mixer_cfg_rgb_fmt(ctx, mode);
@@ -712,7 +714,7 @@ static irqreturn_t mixer_irq_handler(int irq, void *arg)
 				goto out;
 		}
 
-		drm_crtc_handle_vblank(&ctx->crtc->base);
+		drm_crtc_handle_vblank(&ctx->crtc.base);
 	}
 
 out:
@@ -856,7 +858,7 @@ static void mixer_ctx_remove(struct mixer_context *mixer_ctx)
 
 static int mixer_enable_vblank(struct exynos_drm_crtc *crtc)
 {
-	struct mixer_context *mixer_ctx = crtc->ctx;
+	struct mixer_context *mixer_ctx = to_mixer(crtc);
 
 	__set_bit(MXR_BIT_VSYNC, &mixer_ctx->flags);
 	if (!test_bit(MXR_BIT_POWERED, &mixer_ctx->flags))
@@ -871,7 +873,7 @@ static int mixer_enable_vblank(struct exynos_drm_crtc *crtc)
 
 static void mixer_disable_vblank(struct exynos_drm_crtc *crtc)
 {
-	struct mixer_context *mixer_ctx = crtc->ctx;
+	struct mixer_context *mixer_ctx = to_mixer(crtc);
 
 	__clear_bit(MXR_BIT_VSYNC, &mixer_ctx->flags);
 
@@ -885,7 +887,7 @@ static void mixer_disable_vblank(struct exynos_drm_crtc *crtc)
 
 static void mixer_atomic_begin(struct exynos_drm_crtc *crtc)
 {
-	struct mixer_context *mixer_ctx = crtc->ctx;
+	struct mixer_context *mixer_ctx = to_mixer(crtc);
 
 	if (!test_bit(MXR_BIT_POWERED, &mixer_ctx->flags))
 		return;
@@ -896,7 +898,7 @@ static void mixer_atomic_begin(struct exynos_drm_crtc *crtc)
 static void mixer_update_plane(struct exynos_drm_crtc *crtc,
 			       struct exynos_drm_plane *plane)
 {
-	struct mixer_context *mixer_ctx = crtc->ctx;
+	struct mixer_context *mixer_ctx = to_mixer(crtc);
 
 	DRM_DEBUG_KMS("win: %d\n", plane->index);
 
@@ -912,7 +914,7 @@ static void mixer_update_plane(struct exynos_drm_crtc *crtc,
 static void mixer_disable_plane(struct exynos_drm_crtc *crtc,
 				struct exynos_drm_plane *plane)
 {
-	struct mixer_context *mixer_ctx = crtc->ctx;
+	struct mixer_context *mixer_ctx = to_mixer(crtc);
 	unsigned long flags;
 
 	DRM_DEBUG_KMS("win: %d\n", plane->index);
@@ -927,7 +929,7 @@ static void mixer_disable_plane(struct exynos_drm_crtc *crtc,
 
 static void mixer_atomic_flush(struct exynos_drm_crtc *crtc)
 {
-	struct mixer_context *mixer_ctx = crtc->ctx;
+	struct mixer_context *mixer_ctx = to_mixer(crtc);
 
 	if (!test_bit(MXR_BIT_POWERED, &mixer_ctx->flags))
 		return;
@@ -938,7 +940,7 @@ static void mixer_atomic_flush(struct exynos_drm_crtc *crtc)
 
 static void mixer_enable(struct exynos_drm_crtc *crtc)
 {
-	struct mixer_context *ctx = crtc->ctx;
+	struct mixer_context *ctx = to_mixer(crtc);
 
 	if (test_bit(MXR_BIT_POWERED, &ctx->flags))
 		return;
@@ -967,7 +969,7 @@ static void mixer_enable(struct exynos_drm_crtc *crtc)
 
 static void mixer_disable(struct exynos_drm_crtc *crtc)
 {
-	struct mixer_context *ctx = crtc->ctx;
+	struct mixer_context *ctx = to_mixer(crtc);
 	int i;
 
 	if (!test_bit(MXR_BIT_POWERED, &ctx->flags))
@@ -989,7 +991,7 @@ static void mixer_disable(struct exynos_drm_crtc *crtc)
 static int mixer_mode_valid(struct exynos_drm_crtc *crtc,
 		const struct drm_display_mode *mode)
 {
-	struct mixer_context *ctx = crtc->ctx;
+	struct mixer_context *ctx = to_mixer(crtc);
 	u32 w = mode->hdisplay, h = mode->vdisplay;
 
 	DRM_DEBUG_KMS("xres=%d, yres=%d, refresh=%d, intl=%d\n", w, h,
@@ -1015,7 +1017,7 @@ static bool mixer_mode_fixup(struct exynos_drm_crtc *crtc,
 		   const struct drm_display_mode *mode,
 		   struct drm_display_mode *adjusted_mode)
 {
-	struct mixer_context *ctx = crtc->ctx;
+	struct mixer_context *ctx = to_mixer(crtc);
 	int width = mode->hdisplay, height = mode->vdisplay, i;
 
 	struct {
@@ -1117,7 +1119,6 @@ static int mixer_bind(struct device *dev, struct device *manager, void *data)
 {
 	struct mixer_context *ctx = dev_get_drvdata(dev);
 	struct drm_device *drm_dev = data;
-	struct exynos_drm_plane *exynos_plane;
 	unsigned int i;
 	int ret;
 	static enum drm_plane_type types[] = { DRM_PLANE_TYPE_PRIMARY,
@@ -1151,14 +1152,14 @@ static int mixer_bind(struct device *dev, struct device *manager, void *data)
 			return ret;
 	}
 
-	exynos_plane = &ctx->planes[DEFAULT_WIN];
-	ctx->crtc = exynos_drm_crtc_create(drm_dev, &exynos_plane->base,
-			EXYNOS_DISPLAY_TYPE_HDMI, &mixer_crtc_ops, ctx);
-	if (IS_ERR(ctx->crtc)) {
+	ctx->crtc.type = EXYNOS_DISPLAY_TYPE_HDMI;
+	ctx->crtc.ops = &mixer_crtc_ops;
+	ret = exynos_drm_crtc_init(&ctx->crtc, drm_dev);
+	if (ret) {
 		mixer_ctx_remove(ctx);
-		ret = PTR_ERR(ctx->crtc);
 		goto free_ctx;
 	}
+	ctx->crtc.base.primary = &ctx->planes[DEFAULT_WIN].base;
 
 	return 0;
 
-- 
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-20 13:07 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20190320130711eucas1p2b9f18d009647652b4bb912fdd40c9f74@eucas1p2.samsung.com>
2019-03-20 13:06 ` [PATCH v2 RESEND 00/24] drm/exynos: add support for GSCALER planes on Exynos5433 Andrzej Hajda
     [not found]   ` <CGME20190320130712eucas1p2c98ef5f0f42d422dc711c222fa4da11b@eucas1p2.samsung.com>
2019-03-20 13:06     ` [PATCH v2 RESEND 01/24] drm/exynos: remove exynos_drm_plane.h header Andrzej Hajda
     [not found]   ` <CGME20190320130712eucas1p2f3735c6c5afd7117f297ce7f495e4479@eucas1p2.samsung.com>
2019-03-20 13:06     ` [PATCH v2 RESEND 02/24] drm/exynos: remove spare macro Andrzej Hajda
     [not found]   ` <CGME20190320130713eucas1p137746c8fcdf13bbe1c897c27a245b22a@eucas1p1.samsung.com>
2019-03-20 13:06     ` [PATCH v2 RESEND 03/24] drm/exynos: drop exynos_drm_plane_config structure Andrzej Hajda
     [not found]   ` <CGME20190320130713eucas1p2dd57732ea0135355863ba26424a8bacf@eucas1p2.samsung.com>
2019-03-20 13:06     ` [PATCH v2 RESEND 04/24] drm/exynos: add exynos_drm_crtc_init function Andrzej Hajda
     [not found]   ` <CGME20190320130714eucas1p1c0b414ed76d7d0d78da56c9c0a6c8973@eucas1p1.samsung.com>
2019-03-20 13:06     ` [PATCH v2 RESEND 05/24] drm/exynos/decon5433: embed exynos_drm_crtc directly into context Andrzej Hajda
     [not found]   ` <CGME20190320130714eucas1p2e4f96fe67486283560c7b6a8627b769c@eucas1p2.samsung.com>
2019-03-20 13:06     ` [PATCH v2 RESEND 06/24] drm/exynos/decon7: " Andrzej Hajda
     [not found]   ` <CGME20190320130714eucas1p1d3ab6fceec849f22bab69df1e46b972d@eucas1p1.samsung.com>
2019-03-20 13:06     ` [PATCH v2 RESEND 07/24] drm/exynos/fimd: " Andrzej Hajda
     [not found]   ` <CGME20190320130715eucas1p250b6b902360896cd36bff8536b6292bf@eucas1p2.samsung.com>
2019-03-20 13:06     ` Andrzej Hajda [this message]
     [not found]   ` <CGME20190320130715eucas1p2ab0449e8b243fcfa2d63524363eb8544@eucas1p2.samsung.com>
2019-03-20 13:06     ` [PATCH v2 RESEND 09/24] drm/exynos/vidi: " Andrzej Hajda
     [not found]   ` <CGME20190320130715eucas1p1cc35aa50021848a6f3d5459bb0c6d1bf@eucas1p1.samsung.com>
2019-03-20 13:06     ` [PATCH v2 RESEND 10/24] drm/exynos: remove standalone exynos_drm_crtc leftovers Andrzej Hajda
     [not found]   ` <CGME20190320130716eucas1p2fa37979f7715c411e079d146b96628cb@eucas1p2.samsung.com>
2019-03-20 13:06     ` [PATCH v2 RESEND 11/24] drm/exynos/vidi: remove encoder_to_vidi helper Andrzej Hajda
     [not found]   ` <CGME20190320130716eucas1p121bc6480ad28d1c0c79c195ae943ee55@eucas1p1.samsung.com>
2019-03-20 13:06     ` [PATCH v2 RESEND 12/24] drm/exynos: unify plane type assignment Andrzej Hajda
     [not found]   ` <CGME20190320130717eucas1p2a2a480a8c5d71fc66741410829a0d016@eucas1p2.samsung.com>
2019-03-20 13:06     ` [PATCH v2 RESEND 13/24] drm/exynos: set primary plane in exynos_drm_crtc_init Andrzej Hajda
     [not found]   ` <CGME20190320130717eucas1p2c75749455fa4b34b4d21f9873b3d9cb6@eucas1p2.samsung.com>
2019-03-20 13:06     ` [PATCH v2 RESEND 14/24] drm/exynos: set cursor " Andrzej Hajda
     [not found]   ` <CGME20190320130718eucas1p15d440d88365fa5ea213f592b97e6f226@eucas1p1.samsung.com>
2019-03-20 13:06     ` [PATCH v2 RESEND 15/24] drm/exynos: add plane update/disable callbacks for planes Andrzej Hajda
     [not found]   ` <CGME20190320130718eucas1p1e42feb422bda24a2db733d50eb41ea47@eucas1p1.samsung.com>
2019-03-20 13:06     ` [PATCH v2 RESEND 16/24] drm/exynos: add GSCALER plane capability Andrzej Hajda
     [not found]   ` <CGME20190320130719eucas1p1b411bcd1e32a500202a19a24a4ba92a6@eucas1p1.samsung.com>
2019-03-20 13:07     ` [PATCH v2 RESEND 17/24] drm/exynos/gscaler: fix id assignement Andrzej Hajda
     [not found]   ` <CGME20190320130719eucas1p274be59cfcd798d21ea583bc22f218ff7@eucas1p2.samsung.com>
2019-03-20 13:07     ` [PATCH v2 RESEND 18/24] arm64: dts: exynos: configure GSCALER related clocks Andrzej Hajda
     [not found]   ` <CGME20190320130719eucas1p2e59268e628f6c88db6b632abb153313a@eucas1p2.samsung.com>
2019-03-20 13:07     ` [PATCH v2 RESEND 19/24] arm64: dts: exynos: add DSD/GSD clocks to DECONs and GSCALERs Andrzej Hajda
     [not found]   ` <CGME20190320130720eucas1p1b6f2351c2262d2c89a464fdc10a6a607@eucas1p1.samsung.com>
2019-03-20 13:07     ` [PATCH v2 RESEND 20/24] drm/exynos/gscaler: add local path support Andrzej Hajda
     [not found]   ` <CGME20190320130720eucas1p1f2b27e5d340a50dc710155b37e7b173b@eucas1p1.samsung.com>
2019-03-20 13:07     ` [PATCH v2 RESEND 21/24] drm/exynos/decon5433: " Andrzej Hajda
     [not found]   ` <CGME20190320130721eucas1p2097f22c60919e45a10f9dff6dd678c99@eucas1p2.samsung.com>
2019-03-20 13:07     ` [PATCH v2 RESEND 22/24] drm/exynos/decon5433: wait for finish previous update Andrzej Hajda
     [not found]   ` <CGME20190320130721eucas1p258d3ace8294e90446d369c1d45941dc9@eucas1p2.samsung.com>
2019-03-20 13:07     ` [PATCH v2 RESEND 23/24] drm/exynos/gscaler: change supported color format BGRX8888 to XBGR8888 Andrzej Hajda
     [not found]   ` <CGME20190320130722eucas1p201e6452c3329fdbbc651051da9b14155@eucas1p2.samsung.com>
2019-03-20 13:07     ` [PATCH v2 RESEND 24/24] drm/exynos/gscaler: fix handling YVU420 pixel format Andrzej Hajda
2019-03-25  3:12   ` [PATCH v2 RESEND 00/24] drm/exynos: add support for GSCALER planes on Exynos5433 Inki Dae
2019-03-25  7:21     ` 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=20190320130707.25161-9-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=krzk@kernel.org \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).