All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kunal Joshi <kunal1.joshi@intel.com>
To: igt-dev@lists.freedesktop.org
Cc: Kunal Joshi <kunal1.joshi@intel.com>
Subject: [igt-dev] [PATCH i-g-t 1/3] Make basic chamelium function accessible to other tests
Date: Thu, 26 Dec 2019 16:20:21 +0530	[thread overview]
Message-ID: <1577357423-6663-2-git-send-email-kunal1.joshi@intel.com> (raw)
In-Reply-To: <1577357423-6663-1-git-send-email-kunal1.joshi@intel.com>

There are many uses cases where we can integrate chamelium with other 
tests,Migrating basic chamelium functions to igt_chamelium lib to avoid
code rewriting.

Signed-off-by: Kunal Joshi <kunal1.joshi@intel.com>
Signed-off-by: Karthik B S <karthik.b.s@intel.com>
---
 lib/igt_chamelium.c   | 50 ++++++++++++++++++++++++++++++++++++++++
 lib/igt_chamelium.h   | 20 ++++++++++++++++
 tests/kms_chamelium.c | 64 +--------------------------------------------------
 3 files changed, 71 insertions(+), 63 deletions(-)

diff --git a/lib/igt_chamelium.c b/lib/igt_chamelium.c
index 9971f51..29949bb 100644
--- a/lib/igt_chamelium.c
+++ b/lib/igt_chamelium.c
@@ -132,6 +132,56 @@ static struct chamelium *cleanup_instance;
 static void chamelium_do_calculate_fb_crc(cairo_surface_t *fb_surface,
 					  igt_crc_t *out);
 
+drmModeConnection
+reprobe_connector(struct data_chamelium_t *data, struct chamelium_port *port)
+{
+	drmModeConnector *connector;
+	drmModeConnection status;
+
+	igt_debug("Reprobing %s...\n", chamelium_port_get_name(port));
+	connector = chamelium_port_get_connector(data->chamelium, port, true);
+	igt_assert(connector);
+	status = connector->connection;
+
+	drmModeFreeConnector(connector);
+	return status;
+}
+
+const char *connection_str(drmModeConnection c)
+{
+	switch (c) {
+	case DRM_MODE_CONNECTED:
+		return "connected";
+	case DRM_MODE_DISCONNECTED:
+		return "disconnected";
+	case DRM_MODE_UNKNOWNCONNECTION:
+		return "unknown";
+	}
+	assert(0); /* unreachable */
+}
+
+void
+wait_for_connector(struct data_chamelium_t *data, struct chamelium_port *port,
+		   drmModeConnection status)
+{
+	igt_debug("Waiting for %s to get %s...\n",
+		chamelium_port_get_name(port), connection_str(status));
+
+	/*
+	 * Rely on simple reprobing so we don't fail tests that don't require
+	 * that hpd events work in the event that hpd doesn't work on the system
+	 */
+	igt_until_timeout(HOTPLUG_TIMEOUT) {
+	if (reprobe_connector(data, port) == status)
+		return;
+
+	usleep(50000);
+
+	}
+	igt_assert_f(false, "Timed out waiting for %s to get %s\n",
+		chamelium_port_get_name(port), connection_str(status));
+}
+
 /**
  * chamelium_get_ports:
  * @chamelium: The Chamelium instance to use
diff --git a/lib/igt_chamelium.h b/lib/igt_chamelium.h
index 08705a9..3ce78a2 100644
--- a/lib/igt_chamelium.h
+++ b/lib/igt_chamelium.h
@@ -25,6 +25,8 @@
 
 #ifndef IGT_CHAMELIUM_H
 #define IGT_CHAMELIUM_H
+#define TEST_EDID_COUNT 2
+#define HOTPLUG_TIMEOUT 20
 
 #include "config.h"
 
@@ -32,6 +34,7 @@
 #include <xf86drmMode.h>
 
 #include "igt_debugfs.h"
+#include "igt_kms.h"
 
 struct igt_fb;
 struct edid;
@@ -81,6 +84,17 @@ struct chamelium_infoframe {
 
 struct chamelium_edid;
 
+struct data_chamelium_t {
+	struct chamelium *chamelium;
+	struct chamelium_port **ports;
+	igt_display_t display;
+	int port_count;
+
+	int drm_fd;
+
+	struct chamelium_edid *edids[TEST_EDID_COUNT];
+};
+
 /**
  * CHAMELIUM_MAX_PORTS: the maximum number of ports supported by igt_chamelium.
  *
@@ -210,4 +224,10 @@ void chamelium_destroy_frame_dump(struct chamelium_frame_dump *dump);
 void chamelium_destroy_audio_file(struct chamelium_audio_file *audio_file);
 void chamelium_infoframe_destroy(struct chamelium_infoframe *infoframe);
 
+drmModeConnection
+reprobe_connector(struct data_chamelium_t *data, struct chamelium_port *port);
+const char *connection_str(drmModeConnection c);
+void
+wait_for_connector(struct data_chamelium_t *data, struct chamelium_port *port,
+		   drmModeConnection status);
 #endif /* IGT_CHAMELIUM_H */
diff --git a/tests/kms_chamelium.c b/tests/kms_chamelium.c
index 5c4a189..da2037b 100644
--- a/tests/kms_chamelium.c
+++ b/tests/kms_chamelium.c
@@ -43,20 +43,9 @@ enum test_edid {
 	TEST_EDID_DP_AUDIO,
 	TEST_EDID_ASPECT_RATIO,
 };
-#define TEST_EDID_COUNT 5
 
-typedef struct {
-	struct chamelium *chamelium;
-	struct chamelium_port **ports;
-	igt_display_t display;
-	int port_count;
-
-	int drm_fd;
+typedef struct data_chamelium_t data_t;
 
-	struct chamelium_edid *edids[TEST_EDID_COUNT];
-} data_t;
-
-#define HOTPLUG_TIMEOUT 20 /* seconds */
 #define ONLINE_TIMEOUT 20 /* seconds */
 
 #define HPD_STORM_PULSE_INTERVAL_DP 100 /* ms */
@@ -106,57 +95,6 @@ require_connector_present(data_t *data, unsigned int type)
 		      kmstest_connector_type_str(type));
 }
 
-static drmModeConnection
-reprobe_connector(data_t *data, struct chamelium_port *port)
-{
-	drmModeConnector *connector;
-	drmModeConnection status;
-
-	igt_debug("Reprobing %s...\n", chamelium_port_get_name(port));
-	connector = chamelium_port_get_connector(data->chamelium, port, true);
-	igt_assert(connector);
-	status = connector->connection;
-
-	drmModeFreeConnector(connector);
-	return status;
-}
-
-static const char *connection_str(drmModeConnection c)
-{
-	switch (c) {
-	case DRM_MODE_CONNECTED:
-		return "connected";
-	case DRM_MODE_DISCONNECTED:
-		return "disconnected";
-	case DRM_MODE_UNKNOWNCONNECTION:
-		return "unknown";
-	}
-	assert(0); /* unreachable */
-}
-
-static void
-wait_for_connector(data_t *data, struct chamelium_port *port,
-		   drmModeConnection status)
-{
-	igt_debug("Waiting for %s to get %s...\n",
-		  chamelium_port_get_name(port), connection_str(status));
-
-	/*
-	 * Rely on simple reprobing so we don't fail tests that don't require
-	 * that hpd events work in the event that hpd doesn't work on the system
-	 */
-	igt_until_timeout(HOTPLUG_TIMEOUT) {
-		if (reprobe_connector(data, port) == status) {
-			return;
-		}
-
-		usleep(50000);
-	}
-
-	igt_assert_f(false, "Timed out waiting for %s to get %s\n",
-		  chamelium_port_get_name(port), connection_str(status));
-}
-
 static int chamelium_vga_modes[][2] = {
 	{ 1600, 1200 },
 	{ 1920, 1200 },
-- 
2.7.4

_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

  reply	other threads:[~2019-12-26 10:51 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-26 10:50 [igt-dev] [PATCH i-g-t 0/3] Test tiled display with aid of chamelium Kunal Joshi
2019-12-26 10:50 ` Kunal Joshi [this message]
2019-12-26 10:50 ` [igt-dev] [PATCH i-g-t 2/3] Added structures and functions to generate tiled edids Kunal Joshi
2019-12-26 10:50 ` [igt-dev] [PATCH i-g-t 3/3] Added a subtest where chamelium acts as a tiled panel Kunal Joshi
2019-12-26 11:28 ` [igt-dev] ✗ GitLab.Pipeline: warning for Test tiled display with aid of chamelium Patchwork
2019-12-26 11:54 ` [igt-dev] ✗ Fi.CI.BAT: failure " 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=1577357423-6663-2-git-send-email-kunal1.joshi@intel.com \
    --to=kunal1.joshi@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 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.