All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bhanuprakash Modem <bhanuprakash.modem@intel.com>
To: igt-dev@lists.freedesktop.org
Cc: Petri Latvala <petri.latvala@intel.com>
Subject: [igt-dev] [RFC i-g-t 3/4] lib/igt_kms: Add support for --resolution from igt_runner
Date: Fri, 27 May 2022 13:43:52 +0530	[thread overview]
Message-ID: <20220527081353.3800969-4-bhanuprakash.modem@intel.com> (raw)
In-Reply-To: <20220527081353.3800969-1-bhanuprakash.modem@intel.com>

Upon user request igt_runner will set an environment variable to choose
default DRM display mode for subtests instead of taking the preferred
mode.

Example:
Eventhough we have an 8K panel, Kernel may expose 4K or lesser mode
as a preferred mode. So all subtests will take this mode as a default
may cause losing the coverage.

This patch will parse the environment variable exposed by igt_runner
and take the decision to choose the mode from the available list.

The default is still to take the preferred mode exposed by the Kernel.
Other options are:
 * highest: Choose the mode with highest possible resolution.
 * lowest:  Choose the mode with lowest possible resolution.

Cc: Petri Latvala <petri.latvala@intel.com>
Cc: Swati Sharma <swati2.sharma@intel.com>
Signed-off-by: Bhanuprakash Modem <bhanuprakash.modem@intel.com>
---
 lib/igt_kms.c | 37 ++++++++++++++++++++++++++++++++++++-
 1 file changed, 36 insertions(+), 1 deletion(-)

diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index 84e798b5..aa964e11 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -1431,6 +1431,20 @@ void kmstest_force_edid(int drm_fd, drmModeConnector *connector,
 	igt_assert(ret != -1);
 }
 
+static int sort_drm_modes_asc(const void *a, const void *b)
+{
+	const drmModeModeInfo *mode1 = a, *mode2 = b;
+
+	return (mode1->hdisplay > mode2->hdisplay) - (mode2->hdisplay > mode1->hdisplay);
+}
+
+static int sort_drm_modes_dsc(const void *a, const void *b)
+{
+	const drmModeModeInfo *mode1 = a, *mode2 = b;
+
+	return (mode1->hdisplay < mode2->hdisplay) - (mode2->hdisplay < mode1->hdisplay);
+}
+
 /**
  * kmstest_get_connector_default_mode:
  * @drm_fd: DRM fd
@@ -1444,7 +1458,13 @@ void kmstest_force_edid(int drm_fd, drmModeConnector *connector,
 bool kmstest_get_connector_default_mode(int drm_fd, drmModeConnector *connector,
 					drmModeModeInfo *mode)
 {
-	int i;
+	enum {
+		RESOLUTION_DEFAULT = 0,
+		RESOLUTION_HIGHEST,
+		RESOLUTION_LOWEST,
+	};
+	char *env;
+	int i, res = RESOLUTION_DEFAULT;
 
 	if (!connector->count_modes) {
 		igt_warn("no modes for connector %d\n",
@@ -1452,6 +1472,21 @@ bool kmstest_get_connector_default_mode(int drm_fd, drmModeConnector *connector,
 		return false;
 	}
 
+	env = getenv("IGT_KMS_RESOLUTION");
+	if (env)
+		res = atoi(env);
+
+	if (res) {
+		qsort(connector->modes,
+		      connector->count_modes,
+		      sizeof(drmModeModeInfo),
+		      (res == RESOLUTION_HIGHEST) ?
+			sort_drm_modes_dsc : sort_drm_modes_asc);
+
+		*mode = connector->modes[0];
+		return true;
+	}
+
 	for (i = 0; i < connector->count_modes; i++) {
 		if (i == 0 ||
 		    connector->modes[i].type & DRM_MODE_TYPE_PREFERRED) {
-- 
2.35.1

  parent reply	other threads:[~2022-05-27  8:17 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-27  8:13 [igt-dev] [RFC i-g-t 0/4] runner: Introduce --resolution to igt_runner Bhanuprakash Modem
2022-05-27  8:13 ` [igt-dev] [RFC i-g-t 1/4] " Bhanuprakash Modem
2022-05-27 12:39   ` Petri Latvala
2022-06-10 11:31     ` Petri Latvala
2022-06-10 12:16       ` Knop, Ryszard
2022-06-10 13:21         ` Petri Latvala
2022-05-27  8:13 ` [igt-dev] [RFC i-g-t 2/4] runner: Unit tests for the --resolution option Bhanuprakash Modem
2022-05-27  8:13 ` Bhanuprakash Modem [this message]
2022-06-10 11:33   ` [igt-dev] [RFC i-g-t 3/4] lib/igt_kms: Add support for --resolution from igt_runner Petri Latvala
2022-05-27  8:13 ` [igt-dev] [RFC i-g-t 4/4] HAX: Add debug prints in choosing the default mode Bhanuprakash Modem
2022-05-27  8:43 ` [igt-dev] ✗ GitLab.Pipeline: warning for runner: Introduce --resolution to igt_runner Patchwork
2022-05-27  9:37 ` [igt-dev] ✓ Fi.CI.BAT: success " Patchwork
2022-05-27 11:49 ` [igt-dev] ✓ Fi.CI.IGT: " 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=20220527081353.3800969-4-bhanuprakash.modem@intel.com \
    --to=bhanuprakash.modem@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=petri.latvala@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.