Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Nautiyal, Ankit K" <ankit.k.nautiyal@intel.com>
To: Swati Sharma <swati2.sharma@intel.com>, <igt-dev@lists.freedesktop.org>
Subject: Re: [PATCH i-g-t 4/5] lib/igt_kms: Add igt_get_max_cdclk()
Date: Mon, 17 Feb 2025 14:05:00 +0530	[thread overview]
Message-ID: <ea65922c-8d71-4b58-8641-0a2048851310@intel.com> (raw)
In-Reply-To: <20250213110814.351186-5-swati2.sharma@intel.com>


On 2/13/2025 4:38 PM, Swati Sharma wrote:
> 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;


I think there can be some code that can be re-used between this and 
igt_get_max_dotclock() to read the debugfs.

The search string "Max CD clock frequency" or "Max pixel clock 
frequency" can be passed and it can return the parsed value in Khz.

Regards,

Ankit


> +}
> +
>   /**
>    * 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);

  reply	other threads:[~2025-02-17  8:35 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 ` [PATCH i-g-t 4/5] lib/igt_kms: Add igt_get_max_cdclk() Swati Sharma
2025-02-17  8:35   ` Nautiyal, Ankit K [this message]
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=ea65922c-8d71-4b58-8641-0a2048851310@intel.com \
    --to=ankit.k.nautiyal@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    --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