All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jeevan B <jeevan.b@intel.com>
To: igt-dev@lists.freedesktop.org
Cc: uma.shankar@intel.com, Jeevan B <jeevan.b@intel.com>
Subject: [PATCH i-g-t] RFC: Add library functions to query tiling modes on a platform basis
Date: Wed, 14 May 2025 14:37:02 +0530	[thread overview]
Message-ID: <20250514090702.1379441-1-jeevan.b@intel.com> (raw)

This commit introduces functions to dynamically query the supported basic and
full tiling modes from the kernel (`igt_get_basic_tiling_mode()` and
`igt_get_full_tiling_mode()`). The goal is to eliminate hardcoding of tiling modes,
ensuring that the test environment reflects the actual supported configurations
for the platform.

By using this approach, we:
- Reduce the number of dynamic test cases, as only the supported tiling modes
  are tested.
- Avoid unnecessary noise in test results by ensuring only relevant tiling
  configurations are included.
- Improve test accuracy and reliability by directly aligning with the kernel's
  reported capabilities.

WIP:
- Added basic tiling mode query function.
- Added full tiling mode query function.
- Introduced helper function for tiling modifier string conversion.
- Defined enums for basic and full tiling modes.

Signed-off-by: Jeevan B <jeevan.b@intel.com>
---
 lib/igt_kms.c | 70 +++++++++++++++++++++++++++++++++++++++++++++++++++
 lib/igt_kms.h | 40 +++++++++++++++++++++++++++++
 2 files changed, 110 insertions(+)

diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index f3bc481f2..99b14bed5 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -7442,3 +7442,73 @@ int igt_backlight_write(int value, const char *fname, igt_backlight_context_t *c
 
 	return 0;
 }
+
+int igt_get_basic_tiling_mode(int fd, uint64_t *modifiers,
+			      enum igt_tiling_mode *basic_tiling)
+{
+/*
+     * Step 1: Define a local array of known basic tiling modes
+     *         Map each basic tiling to its corresponding I915_TILING_* value
+     */
+
+    /*
+     * Step 2: Loop over each tiling mode supported using the kms_flip_tiling logic
+     *
+     *         For each tiling:
+     *         - Create a small test buffer
+     *         - Attempt to set the tiling mode
+     *         - If ioctl succeeds, store the tiling mode in basic_tiling[]
+     *         - Store a default/zero modifier (optional)
+     */
+
+    /*
+     * Step 3: Return the number of tiling modes successfully supported
+     */
+return 0;
+}
+int igt_get_full_tiling_mode(int fd, uint64_t *modifiers,
+			     enum igt_tiling_mode *basic_tiling,
+			     enum igt_format_modifier *all_tiling)
+{
+/*
+     * Step 1: Define a static list of known Intel format modifiers
+     *         Use enum values from IGT_FMT_MOD_* defined in igt_kms.h
+     */
+
+    /*
+     * Step 2: For each modifier:
+     *         - Try to create an fb with that modifier
+     *         - If the fb is successfully created:
+     *             - Add the modifier to all_tiling[]
+     */
+
+    /*
+     * Step 3: Return the number of supported modifiers detected
+     */
+return 0;
+}
+
+const char *igt_modifier_str(uint64_t modifier)
+{
+	switch (modifier) {
+		case IGT_FMT_MOD_X_TILED: return "X_TILED";
+		case IGT_FMT_MOD_Y_TILED: return "Y_TILED";
+		case IGT_FMT_MOD_Yf_TILED: return "Yf_TILED";
+		case IGT_FMT_MOD_Y_TILED_CCS: return "Y_TILED_CCS";
+		case IGT_FMT_MOD_Yf_TILED_CCS: return "Yf_TILED_CCS";
+		case IGT_FMT_MOD_Y_TILED_GEN12_RC_CCS: return "GEN12_RC_CCS";
+		case IGT_FMT_MOD_Y_TILED_GEN12_MC_CCS: return "GEN12_MC_CCS";
+		case IGT_FMT_MOD_Y_TILED_GEN12_RC_CCS_CC: return "GEN12_RC_CCS_CC";
+		case IGT_FMT_MOD_4_TILED: return "4_TILED";
+		case IGT_FMT_MOD_4_TILED_DG2_RC_CCS: return "DG2_RC_CCS";
+		case IGT_FMT_MOD_4_TILED_DG2_MC_CCS: return "DG2_MC_CCS";
+		case IGT_FMT_MOD_4_TILED_DG2_RC_CCS_CC: return "DG2_RC_CCS_CC";
+		case IGT_FMT_MOD_4_TILED_MTL_RC_CCS: return "MTL_RC_CCS";
+		case IGT_FMT_MOD_4_TILED_MTL_MC_CCS: return "MTL_MC_CCS";
+		case IGT_FMT_MOD_4_TILED_MTL_RC_CCS_CC: return "MTL_RC_CCS_CC";
+		case IGT_FMT_MOD_4_TILED_LNL_CCS: return "LNL_CCS";
+		case IGT_FMT_MOD_4_TILED_BMG_CCS: return "BMG_CCS";
+
+		default: return "UNKNOWN";
+	}
+}
diff --git a/lib/igt_kms.h b/lib/igt_kms.h
index 0381c82ad..f03de1e3d 100644
--- a/lib/igt_kms.h
+++ b/lib/igt_kms.h
@@ -168,6 +168,36 @@ enum igt_atomic_crtc_properties {
        IGT_NUM_CRTC_PROPS
 };
 
+/* Basic tiling format modifiers */
+enum igt_basic_tiling_mode {
+    IGT_TILING_NONE = 0,
+    IGT_TILING_X    = 1,
+    IGT_TILING_Y    = 2,
+    IGT_TILING_Yf   = 3,
+    IGT_TILING_4    = 4,
+};
+
+/* Full tiling format modifiers */
+enum igt_full_tiling_mode {
+    IGT_FMT_MOD_X_TILED                 = I915_FORMAT_MOD_X_TILED,
+    IGT_FMT_MOD_Y_TILED                 = I915_FORMAT_MOD_Y_TILED,
+    IGT_FMT_MOD_Yf_TILED                = I915_FORMAT_MOD_Yf_TILED,
+    IGT_FMT_MOD_Y_TILED_CCS             = I915_FORMAT_MOD_Y_TILED_CCS,
+    IGT_FMT_MOD_Yf_TILED_CCS            = I915_FORMAT_MOD_Yf_TILED_CCS,
+    IGT_FMT_MOD_Y_TILED_GEN12_RC_CCS    = I915_FORMAT_MOD_Y_TILED_GEN12_RC_CCS,
+    IGT_FMT_MOD_Y_TILED_GEN12_MC_CCS    = I915_FORMAT_MOD_Y_TILED_GEN12_MC_CCS,
+    IGT_FMT_MOD_Y_TILED_GEN12_RC_CCS_CC = I915_FORMAT_MOD_Y_TILED_GEN12_RC_CCS_CC,
+    IGT_FMT_MOD_4_TILED                 = I915_FORMAT_MOD_4_TILED,
+    IGT_FMT_MOD_4_TILED_DG2_RC_CCS      = I915_FORMAT_MOD_4_TILED_DG2_RC_CCS,
+    IGT_FMT_MOD_4_TILED_DG2_MC_CCS      = I915_FORMAT_MOD_4_TILED_DG2_MC_CCS,
+    IGT_FMT_MOD_4_TILED_DG2_RC_CCS_CC   = I915_FORMAT_MOD_4_TILED_DG2_RC_CCS_CC,
+    IGT_FMT_MOD_4_TILED_MTL_RC_CCS      = I915_FORMAT_MOD_4_TILED_MTL_RC_CCS,
+    IGT_FMT_MOD_4_TILED_MTL_MC_CCS      = I915_FORMAT_MOD_4_TILED_MTL_MC_CCS,
+    IGT_FMT_MOD_4_TILED_MTL_RC_CCS_CC   = I915_FORMAT_MOD_4_TILED_MTL_RC_CCS_CC,
+    IGT_FMT_MOD_4_TILED_LNL_CCS         = I915_FORMAT_MOD_4_TILED_LNL_CCS,
+    IGT_FMT_MOD_4_TILED_BMG_CCS         = I915_FORMAT_MOD_4_TILED_BMG_CCS,
+};
+
 /**
  * igt_crtc_prop_names
  *
@@ -1280,4 +1310,14 @@ void igt_set_link_params(int drm_fd, igt_output_t *output,
 int igt_backlight_read(int *result, const char *fname, igt_backlight_context_t *context);
 int igt_backlight_write(int value, const char *fname, igt_backlight_context_t *context);
 
+/* Queries */
+int igt_get_basic_tiling_mode(int fd, uint64_t *modifiers,
+			      enum igt_tiling_mode *basic_tiling);
+int igt_get_full_tiling_mode(int fd, uint64_t *modifiers,
+			     enum igt_tiling_mode *basic_tiling,
+			     enum igt_format_modifier *all_tiling);
+
+/* Helpers */
+const char *igt_modifier_str(uint64_t modifier);
+
 #endif /* __IGT_KMS_H__ */
-- 
2.25.1


                 reply	other threads:[~2025-05-14  8:51 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20250514090702.1379441-1-jeevan.b@intel.com \
    --to=jeevan.b@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=uma.shankar@intel.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.