Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Swati Sharma <swati2.sharma@intel.com>
To: igt-dev@lists.freedesktop.org
Subject: [igt-dev] [v2 3/4] tests/kms: use dp-mst helpers
Date: Thu, 10 Aug 2023 13:47:42 +0530	[thread overview]
Message-ID: <20230810081743.1065566-4-swati2.sharma@intel.com> (raw)
In-Reply-To: <20230810081743.1065566-1-swati2.sharma@intel.com>

Remove duplicate code and use helpers instead.

v2: -fixed if() (CI)

Signed-off-by: Swati Sharma <swati2.sharma@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 6cdf81a28..b65d7cd0b 100644
--- a/tests/kms_content_protection.c
+++ b/tests/kms_content_protection.c
@@ -534,43 +534,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(data.drm_fd, 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
@@ -582,8 +554,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 93d91ef5b..84fc7738b 100644
--- a/tests/kms_display_modes.c
+++ b/tests/kms_display_modes.c
@@ -77,46 +77,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(data->drm_fd, 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

  parent reply	other threads:[~2023-08-10  8:17 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-10  8:17 [igt-dev] [v2 0/4] dp-mst helpers Swati Sharma
2023-08-10  8:17 ` [igt-dev] [v2 1/4] lib/igt_kms: add helper to check if output is mst Swati Sharma
2023-08-17 18:20   ` Modem, Bhanuprakash
2023-08-10  8:17 ` [igt-dev] [v2 2/4] lib/igt_kms: add helper for dp-mst connector id Swati Sharma
2023-08-17 18:29   ` Modem, Bhanuprakash
2023-08-10  8:17 ` Swati Sharma [this message]
2023-08-17 18:33   ` [igt-dev] [v2 3/4] tests/kms: use dp-mst helpers Modem, Bhanuprakash
2023-08-10  8:17 ` [igt-dev] [v2 4/4] tests/kms_color: skip deep-color test for mst Swati Sharma
2023-08-17 18:44   ` Modem, Bhanuprakash
2023-08-10 10:45 ` [igt-dev] ○ CI.xeBAT: info for dp-mst helpers (rev3) Patchwork
2023-08-10 10:46 ` [igt-dev] ✗ Fi.CI.BAT: failure " Patchwork
2023-08-10 11:21 ` [igt-dev] ✗ GitLab.Pipeline: warning " Patchwork
2023-08-17 19:46 ` [igt-dev] ○ CI.xeBAT: info for dp-mst helpers (rev4) Patchwork
2023-08-17 19:58 ` [igt-dev] ✓ Fi.CI.BAT: success " Patchwork
2023-08-18 14:31 ` [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=20230810081743.1065566-4-swati2.sharma@intel.com \
    --to=swati2.sharma@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    /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