All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ville Syrjala <ville.syrjala@linux.intel.com>
To: igt-dev@lists.freedesktop.org
Subject: [PATCH i-g-t 11/11] lib/kms: Streamline plane index handling further
Date: Wed, 17 Dec 2025 17:37:57 +0200	[thread overview]
Message-ID: <20251217153758.9369-12-ville.syrjala@linux.intel.com> (raw)
In-Reply-To: <20251217153758.9369-1-ville.syrjala@linux.intel.com>

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

Eliminate some redundant plane type checks and just rely
on plane_type_index() knowing what it's doing.

We do need to keep one plane type check to determing
what to do with pipe->num_primary_plane and
pipe->has_cursor_plane. But it's a bit more obvious
what's happening there now that index stuff isn't mixed in.

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 lib/igt_kms.c | 43 +++++++++++++++++++------------------------
 1 file changed, 19 insertions(+), 24 deletions(-)

diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index 4f30732bf1bb..04a86f235471 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -3075,24 +3075,26 @@ static void igt_crtc_plane_init(igt_display_t *display,
 	drmModePlane *drm_plane = global_plane->drm_plane;
 	int type = global_plane->type;
 	igt_plane_t *plane;
-	int index = plane_type_index(pipe, type);
+	int index;
 
-	if (type == DRM_PLANE_TYPE_PRIMARY && pipe->planes[index].index < 0) {
+	switch (type) {
+	case DRM_PLANE_TYPE_PRIMARY:
 		pipe->num_primary_planes++;
-	} else if (type == DRM_PLANE_TYPE_CURSOR && pipe->planes[index].index < 0) {
+		break;
+	case DRM_PLANE_TYPE_CURSOR:
 		display->has_cursor_plane = true;
-	} else {
+		break;
+	default:
+		break;
+	}
+
+	index = plane_type_index(pipe, type);
+
+	if (index < 0 || pipe->planes[index].index >= 0) {
 		for (index = 1; index < pipe->n_planes; index++) {
 			if (pipe->planes[index].index < 0)
 				break;
 		}
-
-		/*
-		 * Increment num_primary_planes for any extra
-		 * primary plane found.
-		 */
-		if (type == DRM_PLANE_TYPE_PRIMARY)
-			pipe->num_primary_planes++;
 	}
 
 	igt_assert_lt(index, pipe->n_planes);
@@ -3576,20 +3578,13 @@ static igt_plane_t *igt_pipe_get_plane(igt_crtc_t *pipe, int plane_idx)
  */
 igt_plane_t *igt_pipe_get_plane_type(igt_crtc_t *pipe, int plane_type)
 {
-	int i, plane_idx = -1;
+	int plane_idx = plane_type_index(pipe, plane_type);
 
-	switch(plane_type) {
-	case DRM_PLANE_TYPE_CURSOR:
-	case DRM_PLANE_TYPE_PRIMARY:
-		plane_idx = plane_type_index(pipe, plane_type);
-		break;
-	case DRM_PLANE_TYPE_OVERLAY:
-		for(i = 0; i < pipe->n_planes; i++)
-			if (pipe->planes[i].type == DRM_PLANE_TYPE_OVERLAY)
-			    plane_idx = i;
-		break;
-	default:
-		break;
+	if (plane_idx < 0) {
+		for (plane_idx = 0; plane_idx < pipe->n_planes; plane_idx++) {
+			if (pipe->planes[plane_idx].type == plane_type)
+				break;
+		}
 	}
 
 	igt_require_f(plane_idx >= 0 && plane_idx < pipe->n_planes,
-- 
2.51.2


  parent reply	other threads:[~2025-12-17 15:38 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-17 15:37 [PATCH i-g-t 00/11] lib/kms: Carve up igt_display_require() Ville Syrjala
2025-12-17 15:37 ` [PATCH i-g-t 01/11] lib/kms: Extract igt_crtc_init() Ville Syrjala
2025-12-17 19:04   ` Jani Nikula
2025-12-17 15:37 ` [PATCH i-g-t 02/11] lib/kms: Nuke 'n_planes' from igt_crtc_init() Ville Syrjala
2025-12-17 19:11   ` Jani Nikula
2025-12-17 15:37 ` [PATCH i-g-t 03/11] lib/kms: Nuke 'last_plane' " Ville Syrjala
2025-12-17 19:12   ` Jani Nikula
2025-12-17 15:37 ` [PATCH i-g-t 04/11] lib/kms: Get rid of the 'p' plane index variable Ville Syrjala
2025-12-17 19:17   ` Jani Nikula
2025-12-18 11:33   ` Jani Nikula
2025-12-18 15:47   ` [PATCH i-g-t v2 " Ville Syrjala
2025-12-19 10:55     ` Jani Nikula
2025-12-17 15:37 ` [PATCH i-g-t 05/11] lib/kms: Extract igt_crtc_plane_init() Ville Syrjala
2025-12-17 19:18   ` Jani Nikula
2025-12-18 15:48   ` [PATCH i-g-t v2 " Ville Syrjala
2025-12-17 15:37 ` [PATCH i-g-t 06/11] lib/kms: Nuke pipe->plane_primary Ville Syrjala
2025-12-18 11:37   ` Jani Nikula
2025-12-17 15:37 ` [PATCH i-g-t 07/11] lib/kms: Nuke pipe->plane_cursor Ville Syrjala
2025-12-18 11:39   ` Jani Nikula
2025-12-17 15:37 ` [PATCH i-g-t 08/11] lib/kms: Use '{old, new}_primary' variable names in plane swapping Ville Syrjala
2025-12-17 19:20   ` Jani Nikula
2025-12-17 15:37 ` [PATCH i-g-t 09/11] lib/kms: Pimp the priamry " Ville Syrjala
2025-12-19 12:00   ` Jani Nikula
2025-12-17 15:37 ` [PATCH i-g-t 10/11] lib/kms: Extract plane_type_index() Ville Syrjala
2025-12-19 12:08   ` Jani Nikula
2025-12-17 15:37 ` Ville Syrjala [this message]
2025-12-19 12:10   ` [PATCH i-g-t 11/11] lib/kms: Streamline plane index handling further Jani Nikula
2025-12-17 20:36 ` ✗ Xe.CI.BAT: failure for lib/kms: Carve up igt_display_require() Patchwork
2025-12-17 21:00 ` ✗ i915.CI.BAT: " Patchwork
2025-12-18 20:21 ` ✗ Xe.CI.Full: " Patchwork

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=20251217153758.9369-12-ville.syrjala@linux.intel.com \
    --to=ville.syrjala@linux.intel.com \
    --cc=igt-dev@lists.freedesktop.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 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.