[igt-dev] [v3 3/4] tests/kms: use dp-mst helpers

Swati Sharma swati2.sharma at intel.com
Thu Aug 24 08:12:55 UTC 2023


Remove duplicate code and use helpers instead.

v2: -fixed if() (CI)
v3: -update callers

Signed-off-by: Swati Sharma <swati2.sharma at intel.com>
Reviewed-by: Bhanuprakash Modem <bhanuprakash.modem at intel.com>
---
 tests/kms_content_protection.c | 34 ++-------------------------------
 tests/kms_display_modes.c      | 35 ++--------------------------------
 2 files changed, 4 insertions(+), 65 deletions(-)

diff --git a/tests/kms_content_protection.c b/tests/kms_content_protection.c
index 59c617493..3de317207 100644
--- a/tests/kms_content_protection.c
+++ b/tests/kms_content_protection.c
@@ -599,43 +599,15 @@ test_content_protection(enum igt_commit_style s, int content_type)
 		igt_cleanup_uevents(data.uevent_monitor);
 }
 
-static int parse_path_blob(char *blob_data)
-{
-	int connector_id;
-	char *encoder;
-
-	encoder = strtok(blob_data, ":");
-	igt_assert_f(!strcmp(encoder, "mst"), "PATH connector property expected to have 'mst'\n");
-
-	connector_id = atoi(strtok(NULL, "-"));
-
-	return connector_id;
-}
-
 static bool output_is_dp_mst(igt_output_t *output, int i)
 {
-	drmModePropertyBlobPtr path_blob = NULL;
-	uint64_t path_blob_id;
-	drmModeConnector *connector = output->config.connector;
-	struct kmstest_connector_config config;
-	const char *encoder;
 	int connector_id;
 	static int prev_connector_id;
 
-	kmstest_get_connector_config(data.drm_fd, output->config.connector->connector_id, -1, &config);
-	encoder = kmstest_encoder_type_str(config.encoder->encoder_type);
-
-	if (strcmp(encoder, "DP MST"))
+	connector_id = igt_get_dp_mst_connector_id(output);
+	if (connector_id < 0)
 		return false;
 
-	igt_assert(kmstest_get_property(data.drm_fd, connector->connector_id,
-		   DRM_MODE_OBJECT_CONNECTOR, "PATH", NULL,
-		   &path_blob_id, NULL));
-
-	igt_assert(path_blob = drmModeGetPropertyBlob(data.drm_fd, path_blob_id));
-
-	connector_id = parse_path_blob((char *) path_blob->data);
-
 	/*
 	 * Discarding outputs of other DP MST topology.
 	 * Testing only on outputs on the topology we got previously
@@ -647,8 +619,6 @@ static bool output_is_dp_mst(igt_output_t *output, int i)
 			return false;
 	}
 
-	drmModeFreePropertyBlob(path_blob);
-
 	return true;
 }
 
diff --git a/tests/kms_display_modes.c b/tests/kms_display_modes.c
index 5dbf0a88d..738b7303a 100644
--- a/tests/kms_display_modes.c
+++ b/tests/kms_display_modes.c
@@ -82,46 +82,15 @@ static drmModeModeInfo *get_mode(igt_output_t *output)
 	return required_mode;
 }
 
-static int parse_path_blob(char *blob_data)
-{
-	int connector_id;
-	char *encoder;
-
-	encoder = strtok(blob_data, ":");
-	igt_assert_f(!strcmp(encoder, "mst"), "PATH connector property expected to have 'mst'\n");
-
-	connector_id = atoi(strtok(NULL, "-"));
-
-	return connector_id;
-}
-
 static bool output_is_dp_mst(data_t *data, igt_output_t *output, int i)
 {
-	drmModePropertyBlobPtr path_blob = NULL;
-	uint64_t path_blob_id;
-	drmModeConnector *connector = output->config.connector;
-	struct kmstest_connector_config config;
-	const char *encoder;
 	int connector_id;
 	static int prev_connector_id;
 
-	kmstest_get_connector_config(data->drm_fd, output->config.connector->connector_id,
-				     -1, &config);
-	encoder = kmstest_encoder_type_str(config.encoder->encoder_type);
-
-	if (strcmp(encoder, "DP MST"))
+	connector_id = igt_get_dp_mst_connector_id(output);
+	if (connector_id < 0)
 		return false;
 
-	igt_assert(kmstest_get_property(data->drm_fd, connector->connector_id,
-		   DRM_MODE_OBJECT_CONNECTOR, "PATH", NULL,
-		   &path_blob_id, NULL));
-
-	igt_assert(path_blob = drmModeGetPropertyBlob(data->drm_fd, path_blob_id));
-
-	connector_id = parse_path_blob((char *) path_blob->data);
-
-	drmModeFreePropertyBlob(path_blob);
-
 	/*
 	 * Discarding outputs of other DP MST topology.
 	 * Testing only on outputs on the topology we got previously
-- 
2.25.1



More information about the igt-dev mailing list