Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Bhanuprakash Modem <bhanuprakash.modem@intel.com>
To: igt-dev@lists.freedesktop.org, ville.syrjala@linux.intel.com,
	mitulkumar.ajitkumar.golani@intel.com
Subject: [igt-dev] [i-g-t V6 07/10] tests/kms_vrr: Add new subtest to switch RR without modeset
Date: Thu,  7 Dec 2023 12:18:57 +0530	[thread overview]
Message-ID: <20231207064900.3328723-8-bhanuprakash.modem@intel.com> (raw)
In-Reply-To: <20231207064900.3328723-1-bhanuprakash.modem@intel.com>

Add new subtest to switch between low refresh rate to high
refresh rate and vice versa seamlessly without modeset.

Below are the sequence of operations to perform:

1. Use High RR mode + VRR On  -> Measure vblank timings
2. Switch to Low RR mode -> Measure vblank timings
3. Switch back to High RR mode -> Measure vblank timings

Signed-off-by: Bhanuprakash Modem <bhanuprakash.modem@intel.com>
Tested-by: Vidya Srinivas <vidya.srinivas@intel.com>
---
 tests/kms_vrr.c | 95 +++++++++++++++++++++++++++++++++++++++++++------
 1 file changed, 85 insertions(+), 10 deletions(-)

diff --git a/tests/kms_vrr.c b/tests/kms_vrr.c
index f3cd18dcd..6cb5a9b10 100644
--- a/tests/kms_vrr.c
+++ b/tests/kms_vrr.c
@@ -53,6 +53,10 @@
  * SUBTEST: flipline
  * Description: Make sure that flips happen at flipline decision boundary.
  *
+ * SUBTEST: seamless-rr-switch-vrr
+ * Description: Test to switch RR seamlessly without modeset.
+ * Functionality: adaptive_sync, lrr
+ *
  * SUBTEST: negative-basic
  * Description: Make sure that VRR should not be enabled on the Non-VRR panel.
  */
@@ -70,7 +74,14 @@ enum {
 	TEST_DPMS = 1 << 1,
 	TEST_SUSPEND = 1 << 2,
 	TEST_FLIPLINE = 1 << 3,
-	TEST_NEGATIVE = 1 << 4,
+	TEST_SEAMLESS_VRR = 1 << 4,
+	TEST_NEGATIVE = 1 << 5,
+};
+
+enum {
+	HIGH_RR_MODE,
+	LOW_RR_MODE,
+	RR_MODES_COUNT,
 };
 
 typedef struct range {
@@ -85,6 +96,7 @@ typedef struct data {
 	igt_fb_t fb0;
 	igt_fb_t fb1;
 	range_t range;
+	drmModeModeInfo switch_modes[RR_MODES_COUNT];
 } data_t;
 
 typedef struct vtest_ns {
@@ -397,6 +409,8 @@ test_basic(data_t *data, enum pipe pipe, igt_output_t *output, uint32_t flags)
 
 	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);
+	igt_info("Override Mode: ");
+	kmstest_dump_mode(&data->switch_modes[HIGH_RR_MODE]);
 
 	set_vrr_on_pipe(data, pipe, true);
 
@@ -472,6 +486,53 @@ test_basic(data_t *data, enum pipe pipe, igt_output_t *output, uint32_t flags)
 		     ((range.max + range.min) / 2), rate, (flags & TEST_NEGATIVE)? "on" : "off", result);
 }
 
+static void
+test_seamless_rr_basic(data_t *data, enum pipe pipe, igt_output_t *output, uint32_t flags)
+{
+	uint32_t result;
+	vtest_ns_t vtest_ns;
+	uint64_t rate;
+
+	igt_info("Use HIGH_RR Mode as default: ");
+	kmstest_dump_mode(&data->switch_modes[HIGH_RR_MODE]);
+
+	prepare_test(data, output, pipe);
+	vtest_ns = get_test_rate_ns(data->range);
+
+	igt_pipe_set_prop_value(&data->display, pipe, IGT_CRTC_VRR_ENABLED, true);
+	igt_assert(igt_display_try_commit_atomic(&data->display, 0, NULL) == 0);
+
+	rate = vtest_ns.max;
+	result = flip_and_measure(data, output, pipe, rate, TEST_DURATION_NS);
+	igt_assert_f(result > 75,
+		     "Refresh rate (%u Hz) %"PRIu64"ns: Target VRR on threshold not reached, result was %u%%\n",
+		     data->range.max, rate, result);
+
+	/* Switch to low rr mode without modeset. */
+	igt_info("Switch to LOW_RR Mode: ");
+	kmstest_dump_mode(&data->switch_modes[LOW_RR_MODE]);
+	igt_output_override_mode(output, &data->switch_modes[LOW_RR_MODE]);
+	igt_assert(igt_display_try_commit_atomic(&data->display, 0, NULL) == 0);
+
+	rate = vtest_ns.min;
+	result = flip_and_measure(data, output, pipe, rate, TEST_DURATION_NS);
+	igt_assert_f(result > 75,
+		     "Refresh rate (%u Hz) %"PRIu64"ns: Target VRR on threshold not reached, result was %u%%\n",
+		     data->range.min, rate, result);
+
+	/* Switch back to high rr mode without modeset. */
+	igt_info("Switch back to HIGH_RR Mode: ");
+	kmstest_dump_mode(&data->switch_modes[HIGH_RR_MODE]);
+	igt_output_override_mode(output, &data->switch_modes[HIGH_RR_MODE]);
+	igt_assert(igt_display_try_commit_atomic(&data->display, 0, NULL) == 0);
+
+	rate = vtest_ns.mid;
+	result = flip_and_measure(data, output, pipe, rate, TEST_DURATION_NS);
+	igt_assert_f(result > 75,
+		     "Refresh rate (%u Hz) %"PRIu64"ns: Target VRR on threshold not reached, result was %u%%\n",
+		     ((data->range.max + data->range.min) / 2), rate, result);
+}
+
 static void test_cleanup(data_t *data, enum pipe pipe, igt_output_t *output)
 {
 	igt_pipe_set_prop_value(&data->display, pipe, IGT_CRTC_VRR_ENABLED, false);
@@ -484,9 +545,11 @@ static void test_cleanup(data_t *data, enum pipe pipe, igt_output_t *output)
 	igt_remove_fb(data->drm_fd, &data->fb0);
 }
 
-static bool output_constraint(data_t *data, igt_output_t *output)
+static bool output_constraint(data_t *data, igt_output_t *output, uint32_t flags)
 {
-	drmModeModeInfo mode;
+	if ((flags & TEST_SEAMLESS_VRR) &&
+	    output->config.connector->connector_type != DRM_MODE_CONNECTOR_eDP)
+		return false;
 
 	/* Reset output */
 	igt_display_reset(&data->display);
@@ -499,16 +562,22 @@ static bool output_constraint(data_t *data, igt_output_t *output)
 	 *   - vrr_min range should be less than the override mode vrefresh.
 	 *   - Limit the vrr_max range with the override mode vrefresh.
 	 */
-	mode = output_mode_with_maxrate(output, data->range.max);
-	if (mode.vrefresh < data->range.min)
+	data->switch_modes[HIGH_RR_MODE] = output_mode_with_maxrate(output, data->range.max);
+	if (data->switch_modes[HIGH_RR_MODE].vrefresh < data->range.min)
 		return false;
 
-	data->range.max = mode.vrefresh;
+	data->range.max = data->switch_modes[HIGH_RR_MODE].vrefresh;
+	igt_output_override_mode(output, &data->switch_modes[HIGH_RR_MODE]);
 
-	igt_info("Override Mode: ");
-	kmstest_dump_mode(&mode);
+	/* Search for a low refresh rate mode. */
+	if (!(flags & TEST_SEAMLESS_VRR))
+		return true;
 
-	igt_output_override_mode(output, &mode);
+	data->switch_modes[LOW_RR_MODE] = low_rr_mode_with_same_res(output, data->range.min);
+	if (data->switch_modes[LOW_RR_MODE].vrefresh == data->switch_modes[HIGH_RR_MODE].vrefresh)
+		return false;
+
+	data->range.min = data->switch_modes[LOW_RR_MODE].vrefresh;
 
 	return true;
 }
@@ -525,7 +594,7 @@ static bool config_constraint(data_t *data, igt_output_t *output, uint32_t flags
 	if ((flags & ~TEST_NEGATIVE) && !vrr_capable(output))
 		return false;
 
-	if (!output_constraint(data, output))
+	if (!output_constraint(data, output, flags))
 		return false;
 
 	return true;
@@ -601,6 +670,12 @@ igt_main
 	igt_subtest_with_dynamic("negative-basic")
 		run_vrr_test(&data, test_basic, TEST_NEGATIVE);
 
+	igt_describe("Test to switch RR seamlessly without modeset.");
+	igt_subtest_with_dynamic("seamless-rr-switch-vrr"){
+		igt_require_intel(data.drm_fd);
+		run_vrr_test(&data, test_seamless_rr_basic, TEST_SEAMLESS_VRR);
+	}
+
 	igt_fixture {
 		igt_display_fini(&data.display);
 		drm_close_driver(data.drm_fd);
-- 
2.40.0

  parent reply	other threads:[~2023-12-07  7:00 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-07  6:48 [igt-dev] [i-g-t V6 00/10] tests/kms_vrr: Add new subtest to switch RR without modeset Bhanuprakash Modem
2023-12-07  6:48 ` [igt-dev] [i-g-t V6 01/10] tests/kms_vrr: Use lib helper to print connector modes Bhanuprakash Modem
2023-12-07 14:08   ` Golani, Mitulkumar Ajitkumar
2023-12-07  6:48 ` [igt-dev] [i-g-t V6 02/10] tests/kms_vrr: Clear VRR before exit Bhanuprakash Modem
2023-12-07 14:12   ` Golani, Mitulkumar Ajitkumar
2023-12-07  6:48 ` [igt-dev] [i-g-t V6 03/10] tests/kms_vrr: Move all config constaints to new function Bhanuprakash Modem
2023-12-07 16:04   ` Golani, Mitulkumar Ajitkumar
2023-12-07  6:48 ` [igt-dev] [i-g-t V6 04/10] tests/kms_vrr: Fix bigjoiner constraint Bhanuprakash Modem
2023-12-07  6:48 ` [igt-dev] [i-g-t V6 05/10] tests/kms_vrr: Fix the logic to calculate expected rate Bhanuprakash Modem
2023-12-11  6:56   ` Golani, Mitulkumar Ajitkumar
2023-12-07  6:48 ` [igt-dev] [i-g-t V6 06/10] tests/kms_vrr: Add a helper to get the low refresh mode Bhanuprakash Modem
2023-12-07 14:42   ` Golani, Mitulkumar Ajitkumar
2023-12-07  6:48 ` Bhanuprakash Modem [this message]
2023-12-07  6:48 ` [igt-dev] [i-g-t V6 08/10] tests/kms_vrr: Add new subtest for DRRS without modeset Bhanuprakash Modem
2023-12-11  8:35   ` Golani, Mitulkumar Ajitkumar
2023-12-11 11:18     ` Modem, Bhanuprakash
2023-12-07  6:48 ` [igt-dev] [i-g-t V6 09/10] tests/kms_vrr: New subtest for toggle VRR during fastsets Bhanuprakash Modem
2023-12-07 10:40   ` Srinivas, Vidya
2023-12-11  8:51     ` Golani, Mitulkumar Ajitkumar
2023-12-07  6:49 ` [igt-dev] [i-g-t V6 10/10] HAX: DO_NOT_MERGE: test only vrr tests Bhanuprakash Modem
2023-12-07  7:59 ` [igt-dev] ✗ Fi.CI.BAT: failure for tests/kms_vrr: Add new subtest to switch RR without modeset (rev7) Patchwork
2023-12-07  8:01 ` [igt-dev] ✗ CI.xeBAT: " 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=20231207064900.3328723-8-bhanuprakash.modem@intel.com \
    --to=bhanuprakash.modem@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=mitulkumar.ajitkumar.golani@intel.com \
    --cc=ville.syrjala@linux.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