public inbox for igt-dev@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Ville Syrjala <ville.syrjala@linux.intel.com>
To: igt-dev@lists.freedesktop.org
Subject: [PATCH i-g-t 13/17] tests/kms_vrr: Use igt_crtc_t instead of enum pipe
Date: Wed, 11 Feb 2026 18:34:00 +0200	[thread overview]
Message-ID: <20260211163404.2018-14-ville.syrjala@linux.intel.com> (raw)
In-Reply-To: <20260211163404.2018-1-ville.syrjala@linux.intel.com>

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

Convert the use of enum pipe to igt_crtc_t in
tests/kms_vrr.

The use of function pointers makes this a bit more
complicated than your average test.

 #include "scripts/iterators.cocci"

@func@
typedef igt_crtc_t;
identifier FUNC;
identifier PIPE;
parameter list[N] P;
@@
 FUNC(P
-	,enum pipe PIPE
+	,igt_crtc_t *crtc
	,...)
{
<...
(
- igt_crtc_for_pipe(..., PIPE)
+ crtc
|
- kmstest_pipe_name(PIPE)
+ igt_crtc_name(crtc)
|
- PIPE
+ crtc->pipe
)
...>
}

@depends on func@
identifier func.FUNC;
expression list[func.N] EP;
expression PIPE;
@@
FUNC(EP
-    ,PIPE
+    ,igt_crtc_for_pipe(display, PIPE)
     ,...)

@@
identifier FUNC, CRTC;
@@
FUNC(..., igt_crtc_t *CRTC, ...)
{
...
(
- igt_crtc_t *CRTC = CRTC;
|
- igt_crtc_t *CRTC = igt_crtc_for_pipe(...);
|
- igt_crtc_t *CRTC;
...
- CRTC = igt_crtc_for_pipe(...);
)
...
}

@func_ptr@
parameter list[N] P;
type T, FT;
@@
typedef T (*FT)(P
-	,enum pipe
+	,igt_crtc_t *crtc
	,...);

@depends on func_ptr@
func_ptr.FT FUNC;
expression list[func_ptr.N] EP;
expression PIPE;
@@
FUNC(EP
- ,PIPE
+ ,igt_crtc_for_pipe(display, PIPE)
 ,...)

@@
igt_crtc_t *CRTC;
@@
- igt_crtc_for_pipe(..., CRTC->pipe)
+ CRTC

@@
identifier DISPLAY;
expression E;
@@
- igt_display_t *DISPLAY = E;
... when != DISPLAY

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 tests/kms_vrr.c | 66 ++++++++++++++++++++++++++++---------------------
 1 file changed, 38 insertions(+), 28 deletions(-)

diff --git a/tests/kms_vrr.c b/tests/kms_vrr.c
index 55671c71e095..f500d7a59120 100644
--- a/tests/kms_vrr.c
+++ b/tests/kms_vrr.c
@@ -158,7 +158,7 @@ typedef struct data {
 	uint32_t flag;
 } data_t;
 
-typedef void (*test_t)(data_t*, enum pipe, igt_output_t*, uint32_t);
+typedef void (*test_t)(data_t*, igt_crtc_t *crtc, igt_output_t*, uint32_t);
 
 /* Converts a timespec structure to nanoseconds. */
 static uint64_t timespec_to_ns(struct timespec *ts)
@@ -306,11 +306,9 @@ static bool vrr_capable(igt_output_t *output)
 }
 
 /* Toggles variable refresh rate on the pipe. */
-static void set_vrr_on_pipe(data_t *data, enum pipe pipe,
+static void set_vrr_on_pipe(data_t *data, igt_crtc_t *crtc,
 			    bool need_modeset, bool enabled)
 {
-	igt_display_t *display = &data->display;
-	igt_crtc_t *crtc = igt_crtc_for_pipe(display, pipe);
 	igt_crtc_set_prop_value(crtc,
 				    IGT_CRTC_VRR_ENABLED,
 				    enabled);
@@ -339,10 +337,8 @@ static void paint_bar(cairo_t *cr, unsigned int x, unsigned int y,
 }
 
 /* Prepare the display for testing on the given pipe. */
-static void prepare_test(data_t *data, igt_output_t *output, enum pipe pipe)
+static void prepare_test(data_t *data, igt_output_t *output, igt_crtc_t *crtc)
 {
-	igt_display_t *display = &data->display;
-	igt_crtc_t *crtc = igt_crtc_for_pipe(display, pipe);
 	unsigned int num_bars = 256;
 	drmModeModeInfo mode;
 	cairo_t *cr;
@@ -657,24 +653,26 @@ flip_and_measure_cmrr(data_t *data, igt_output_t *output,
 
 /* Basic VRR flip functionality test - enable, measure, disable, measure */
 static void
-test_basic(data_t *data, enum pipe pipe, igt_output_t *output, uint32_t flags)
+test_basic(data_t *data, igt_crtc_t *crtc, igt_output_t *output,
+	   uint32_t flags)
 {
 	uint32_t result;
 	vtest_ns_t vtest_ns;
 	range_t range;
 	uint64_t rate[] = {0};
 
-	prepare_test(data, output, pipe);
+	prepare_test(data, output, crtc);
 	range = data->range;
 	vtest_ns = data->vtest_ns;
 	rate[0] = vtest_ns.rate_ns;
 
 	igt_info("VRR Test execution on %s, PIPE_%s with VRR range: (%u-%u) Hz\n",
-		 output->name, kmstest_pipe_name(pipe), range.min, range.max);
+		 output->name, igt_crtc_name(crtc), range.min, range.max);
 	igt_info("Override Mode: ");
 	kmstest_dump_mode(&data->switch_modes[HIGH_RR_MODE]);
 
-	set_vrr_on_pipe(data, pipe, !(flags & TEST_FASTSET), true);
+	set_vrr_on_pipe(data, crtc,
+			!(flags & TEST_FASTSET), true);
 
 	/*
 	 * Do a short run with VRR, but don't check the result.
@@ -756,7 +754,9 @@ test_basic(data_t *data, enum pipe pipe, igt_output_t *output, uint32_t flags)
 	 * modeset. And the expected behavior is the same as disabling VRR on
 	 * a VRR capable panel.
 	 */
-	set_vrr_on_pipe(data, pipe, !(flags & TEST_FASTSET), (flags & TEST_NEGATIVE) ? true : false);
+	set_vrr_on_pipe(data, crtc,
+			!(flags & TEST_FASTSET),
+			(flags & TEST_NEGATIVE) ? true : false);
 	rate[0] = vtest_ns.rate_ns;
 	result = flip_and_measure(data, output, rate, 1, data->duration_ns);
 	igt_assert_f(result < 10,
@@ -765,7 +765,8 @@ test_basic(data_t *data, enum pipe pipe, igt_output_t *output, uint32_t flags)
 }
 
 static void
-test_seamless_rr_basic(data_t *data, enum pipe pipe, igt_output_t *output, uint32_t flags)
+test_seamless_rr_basic(data_t *data, igt_crtc_t *crtc, igt_output_t *output,
+		       uint32_t flags)
 {
 	uint32_t result;
 	vtest_ns_t vtest_ns;
@@ -775,11 +776,12 @@ test_seamless_rr_basic(data_t *data, enum pipe pipe, igt_output_t *output, uint3
 	igt_info("Use HIGH_RR Mode as default (VRR: %s): ", vrr ? "ON" : "OFF");
 	kmstest_dump_mode(&data->switch_modes[HIGH_RR_MODE]);
 
-	prepare_test(data, output, pipe);
+	prepare_test(data, output, crtc);
 	vtest_ns = data->vtest_ns;
 
 	if (vrr)
-		set_vrr_on_pipe(data, pipe, false, true);
+		set_vrr_on_pipe(data, crtc,
+				false, true);
 	else {
 		/*
 		 * Sink with DRRS and VRR can be in downclock mode.
@@ -822,7 +824,8 @@ test_seamless_rr_basic(data_t *data, enum pipe pipe, igt_output_t *output, uint3
 }
 
 static void
-test_seamless_virtual_rr_basic(data_t *data, enum pipe pipe, igt_output_t *output, uint32_t flags)
+test_seamless_virtual_rr_basic(data_t *data, igt_crtc_t *crtc,
+			       igt_output_t *output, uint32_t flags)
 {
 	uint32_t result;
 	unsigned int vrefresh;
@@ -833,7 +836,7 @@ test_seamless_virtual_rr_basic(data_t *data, enum pipe pipe, igt_output_t *outpu
 	igt_info("Use HIGH_RR Mode as default\n");
 	kmstest_dump_mode(&data->switch_modes[HIGH_RR_MODE]);
 
-	prepare_test(data, output, pipe);
+	prepare_test(data, output, crtc);
 	rate[0] = igt_kms_frame_time_from_vrefresh(data->switch_modes[HIGH_RR_MODE].vrefresh);
 
 	/*
@@ -889,18 +892,20 @@ test_seamless_virtual_rr_basic(data_t *data, enum pipe pipe, igt_output_t *outpu
  */
 
 static void
-test_lobf(data_t *data, enum pipe pipe, igt_output_t *output, uint32_t flags)
+test_lobf(data_t *data, igt_crtc_t *crtc, igt_output_t *output,
+	  uint32_t flags)
 {
 	uint64_t rate[] = {0};
 	uint32_t step_size, vrefresh;
 	bool lobf_enabled = false;
 
 	rate[0] = igt_kms_frame_time_from_vrefresh(data->switch_modes[HIGH_RR_MODE].vrefresh);
-	prepare_test(data, output, pipe);
+	prepare_test(data, output, crtc);
 	data->flag |= flags;
 
 	igt_info("LOBF test execution on %s, PIPE %s with VRR range: (%u-%u) Hz\n",
-		 output->name, kmstest_pipe_name(pipe), data->range.min, data->range.max);
+		 output->name, igt_crtc_name(crtc), data->range.min,
+		 data->range.max);
 
 	igt_output_override_mode(output, &data->switch_modes[HIGH_RR_MODE]);
 	flip_and_measure(data, output, rate, 1, TEST_DURATION_NS);
@@ -928,7 +933,8 @@ test_lobf(data_t *data, enum pipe pipe, igt_output_t *output, uint32_t flags)
 }
 
 static void
-test_cmrr(data_t *data, enum pipe pipe, igt_output_t *output, uint32_t flags)
+test_cmrr(data_t *data, igt_crtc_t *crtc, igt_output_t *output,
+	  uint32_t flags)
 {
 	uint32_t result;
 	int i;
@@ -937,7 +943,8 @@ test_cmrr(data_t *data, enum pipe pipe, igt_output_t *output, uint32_t flags)
 	drmModeModeInfo mode = *igt_output_get_mode(output);
 
 	igt_info("CMRR test execution on %s, PIPE_%s with VRR range: (%u-%u) Hz\n",
-		 output->name, kmstest_pipe_name(pipe), data->range.min, data->range.max);
+		 output->name, igt_crtc_name(crtc), data->range.min,
+		 data->range.max);
 
 	for (i = 0; i < connector->count_modes; i++) {
 		if (is_cmrr_mode(&connector->modes[i])) {
@@ -963,7 +970,8 @@ test_cmrr(data_t *data, enum pipe pipe, igt_output_t *output, uint32_t flags)
 	igt_output_override_mode(output, &mode);
 
 	if (!igt_display_try_commit2(&data->display, COMMIT_ATOMIC)) {
-		prepare_test(data, output, pipe);
+		prepare_test(data, output,
+			     crtc);
 		result = flip_and_measure_cmrr(data, output, TEST_DURATION_NS * 2);
 		igt_assert_f(result > 75,
 			     "Refresh rate (%u Hz) %"PRIu64"ns: Target CMRR on threshold not reached, result was %u%%\n",
@@ -972,10 +980,8 @@ test_cmrr(data_t *data, enum pipe pipe, igt_output_t *output, uint32_t flags)
 	}
 }
 
-static void test_cleanup(data_t *data, enum pipe pipe, igt_output_t *output)
+static void test_cleanup(data_t *data, igt_crtc_t *crtc, igt_output_t *output)
 {
-	igt_display_t *display = &data->display;
-	igt_crtc_t *crtc = igt_crtc_for_pipe(display, pipe);
 	igt_crtc_set_prop_value(crtc,
 				    IGT_CRTC_VRR_ENABLED, false);
 
@@ -1112,9 +1118,13 @@ run_vrr_test(data_t *data, test_t test, uint32_t flags)
 
 			igt_dynamic_f("pipe-%s-%s",
 				      igt_crtc_name(crtc), output->name)
-				test(data, crtc->pipe, output, flags);
+				test(data,
+				     crtc,
+				     output, flags);
 
-			test_cleanup(data, crtc->pipe, output);
+			test_cleanup(data,
+				     crtc,
+				     output);
 
 			break;
 		}
-- 
2.52.0


  parent reply	other threads:[~2026-02-11 16:35 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-11 16:33 [PATCH i-g-t 00/17] tests/kms: Use igt_crtc_t instead of enum pipe Ville Syrjala
2026-02-11 16:33 ` [PATCH i-g-t 01/17] tests/kms_plane_alpha_blend: " Ville Syrjala
2026-02-11 16:33 ` [PATCH i-g-t 02/17] tests/kms: Remove unused 'pipe' function parameters Ville Syrjala
2026-02-11 16:33 ` [PATCH i-g-t 03/17] tests/kms: Remove const qualifier from " Ville Syrjala
2026-02-11 16:33 ` [PATCH i-g-t 04/17] tests/intel/kms_busy: Use 'enum pipe' instead of 'int' Ville Syrjala
2026-02-11 16:33 ` [PATCH i-g-t 05/17] tests/kms_atomic_interruptible: s/crtc/drm_crtc/ Ville Syrjala
2026-02-11 16:33 ` [PATCH i-g-t 06/17] tests/intel/kms_psr2_su: Use igt_crtc_t instead of enum pipe Ville Syrjala
2026-02-11 16:33 ` [PATCH i-g-t 07/17] tests/intel/kms_dsc*: " Ville Syrjala
2026-02-11 16:33 ` [PATCH i-g-t 08/17] tests/kms_cursor_legacy: " Ville Syrjala
2026-02-11 16:33 ` [PATCH i-g-t 09/17] tests/kms_color*: " Ville Syrjala
2026-02-11 16:33 ` [PATCH i-g-t 10/17] tests/kms_atomic_transition: " Ville Syrjala
2026-02-11 16:33 ` [PATCH i-g-t 11/17] tests/kms_plane: " Ville Syrjala
2026-02-11 16:33 ` [PATCH i-g-t 12/17] tests/intel/kms_pipe_b_c_ivb: " Ville Syrjala
2026-02-11 16:34 ` Ville Syrjala [this message]
2026-02-11 16:34 ` [PATCH i-g-t 14/17] tests/kms_display_modes: " Ville Syrjala
2026-02-11 16:34 ` [PATCH i-g-t 15/17] tests/kms_rotation_crc: " Ville Syrjala
2026-02-11 16:34 ` [PATCH i-g-t 16/17] tests/kms_properties: " Ville Syrjala
2026-02-11 16:34 ` [PATCH i-g-t 17/17] tests/kms: " Ville Syrjala
2026-02-11 17:35 ` ✗ Xe.CI.BAT: failure for " Patchwork
2026-02-11 17:47 ` ✓ i915.CI.BAT: success " Patchwork
2026-02-12  6:18 ` ✗ i915.CI.Full: failure " Patchwork
2026-02-12  9:42 ` [PATCH i-g-t 00/17] " Jani Nikula
2026-02-13  2:09 ` ✗ Xe.CI.FULL: failure for " 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=20260211163404.2018-14-ville.syrjala@linux.intel.com \
    --to=ville.syrjala@linux.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