From: Karthik B S <karthik.b.s@intel.com>
To: igt-dev@lists.freedesktop.org
Cc: kamil.konieczny@linux.intel.com, swati2.sharma@intel.com,
Karthik B S <karthik.b.s@intel.com>
Subject: [PATCH i-g-t 1/2] lib/igt_kms: Add helper to validate modes
Date: Mon, 12 Jan 2026 14:14:54 +0530 [thread overview]
Message-ID: <20260112084455.157949-2-karthik.b.s@intel.com> (raw)
In-Reply-To: <20260112084455.157949-1-karthik.b.s@intel.com>
Add a helper function kmstest_mode_is_valid() that checks if
a given drmModeModeInfo pointer is non-NULL and has positive
width, height, and pixel clock.
This allows tests to safely check if an output mode is usable before
assigning it to a pipe or creating a framebuffer.
Signed-off-by: Karthik B S <karthik.b.s@intel.com>
---
lib/igt_kms.c | 14 ++++++++++++++
lib/igt_kms.h | 1 +
2 files changed, 15 insertions(+)
diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index a58f41b48..9e5820d43 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -5197,6 +5197,20 @@ const char *igt_output_name(igt_output_t *output)
return output->name;
}
+/**
+ * kmstest_mode_is_valid:
+ * @mode: pointer to drmModeModeInfo
+ *
+ * Returns: True if the mode is non-NULL and has valid width, height and RR.
+ */
+bool kmstest_mode_is_valid(const drmModeModeInfo *mode)
+{
+ return mode &&
+ mode->hdisplay > 0 &&
+ mode->vdisplay > 0 &&
+ mode->vrefresh > 0;
+}
+
/**
* igt_output_get_mode:
* @output: Target output
diff --git a/lib/igt_kms.h b/lib/igt_kms.h
index 4a814f0e9..e10441017 100644
--- a/lib/igt_kms.h
+++ b/lib/igt_kms.h
@@ -585,6 +585,7 @@ static inline igt_crtc_t *igt_crtc_for_pipe(igt_display_t *display, enum pipe pi
}
const char *igt_output_name(igt_output_t *output);
+bool kmstest_mode_is_valid(const drmModeModeInfo *mode);
drmModeModeInfo *igt_output_get_mode(igt_output_t *output);
drmModeModeInfo *igt_output_get_highres_mode(igt_output_t *output);
drmModeModeInfo *igt_output_get_lowres_mode(igt_output_t *output);
--
2.43.0
next prev parent reply other threads:[~2026-01-12 8:49 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-12 8:44 [PATCH i-g-t 0/2] Add helper to validate modes Karthik B S
2026-01-12 8:44 ` Karthik B S [this message]
2026-01-12 9:04 ` [PATCH i-g-t 1/2] lib/igt_kms: " Kamil Konieczny
2026-01-12 15:19 ` Karthik B S
2026-01-12 8:44 ` [PATCH i-g-t 2/2] tests/kms_joiner: Add check to validate mode Karthik B S
2026-01-12 9:21 ` B, Jeevan
2026-01-12 9:38 ` ✓ Xe.CI.BAT: success for Add helper to validate modes Patchwork
2026-01-12 9:48 ` ✓ i915.CI.BAT: " Patchwork
2026-01-12 11:08 ` ✗ Xe.CI.Full: failure " Patchwork
2026-01-12 12:24 ` ✗ i915.CI.Full: " Patchwork
2026-01-12 15:22 ` Karthik B S
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=20260112084455.157949-2-karthik.b.s@intel.com \
--to=karthik.b.s@intel.com \
--cc=igt-dev@lists.freedesktop.org \
--cc=kamil.konieczny@linux.intel.com \
--cc=swati2.sharma@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox