[igt-dev] [RFC i-g-t 3/4] lib/igt_kms: Add support for --resolution from igt_runner
Bhanuprakash Modem
bhanuprakash.modem at intel.com
Fri May 27 08:13:52 UTC 2022
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 at intel.com>
Cc: Swati Sharma <swati2.sharma at intel.com>
Signed-off-by: Bhanuprakash Modem <bhanuprakash.modem at 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
More information about the igt-dev
mailing list