[PATCH i-g-t 2/2] lib/igt_kms: add support for choosing big joiner mode

Kunal Joshi kunal1.joshi at intel.com
Mon Jan 15 10:58:54 UTC 2024


add support to choose big joiner mode with environment
variable, use mode with highest clock if no mode with big joiner
found.

v2: reuse bigjoiner_mode_found (Bhanu)
v3: avoid returning from multiple places (Bhanu)
    avoid frequent debugfs reads (Bhanu)

Cc: Karthik B S <karthik.b.s at intel.com>
Cc: Bhanuprakash Modem <bhanuprakash.modem at intel.com>
Signed-off-by: Kunal Joshi <kunal1.joshi at intel.com>
---
 lib/igt_kms.c | 24 +++++++++++++++++++-----
 1 file changed, 19 insertions(+), 5 deletions(-)

diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index cb6d57c2d..2c4210d4b 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -1771,8 +1771,9 @@ void igt_sort_connector_modes(drmModeConnector *connector,
 bool kmstest_get_connector_default_mode(int drm_fd, drmModeConnector *connector,
 					drmModeModeInfo *mode)
 {
+	bool found;
 	char *env;
-	int i;
+	int i, max_dotclock;
 
 	if (!connector->count_modes) {
 		igt_warn("no modes for connector %d\n",
@@ -1781,21 +1782,34 @@ bool kmstest_get_connector_default_mode(int drm_fd, drmModeConnector *connector,
 	}
 
 	env = getenv("IGT_KMS_RESOLUTION");
+	max_dotclock = igt_get_max_dotclock(drm_fd);
 	if (env) {
 		/*
-		 * Only (0 or 1) and (lowest or highest) are allowed.
+		 * Only (0 or 1 or 2) and (lowest or highest or joiner) are allowed.
 		 *
 		 * 0/lowest: Choose connector mode with lowest possible resolution.
 		 * 1/highest: Choose connector mode with highest possible resolution.
+		 * 2/joiner: Choose connector mode with bigjoiner support or with
+			     highest clock if can't support  big joiner
 		 */
-		if (!strcmp(env, "highest") || !strcmp(env, "1"))
+		if (!strcmp(env, "joiner") || !strcmp(env, "2"))
+			found = bigjoiner_mode_found(drm_fd, connector,
+						     sort_drm_modes_by_clk_dsc,mode,
+						     max_dotclock) ||
+				bigjoiner_mode_found(drm_fd, connector,
+						     sort_drm_modes_by_res_dsc, mode,
+						     max_dotclock) ||
+				bigjoiner_mode_found(drm_fd, connector,
+						     sort_drm_modes_by_clk_dsc, mode,
+						     max_dotclock);
+		else if (!strcmp(env, "highest") || !strcmp(env, "1"))
 			igt_sort_connector_modes(connector, sort_drm_modes_by_res_dsc);
 		else if (!strcmp(env, "lowest") || !strcmp(env, "0"))
 			igt_sort_connector_modes(connector, sort_drm_modes_by_res_asc);
 		else
 			goto default_mode;
-
-		*mode = connector->modes[0];
+		if (!found)
+			*mode = connector->modes[0];
 		return true;
 	}
 
-- 
2.25.1



More information about the igt-dev mailing list