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,
	Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>,
	Krzysztof Kozlowski <krzk@kernel.org>,
	dri-devel@lists.freedesktop.org,
	Marek Szyprowski <m.szyprowski@samsung.com>
Subject: [PATCH v3 RESEND 14/24] drm/exynos: unify plane type assignment
Date: Mon, 25 Mar 2019 08:13:39 +0100	[thread overview]
Message-ID: <20190325071349.22600-15-a.hajda@samsung.com> (raw)
In-Reply-To: <20190325071349.22600-1-a.hajda@samsung.com>

Since all Exynos CRTCs uses the first plane as primary plane and the last
one as cursor plane we can drop custom assignments per CRTC and replace it
with common code.

Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
---
 drivers/gpu/drm/exynos/exynos5433_drm_decon.c |  7 +------
 drivers/gpu/drm/exynos/exynos7_drm_decon.c    |  7 +------
 drivers/gpu/drm/exynos/exynos_drm_drv.h       |  2 +-
 drivers/gpu/drm/exynos/exynos_drm_fimd.c      | 10 +---------
 drivers/gpu/drm/exynos/exynos_drm_plane.c     | 19 +++++++++++++------
 drivers/gpu/drm/exynos/exynos_drm_vidi.c      |  8 +-------
 drivers/gpu/drm/exynos/exynos_mixer.c         |  6 ++----
 7 files changed, 20 insertions(+), 39 deletions(-)

diff --git a/drivers/gpu/drm/exynos/exynos5433_drm_decon.c b/drivers/gpu/drm/exynos/exynos5433_drm_decon.c
index 0d409f453923..663446ca2d09 100644
--- a/drivers/gpu/drm/exynos/exynos5433_drm_decon.c
+++ b/drivers/gpu/drm/exynos/exynos5433_drm_decon.c
@@ -78,11 +78,6 @@ static const uint32_t decon_formats[] = {
 	DRM_FORMAT_ARGB8888,
 };
 
-static const enum drm_plane_type decon_win_types[WINDOWS_NR] = {
-	[PRIMARY_WIN] = DRM_PLANE_TYPE_PRIMARY,
-	[CURSON_WIN] = DRM_PLANE_TYPE_CURSOR,
-};
-
 static inline void decon_set_bits(struct decon_context *ctx, u32 reg, u32 mask,
 				  u32 val)
 {
@@ -619,7 +614,7 @@ static int decon_bind(struct device *dev, struct device *master, void *data)
 					| EXYNOS_DRM_PLANE_CAP_PIX_BLEND;
 		ret = exynos_plane_init(drm_dev, &ctx->planes[i],
 			decon_formats, ARRAY_SIZE(decon_formats),
-			decon_win_types[i]);
+			WINDOWS_NR - ctx->first_win);
 		if (ret)
 			return ret;
 	}
diff --git a/drivers/gpu/drm/exynos/exynos7_drm_decon.c b/drivers/gpu/drm/exynos/exynos7_drm_decon.c
index 22659f2da755..b6ad2faed159 100644
--- a/drivers/gpu/drm/exynos/exynos7_drm_decon.c
+++ b/drivers/gpu/drm/exynos/exynos7_drm_decon.c
@@ -78,11 +78,6 @@ static const uint32_t decon_formats[] = {
 	DRM_FORMAT_BGRA8888,
 };
 
-static const enum drm_plane_type decon_win_types[WINDOWS_NR] = {
-	DRM_PLANE_TYPE_PRIMARY,
-	DRM_PLANE_TYPE_CURSOR,
-};
-
 static void decon_wait_for_vblank(struct exynos_drm_crtc *crtc)
 {
 	struct decon_context *ctx = to_decon(crtc);
@@ -628,7 +623,7 @@ static int decon_bind(struct device *dev, struct device *master, void *data)
 	for (i = 0; i < WINDOWS_NR; i++) {
 		ctx->planes[i].index = i;
 		ret = exynos_plane_init(drm_dev, &ctx->planes[i], decon_formats,
-			ARRAY_SIZE(decon_formats), decon_win_types[i]);
+			ARRAY_SIZE(decon_formats), WINDOWS_NR);
 		if (ret)
 			return ret;
 	}
diff --git a/drivers/gpu/drm/exynos/exynos_drm_drv.h b/drivers/gpu/drm/exynos/exynos_drm_drv.h
index 82af112be03d..23b27b82de6e 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_drv.h
+++ b/drivers/gpu/drm/exynos/exynos_drm_drv.h
@@ -97,7 +97,7 @@ struct exynos_drm_plane {
 
 int exynos_plane_init(struct drm_device *dev, struct exynos_drm_plane *plane,
 		      const uint32_t *pixel_formats, int num_pixel_formats,
-		      enum drm_plane_type type);
+		      int win_count);
 
 /*
  * Exynos drm crtc ops
diff --git a/drivers/gpu/drm/exynos/exynos_drm_fimd.c b/drivers/gpu/drm/exynos/exynos_drm_fimd.c
index 8ea1cfd51736..b3c11bca5aed 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_fimd.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_fimd.c
@@ -212,14 +212,6 @@ static const struct of_device_id fimd_driver_dt_match[] = {
 };
 MODULE_DEVICE_TABLE(of, fimd_driver_dt_match);
 
-static const enum drm_plane_type fimd_win_types[WINDOWS_NR] = {
-	DRM_PLANE_TYPE_PRIMARY,
-	DRM_PLANE_TYPE_OVERLAY,
-	DRM_PLANE_TYPE_OVERLAY,
-	DRM_PLANE_TYPE_OVERLAY,
-	DRM_PLANE_TYPE_CURSOR,
-};
-
 static const uint32_t fimd_formats[] = {
 	DRM_FORMAT_C8,
 	DRM_FORMAT_XRGB1555,
@@ -1049,7 +1041,7 @@ static int fimd_bind(struct device *dev, struct device *master, void *data)
 					    | EXYNOS_DRM_PLANE_CAP_WIN_BLEND
 					    | EXYNOS_DRM_PLANE_CAP_PIX_BLEND;
 		ret = exynos_plane_init(drm_dev, &ctx->planes[i], fimd_formats,
-				ARRAY_SIZE(fimd_formats), fimd_win_types[i]);
+				ARRAY_SIZE(fimd_formats), WINDOWS_NR);
 		if (ret)
 			return ret;
 	}
diff --git a/drivers/gpu/drm/exynos/exynos_drm_plane.c b/drivers/gpu/drm/exynos/exynos_drm_plane.c
index e1aa504539fa..5f8f56b69369 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_plane.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_plane.c
@@ -291,9 +291,18 @@ static void exynos_plane_attach_zpos_property(struct drm_plane *plane,
 		drm_plane_create_zpos_property(plane, zpos, 0, MAX_PLANE - 1);
 }
 
+static inline enum drm_plane_type exynos_plane_type(int index, int count)
+{
+	if (count && !index)
+		return DRM_PLANE_TYPE_PRIMARY;
+	if (index == count - 1)
+		return DRM_PLANE_TYPE_CURSOR;
+	return DRM_PLANE_TYPE_OVERLAY;
+}
+
 int exynos_plane_init(struct drm_device *dev, struct exynos_drm_plane *plane,
 		      const uint32_t *pixel_formats, int num_pixel_formats,
-		      enum drm_plane_type type)
+		      int win_count)
 {
 	int err;
 	unsigned int supported_modes = BIT(DRM_MODE_BLEND_PIXEL_NONE) |
@@ -302,11 +311,9 @@ int exynos_plane_init(struct drm_device *dev, struct exynos_drm_plane *plane,
 	struct drm_plane *bplane = &plane->base;
 
 	err = drm_universal_plane_init(dev, bplane,
-				       1 << dev->mode_config.num_crtc,
-				       &exynos_plane_funcs,
-				       pixel_formats,
-				       num_pixel_formats,
-				       NULL, type, NULL);
+		1 << dev->mode_config.num_crtc,
+		&exynos_plane_funcs, pixel_formats, num_pixel_formats,NULL,
+		exynos_plane_type(plane->index, win_count), NULL);
 	if (err) {
 		DRM_ERROR("failed to initialize plane\n");
 		return err;
diff --git a/drivers/gpu/drm/exynos/exynos_drm_vidi.c b/drivers/gpu/drm/exynos/exynos_drm_vidi.c
index 2579462aec70..eb1fd3a2cdf3 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_vidi.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_vidi.c
@@ -85,12 +85,6 @@ static const uint32_t formats[] = {
 	DRM_FORMAT_NV12,
 };
 
-static const enum drm_plane_type vidi_win_types[WINDOWS_NR] = {
-	DRM_PLANE_TYPE_PRIMARY,
-	DRM_PLANE_TYPE_OVERLAY,
-	DRM_PLANE_TYPE_CURSOR,
-};
-
 static int vidi_enable_vblank(struct exynos_drm_crtc *crtc)
 {
 	struct vidi_context *ctx = to_vidi(crtc);
@@ -381,7 +375,7 @@ static int vidi_bind(struct device *dev, struct device *master, void *data)
 
 	for (i = 0; i < WINDOWS_NR; i++) {
 		ret = exynos_plane_init(drm_dev, &ctx->planes[i], formats,
-				        ARRAY_SIZE(formats), vidi_win_types[i]);
+				        ARRAY_SIZE(formats), WINDOWS_NR);
 		if (ret)
 			return ret;
 	}
diff --git a/drivers/gpu/drm/exynos/exynos_mixer.c b/drivers/gpu/drm/exynos/exynos_mixer.c
index 7fcefcbe68db..a61fb2069e32 100644
--- a/drivers/gpu/drm/exynos/exynos_mixer.c
+++ b/drivers/gpu/drm/exynos/exynos_mixer.c
@@ -1143,8 +1143,6 @@ static int mixer_bind(struct device *dev, struct device *manager, void *data)
 	struct drm_device *drm_dev = data;
 	unsigned int i;
 	int ret;
-	static enum drm_plane_type types[] = { DRM_PLANE_TYPE_PRIMARY,
-		DRM_PLANE_TYPE_CURSOR, DRM_PLANE_TYPE_OVERLAY };
 
 	ret = mixer_initialize(ctx, drm_dev);
 	if (ret)
@@ -1157,7 +1155,7 @@ static int mixer_bind(struct device *dev, struct device *manager, void *data)
 					      EXYNOS_DRM_PLANE_CAP_PIX_BLEND |
 					      EXYNOS_DRM_PLANE_CAP_WIN_BLEND;
 		ret = exynos_plane_init(drm_dev, &ctx->planes[i], mixer_formats,
-			ARRAY_SIZE(mixer_formats), types[i]);
+			ARRAY_SIZE(mixer_formats), VP_DEFAULT_WIN);
 		if (ret)
 			return ret;
 	}
@@ -1169,7 +1167,7 @@ static int mixer_bind(struct device *dev, struct device *manager, void *data)
 					      EXYNOS_DRM_PLANE_CAP_TILE |
 					      EXYNOS_DRM_PLANE_CAP_WIN_BLEND;
 		ret = exynos_plane_init(drm_dev, &ctx->planes[i], vp_formats,
-			ARRAY_SIZE(vp_formats), types[i]);
+			ARRAY_SIZE(vp_formats), VP_DEFAULT_WIN);
 		if (ret)
 			return ret;
 	}
-- 
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-25  7:13 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20190325071353eucas1p185d973e14dac923aab381083b2b67445@eucas1p1.samsung.com>
2019-03-25  7:13 ` [PATCH v3 RESEND 00/24] drm/exynos: add support for GSCALER planes on Exynos5433 Andrzej Hajda
     [not found]   ` <CGME20190325071353eucas1p13470b85473aa92b25d38fcf4eceea76e@eucas1p1.samsung.com>
2019-03-25  7:13     ` [PATCH v3 RESEND 01/24] arm64: dts: exynos: configure GSCALER related clocks Andrzej Hajda
2019-03-25  7:50       ` Krzysztof Kozlowski
2019-03-25  8:31         ` Andrzej Hajda
2019-03-25  8:44           ` Krzysztof Kozlowski
     [not found]   ` <CGME20190325071354eucas1p17f990ee93878c5909800044779b41451@eucas1p1.samsung.com>
2019-03-25  7:13     ` [PATCH v3 RESEND 02/24] arm64: dts: exynos: add DSD/GSD clocks to DECONs and GSCALERs Andrzej Hajda
     [not found]   ` <CGME20190325071354eucas1p181987b86e0e2df42f704f3e95f0c2b18@eucas1p1.samsung.com>
2019-03-25  7:13     ` [PATCH v3 RESEND 03/24] drm/exynos: remove exynos_drm_plane.h header Andrzej Hajda
     [not found]   ` <CGME20190325071354eucas1p11b39f3a06807b8619cea583c7dc40c18@eucas1p1.samsung.com>
2019-03-25  7:13     ` [PATCH v3 RESEND 04/24] drm/exynos: remove spare macro Andrzej Hajda
     [not found]   ` <CGME20190325071355eucas1p1bc10232953b0d9f122ee7d3d532374e8@eucas1p1.samsung.com>
2019-03-25  7:13     ` [PATCH v3 RESEND 05/24] drm/exynos: drop exynos_drm_plane_config structure Andrzej Hajda
     [not found]   ` <CGME20190325071355eucas1p1cbb56752b2560cb6384d79df9c4124a3@eucas1p1.samsung.com>
2019-03-25  7:13     ` [PATCH v3 RESEND 06/24] drm/exynos: add exynos_drm_crtc_init function Andrzej Hajda
     [not found]   ` <CGME20190325071356eucas1p111ff1323f9ef55582b6983ce91a0e58a@eucas1p1.samsung.com>
2019-03-25  7:13     ` [PATCH v3 RESEND 07/24] drm/exynos/decon5433: embed exynos_drm_crtc directly into context Andrzej Hajda
     [not found]   ` <CGME20190325071356eucas1p17598af50b99cecd3f04bd5bd7b665468@eucas1p1.samsung.com>
2019-03-25  7:13     ` [PATCH v3 RESEND 08/24] drm/exynos/decon7: " Andrzej Hajda
     [not found]   ` <CGME20190325071356eucas1p169112fff9a6b5914c93b162a267348f1@eucas1p1.samsung.com>
2019-03-25  7:13     ` [PATCH v3 RESEND 09/24] drm/exynos/fimd: " Andrzej Hajda
     [not found]   ` <CGME20190325071357eucas1p1d1def486ebc1697def8c4d670b7cd15c@eucas1p1.samsung.com>
2019-03-25  7:13     ` [PATCH v3 RESEND 10/24] drm/exynos/mixer: " Andrzej Hajda
     [not found]   ` <CGME20190325071357eucas1p107f56a7c71d033687e02d8eab03c8635@eucas1p1.samsung.com>
2019-03-25  7:13     ` [PATCH v3 RESEND 11/24] drm/exynos/vidi: " Andrzej Hajda
     [not found]   ` <CGME20190325071358eucas1p19d8fa7080e588979618ac4bb4aeccbeb@eucas1p1.samsung.com>
2019-03-25  7:13     ` [PATCH v3 RESEND 12/24] drm/exynos: remove standalone exynos_drm_crtc leftovers Andrzej Hajda
     [not found]   ` <CGME20190325071358eucas1p1e7f9aa715ac8f04b20fe6a64aa83700d@eucas1p1.samsung.com>
2019-03-25  7:13     ` [PATCH v3 RESEND 13/24] drm/exynos/vidi: remove encoder_to_vidi helper Andrzej Hajda
     [not found]   ` <CGME20190325071359eucas1p1b08952b714f0f81d694a0c0db8332521@eucas1p1.samsung.com>
2019-03-25  7:13     ` Andrzej Hajda [this message]
     [not found]   ` <CGME20190325071359eucas1p1701719f798584cd23cc8058d2f2c495b@eucas1p1.samsung.com>
2019-03-25  7:13     ` [PATCH v3 RESEND 15/24] drm/exynos: set primary plane in exynos_drm_crtc_init Andrzej Hajda
     [not found]   ` <CGME20190325071359eucas1p1b97bf55b51b840f4a049df4779800f11@eucas1p1.samsung.com>
2019-03-25  7:13     ` [PATCH v3 RESEND 16/24] drm/exynos: set cursor " Andrzej Hajda
     [not found]   ` <CGME20190325071400eucas1p1f80832bb0feba9bd11187aecf1ae61c7@eucas1p1.samsung.com>
2019-03-25  7:13     ` [PATCH v3 RESEND 17/24] drm/exynos: add plane update/disable callbacks for planes Andrzej Hajda
     [not found]   ` <CGME20190325071400eucas1p1a6740040c56d51b0a3658ec01c1bb9f6@eucas1p1.samsung.com>
2019-03-25  7:13     ` [PATCH v3 RESEND 18/24] drm/exynos: add GSCALER plane capability Andrzej Hajda
     [not found]   ` <CGME20190325071401eucas1p1ddc56702c8ff146f0fd84277f3f84e08@eucas1p1.samsung.com>
2019-03-25  7:13     ` [PATCH v3 RESEND 19/24] drm/exynos/gscaler: fix id assignement Andrzej Hajda
     [not found]   ` <CGME20190325071401eucas1p10d9ad1fcfc4a5e4f2b964cf04e5e5fe8@eucas1p1.samsung.com>
2019-03-25  7:13     ` [PATCH v3 RESEND 20/24] drm/exynos/gscaler: add local path support Andrzej Hajda
     [not found]   ` <CGME20190325071401eucas1p10df709b256570f1aba9cbc4e875da1b3@eucas1p1.samsung.com>
2019-03-25  7:13     ` [PATCH v3 RESEND 21/24] drm/exynos/decon5433: " Andrzej Hajda
2022-02-06 16:51       ` Krzysztof Kozlowski
2022-03-02  1:00         ` Inki Dae
2022-03-03 16:03           ` Krzysztof Kozlowski
2022-03-03 16:11             ` Marek Szyprowski
2022-03-03 16:12               ` Krzysztof Kozlowski
     [not found]   ` <CGME20190325071402eucas1p12176421bacd4f9bcf9341bc776044c56@eucas1p1.samsung.com>
2019-03-25  7:13     ` [PATCH v3 RESEND 22/24] drm/exynos/decon5433: wait for finish previous update Andrzej Hajda
     [not found]   ` <CGME20190325071402eucas1p1b21cd8cb6a2bfa0349821597b6291af5@eucas1p1.samsung.com>
2019-03-25  7:13     ` [PATCH v3 RESEND 23/24] drm/exynos/gscaler: change supported color format BGRX8888 to XBGR8888 Andrzej Hajda
     [not found]   ` <CGME20190325071403eucas1p15267241039dc4b1911f2357b7a43baac@eucas1p1.samsung.com>
2019-03-25  7:13     ` [PATCH v3 RESEND 24/24] drm/exynos/gscaler: fix handling YVU420 pixel format Andrzej Hajda
2019-03-26  8:45   ` [PATCH v3 RESEND 00/24] drm/exynos: add support for GSCALER planes on Exynos5433 Inki Dae
2019-03-26 13:51     ` Andrzej Hajda
2019-03-27  2:26       ` Inki Dae

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=20190325071349.22600-15-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 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.