Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Swati Sharma <swati2.sharma@intel.com>
To: igt-dev@lists.freedesktop.org
Cc: ankit.k.nautiyal@intel.com, Swati Sharma <swati2.sharma@intel.com>
Subject: [PATCH i-g-t 4/5] lib/igt_kms: Add igt_get_max_cdclk()
Date: Thu, 13 Feb 2025 16:38:13 +0530	[thread overview]
Message-ID: <20250213110814.351186-5-swati2.sharma@intel.com> (raw)
In-Reply-To: <20250213110814.351186-1-swati2.sharma@intel.com>

Add igt_get_max_cdclk() to return max cdclk frequency.

Signed-off-by: Swati Sharma <swati2.sharma@intel.com>
---
 lib/igt_kms.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
 lib/igt_kms.h |  1 +
 2 files changed, 50 insertions(+)

diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index 8220cc0eb..aa5dfa8ce 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -6390,6 +6390,55 @@ int igt_get_max_dotclock(int fd)
 	return max_dotclock;
 }
 
+/**
+ * igt_get_max_cdclk:
+ * @fd: A drm file descriptor
+ *
+ * Get the Max CD clock frequency from intel specific debugfs
+ * "i915_frequency_info" (or) "i915_cdclk_info".
+ *
+ * Returns: Max supported CD clock frequency.
+ */
+int igt_get_max_cdclk(int fd)
+{
+	char buf[4096];
+	char *s;
+	int dir, res, max_cdclk = 0;
+	drmModeRes *resources;
+
+	if (!is_intel_device(fd))
+		return max_cdclk;
+
+	/* If there is no display, then no point to check for cdclk. */
+	resources = drmModeGetResources(fd);
+	if (!resources)
+		return max_cdclk;
+
+	drmModeFreeResources(resources);
+
+	dir = igt_debugfs_dir(fd);
+	igt_require(dir != -1);
+
+	/*
+	 * Display specific clock frequency info is moved to i915_cdclk_info,
+	 * On older kernels if this debugfs is not found, fallback to read from
+	 * i915_frequency_info.
+	 */
+	res = igt_debugfs_simple_read(dir, "i915_cdclk_info",
+				      buf, sizeof(buf));
+	if (res <= 0)
+		res = igt_debugfs_simple_read(dir, "i915_frequency_info",
+					      buf, sizeof(buf));
+	close(dir);
+
+	igt_require(res > 0);
+
+	igt_assert(s = strstr(buf, "Max CD clock frequency:"));
+	igt_assert_eq(sscanf(s, "Max CD clock frequency: %d kHz", &max_cdclk), 1);
+
+	return max_cdclk;
+}
+
 /**
  * igt_bigjoiner_possible:
  * @drm_fd: drm file descriptor
diff --git a/lib/igt_kms.h b/lib/igt_kms.h
index 5cf0b89d3..e6665abdd 100644
--- a/lib/igt_kms.h
+++ b/lib/igt_kms.h
@@ -1244,6 +1244,7 @@ void igt_sort_connector_modes(drmModeConnector *connector,
 bool igt_max_bpc_constraint(igt_display_t *display, enum pipe pipe,
 		igt_output_t *output, int bpc);
 int igt_get_max_dotclock(int fd);
+int igt_get_max_cdclk(int fd);
 bool igt_bigjoiner_possible(int drm_fd, drmModeModeInfo *mode, int max_dotclock);
 bool bigjoiner_mode_found(int drm_fd, drmModeConnector *connector,
 			  int max_dotclock, drmModeModeInfo *mode);
-- 
2.25.1


  parent reply	other threads:[~2025-02-13 11:03 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-13 11:08 [PATCH i-g-t 0/5] tests/intel/kms_cdclk: Refactor mode setting and CD clock verification Swati Sharma
2025-02-13 11:08 ` [PATCH i-g-t 1/5] lib/igt_kms: Add highres() and lowres() func Swati Sharma
2025-02-17  8:12   ` Nautiyal, Ankit K
2025-02-13 11:08 ` [PATCH i-g-t 2/5] tests/intel/kms_cdclk: Add conditions to filter valid outputs Swati Sharma
2025-02-17  8:17   ` Nautiyal, Ankit K
2025-02-13 11:08 ` [PATCH i-g-t 3/5] tests/intel/kms_cdclk: Introduce set_mode() Swati Sharma
2025-02-13 11:08 ` Swati Sharma [this message]
2025-02-17  8:35   ` [PATCH i-g-t 4/5] lib/igt_kms: Add igt_get_max_cdclk() Nautiyal, Ankit K
2025-02-13 11:08 ` [PATCH i-g-t 5/5] tests/intel/kms_cdclk: Use igt_get_max_cdclk() Swati Sharma
2025-02-17  8:36   ` Nautiyal, Ankit K
2025-02-13 12:33 ` ✓ Xe.CI.BAT: success for tests/intel/kms_cdclk: Refactor mode setting and CD clock verification (rev3) Patchwork
2025-02-13 12:50 ` ✓ i915.CI.BAT: " Patchwork
2025-02-13 20:09 ` ✗ i915.CI.Full: failure " Patchwork
2025-02-14  4:35 ` ✗ 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=20250213110814.351186-5-swati2.sharma@intel.com \
    --to=swati2.sharma@intel.com \
    --cc=ankit.k.nautiyal@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox