From: "Naladala, Ramanaidu" <Ramanaidu.naladala@intel.com>
To: "Golani,
Mitulkumar Ajitkumar" <mitulkumar.ajitkumar.golani@intel.com>,
"igt-dev@lists.freedesktop.org" <igt-dev@lists.freedesktop.org>
Cc: "Borah, Chaitanya Kumar" <chaitanya.kumar.borah@intel.com>
Subject: Re: [PATCH i-g-t v4 1/2] lib/igt_vrr:Add VRR helper library for display refresh rate testing
Date: Tue, 25 Aug 2026 10:20:55 +0530 [thread overview]
Message-ID: <20362f4b-dd10-443f-aa18-f83776079690@intel.com> (raw)
In-Reply-To: <IA1PR11MB63484C2CD1A2927C2ED964FDB2A52@IA1PR11MB6348.namprd11.prod.outlook.com>
Hi Mitul,
Thanks for the review.
On 8/19/2026 9:33 PM, Golani, Mitulkumar Ajitkumar wrote:
>
>> -----Original Message-----
>> From: Naladala, Ramanaidu <ramanaidu.naladala@intel.com>
>> Sent: 12 August 2026 18:38
>> To: igt-dev@lists.freedesktop.org
>> Cc: Borah, Chaitanya Kumar <chaitanya.kumar.borah@intel.com>; Golani,
>> Mitulkumar Ajitkumar <mitulkumar.ajitkumar.golani@intel.com>; Naladala,
>> Ramanaidu <ramanaidu.naladala@intel.com>
>> Subject: [PATCH i-g-t v4 1/2] lib/igt_vrr:Add VRR helper library for display
>> refresh rate testing
>>
>> Introduce a new helper library for Variable Refresh Rate (VRR).
>>
>> Add helpers to validate targeted refresh-rate testing.
>>
>> v2: Modify debugfs with helpers.
>> v3: Add helper to check cmrr support.
>> Address review comments. (Mitul)
>>
> Please update change log, this helps reader to track what new changes are coming as part of this revision.
Sure. i will update this from next revision.
>
>> Signed-off-by: Naladala Ramanaidu <ramanaidu.naladala@intel.com>
>> ---
>> lib/igt_vrr.c | 154 ++++++++++++++++++++++++++++++++++++++++++++++++
>> lib/igt_vrr.h | 44 ++++++++++++++
>> lib/meson.build | 1 +
>> 3 files changed, 199 insertions(+)
>> create mode 100644 lib/igt_vrr.c
>> create mode 100644 lib/igt_vrr.h
>>
>> diff --git a/lib/igt_vrr.c b/lib/igt_vrr.c new file mode 100644 index
>> 000000000..704eaa3a3
>> --- /dev/null
>> +++ b/lib/igt_vrr.c
>> @@ -0,0 +1,154 @@
>> +// SPDX-License-Identifier: MIT
>> +/*
>> + * Copyright © 2026 Intel Corporation
>> + */
>> +
>> +#include <inttypes.h>
>> +
>> +#include "igt_vrr.h"
>> +#include "igt_sysfs.h"
>> +
>> +const uint32_t igt_vrr_standard_video_timing_fps[] = {
>> + 24, 25, 30, 48, 50, 60, 75, 90, 96, 100, 120, 144, 165, 180, 200, 240,
>> +};
>> +
>> +const size_t igt_vrr_standard_video_timing_fps_count =
>> + ARRAY_SIZE(igt_vrr_standard_video_timing_fps);
>> +
>> +/**
>> + * igt_target_rr_debugfs_write:
>> + * @fd: DRM file descriptor.
>> + * @crtc_index: Index of the CRTC.
>> + * @vrefresh: Target refresh rate to program.
>> + * @numerator: Numerator component of the target refresh rate fraction.
>> + * @denominator: Denominator component of the target refresh rate
>> fraction.
>> + *
>> + * Write the target refresh rate configuration to the per-CRTC
>> + * VRR debugfs interface.
>> + *
>> + * Returns: None.
>> + */
>> +void
>> +igt_target_rr_debugfs_write(int fd, int crtc_index,
>> + uint32_t vrefresh,
>> + uint32_t numerator,
>> + uint32_t denominator)
>> +{
>> + char buf[32];
>> + int ret, dir;
>> + uint64_t val;
>> +
>> + val = vrefresh * numerator;
> Use val = (uint64_t)vrefresh * numerator; for safety even though current ranges don't overflow.
sure. i will fix this in next revision.
>
>> +
>> + snprintf(buf, sizeof(buf), "%" PRIu64 "/%u",
>> + val, denominator);
>> +
>> + dir = igt_debugfs_crtc_dir(fd, crtc_index);
>> + igt_require_fd(dir);
>> +
>> + ret = igt_sysfs_write(dir, "intel_vrr_target_refresh_rate",
>> + buf, sizeof(buf) - 1);
> write the actual string length, not a fixed size. buf is uninitialized stack, so this sends garbage bytes after the terminating NUL
> to the kernel. Please write strlen(buf) and assert against that.
>
> "size_t n = strlen(buf);
> ret = igt_sysfs_write(dir, "intel_vrr_target_refresh_rate", buf, n);
> igt_assert_f(ret == n, "debugfs write failed\n");"
sure. i will fix this in next revision.
>
>> + close(dir);
>> + igt_assert_f(ret == (sizeof(buf) - 1), "debugfs_write failed"); }
>> +
>> +/**
>> + * igt_cmrr_debugfs_read:
>> + * @fd: DRM file descriptor.
>> + * @crtc_index: Index of the CRTC.
>> + *
>> + * Read the configured refresh rate from the per-CRTC VRR debugfs node.
>> + *
>> + * Return: None.
>> + */
>> +void
>> +igt_target_rr_debugfs_read(int fd, int crtc_index) {
> The above doc block says igt_cmrr_debugfs_read but the function is igt_target_rr_debugfs_read.
sure. i will fix this in next revision.
>
>> + char buf[32];
>> + int ret, dir;
>> +
>> + dir = igt_debugfs_crtc_dir(fd, crtc_index);
>> + igt_require_fd(dir);
>> +
>> + ret = igt_sysfs_read(dir, "intel_vrr_target_refresh_rate",
>> + buf, sizeof(buf) - 1);
>> + close(dir);
>> + igt_assert_f(ret >= 0,
>> + "Failed to read intel_vrr_target_refresh_rate.\n");
> The close(dir) and igt_assert_f(...) lines in the write helper use spaces; IGT uses tabs.
sure. i will fix this in next revision.
>
>> +
>> + buf[ret] = '\0';
>> +
>> + igt_info("vrr target RR: %s\n", buf);
>> +}
>> +
>> +/**
>> + * igt_vrr_mode_line_refresh_hz:
>> + * @mode: DRM display mode used for the calculation
>> + *
>> + * Compute the refresh rate directly from the mode timing parameters.
>> + *
>> + * Returns: Refresh rate in Hz as a floating-point value.
>> + */
>> +double igt_vrr_mode_line_refresh_hz(const drmModeModeInfo *mode) {
>> + return (double)mode->clock * 1000.0 / ((double)mode->htotal *
>> +(double)mode->vtotal); }
>> +
>> +/**
>> + * igt_vrr_get_mode_with_video_timing:
>> + * @output: Display output containing connector mode list
>> + * @fps: Requested integer refresh rate in Hz
>> + * @matched_mode: Returned mode that matches @fps
>> + *
>> + * Find and return a connector mode that matches the requested
>> + * video timing refresh rate in Hz.
>> + *
>> + * Returns: true when a mode is found, false otherwise */
>> +
>> +bool igt_vrr_get_mode_with_video_timing(igt_output_t *output,
>> + uint32_t fps,
>> + drmModeModeInfo
>> *matched_mode)
>> +{
>> + drmModeConnectorPtr connector;
>> +
>> + connector = output->config.connector;
>> + if (!connector)
>> + return false;
>> +
>> + for (int i = 0; i < connector->count_modes; i++) {
>> + if (connector->modes[i].vrefresh == fps) {
>> + *matched_mode = connector->modes[i];
>> + return true;
>> + }
>> + }
>> + return false;
>> +}
>> +
>> +/**
>> + * cmrr_supported:
>> + * @fd: DRM device file descriptor.
>> + * @crtc_index: Index of the CRTC.
>> + *
>> + * Checks whether the intel_vrr_target_refresh_rate debugfs node is
>> +present
>> + * for the specified CRTC, indicating CMRR support.
>> + *
>> + * Returns: true if CMRR is supported, false otherwise.
>> + */
>> +bool cmrr_supported(int fd, int crtc_index) {
> add the igt_ namespace prefix. cmrr_supported in a shared lib is inconsistent with every other exported symbol.
> Rename to igt_vrr_cmrr_supported() (update the header and callers).
sure. i will fix this in next revision.
>
>> + int dir;
>> +
>> + dir = igt_debugfs_crtc_dir(fd, crtc_index);
>> +
>> + if (dir < 0)
>> + return false;
>> +
>> + if (faccessat(dir, "intel_vrr_target_refresh_rate", F_OK, 0) == 0) {
>> + close(dir);
>> + return true;
>> + }
>> +
>> + close(dir);
>> + return false;
>> +}
>> diff --git a/lib/igt_vrr.h b/lib/igt_vrr.h new file mode 100644 index
>> 000000000..a317d4684
>> --- /dev/null
>> +++ b/lib/igt_vrr.h
>> @@ -0,0 +1,44 @@
>> +/* SPDX-License-Identifier: MIT */
>> +/*
>> + * Copyright © 2026 Intel Corporation
>> + */
>> +
>> +#ifndef IGT_VRR_H
>> +#define IGT_VRR_H
>> +
>> +#include <stdbool.h>
>> +#include <stdint.h>
>> +#include "igt.h"
>> +#include "igt_kms.h"
>> +
>> +#define CMRR_NUMERATOR 1000ULL
>> +#define CMRR_DENOMINATOR 1000ULL
>> +#define CMRR_VIDEO_MODE_DENOMINATOR 1001ULL #define
>> +TARGET_RR_SAMP_COUNT 100
>> +
>> +enum {
>> + CMRR_VIDEO_MODE,
>> + CMRR_NON_VIDEO_MODE,
>> + CMRR_DISABLE,
>> +};
>> +
>> +extern const uint32_t igt_vrr_standard_video_timing_fps[];
>> +extern const size_t igt_vrr_standard_video_timing_fps_count;
>> +
>> +void
>> +igt_target_rr_debugfs_write(int fd, int crtc_index,
>> + uint32_t vrefresh,
>> + uint32_t numerator,
>> + uint32_t denominator);
>> +void
>> +igt_target_rr_debugfs_read(int fd, int crtc_index);
>> +
>> +double igt_vrr_mode_line_refresh_hz(const drmModeModeInfo *mode);
>> +
>> +bool igt_vrr_get_mode_with_video_timing(igt_output_t *output,
>> + uint32_t fps,
>> + drmModeModeInfo
>> *matched_mode);
>> +
>> +bool cmrr_supported(int fd, int crtc_index);
>> +
>> +#endif
>> diff --git a/lib/meson.build b/lib/meson.build index 3001b473e..8675bd4a6
>> 100644
>> --- a/lib/meson.build
>> +++ b/lib/meson.build
>> @@ -22,6 +22,7 @@ lib_sources = [
>> 'igt_configfs.c',
>> 'igt_facts.c',
>> 'igt_crc.c',
>> + 'igt_vrr.c',
>> 'igt_debugfs.c',
>> 'igt_device.c',
>> 'igt_device_scan.c',
>> --
>> 2.43.0
next prev parent reply other threads:[~2026-08-25 4:51 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-12 13:07 [PATCH i-g-t v4 0/2] Add CMRR subtests Naladala Ramanaidu
2026-08-12 13:07 ` [PATCH i-g-t v4 1/2] lib/igt_vrr:Add VRR helper library for display refresh rate testing Naladala Ramanaidu
2026-08-19 16:03 ` Golani, Mitulkumar Ajitkumar
2026-08-25 4:50 ` Naladala, Ramanaidu [this message]
2026-08-20 11:08 ` Borah, Chaitanya Kumar
2026-08-25 4:47 ` Naladala, Ramanaidu
2026-08-12 13:07 ` [PATCH i-g-t v4 2/2] tests/kms_vrr: add CMRR fixed and video mode subtests Naladala Ramanaidu
2026-08-19 17:00 ` Golani, Mitulkumar Ajitkumar
2026-08-20 11:10 ` Borah, Chaitanya Kumar
2026-08-20 11:10 ` Borah, Chaitanya Kumar
2026-08-12 14:12 ` ✓ i915.CI.BAT: success for Add CMRR subtests (rev4) Patchwork
2026-08-12 14:14 ` ✓ Xe.CI.BAT: " Patchwork
2026-08-12 17:49 ` ✗ Xe.CI.FULL: failure " Patchwork
2026-08-12 18:01 ` ✗ i915.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=20362f4b-dd10-443f-aa18-f83776079690@intel.com \
--to=ramanaidu.naladala@intel.com \
--cc=chaitanya.kumar.borah@intel.com \
--cc=igt-dev@lists.freedesktop.org \
--cc=mitulkumar.ajitkumar.golani@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.