Skip to contentSkip to conversation

Unigraf integration

PATCH Superseded Louis Chauvet 2 participants 29 messages Jul 17, 2025

Subsystems (2)

v2 of 11 Superseded Latest is v11 →

lore
Share & tools
lore
#0 lore raw

v2 cover Unigraf integration

Hi everyone,

I am excited to share I currently have access to a Unigraf device, which I believe could significantly enhance the capabilities within IGT. This device has the potential to enable testing of low-level hardware features that are currently not covered. Specifically, Unigraf devices can assist in testing link training, signal integrity, HDCP, DSC, and more.

It's important to note that the Unigraf SDK is not open-source, and the communication protocol with the device is proprietary. As a result, I have utilized the libTSI.so library, which can be downloaded from [1]. In this RFC, I have not used the official TSI_types.h header because it was incompatible with C, so I hardcoded some necessary values. The next iteration will use the official TSI_types.h (they plan to fix it for the next release).

This RFC is intentionally concise to gather initial feedback from the community regarding the integration of a proprietary device into the test suite. I plan to expand on this work by adding more features and pushing the developments upstream.

I have also started to work on MST testing (hotplug, link training, bandwith limitation), but I have a big issue: connector detection is very strange when changing MST configurat (MST->SST, sink count...).

If I use the Unigraf GUI or my own C script outside IGT, everything seems
fine: watch -n0 modetest -c update connector status almost immediatly after a HDP pulse, never hang and always have the correct result.

But if I do the same in IGT (same script in igt_main), igt have too much/not all connectors, and some of them are broken (no EDID property for example). I tried to run watch -n0 modetest -c in parallel, but modetest can:
- hang
- only update once igt test is finished.

Do you have any hint about something I missed in IGT to properly enumerate connectors? I tried close/open the DRM device, added a lot of delay everywhere, emulate plug/unplug... I used kms_wait_for_new_connectors (in this series) and for_each_connected_output to get list the connectors.

Looking forward to your thoughts and suggestions!

Thanks,
Louis Chauvet

---
Changes in v2:
- Splitted in many commits
- Add CRC support
- Link to v1: https://lore.kernel.org/r/[email protected]

---
Louis Chauvet (26):
lib/igt_kms: Add a detect timeout value
lib/igt_kms: Add helper to wait for a specific status on a connector lib/igt_kms: Add function to list connected connectors lib/igt_kms: Add helper to obtain a connector by its name or MST path lib/igt_kms: Add helper to wait for new connectors lib/monitor_edids: Add helper functions for using monitor_edid objects lib/monitor_edids: Add helper to get an EDID by its name lib/monitor_edids: Add helper to print all available EDID names [DO NOT MERGE] lib/unigraf: Add used defines for TSI_Types lib/unigraf: Add TSI.h
lib/unigraf: Initial Unigraf support
lib/igt_kms: Automatically connect unigraf on display require lib/unigraf: Introduce device configuration
lib/unigraf: Introduce role configuration
lib/unigraf: Introduce input configuration
lib/unigraf: Add unigraf assert and deassert helpers lib/unigraf: Add plug/unplug helpers
lib/unigraf: Allows sst/mst configuration
lib/unigraf: Add helpers to read and write edid lib/unigraf: Add connector configuration
lib/unigraf: Add connector autodetection
lib/unigraf: Add edid configuration
tests/unigraf: Add basic unigraf tests
lib/unigraf: Add unigraf CRC grab
lib/unigraf: Add configuration for CRC usage lib/igt_pipe_crc: Add ungiraf crc calculation

 lib/igt_core.c                           |   4 +
 lib/igt_kms.c                            | 346 ++++++++++++++++++++
 lib/igt_kms.h                            |  23 ++
 lib/igt_pipe_crc.c                       |  22 ++
 lib/meson.build                          |  10 +
 lib/monitor_edids/dp_edids.h             |   3 +
 lib/monitor_edids/hdmi_edids.h           |   3 +
 lib/monitor_edids/monitor_edids_helper.c | 127 ++++++++
 lib/monitor_edids/monitor_edids_helper.h |  10 +-
 lib/unigraf/TSI.h                        | 227 +++++++++++++
 lib/unigraf/TSI_types.h                  |  44 +++
 lib/unigraf/unigraf.c                    | 530 +++++++++++++++++++++++++++++++
 lib/unigraf/unigraf.h                    | 168 ++++++++++
 meson.build                              |  14 +
 tests/meson.build                        |   4 +
 tests/unigraf/meson.build                |  12 +
 tests/unigraf/unigraf_connectivity.c     | 126 ++++++++
 17 files changed, 1672 insertions(+), 1 deletion(-)

---
base-commit: b4e1ccd32037008012d5c41ac6bb04da22082302
change-id: 20250425-unigraf-integration-11ed330755d5

Best regards,

Signature · 1 line
Louis Chauvet <[email protected]>
#1 lore raw

PATCH v2 1/26 lib/igt_kms: Add a detect timeout value

Some tests need to wait for a specific connector status. In order to make the timeout customisable for each target, add an option in the configuration file.

---
 lib/igt_core.c |  4 ++++
 lib/igt_kms.c  | 35 +++++++++++++++++++++++++++++++++++
 lib/igt_kms.h  | 10 ++++++++++
 3 files changed, 49 insertions(+)
lib/igt_core.c +4 -0
index c2674a27203cbbe5413cb579153dbeed105621bc..3bafaf971c4c9f0fe8718cab261464c0f4477d3f 100644
@@ -271,6 +271,10 @@
  *	&num; It is not mandatory and allows overriding default values.
  *	[DUT]
  *	SuspendResumeDelay=10
+ *
+ *	&num; The following option define the timeout for detection feature
+ *	&num; (waiting for a connector status)
+ *	DisplayDetectTimeout=10.0
  * ]|
  *
  * Some specific configuration options may be used by specific parts of IGT,
lib/igt_kms.c +35 -0
index 9ee03e87092716841a91322d38da8023aaaae611..d0dcce5d008eb0e1953a2b60a6670c98562ba7a1 100644
@@ -59,6 +59,7 @@
 #include "intel_chipset.h"
 #include "igt_debugfs.h"
 #include "igt_device.h"
+#include "igt_rc.h"
 #include "igt_sysfs.h"
 #include "sw_sync.h"
 #ifdef HAVE_CHAMELIUM
@@ -7472,3 +7473,37 @@ int igt_backlight_write(int value, const char *fname, igt_backlight_context_t *c
 
 	return 0;
 }
+
+/**
+ * igt_default_display_detect_timeout:
+ *
+ * Get the default timeout value for detection feature
+ *
+ * Some tests requires to wait for a specific connector status. This value will determine the
+ * timeout value for this waiting.
+ */
+double igt_default_display_detect_timeout(void)
+{
+	static double timeout = 0.0;
+	static bool first_call = true;
+	GError *error = NULL;
+
+	if (first_call) {
+		if (igt_key_file) {
+			timeout = g_key_file_get_double(igt_key_file, "DUT", "DisplayDetectTimeout",
+							&error);
+			if (error) {
+				igt_debug("Failed to read DisplayDetectTimeout, defaulting to %f\n",
+					  DEFAULT_DETECT_TIMEOUT);
+				g_clear_error(&error);
+				timeout = DEFAULT_DETECT_TIMEOUT;
+			}
+		} else {
+			timeout = DEFAULT_DETECT_TIMEOUT;
+		}
+
+		first_call = false;
+	}
+
+	return timeout;
+}
lib/igt_kms.h +10 -0
index a85fee515f56206d14394682f878e84cde62a758..e39745b0a68cbac4bd57c4c4ceae82a64cfab5a9 100644
@@ -40,6 +40,14 @@
 #include "igt_fb.h"
 #include "ioctl_wrappers.h"
 
+/**
+ * define DEFAULT_DETECT_TIMEOUT - Default timeout in second used for some screen detection
+ * functions
+ *
+ * It can be overiden by option DetectTimeout in the .igtrc file.
+ */
+#define DEFAULT_DETECT_TIMEOUT 10.0
+
 /* Low-level helpers with kmstest_ prefix */
 
 /**
@@ -1281,4 +1289,6 @@ void igt_set_link_params(int drm_fd, igt_output_t *output,
 int igt_backlight_read(int *result, const char *fname, igt_backlight_context_t *context);
 int igt_backlight_write(int value, const char *fname, igt_backlight_context_t *context);
 
+double igt_default_display_detect_timeout(void);
+
 #endif /* __IGT_KMS_H__ */
Signature · 1 line
2.50.0
#2 lore raw

PATCH v2 2/26 lib/igt_kms: Add helper to wait for a specific status on a connector

In reply to Louis Chauvet

During testing with chamelium, it is frequent to wait for a specific connector status. This new helper is polling the DRM API to wait for this status. This allows detecting it without notifier systems which can fail if hot plug detection is not working properly on the device under test.

---
 lib/igt_kms.c | 39 +++++++++++++++++++++++++++++++++++++++
 lib/igt_kms.h |  3 +++
 2 files changed, 42 insertions(+)
lib/igt_kms.c +39 -0
index d0dcce5d008eb0e1953a2b60a6670c98562ba7a1..ad3a31b7a487f986083c6648e2cc1f5f14d5b4a2 100644
@@ -7507,3 +7507,42 @@ double igt_default_display_detect_timeout(void)
 
 	return timeout;
 }
+
+/**
+ * igt_wait_for_connector_status:
+ * @drm_fd: drm file descriptor
+ * @connector_id: connector to monitor
+ * @timeout: maximum duration to wait, in second. Use -1.0 to set the timeout
+ *           to igt_default_detect_timeout().
+ * @drm_mode: mode to wait for, see enum drmModeConnection
+ *
+ * Wait for at most @timeout that the connector @connector_id  status
+ * become @drm_mode
+ * Returns: true when the status is reached, false if there is a timeout
+ */
+bool igt_wait_for_connector_status(int drm_fd, unsigned int connector_id, double timeout,
+				   int drm_mode)
+{
+	drmModeConnector *connector;
+	struct timespec start, end;
+
+	if (timeout == -1.0)
+		timeout = igt_default_display_detect_timeout();
+
+	clock_gettime(CLOCK_MONOTONIC, &start);
+	end = start;
+
+	while (igt_time_elapsed(&start, &end) <= timeout) {
+		connector = drmModeGetConnector(drm_fd, connector_id);
+		if (connector && connector->connection == drm_mode) {
+			drmModeFreeConnector(connector);
+			return true;
+		}
+		drmModeFreeConnector(connector);
+		clock_gettime(CLOCK_MONOTONIC, &end);
+	}
+
+	igt_debug("Timeout waiting for connection status %d on connector %d\n", drm_mode,
+		  connector_id);
+	return false;
+}
lib/igt_kms.h +3 -0
index e39745b0a68cbac4bd57c4c4ceae82a64cfab5a9..1a2ecfd154769e5fcc755f126cd1e9c8dd1bc7c2 100644
@@ -1291,4 +1291,7 @@ int igt_backlight_write(int value, const char *fname, igt_backlight_context_t *c
 
 double igt_default_display_detect_timeout(void);
 
+bool igt_wait_for_connector_status(int drm_fd, unsigned int connector_id, double timeout,
+				   int drm_mode);
+
 #endif /* __IGT_KMS_H__ */
Signature · 1 line
2.50.0
#3 lore raw

PATCH v2 3/26 lib/igt_kms: Add function to list connected connectors

In reply to Louis Chauvet

Introduce the igt_get_connected_connectors() function, which returns a list of connector IDs that are currently connected according to DRM.

This function includes a timeout mechanism because connectors can be unplugged at any time. Also, especially with MST, the connector can be listed by drmModeGetResources() but not yet accessible with drmModeGetConnector().

---
 lib/igt_kms.c | 67 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 lib/igt_kms.h |  1 +
 2 files changed, 68 insertions(+)
lib/igt_kms.c +67 -0
index ad3a31b7a487f986083c6648e2cc1f5f14d5b4a2..98f86ae18f79ff6ec068878041de59fcefa8744d 100644
@@ -7508,6 +7508,29 @@ double igt_default_display_detect_timeout(void)
 	return timeout;
 }
 
+static drmModeConnectorPtr igt_wait_for_connector(int drm_fd, unsigned int connector_id,
+						  double timeout)
+{
+	drmModeConnectorPtr connector = NULL;
+	struct timespec start, end;
+
+	connector = drmModeGetConnector(drm_fd, connector_id);
+	/*
+	 * This time is required as sometimes some id in the connector list are not totally
+	 * ready or can disappear
+	 */
+	clock_gettime(CLOCK_MONOTONIC, &start);
+	end = start;
+
+	while (!connector &&
+	       igt_time_elapsed(&start, &end) <= timeout) {
+		connector = drmModeGetConnector(drm_fd, connector_id);
+		clock_gettime(CLOCK_MONOTONIC, &end);
+	}
+
+	return connector;
+}
+
 /**
  * igt_wait_for_connector_status:
  * @drm_fd: drm file descriptor
@@ -7546,3 +7569,47 @@ bool igt_wait_for_connector_status(int drm_fd, unsigned int connector_id, double
 		  connector_id);
 	return false;
 }
+
+/**
+ * igt_get_connected_connectors:
+ *
+ * @drm_fd: DRM file description
+ * @connector_ids: Out pointer for the list of connector ids connected. It must be freed by the
+ * caller.
+ *
+ * This will probe all the connectors and return the list of all
+ * connected connectors.
+ * Returns: The number of connectors in @connector_ids
+ */
+int igt_get_connected_connectors(int drm_fd, uint32_t **connector_ids)
+{
+	int connected_count = 0;
+	double timeout = igt_default_display_detect_timeout();
+	drmModeResPtr resources;
+
+	igt_assert(drm_fd);
+	*connector_ids = NULL;
+
+	resources = drmModeGetResources(drm_fd);
+	igt_assert(resources);
+	for (int j = 0; j < resources->count_connectors; j++) {
+		drmModeConnectorPtr connector = igt_wait_for_connector(drm_fd,
+								       resources->connectors[j],
+								       timeout);
+
+		if (connector) {
+			if (connector->connection == DRM_MODE_CONNECTED) {
+				*connector_ids = reallocarray(*connector_ids,
+							      connected_count
+							      + 1, sizeof(**connector_ids));
+				igt_assert(*connector_ids);
+				(*connector_ids)[connected_count] = resources->connectors[j];
+				connected_count++;
+			}
+			drmModeFreeConnector(connector);
+		}
+	}
+	drmModeFreeResources(resources);
+
+	return connected_count;
+}
lib/igt_kms.h +1 -0
index 1a2ecfd154769e5fcc755f126cd1e9c8dd1bc7c2..fb0ef6f00477283c19e4322f832f389bde317c4f 100644
@@ -1293,5 +1293,6 @@ double igt_default_display_detect_timeout(void);
 
 bool igt_wait_for_connector_status(int drm_fd, unsigned int connector_id, double timeout,
 				   int drm_mode);
+int igt_get_connected_connectors(int drm_fd, uint32_t **connector_ids);
 
 #endif /* __IGT_KMS_H__ */
Signature · 1 line
2.50.0
#4 lore raw

PATCH v2 4/26 lib/igt_kms: Add helper to obtain a connector by its name or MST path

In reply to Louis Chauvet

Introduce the functions igt_get_connector_from_name() and igt_get_connector_id_from_mst_path(). These functions serve to retrieve the connector object using a connector name and a connector ID from its MST path, respectively.

Given that the connector id may not be consistent, especially with MST connectors, these functions are essential to recognize each connector even after system reboots and plug/unplug events.

The function igt_get_connector_id_from_name() is a convenient wrapper for igt_get_connector_from_name() to streamline its usage when the caller only requires the connector id.

---
 lib/igt_kms.c | 109 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 lib/igt_kms.h |   3 ++
 2 files changed, 112 insertions(+)
lib/igt_kms.c +109 -0
index 98f86ae18f79ff6ec068878041de59fcefa8744d..27326eec49047bc521eadf39b9f25671ff1e9e26 100644
@@ -93,6 +93,10 @@
 #define MAX_CONNECTORS 32
 #define MAX_EDID 2
 #define DISPLAY_TILE_BLOCK 0x12
+/**
+ * define IGT_KMS_CONNECTOR_NAME_SIZE - Size used when a connector name is needed
+ */
+#define IGT_KMS_CONNECTOR_NAME_SIZE 50
 
 typedef bool (*igt_connector_attr_set)(int dir, const char *attr, const char *value);
 
@@ -7613,3 +7617,108 @@ int igt_get_connected_connectors(int drm_fd, uint32_t **connector_ids)
 
 	return connected_count;
 }
+
+
+/**
+ * igt_get_connector_from_name:
+ * @drm_fd: DRM file descriptor
+ * @port_name: Port name to search
+ *
+ * Returns: The connector if found, NULL otherwise. The pointer must
+ * be freed with drmModeFreeConnector()
+ */
+drmModeConnectorPtr igt_get_connector_from_name(int drm_fd, const char *port_name)
+{
+	drmModeResPtr res = drmModeGetResources(drm_fd);
+	double timeout = igt_default_display_detect_timeout();
+	int i, len;
+
+	if (!res)
+		return NULL;
+
+	for (i = 0; i < res->count_connectors; i++) {
+		char name[IGT_KMS_CONNECTOR_NAME_SIZE];
+
+		drmModeConnectorPtr connector = igt_wait_for_connector(drm_fd, res->connectors[i],
+								       timeout);
+
+		if (connector) {
+			/* We have to generate the connector name on our own */
+			len = snprintf(name, ARRAY_SIZE(name), "%s-%u",
+				 kmstest_connector_type_str(connector->connector_type),
+				 connector->connector_type_id);
+			name[len] = 0;
+
+
+			if (strcmp(port_name, name) == 0) {
+				drmModeFreeResources(res);
+
+				return connector;
+			}
+
+			drmModeFreeConnector(connector);
+		}
+	}
+
+	drmModeFreeResources(res);
+
+	return NULL;
+}
+
+/**
+ * igt_get_connector_id_from_name:
+ * @drm_fd: DRM file descriptor
+ * @port_name: Port name to find in the connector
+ *
+ * Returns: The connector id if the port is found, 0 if the port is not found
+ */
+uint32_t igt_get_connector_id_from_name(int drm_fd, const char *port_name)
+{
+	drmModeConnectorPtr connector = igt_get_connector_from_name(drm_fd, port_name);
+
+	if (connector) {
+		uint32_t connector_id = connector->connector_id;
+
+		drmModeFreeConnector(connector);
+
+		return connector_id;
+	}
+
+	return 0;
+}
+
+/**
+ * igt_get_connector_id_from_mst_path:
+ * @drm_fd: DRM file descriptor
+ * @mst_path: MST path to find in the connector
+ *
+ * Returns: 0 when no connector is found with the correct mst path
+ */
+uint32_t igt_get_connector_id_from_mst_path(int drm_fd, const void *mst_path)
+{
+	drmModeResPtr res = drmModeGetResources(drm_fd);
+	int i;
+
+	if (!res)
+		return 0;
+
+	for (i = 0; i < res->count_connectors; i++) {
+		uint32_t connector_id = res->connectors[i];
+
+		drmModePropertyBlobPtr path_blob = kmstest_get_path_blob(drm_fd, connector_id);
+
+		if (path_blob) {
+			if (memcmp(path_blob->data, mst_path, path_blob->length) == 0) {
+				drmModeFreePropertyBlob(path_blob);
+				drmModeFreeResources(res);
+				return connector_id;
+			}
+
+			drmModeFreePropertyBlob(path_blob);
+		}
+	}
+
+	drmModeFreeResources(res);
+
+	return 0;
+}
lib/igt_kms.h +3 -0
index fb0ef6f00477283c19e4322f832f389bde317c4f..8939ed84bd016ab03b6f165621b62664039bca9e 100644
@@ -1294,5 +1294,8 @@ double igt_default_display_detect_timeout(void);
 bool igt_wait_for_connector_status(int drm_fd, unsigned int connector_id, double timeout,
 				   int drm_mode);
 int igt_get_connected_connectors(int drm_fd, uint32_t **connector_ids);
+drmModeConnectorPtr igt_get_connector_from_name(int drm_fd, const char *port_name);
+uint32_t igt_get_connector_id_from_name(int drm_fd, const char *port_name);
+uint32_t igt_get_connector_id_from_mst_path(int drm_fd, const void *mst_path);
 
 #endif /* __IGT_KMS_H__ */
Signature · 1 line
2.50.0
#5 lore raw

PATCH v2 5/26 lib/igt_kms: Add helper to wait for new connectors

In reply to Louis Chauvet

Add list comparison utilities and a new function to wait for new connectors to appear on the system.

---
 lib/igt_kms.c | 93 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 lib/igt_kms.h |  6 ++++
 2 files changed, 99 insertions(+)
lib/igt_kms.c +93 -0
index 27326eec49047bc521eadf39b9f25671ff1e9e26..c79f9b946ca84c7c374ca514c05def2c34f81383 100644
@@ -7722,3 +7722,96 @@ uint32_t igt_get_connector_id_from_mst_path(int drm_fd, const void *mst_path)
 
 	return 0;
 }
+
+/**
+ * list_contains() - Search an element in the list
+ *
+ * @list: Pointer to the list to search into
+ * @list_len: Length of the list
+ * @value: Value to search in the list
+ *
+ * Returns true if @list contains @value
+ */
+static bool list_contains(const uint32_t *list, int list_len, uint32_t value)
+{
+	igt_assert((list == NULL && list_len == 0) || list);
+	for (int i = 0; i < list_len; i++) {
+		if (list[i] == value)
+			return true;
+	}
+	return false;
+}
+
+/**
+ * get_list_diff() - Compute and return the difference between two lists
+ *
+ * @list_a: Pointer to the first list to compare
+ * @list_a_len: Length of the first list
+ * @list_b: Pointer to the second list to compare
+ * @list_b_len: Length of the second list
+ * @diff: Out pointer for the difference. Can be null to only count new elements.
+ *
+ * Returns the number of element which are in @list_a but not in @list_b.
+ */
+int
+get_list_diff(const uint32_t *list_a, int list_a_len, const uint32_t *list_b, int list_b_len,
+	      uint32_t **diff)
+{
+	int diff_len = 0;
+
+	igt_assert((list_a == NULL && list_a_len == 0) || list_a);
+	igt_assert((list_b == NULL && list_b_len == 0) || list_b);
+
+	if (diff)
+		*diff = malloc(0);
+
+	for (int i = 0; i < list_a_len; i++) {
+		if (!list_contains(list_b, list_b_len, list_a[i])) {
+			if (diff) {
+				*diff = reallocarray(*diff, diff_len + 1, sizeof(**diff));
+				igt_assert(*diff);
+				(*diff)[diff_len] = list_a[i];
+			}
+
+			diff_len++;
+		}
+	}
+
+	return diff_len;
+}
+
+/**
+ * kms_wait_for_new_connectors() - Wait for new connector to appear
+ *
+ * @list_a: Pointer to the first list to compare
+ * @list_a_len: Length of the first list
+ * @list_b: Pointer to the second list to compare
+ * @list_b_len: Length of the second list
+ * @diff: Out pointer for the difference. Can be null.
+ *
+ * Returns the number of element which differ between the two lists.
+ */
+int kms_wait_for_new_connectors(uint32_t **newly_connected,
+					const uint32_t *already_connected,
+					int already_connected_count, int drm_fd)
+{
+	int newly_connected_count;
+	struct timespec start, end;
+
+	igt_assert(newly_connected);
+	igt_assert(drm_fd);
+
+	clock_gettime(CLOCK_MONOTONIC, &start);
+	clock_gettime(CLOCK_MONOTONIC, &end);
+	do {
+		if (*newly_connected)
+			free(*newly_connected);
+		newly_connected_count = igt_get_connected_connectors(drm_fd, newly_connected);
+		clock_gettime(CLOCK_MONOTONIC, &end);
+	} while (get_list_diff(*newly_connected, newly_connected_count,
+			       already_connected, already_connected_count,
+			       NULL) == 0 &&
+		 igt_time_elapsed(&start, &end) <= igt_default_display_detect_timeout());
+
+	return newly_connected_count;
+}
lib/igt_kms.h +6 -0
index 8939ed84bd016ab03b6f165621b62664039bca9e..2149dbbb85f44edeb2c7da2baf2d57cb2d890554 100644
@@ -1298,4 +1298,10 @@ drmModeConnectorPtr igt_get_connector_from_name(int drm_fd, const char *port_nam
 uint32_t igt_get_connector_id_from_name(int drm_fd, const char *port_name);
 uint32_t igt_get_connector_id_from_mst_path(int drm_fd, const void *mst_path);
 
+int kms_wait_for_new_connectors(uint32_t **newly_connected,
+					const uint32_t *already_connected,
+					int already_connected_count, int drm_fd);
+int
+get_list_diff(const uint32_t *list_a, int list_a_len, const uint32_t *list_b, int list_b_len,
+	      uint32_t **diff);
 #endif /* __IGT_KMS_H__ */
Signature · 1 line
2.50.0
#6 lore raw

PATCH v2 6/26 lib/monitor_edids: Add helper functions for using monitor_edid objects

In reply to Louis Chauvet

Introduce the functions edid_from_monitor_edid() and get_edids_for_connector_type(). The former converts a monitor_edid object to a struct edid, which can then be utilized by igt_kms helpers. The latter returns a list of monitor_edid objects for a specific connector with certain characteristics

---
 lib/monitor_edids/dp_edids.h             |  3 ++
 lib/monitor_edids/hdmi_edids.h           |  3 ++
 lib/monitor_edids/monitor_edids_helper.c | 80 ++++++++++++++++++++++++++++++++
 lib/monitor_edids/monitor_edids_helper.h |  7 ++-
 4 files changed, 92 insertions(+), 1 deletion(-)
lib/monitor_edids/dp_edids.h +3 -0
index 144907558be1faa306b646ce3b47b24c13050968..07793381257e0082a1fa7b4321fcef7e5aeaa5a9 100644
@@ -194,4 +194,7 @@ monitor_edid DP_EDIDS_NON_4K[] = {
 
  };
 
+#define DP_EDIDS_4K_COUNT ARRAY_SIZE(DP_EDIDS_4K)
+#define DP_EDIDS_NON_4K_COUNT ARRAY_SIZE(DP_EDIDS_NON_4K)
+
 #endif /* TESTS_CHAMELIUM_MONITOR_EDIDS_DP_EDIDS_H_ */
lib/monitor_edids/hdmi_edids.h +3 -0
index f6cfe82ff6e1c4419160bcdcc851a5e28eb08726..3984241775c3d8e0f39732bdc41cb44f491ce62b 100644
@@ -604,4 +604,7 @@ monitor_edid HDMI_EDIDS_NON_4K[] = {
 		  "1620582c2500baac4200009e0000006b" },
 };
 
+#define HDMI_EDIDS_4K_COUNT ARRAY_SIZE(HDMI_EDIDS_4K)
+#define HDMI_EDIDS_NON_4K_COUNT ARRAY_SIZE(HDMI_EDIDS_NON_4K)
+
 #endif /* TESTS_CHAMELIUM_MONITOR_EDIDS_HDMI_EDIDS_H_ */
lib/monitor_edids/monitor_edids_helper.c +80 -0

89 lines not on this page · raw message

lib/monitor_edids/monitor_edids_helper.h +6 -1
index 05679f0897f3d0618d656cc071b565b48d31da28..e5069868683d97053d8e66666e83692f1b733db3 100644
@@ -12,6 +12,8 @@
 #define TESTS_CHAMELIUM_MONITOR_EDIDS_MONITOR_EDIDS_HELPER_H_
 
 #include <stdint.h>
+#include <stddef.h>
+#include <stdbool.h>
 
 #include "igt_chamelium.h"
 
@@ -30,4 +32,7 @@ get_chameleon_edid_from_monitor_edid(struct chamelium *chamelium,
 				     const monitor_edid *edid);
 void free_chamelium_edid_from_monitor_edid(struct chamelium_edid *edid);
 
-#endif /* TESTS_CHAMELIUM_MONITOR_EDIDS_MONITOR_EDIDS_HELPER_H_ */
\ No newline at end of file
+struct edid *edid_from_monitor_edid(const monitor_edid *monitor_edid);
+struct monitor_edid *get_edids_for_connector_type(uint32_t type, size_t *count, bool four_k);
+
+#endif /* TESTS_CHAMELIUM_MONITOR_EDIDS_MONITOR_EDIDS_HELPER_H_ */
Signature · 1 line
2.50.0
#7 lore raw

PATCH v2 7/26 lib/monitor_edids: Add helper to get an EDID by its name

In reply to Louis Chauvet

For testing specific EDID, it is useful to be able to retrieve an EDID by a verbose name.

---
 lib/monitor_edids/monitor_edids_helper.c | 30 ++++++++++++++++++++++++++++++
 lib/monitor_edids/monitor_edids_helper.h |  1 +
 2 files changed, 31 insertions(+)
lib/monitor_edids/monitor_edids_helper.c +30 -0
index 6043e7a084b320263f1c0525369aaa59a5d32bcc..01feb34a5516916b615a741f773316159c38fccf 100644
@@ -20,6 +20,16 @@
 #include "drmtest.h"
 #include "hdmi_edids.h"
 
+struct {
+	struct monitor_edid *edid_list;
+	int list_size;
+} ALL_EDIDS[] = {
+	{DP_EDIDS_NON_4K,	DP_EDIDS_NON_4K_COUNT},
+	{DP_EDIDS_4K,		DP_EDIDS_4K_COUNT},
+	{HDMI_EDIDS_NON_4K,	HDMI_EDIDS_NON_4K_COUNT},
+	{HDMI_EDIDS_4K,		HDMI_EDIDS_4K_COUNT},
+};
+
 static uint8_t convert_hex_char_to_byte(char c)
 {
 	if (c >= '0' && c <= '9')
@@ -170,3 +180,23 @@ struct monitor_edid *get_edids_for_connector_type(uint32_t type, size_t *count,
 		}
 	}
 }
+
+/**
+ * get_edid_by_name:
+ * @name: Name to search in available EDIDs
+ *
+ * Return the struct edid associated with a specific name. As with edid_from_monitor_edid, the
+ * caller must ensure to free the EDID after use. If no EDID with the exact name is found, returns
+ * NULL.
+ */
+struct edid *get_edid_by_name(const char *name)
+{
+	for (int i = 0; i < ARRAY_SIZE(ALL_EDIDS); i++) {
+		for (int j = 0; j < ALL_EDIDS[i].list_size; j++) {
+			if (strcmp(ALL_EDIDS[i].edid_list[j].name, name) == 0)
+				return edid_from_monitor_edid(&ALL_EDIDS[i].edid_list[j]);
+		}
+	}
+
+	return NULL;
+}
lib/monitor_edids/monitor_edids_helper.h +1 -0
index e5069868683d97053d8e66666e83692f1b733db3..6d9e3fc89592229cac5122c9275fcf226465ab3e 100644
@@ -34,5 +34,6 @@ void free_chamelium_edid_from_monitor_edid(struct chamelium_edid *edid);
 
 struct edid *edid_from_monitor_edid(const monitor_edid *monitor_edid);
 struct monitor_edid *get_edids_for_connector_type(uint32_t type, size_t *count, bool four_k);
+struct edid *get_edid_by_name(const char *name);
 
 #endif /* TESTS_CHAMELIUM_MONITOR_EDIDS_MONITOR_EDIDS_HELPER_H_ */
Signature · 1 line
2.50.0
#8 lore raw

PATCH v2 8/26 lib/monitor_edids: Add helper to print all available EDID names

In reply to Louis Chauvet

During the chamelium v3 configuration, it may be required to know the list of supported EDID names, so add an helper to print them.

---
 lib/monitor_edids/monitor_edids_helper.c | 17 +++++++++++++++++
 lib/monitor_edids/monitor_edids_helper.h |  2 ++
 2 files changed, 19 insertions(+)
lib/monitor_edids/monitor_edids_helper.c +17 -0
index 01feb34a5516916b615a741f773316159c38fccf..34ae6be9dd65e4e34777f9b929358eb7c86aeafc 100644
@@ -200,3 +200,20 @@ struct edid *get_edid_by_name(const char *name)
 
 	return NULL;
 }
+
+
+/*
+ * list_edid_names:
+ * @level: Log level to write the names on
+ *
+ * Print all the EDID available in igt.
+ */
+void list_edid_names(enum igt_log_level level)
+{
+	for (int i = 0; i < ARRAY_SIZE(ALL_EDIDS); i++) {
+		for (int j = 0; j < ALL_EDIDS[i].list_size; j++) {
+			igt_log(IGT_LOG_DOMAIN, level, " - \"%s\"\n",
+				ALL_EDIDS[i].edid_list[j].name);
+		}
+	}
+}
lib/monitor_edids/monitor_edids_helper.h +2 -0
index 6d9e3fc89592229cac5122c9275fcf226465ab3e..7ae0fd40c041b5d37e09b3bd494c6c90cf12fe97 100644
@@ -15,6 +15,7 @@
 #include <stddef.h>
 #include <stdbool.h>
 
+#include "igt_core.h"
 #include "igt_chamelium.h"
 
 /* Max Length can be increased as needed, when new EDIDs are added. */
@@ -35,5 +36,6 @@ void free_chamelium_edid_from_monitor_edid(struct chamelium_edid *edid);
 struct edid *edid_from_monitor_edid(const monitor_edid *monitor_edid);
 struct monitor_edid *get_edids_for_connector_type(uint32_t type, size_t *count, bool four_k);
 struct edid *get_edid_by_name(const char *name);
+void list_edid_names(enum igt_log_level level);
 
 #endif /* TESTS_CHAMELIUM_MONITOR_EDIDS_MONITOR_EDIDS_HELPER_H_ */
Signature · 1 line
2.50.0
#9 lore raw

PATCH v2 9/26 lib/unigraf: Add used defines for TSI_Types

In reply to Louis Chauvet

Current unigraf public release are not c-compatible, this file hardcode some values The next release of libTSI should include a c-compatible TSI_types.h file, that will be directly used in place of this file.

---
 lib/unigraf/TSI_types.h | 44 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 44 insertions(+)
lib/unigraf/TSI_types.h new file +44 -0
new file mode 100644
index 0000000000000000000000000000000000000000..583ee30ef658b1dbc98cde295fd63d8d36602725
@@ -0,0 +1,44 @@
+/* SPDX-License-Identifier: MIT */
+
+// DO NOT MERGE THIS FILE
+//
+// Current unigraf public release are not c-compatible, this file hardcode some values
+// The next release of libTSI should include a c-compatible TSI_types.h file, that will
+// be directly used in place of this file
+
+#ifndef TSI_REG_H
+
+#define TSI_VERSION_TEXT			0x80000001
+#define TSI_DEVCAP_VIDEO_CAPTURE		0x00000001
+#define TSI_SEARCHOPTIONS_SHOW_DEVICES_IN_USE	0x00000001
+
+#define TSI_EDID_TE_INPUT			0x1100
+#define TSI_EDID_SELECT_STREAM			0x1102
+
+#define TSI_BASE_LEGACY_GENERIC(offset)		(0x210 + offset)
+#define	TSI_FORCE_HOT_PLUG_STATE_W		TSI_BASE_LEGACY_GENERIC(0x2)
+
+#define TSI_BASE_HDRX(offset)			(0x50000000u + 0x23000 + offset)
+#define TSI_HDRX_HPD_CONTROL_W			TSI_BASE_HDRX(0x02)
+
+#define TSI_DPRX_LINK_FLAGS_MST			0x01
+#define TSI_DPRX_LINK_FLAGS_TPS3		0x02
+#define TSI_DPRX_LINK_FLAGS_TPS4		0x03
+#define TSI_DPRX_LINK_FLAGS_EDP			0x04
+#define TSI_DPRX_NOT_DOCUMENTED_SIDEBAND_MSG_SUPPORT	0x20
+
+#define TSI_BASE_DPRX(offset)			(0x50000000u + 0x21000 + offset)
+#define TSI_DPRX_HPD_FORCE			TSI_BASE_DPRX(0x12)
+#define TSI_DPRX_MST_SINK_COUNT			TSI_BASE_DPRX(0x9D)
+
+#define TSI_BASE_LEGACY_DPRX(offset)		(0x2b0 + offset)
+#define TSI_DPRX_DPCD_BASE_W			TSI_BASE_LEGACY_DPRX(0x9)
+#define TSI_DPRX_DPCD_DATA			TSI_BASE_LEGACY_DPRX(0xA)
+#define TSI_DPRX_LINK_FLAGS			TSI_BASE_LEGACY_DPRX(0x12)
+#define TSI_DPRX_STREAM_SELECT			TSI_BASE_LEGACY_DPRX(0x13)
+#define TSI_DPRX_CRC_R_R			TSI_BASE_LEGACY_DPRX(0x14)
+#define TSI_DPRX_CRC_G_R			TSI_BASE_LEGACY_DPRX(0x15)
+#define TSI_DPRX_CRC_B_R			TSI_BASE_LEGACY_DPRX(0x16)
+#define TSI_DPRX_HPD_PULSE_W			TSI_BASE_LEGACY_DPRX(0x1B)
+
+#endif
Signature · 1 line
2.50.0
#10 lore raw

PATCH v2 10/26 lib/unigraf: Add TSI.h

In reply to Louis Chauvet

Unigraf does not provide header for the libTSI.so file, only dynamic libary loading helpers for windows.

In order to link against this library and use unigraf devices, add the function declaration used in the dynamic library loading wrappers.

---
 lib/unigraf/TSI.h | 227 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 227 insertions(+)
lib/unigraf/TSI.h new file +227 -0
new file mode 100644
index 0000000000000000000000000000000000000000..e55403a30879d5b1058b6975b3a084383b98415a
@@ -0,0 +1,227 @@
+/* SPDX-License-Identifier: MIT */
+
+/*
+ * tsi.h - Header for libTSI.so
+ * Documentation here is taken from official documentation and developer observation.
+ */
+
+#ifndef TSI_H
+#define TSI_H
+
+#define TSI_CURRENT_VERSION	12
+#define MAX_EDID_SIZE		4096
+
+#define TSI_SUCCESS		0
+
+typedef unsigned int		TSI_VERSION_ID;
+typedef unsigned int		TSI_SEARCH_OPTIONS;
+typedef unsigned int		TSI_DEVICE_CAPS;
+typedef unsigned int		TSI_CONFIG_ID;
+typedef unsigned int		TSI_DEVICE_ID;
+typedef unsigned int		TSI_INPUT_ID;
+typedef int			TSI_RESULT;
+typedef void			*TSI_HANDLE;
+typedef int			TSI_FLAGS;
+
+/**
+ * TSI_Init() - Initialize the TSI library
+ * @ClientVersion: Indicates the version used to call the libTSI.so functions.
+ *
+ * Initialize libTSI for use and sets up internal state. It can be called
+ * multiple times, but TSI_Clean must be called the exact same number of time.
+ *
+ * Returns:
+ * - In case of success: Reference count to the API (number of times to call TSI_Clean)
+ * - TSI_ERROR_NOT_COMPATIBLE if the requested client version is not supported
+ *   by the library
+ * - TSI_ERROR_COMPATIBILITY_MISMATCH if TSI_Init is called twice with
+ *   different client version
+ */
+TSI_RESULT TSI_Init(TSI_VERSION_ID ClientVersion);
+
+/**
+ * TSI_Clean() - Cleans and closes the TSI library
+ *
+ * When TSI_Clean is called for the last time, cleanup the internal state. It
+ * should be called exactly the same number of time as TSI_Init
+ */
+TSI_RESULT TSI_Clean(void);
+
+/**
+ * TSI_MISC_GetErrorDescription() - Get a human readable error message
+ * @ErrorCode: Error code for which you want the message
+ * @ErrorString: Pointer where to copy the message
+ * @StringMaxLen: Size of the allocated string @ErrorString
+ *
+ * The official documentation states: If the function succeeds, the
+ * return value is the number of characters required for the complete
+ * error description string.
+ * In reality, this function always returns 0 or error, so there is no way to
+ * tell if the allocated memory was big enough
+ *
+ * Returns:
+ * - >= 0 on success, theorically the required string len to store the message
+ * - < 0 on failure
+ */
+TSI_RESULT TSI_MISC_GetErrorDescription(TSI_RESULT ErrorCode,
+					char *ErrorString,
+					unsigned int StringMaxLen);
+
+/**
+ * TSIX_TS_GetConfigItem() - Read a configuration item from the UCD device
+ * @Device: Device handle to read config from. Can be NULL for certain configuration items.
+ * @ConfigItemID: Identifier of the requested configuration item.
+ * @ConfigItemData: Pointer to store the read value.
+ * @ItemMaxSize: Size of the allocated memory for @ConfigItemData.
+ *
+ * Returns: The size of the raw data. If the return value is larger than ItemMaxSize, no data
+ *          is copied to ConfigItemData.
+ * Note:
+ * - Some configurations require specific size and alignment for the allocated buffer. Refer to
+ *   the specific item configuration documentation for details.
+ * - Data may still be written to @ConfigItemData even if the return value is larger than
+ *   @ItemMaxSize, potentially causing buffer overflow.
+ */
+TSI_RESULT TSIX_TS_GetConfigItem(TSI_HANDLE Device, TSI_CONFIG_ID ConfigItemID,
+				 void *ConfigItemData,
+				 unsigned int ItemMaxSize);
+
+/**
+ * TSIX_DEV_RescanDevices() - Refresh the internal list of devices for libTSI
+ * @SearchOptions: Options to filter the list of devices (e.g., TSI_SEARCHOPTIONS_SHOW_DEVICES_IN_USE to include devices already in use).
+ * @RequiredCaps: Filter to list only devices with specific capabilities.
+ * @UnallowedCaps: Filter to list only devices without specific capabilities.
+ *
+ * Returns: >=0 in case of success.
+ *
+ * This function should be called every time you need to update the list of connected devices,
+ * and it must be called at least once before calling TSI_DEV_GetDeviceCount.
+ */
+TSI_RESULT TSIX_DEV_RescanDevices(TSI_SEARCH_OPTIONS SearchOptions,
+				  TSI_DEVICE_CAPS RequiredCaps,
+				  TSI_DEVICE_CAPS UnallowedCaps);
+/**
+ * TSIX_DEV_GetDeviceCount() - Get the count of scanned devices
+ * Returns: the number of devices that the previous call to TSIX_DEV_RescanDevices() detected
+ *
+ * Must be called after a TSIX_DEV_RescanDevices.
+ */
+TSI_RESULT TSIX_DEV_GetDeviceCount(void);
+
+/**
+ * TSIX_DEV_OpenDevice() - Open a device from the scanned list
+ * @DeviceID: index in the TSI_DEV_RescanDevices list
+ * @Result: Pointer to store the error code returned while opening the device
+ * Returns: if the device is found, an opaque pointer that can be used for other API calls. If some error occurred during the detection, the status code is written in the pointer @Result.
+ */
+TSI_HANDLE TSIX_DEV_OpenDevice(TSI_DEVICE_ID DeviceID, TSI_RESULT *Result);
+
+/**
+ * TSIX_DEV_CloseDevice() - Close the device handle when finished
+ * @Device: Device handle to close
+ * Returns: >=0 in case of success
+ */
+TSI_RESULT TSIX_DEV_CloseDevice(TSI_HANDLE Device);
+
+/**
+ * TSIX_VIN_Disable() - Disable video input on the specified device
+ * @Device: Device handle to disable video input on
+ * Returns: >=0 in case of success
+ */
+TSI_RESULT TSIX_VIN_Disable(TSI_HANDLE Device);
+
+/**
+ * TSIX_VIN_Select() - Select a specific video input on the specified device
+ * @Device: Device handle on which to select the input
+ * @InputID: Identifier of the input to select
+ * Returns: >=0 in case of success
+ */
+TSI_RESULT TSIX_VIN_Select(TSI_HANDLE Device, TSI_INPUT_ID InputID);
+
+/**
+ * TSIX_DEV_SelectRole() - Select a specific role for the specified device
+ * @Device: Device handle on which to assign the role
+ * @RoleIndex: Index of the role to assign
+ * Returns: >=0 in case of success
+ */
+TSI_RESULT TSIX_DEV_SelectRole(TSI_HANDLE Device, int RoleIndex);
+
+/**
+ * TSIX_TS_SetConfigItem() - Set a configuration item on the specified device
+ * @Device: Device handle to set the configuration on
+ * @ConfigItemID: Identifier of the configuration item to set
+ * @ItemData: Pointer to the data to set
+ * @ItemSize: Size of the data to set
+ * Returns: >=0 in case of success
+ */
+TSI_RESULT TSIX_TS_SetConfigItem(TSI_HANDLE Device, TSI_CONFIG_ID ConfigItemID,
+					const void *ItemData, unsigned int ItemSize);
+
+/**
+ * TSIX_VIN_Enable() - Enable video input on the specified device
+ * @Device: Device handle to enable video input on
+ * @Flags: Flags to specify the options for enabling the video input
+ * Returns: >=0 in case of success
+ */
+TSI_RESULT TSIX_VIN_Enable(TSI_HANDLE Device, TSI_FLAGS Flags);
+
+/**
+ * TSIX_VIN_GetInputCount() - Get the number of video inputs available on a device
+ * @Device: Device handle to query
+ *
+ * Returns: >=0 in case of success, the number of video inputs available on the device
+ */
+TSI_RESULT TSIX_VIN_GetInputCount(TSI_HANDLE Device);
+
+/**
+ * TSIX_DEV_GetDeviceName() - Get the name of a device from the scanned list
+ * @DeviceID: Index in the TSI_DEV_RescanDevices list
+ * @DevNameString: Pointer to store the device name
+ * @NameStringMaxLength: Size of the allocated memory for @DevNameString
+ *
+ * Returns: >=0 in case of success, the length of the device name string
+ * Note: If the return value is larger than NameStringMaxLength, the string may be truncated
+ */
+TSI_RESULT TSIX_DEV_GetDeviceName(TSI_DEVICE_ID DeviceID, char *DevNameString, unsigned int NameStringMaxLength);
+
+/**
+ * TSIX_DEV_GetDeviceRoleCount() - Get the number of roles available for a device
+ * @Device: Device handle to query
+ *
+ * Returns: >=0 in case of success, the number of roles available for the device
+ */
+TSI_RESULT TSIX_DEV_GetDeviceRoleCount(TSI_HANDLE Device);
+
+/**
+ * TSIX_DEV_GetDeviceRoleName() - Get the name of a specific role for a device
+ * @Device: Device handle to query
+ * @RoleIndex: Index of the role to get the name for
+ * @RoleNameString: Pointer to store the role name
+ * @RoleStringMaxLength: Size of the allocated memory for @RoleNameString
+ *
+ * Returns: >=0 in case of success, the length of the role name string
+ * Note: If the return value is larger than RoleStringMaxLength, the string may be truncated
+ */
+TSI_RESULT TSIX_DEV_GetDeviceRoleName(TSI_HANDLE Device, int RoleIndex, char *RoleNameString, unsigned int RoleStringMaxLength);
+
+/**
+ * TSIX_VIN_GetInputCount() - Get the number of video inputs available on a device
+ * @Device: Device handle to query
+ *
+ * Returns: >=0 in case of success, the number of video inputs available on the device
+ */
+TSI_RESULT TSIX_VIN_GetInputCount(TSI_HANDLE Device);
+
+/**
+ * TSIX_VIN_GetInputName() - Get the name of a specific video input on a device
+ * @Device: Device handle to query
+ * @InputID: Identifier of the input to get the name for
+ * @InputNameString: Pointer to store the input name
+ * @NameStringMaxLen: Size of the allocated memory for @InputNameString
+ *
+ * Returns: >=0 in case of success, the length of the input name string
+ * Note: If the return value is larger than NameStringMaxLen, the string may be truncated
+ */
+TSI_RESULT TSIX_VIN_GetInputName(TSI_HANDLE Device, TSI_INPUT_ID InputID, char *InputNameString, unsigned int NameStringMaxLen);
+
+#endif
Signature · 1 line
2.50.0
#11 lore raw

PATCH v2 11/26 lib/unigraf: Initial Unigraf support

In reply to Louis Chauvet

This introduce the basic boilerplate to connect to a unigraf device.

This integration currently only supports one device openned to simplify its usage and cleanup.

The functions unigraf_open_device and unigraf_require_device will register a handler to do proper cleanup on IGT exit.

---
 lib/meson.build       |  10 +++++
 lib/unigraf/unigraf.c | 109 ++++++++++++++++++++++++++++++++++++++++++++++++++
 lib/unigraf/unigraf.h |  48 ++++++++++++++++++++++
 meson.build           |  14 +++++++
 4 files changed, 181 insertions(+)
lib/meson.build +10 -0
index ff81baae13ad810eea56b97a42d556e5c6978718..fa4e4f40da48292d841e684cd0871a1b4894ebdf 100644
@@ -141,6 +141,13 @@ lib_deps = [
 	zlib
 ]
 
+if libtsi.found()
+	lib_deps += libtsi
+	lib_sources += [
+		'unigraf/unigraf.c'
+	]
+endif
+
 if libdrm_nouveau.found()
 	lib_deps += libdrm_nouveau
 	lib_sources += [
@@ -210,6 +217,9 @@ endif
 if chamelium.found()
 	lib_deps += chamelium
 	lib_sources += [ 'igt_chamelium.c', 'igt_chamelium_stream.c' ]
+endif
+
+if chamelium.found() or libtsi.found()
 	lib_sources += 'monitor_edids/monitor_edids_helper.c'
 endif
 
lib/unigraf/unigraf.c new file +109 -0

109 lines not on this page · raw message

lib/unigraf/unigraf.h new file +48 -0

48 lines not on this page · raw message

meson.build +14 -0
index 3d18267e652943c5984575498ddeacdec7e079da..2bc2dd1cf024875adab5adfebfe6da528cab787e 100644
@@ -165,6 +165,12 @@ cairo = dependency('cairo', version : '>1.12.0', required : true)
 libudev = dependency('libudev', required : true)
 glib = dependency('glib-2.0', required : true)
 
+libtsi = cc.find_library('TSI', required : false)
+
+if libtsi.found()
+	config.set('HAVE_UNIGRAF', 1)
+endif
+
 xmlrpc = dependency('xmlrpc', required : false)
 xmlrpc_util = dependency('xmlrpc_util', required : false)
 xmlrpc_client = dependency('xmlrpc_client', required : false)
@@ -288,6 +294,7 @@ libexecdir = join_paths(get_option('libexecdir'), 'igt-gpu-tools')
 amdgpudir = join_paths(libexecdir, 'amdgpu')
 msmdir = join_paths(libexecdir, 'msm')
 panfrostdir = join_paths(libexecdir, 'panfrost')
+unigrafdir = join_paths(libexecdir, 'unigraf')
 v3ddir = join_paths(libexecdir, 'v3d')
 vc4dir = join_paths(libexecdir, 'vc4')
 vmwgfxdir = join_paths(libexecdir, 'vmwgfx')
@@ -356,6 +363,12 @@ if get_option('use_rpath')
 		vmwgfx_rpathdir = join_paths(vmwgfx_rpathdir, '..')
 	endforeach
 	vmwgfx_rpathdir = join_paths(vmwgfx_rpathdir, libdir)
+
+	unigraf_rpathdir = '$ORIGIN'
+	foreach p : unigrafdir.split('/')
+		unigraf_rpathdir = join_paths(unigraf_rpathdir, '..')
+	endforeach
+	unigraf_rpathdir = join_paths(unigraf_rpathdir, libdir)
 else
 	bindir_rpathdir = ''
 	libexecdir_rpathdir = ''
@@ -365,6 +378,7 @@ else
 	v3d_rpathdir = ''
 	vc4_rpathdir = ''
 	vmwgfx_rpathdir = ''
+	unigraf_rpathdir = ''
 endif
 
 build_testplan = get_option('testplan')
Signature · 1 line
2.50.0
#12 lore raw

PATCH v2 12/26 lib/igt_kms: Automatically connect unigraf on display require

In reply to Louis Chauvet

As Unigraf can emualte a display, automatically connect it for all devices. If a test is already using unigraf, this have no effect.

---
 lib/igt_kms.c | 6 ++++++
 1 file changed, 6 insertions(+)
lib/igt_kms.c +6 -0
index c79f9b946ca84c7c374ca514c05def2c34f81383..95ad7885a7dc284031e2f0fda2b0655474f295d2 100644
@@ -2926,6 +2926,12 @@ void igt_display_require(igt_display_t *display, int drm_fd)
 	int i;
 	bool is_intel_dev;
 
+#ifdef HAVE_UNIGRAF
+	if (unigraf_open_device()) {
+		sleep(1);
+	}
+#endif
+
 	memset(display, 0, sizeof(igt_display_t));
 
 	LOG_INDENT(display, "init");
Signature · 1 line
2.50.0
#13 lore raw

PATCH v2 13/26 lib/unigraf: Introduce device configuration

In reply to Louis Chauvet

As there could be multiple devices detected by libTSI, add a configuration field to ensure that igt will use the proper unigraf device.

The unigraf integration will search for a [Unigraf] entry containing a Device=

For example, it can look like:

[Unigraf]
Device=UCD-500 [2434C620]

---
 lib/unigraf/unigraf.c | 71 ++++++++++++++++++++++++++++++++++++++++++++++-----
 1 file changed, 64 insertions(+), 7 deletions(-)
lib/unigraf/unigraf.c +64 -7
index a9f6e94498ef21fbfde3295456aa3bea9fdc7d67..f4b6183dbacf359c5e91ea70bc3b6acb9488839a 100644
@@ -1,21 +1,16 @@
 // SPDX-License-Identifier: MIT
 
-#include "drmtest.h"
 #include "glib.h"
 #include "igt_core.h"
-#include "igt_edid.h"
 #include <stdint.h>
 #include <stdio.h>
 #include <string.h>
 #include <time.h>
 
 #include "unigraf.h"
-#include "TSI.h"
 #include "TSI_types.h"
-#include "igt_kms.h"
-#include "igt_pipe_crc.h"
+#include "TSI.h"
 #include "igt_rc.h"
-#include "monitor_edids/monitor_edids_helper.h"
 
 #define unigraf_debug(fmt, ...)	igt_debug("TSI:%p: " fmt, unigraf_device,##__VA_ARGS__)
 
@@ -24,6 +19,19 @@ static TSI_HANDLE unigraf_device;
 static char *unigraf_default_edid;
 static char *unigraf_connector_name;
 
+/**
+ * UNIGRAF_CONFIG_GROUP - Name of the unigraf group in the configuration file
+ */
+#define UNIGRAF_CONFIG_GROUP "Unigraf"
+/**
+ * UNIGRAF_CONFIG_DEVICE_NAME - Key of the device name in the configuration file
+ */
+#define UNIGRAF_CONFIG_DEVICE_NAME "Device"
+/**
+ * UNIGRAF_NAME_MAX - Maximum name length to be used for TSI functions
+ */
+#define UNIGRAF_NAME_MAX 1024
+
 static void unigraf_close_device(void)
 {
 	unigraf_debug("Closing...\n");
@@ -68,11 +76,28 @@ static unsigned int unigraf_device_count(void)
 	return unigraf_assert(TSIX_DEV_GetDeviceCount());
 }
 
+static int unigraf_find_device(char *request) {
+	int chosen_device = -1;
+	int device_count = unigraf_device_count();
+	for (int i = 0; i < device_count; i++) {
+		char dev_name[UNIGRAF_NAME_MAX];
+		memset(dev_name, 0, UNIGRAF_NAME_MAX);
+		unigraf_assert(TSIX_DEV_GetDeviceName(i, dev_name, UNIGRAF_NAME_MAX));
+		unigraf_debug("Detected unigraf device %d: %s\n", i, dev_name);
+		if(!strncmp(dev_name, request, UNIGRAF_NAME_MAX))
+			chosen_device = i;
+	}
+	return chosen_device;
+}
+
 bool unigraf_open_device(void)
 {
 	TSI_RESULT r;
+	char *cfg_group = NULL;
+	GError *cfg_error = NULL;
+	char *cfg_device = NULL;
 	int device_count;
-	int chosen_device = 0;
+	int chosen_device;
 	int chosen_role = 0;
 	int chosen_input = 0;
 
@@ -83,6 +108,28 @@ bool unigraf_open_device(void)
 
 	unigraf_init();
 
+	if (igt_key_file) {
+		char **group_list = g_key_file_get_groups(igt_key_file, NULL);
+		for (int i = 0; group_list[i] != NULL; i++) {
+			if (strcmp(group_list[i], UNIGRAF_CONFIG_GROUP))
+				continue;
+			cfg_group = strdup(group_list[i]);
+		}
+		g_strfreev(group_list);
+	}
+
+	if(cfg_group == NULL) {
+		unigraf_debug("No device configured, will try to find the first available.\n");
+		cfg_device = NULL;
+		unigraf_connector_name = NULL;
+	} else {
+		cfg_device = g_key_file_get_string(igt_key_file, cfg_group, UNIGRAF_CONFIG_DEVICE_NAME, &cfg_error);
+		if (cfg_error) {
+			unigraf_debug("No device name configured, uses first device available.\n");
+			cfg_device = NULL;
+		}
+	}
+
 	unigraf_assert(TSIX_DEV_RescanDevices(0, TSI_DEVCAP_VIDEO_CAPTURE, 0));
 
 	device_count = unigraf_device_count();
@@ -91,6 +138,16 @@ bool unigraf_open_device(void)
 		return false;
 	}
 
+	if (!cfg_device) {
+		chosen_device = 0;
+	} else {
+		chosen_device = unigraf_find_device(cfg_device);
+		if (chosen_device == -1) {
+			igt_warn("The requested unigraf device %s is not found.\n", cfg_device);
+			return false;
+		}
+	}
+
 	unigraf_device = TSIX_DEV_OpenDevice(chosen_device, &r);
 	unigraf_assert(r);
 	igt_assert(unigraf_device);
Signature · 1 line
2.50.0
#14 lore raw

PATCH v2 14/26 lib/unigraf: Introduce role configuration

In reply to Louis Chauvet

Some unigraf devices, like the UCD-500 can have multiple hardware
configurations: displayport input/output, usbc input/output.

The device configuration can look like:

[Unigraf]
Device=UCD-500 [2434C620]
Role=DisplayPort Source and Sink

---
 lib/unigraf/unigraf.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 52 insertions(+), 3 deletions(-)
lib/unigraf/unigraf.c +52 -3
index f4b6183dbacf359c5e91ea70bc3b6acb9488839a..b4401daaac5a69ef02a15ead1b8edf3f2cac3833 100644
@@ -19,18 +19,30 @@ static TSI_HANDLE unigraf_device;
 static char *unigraf_default_edid;
 static char *unigraf_connector_name;
 
+/**
+ * UNIGRAF_NAME_MAX - Maximum name length to be used for TSI functions
+ */
+#define UNIGRAF_NAME_MAX 1024
+
 /**
  * UNIGRAF_CONFIG_GROUP - Name of the unigraf group in the configuration file
  */
 #define UNIGRAF_CONFIG_GROUP "Unigraf"
+
 /**
  * UNIGRAF_CONFIG_DEVICE_NAME - Key of the device name in the configuration file
  */
 #define UNIGRAF_CONFIG_DEVICE_NAME "Device"
+
 /**
- * UNIGRAF_NAME_MAX - Maximum name length to be used for TSI functions
+ * UNIGRAF_CONFIG_DEVICE_ROLE - Key of the device role in the configuration file
  */
-#define UNIGRAF_NAME_MAX 1024
+#define UNIGRAF_CONFIG_DEVICE_ROLE "Role"
+
+/**
+ * UNIGRAF_DEFAULT_ROLE_NAME - Default role name to search on the unigraf device
+ */
+#define UNIGRAF_DEFAULT_ROLE_NAME "USB-C, DP Alt Mode Source and Sink"
 
 static void unigraf_close_device(void)
 {
@@ -90,15 +102,30 @@ static int unigraf_find_device(char *request) {
 	return chosen_device;
 }
 
+static int unigraf_find_role(char *request) {
+	int chosen_role = -1;
+	int role_count = unigraf_assert(TSIX_DEV_GetDeviceRoleCount(unigraf_device));
+	for (int i = 0; i < role_count; i++) {
+		char role_name[UNIGRAF_NAME_MAX];
+		memset(role_name, 0, UNIGRAF_NAME_MAX);
+		unigraf_assert(TSIX_DEV_GetDeviceRoleName(unigraf_device, i, role_name, UNIGRAF_NAME_MAX));
+		unigraf_debug("Role %d: %s\n", i, role_name);
+		if(!strncmp(role_name, request, UNIGRAF_NAME_MAX))
+			chosen_role = i;
+	}
+	return chosen_role;
+}
+
 bool unigraf_open_device(void)
 {
 	TSI_RESULT r;
 	char *cfg_group = NULL;
 	GError *cfg_error = NULL;
 	char *cfg_device = NULL;
+	char *cfg_role = NULL;
 	int device_count;
 	int chosen_device;
-	int chosen_role = 0;
+	int chosen_role;
 	int chosen_input = 0;
 
 	assert(igt_can_fail());
@@ -121,6 +148,7 @@ bool unigraf_open_device(void)
 	if(cfg_group == NULL) {
 		unigraf_debug("No device configured, will try to find the first available.\n");
 		cfg_device = NULL;
+		cfg_role = NULL;
 		unigraf_connector_name = NULL;
 	} else {
 		cfg_device = g_key_file_get_string(igt_key_file, cfg_group, UNIGRAF_CONFIG_DEVICE_NAME, &cfg_error);
@@ -128,6 +156,13 @@ bool unigraf_open_device(void)
 			unigraf_debug("No device name configured, uses first device available.\n");
 			cfg_device = NULL;
 		}
+
+		cfg_error = NULL;
+		cfg_role = g_key_file_get_string(igt_key_file, cfg_group, UNIGRAF_CONFIG_DEVICE_ROLE, &cfg_error);
+		if (cfg_error) {
+			unigraf_debug("No device role configured.\n");
+			cfg_role = NULL;
+		}
 	}
 
 	unigraf_assert(TSIX_DEV_RescanDevices(0, TSI_DEVCAP_VIDEO_CAPTURE, 0));
@@ -153,6 +188,20 @@ bool unigraf_open_device(void)
 	igt_assert(unigraf_device);
 	unigraf_debug("Successfully opened the unigraf device %d.\n", chosen_device);
 
+	if (!cfg_role) {
+		unigraf_debug("No role configured, trying " UNIGRAF_DEFAULT_ROLE_NAME "\n");
+		chosen_role = unigraf_find_role(UNIGRAF_DEFAULT_ROLE_NAME);
+		if (chosen_role < 0) {
+			char role_name[UNIGRAF_NAME_MAX];
+			chosen_role = 0;
+			unigraf_assert(TSIX_DEV_GetDeviceRoleName(unigraf_device, chosen_role, role_name, UNIGRAF_NAME_MAX));
+			unigraf_debug("Role " UNIGRAF_DEFAULT_ROLE_NAME " not found, using role 0 (%s)\n", role_name);
+		}
+	} else {
+		chosen_role = unigraf_find_role(cfg_role);
+		igt_assert_f(chosen_role >= 0, "TSI:%p: Role %s not found.", unigraf_device, cfg_role);
+	}
+
 	unigraf_assert(TSIX_DEV_SelectRole(unigraf_device, chosen_role));
 	unigraf_assert(TSIX_VIN_Select(unigraf_device, chosen_input));
 	unigraf_assert(TSIX_VIN_Enable(unigraf_device, chosen_input));
Signature · 1 line
2.50.0
#15 lore raw

PATCH v2 15/26 lib/unigraf: Introduce input configuration

In reply to Louis Chauvet

As multiple input can be present on unigraf devices, add a configuration field to select the proper input. By default it will take the first available.

The configuration can look like:

[Unigraf]
Device=UCD-500 [2434C620]
Role=DisplayPort Source and Sink
Input=DP RX

---
 lib/unigraf/unigraf.c | 50 +++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 49 insertions(+), 1 deletion(-)
lib/unigraf/unigraf.c +49 -1
index b4401daaac5a69ef02a15ead1b8edf3f2cac3833..d9e9d80a4cf19c6be67977050ef2a17f2cb489d7 100644
@@ -39,11 +39,21 @@ static char *unigraf_connector_name;
  */
 #define UNIGRAF_CONFIG_DEVICE_ROLE "Role"
 
+/**
+ * UNIGRAF_CONFIG_INPUT_NAME - Key of the input name in the configuration file
+ */
+#define UNIGRAF_CONFIG_INPUT_NAME "Input"
+
 /**
  * UNIGRAF_DEFAULT_ROLE_NAME - Default role name to search on the unigraf device
  */
 #define UNIGRAF_DEFAULT_ROLE_NAME "USB-C, DP Alt Mode Source and Sink"
 
+/**
+ * UNIGRAF_DEFAULT_INPUT_NAME - Default input name to search on the unigraf device
+ */
+#define UNIGRAF_DEFAULT_INPUT_NAME "USB-C, DP Alt Mode Source and Sink"
+
 static void unigraf_close_device(void)
 {
 	unigraf_debug("Closing...\n");
@@ -116,6 +126,20 @@ static int unigraf_find_role(char *request) {
 	return chosen_role;
 }
 
+static int unigraf_find_input(char *request) {
+	int chosen_input = -1;
+	int role_count = unigraf_assert(TSIX_VIN_GetInputCount(unigraf_device));
+	for (int i = 0; i < role_count; i++) {
+		char input_name[UNIGRAF_NAME_MAX];
+		memset(input_name, 0, UNIGRAF_NAME_MAX);
+		unigraf_assert(TSIX_VIN_GetInputName(unigraf_device, i, input_name, UNIGRAF_NAME_MAX));
+		unigraf_debug("Input %d: %s\n", i, input_name);
+		if(!strncmp(input_name, request, UNIGRAF_NAME_MAX))
+			chosen_input = i;
+	}
+	return chosen_input;
+}
+
 bool unigraf_open_device(void)
 {
 	TSI_RESULT r;
@@ -123,10 +147,11 @@ bool unigraf_open_device(void)
 	GError *cfg_error = NULL;
 	char *cfg_device = NULL;
 	char *cfg_role = NULL;
+	char *cfg_input = NULL;
 	int device_count;
 	int chosen_device;
 	int chosen_role;
-	int chosen_input = 0;
+	int chosen_input;
 
 	assert(igt_can_fail());
 
@@ -149,6 +174,7 @@ bool unigraf_open_device(void)
 		unigraf_debug("No device configured, will try to find the first available.\n");
 		cfg_device = NULL;
 		cfg_role = NULL;
+		cfg_input = NULL;
 		unigraf_connector_name = NULL;
 	} else {
 		cfg_device = g_key_file_get_string(igt_key_file, cfg_group, UNIGRAF_CONFIG_DEVICE_NAME, &cfg_error);
@@ -163,6 +189,13 @@ bool unigraf_open_device(void)
 			unigraf_debug("No device role configured.\n");
 			cfg_role = NULL;
 		}
+
+		cfg_error = NULL;
+		cfg_input = g_key_file_get_string(igt_key_file, cfg_group, UNIGRAF_CONFIG_INPUT_NAME, &cfg_error);
+		if (cfg_error) {
+			unigraf_debug("No input name configured.\n");
+			cfg_input = NULL;
+		}
 	}
 
 	unigraf_assert(TSIX_DEV_RescanDevices(0, TSI_DEVCAP_VIDEO_CAPTURE, 0));
@@ -203,6 +236,21 @@ bool unigraf_open_device(void)
 	}
 
 	unigraf_assert(TSIX_DEV_SelectRole(unigraf_device, chosen_role));
+
+	if (!cfg_input) {
+		unigraf_debug("No input configured, trying " UNIGRAF_DEFAULT_INPUT_NAME "\n");
+		chosen_input = unigraf_find_input(UNIGRAF_DEFAULT_INPUT_NAME);
+		if (chosen_input < 0) {
+			char input_name[UNIGRAF_NAME_MAX];
+			chosen_input = 0;
+			unigraf_assert(TSIX_VIN_GetInputName(unigraf_device, chosen_input, input_name, UNIGRAF_NAME_MAX));
+			unigraf_debug("Input " UNIGRAF_DEFAULT_INPUT_NAME " not found, using input 0 (%s).\n", input_name);
+		}
+	} else  {
+		chosen_input = unigraf_find_input(cfg_input);
+		igt_assert_f(chosen_input >= 0, "TSI:%p: Input %s not found.", unigraf_device, cfg_input);
+	}
+
 	unigraf_assert(TSIX_VIN_Select(unigraf_device, chosen_input));
 	unigraf_assert(TSIX_VIN_Enable(unigraf_device, chosen_input));
 
Signature · 1 line
2.50.0
#16 lore raw

PATCH v2 16/26 lib/unigraf: Add unigraf assert and deassert helpers

In reply to Louis Chauvet

Unigraf is able to manipulate the HPD line of the connector, add few helpers to manipulate them.

---
 lib/unigraf/unigraf.c | 38 ++++++++++++++++++++++++++++++++++++++
 lib/unigraf/unigraf.h | 22 ++++++++++++++++++++++
 2 files changed, 60 insertions(+)
lib/unigraf/unigraf.c +38 -0
index d9e9d80a4cf19c6be67977050ef2a17f2cb489d7..3998a3af1bef4490bf9d3c796876d268957e87e2 100644
@@ -88,6 +88,25 @@ static void unigraf_init(void)
 	igt_install_exit_handler(unigraf_exit_handler);
 }
 
+/**
+ * unigraf_write() - Helper to write a value to unigraf
+ * @dev: device handle, can be null for some config id
+ * @config: config id to write
+ * @data: data to write
+ * @data_len: length of the data
+ * Returns
+ */
+static void unigraf_write(TSI_CONFIG_ID config, const void *data, size_t data_len)
+{
+	unigraf_debug("Writing %zu bytes to 0x%x\n", data_len, config);
+
+	if (data_len == 4) {
+		unigraf_debug("Value = 0x%x\n", *(int*)data);
+	}
+
+	unigraf_assert(TSIX_TS_SetConfigItem(unigraf_device, config, data, data_len));
+}
+
 /**
  * unigraf_device_count() - Return the number of scanned devices
  *
@@ -261,3 +280,22 @@ void unigraf_require_device(void)
 {
 	igt_require(unigraf_open_device());
 }
+
+void unigraf_hpd_assert(void)
+{
+	int d = 1;
+	igt_assert(unigraf_device);
+	unigraf_write(TSI_FORCE_HOT_PLUG_STATE_W, &d, sizeof(d));
+}
+
+void unigraf_hpd_pulse(int duration)
+{
+       igt_assert(unigraf_device);
+       unigraf_write(TSI_DPRX_HPD_PULSE_W, &duration, sizeof(duration));
+}
+
+void unigraf_hpd_deassert(void) {
+	int d = 0;
+	igt_assert(unigraf_device);
+	unigraf_write(TSI_FORCE_HOT_PLUG_STATE_W, &d, sizeof(d));
+}
lib/unigraf/unigraf.h +22 -0
index 8e0137ce30ed1bc0b334540561f93c7ade38e386..0a872b6e5859347be371b6a28db5516f4c854d2f 100644
@@ -45,4 +45,26 @@ bool unigraf_open_device(void);
  */
 void unigraf_require_device(void);
 
+/**
+ * unigraf_hpd_deassert() - Deassert Hot Plug Detect signal
+ *
+ * This function deasserts the HPD signal, simulating a device disconnection.
+ */
+void unigraf_hpd_deassert(void);
+
+/**
+ * unigraf_hpd_pulse() - Pulse the Hot Plug Detect signal
+ * @duration: The duration in milliseconds for which the HPD signal should be pulsed
+ *
+ * This function pulses the HPD signal for the specified duration.
+ */
+void unigraf_hpd_pulse(int duration);
+
+/**
+ * unigraf_hpd_assert() - Assert Hot Plug Detect signal
+ *
+ * This function asserts the HPD signal, simulating a device connection.
+ */
+void unigraf_hpd_assert(void);
+
 #endif // UNIGRAF_H
Signature · 1 line
2.50.0
#17 lore raw

PATCH v2 17/26 lib/unigraf: Add plug/unplug helpers

In reply to Louis Chauvet

The unigraf can emulate a full cable plug/unplug, so add helper to emulate this.

---
 lib/unigraf/unigraf.c | 14 ++++++++++++++
 lib/unigraf/unigraf.h | 14 ++++++++++++++
 2 files changed, 28 insertions(+)
lib/unigraf/unigraf.c +14 -0
index 3998a3af1bef4490bf9d3c796876d268957e87e2..565d63d985b1ea99e839c377d7b87876ba2a12c4 100644
@@ -299,3 +299,17 @@ void unigraf_hpd_deassert(void) {
 	igt_assert(unigraf_device);
 	unigraf_write(TSI_FORCE_HOT_PLUG_STATE_W, &d, sizeof(d));
 }
+
+void unigraf_unplug(void)
+{
+       int d = 2 << 2;
+       igt_assert(unigraf_device);
+       unigraf_write(TSI_DPRX_HPD_FORCE, &d, sizeof(d));
+}
+
+void unigraf_plug(void)
+{
+       int d = 3 << 2;
+       igt_assert(unigraf_device);
+       unigraf_write(TSI_DPRX_HPD_FORCE, &d, sizeof(d));
+}
lib/unigraf/unigraf.h +14 -0
index 0a872b6e5859347be371b6a28db5516f4c854d2f..7f6438da66b688b4b7d8aaa6f124474bd2c1d042 100644
@@ -67,4 +67,18 @@ void unigraf_hpd_pulse(int duration);
  */
 void unigraf_hpd_assert(void);
 
+/**
+ * unigraf_plug() - Emulate a cable plug
+ *
+ * This function will emulate a full cable plug (not a simple HPD line change)
+ */
+void unigraf_plug(void);
+
+/**
+ * unigraf_plug() - Emulate a cable unplug
+ *
+ * This function will emulate a full cable unplug (not a simple HPD line change)
+ */
+void unigraf_unplug(void);
+
 #endif // UNIGRAF_H
Signature · 1 line
2.50.0
#18 lore raw

PATCH v2 18/26 lib/unigraf: Allows sst/mst configuration

In reply to Louis Chauvet

Unigraf devices can emulate both SST and MST display port. In order to write tests using both, add fews helper to manipulate them.

The define TSI_DPRX_NOT_DOCUMENTED_SIDEBAND_MSG_SUPPORT is taken from the python SDK, as it was not defined by the C sdk nor documented.

---
 lib/unigraf/unigraf.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++
 lib/unigraf/unigraf.h | 34 +++++++++++++++++++++++++++++
 2 files changed, 93 insertions(+)
lib/unigraf/unigraf.c +59 -0
index 565d63d985b1ea99e839c377d7b87876ba2a12c4..15ded642c2fc6900a6722bdeb62c7126b23e9cee 100644
@@ -313,3 +313,62 @@ void unigraf_plug(void)
        igt_assert(unigraf_device);
        unigraf_write(TSI_DPRX_HPD_FORCE, &d, sizeof(d));
 }
+
+void unigraf_set_sst(void) {
+	int link_flags = 0xFFFFFFFF;
+	igt_assert(unigraf_device);
+	unigraf_unplug();
+	unigraf_assert(TSIX_TS_GetConfigItem(unigraf_device, TSI_DPRX_LINK_FLAGS, &link_flags, sizeof(link_flags)));
+	link_flags &= ~(TSI_DPRX_LINK_FLAGS_MST | TSI_DPRX_NOT_DOCUMENTED_SIDEBAND_MSG_SUPPORT);
+	unigraf_write(TSI_DPRX_LINK_FLAGS, &link_flags, sizeof(link_flags));
+	unigraf_plug();
+	unigraf_hpd_pulse(500000);
+}
+
+void unigraf_set_mst(void) {
+	int link_flags = 0xFFFFFFFF;
+	igt_assert(unigraf_device);
+	unigraf_assert(TSIX_TS_GetConfigItem(unigraf_device, TSI_DPRX_LINK_FLAGS, &link_flags, sizeof(link_flags)));
+	link_flags |= TSI_DPRX_LINK_FLAGS_MST | TSI_DPRX_NOT_DOCUMENTED_SIDEBAND_MSG_SUPPORT;
+	unigraf_write(TSI_DPRX_LINK_FLAGS, &link_flags, sizeof(link_flags));
+}
+
+int unigraf_get_mst_stream_max_count(void)
+{
+	int previous_count;
+	int max_count = -1;
+
+	// You can write any value to the register, but the actual value will not be more than the supported sink count.
+	previous_count = unigraf_get_mst_stream_count();
+	unigraf_write(TSI_DPRX_MST_SINK_COUNT, &max_count, sizeof(max_count));
+	max_count = unigraf_get_mst_stream_count();
+
+	unigraf_write(TSI_DPRX_MST_SINK_COUNT, &previous_count, sizeof(previous_count));
+	return max_count;
+}
+
+int unigraf_get_mst_stream_count(void)
+{
+	int count;
+	igt_assert(unigraf_device);
+
+	unigraf_assert(TSIX_TS_GetConfigItem(unigraf_device, TSI_DPRX_MST_SINK_COUNT, &count, sizeof(count)));
+
+	return count;
+}
+
+bool unigraf_set_mst_stream_count(int count) {
+	int new_count;
+
+	unigraf_write(TSI_DPRX_MST_SINK_COUNT, &count, sizeof(count));
+	new_count = unigraf_get_mst_stream_count();
+
+	igt_warn_on_f(count != new_count, "IGT:%p: Requested MST stream count (%d) differ from what was applied by the device (%d)\n", unigraf_device, count, new_count);
+
+	return count == new_count;
+}
+void unigraf_select_stream(int stream)
+{
+	igt_assert(unigraf_device);
+	unigraf_write(TSI_DPRX_STREAM_SELECT, &stream, sizeof(stream));
+}
lib/unigraf/unigraf.h +34 -0
index 7f6438da66b688b4b7d8aaa6f124474bd2c1d042..6ecd1248cdd70a2af99ae09ae19f9fc8c061ff56 100644
@@ -81,4 +81,38 @@ void unigraf_plug(void);
  */
 void unigraf_unplug(void);
 
+/**
+ * unigraf_set_sst() - Configure the device for Single Stream Transport mode
+ *
+ * This function sets the device to operate in Single Stream Transport (SST) mode.
+ */
+void unigraf_set_sst(void);
+
+/**
+ * unigraf_set_mst() - Configure the device for Multi Stream Transport mode
+ *
+ * This function sets the device to operate in Multi Stream Transport (MST) mode.
+ */
+void unigraf_set_mst(void);
+
+/**
+ * unigraf_get_mst_stream_count() - Get the current number of MST streams
+ *
+ * Returns: The current number of MST streams configured on the device.
+ */
+int unigraf_get_mst_stream_count(void);
+
+/**
+ * unigraf_set_mst_stream_count() - Set the number of accepted stream count
+ *
+ * Returns true when the stream count was properly applied, false if the final stream count is not the one requested
+ */
+bool unigraf_set_mst_stream_count(int count);
+
+/**
+ * unigraf_get_mst_stream_max_count() - Get the maximum number of stream count accepted by the device
+ * Caution: This function can be destructive to some configuration: the only way to get the information is to try and read the new value.
+ */
+int unigraf_get_mst_stream_max_count(void);
+
 #endif // UNIGRAF_H
Signature · 1 line
2.50.0
#19 lore raw

PATCH v2 19/26 lib/unigraf: Add helpers to read and write edid

In reply to Louis Chauvet

Read and writing EDID on unigraf can be useful to emulate different screens, add helpers to read and write them.

There is a limitation on the libTSI.so, it is only possible to read EDID using buffers of size multiple of 128 bytes, and there is no way to query the actual EDID size. The current implementation can only read EDID up to 2048 bytes.

---
 lib/unigraf/unigraf.c | 25 +++++++++++++++++++++++++
 lib/unigraf/unigraf.h | 21 +++++++++++++++++++++
 2 files changed, 46 insertions(+)
lib/unigraf/unigraf.c +25 -0
index 15ded642c2fc6900a6722bdeb62c7126b23e9cee..6df48da4672c1774bd85125076fcc63e9891b6cc 100644
@@ -281,6 +281,31 @@ void unigraf_require_device(void)
 	igt_require(unigraf_open_device());
 }
 
+struct edid *unigraf_read_edid(uint32_t stream, uint32_t *edid_size)
+{
+	void *edid;
+
+	igt_assert(unigraf_device);
+	unigraf_debug("Read EDID for stream %d...\n", stream);
+
+	edid = malloc(2048);
+	memset(edid, 0, 2048);
+
+	unigraf_write(TSI_EDID_SELECT_STREAM, &stream, sizeof(stream));
+	*edid_size = unigraf_assert(TSIX_TS_GetConfigItem(unigraf_device, TSI_EDID_TE_INPUT, edid, 2048));
+
+	return edid;
+}
+
+void unigraf_write_edid(uint32_t stream, const struct edid *edid, uint32_t edid_size)
+{
+	igt_assert(unigraf_device);
+	unigraf_debug("Write EDID for stream %d...\n", stream);
+
+	unigraf_write(TSI_EDID_SELECT_STREAM, &stream, edid_size);
+	unigraf_write(TSI_EDID_TE_INPUT, edid, 2048);
+}
+
 void unigraf_hpd_assert(void)
 {
 	int d = 1;
lib/unigraf/unigraf.h +21 -0
index 6ecd1248cdd70a2af99ae09ae19f9fc8c061ff56..e843aa8f2badddcfaeceb8773d5ad19e572e37d9 100644
@@ -45,6 +45,27 @@ bool unigraf_open_device(void);
  */
 void unigraf_require_device(void);
 
+/**
+ * unigraf_read_edid() - Read the EDID from the specified input
+ * @dev: The device handle
+ * @stream: The stream ID to read the EDID from
+ * @edid_size: Pointer to an integer where the size of the EDID will be stored
+ *
+ * Returns: A pointer to the EDID structure, or NULL if the operation failed. The caller
+ * is responsible to free this pointer.
+ */
+struct edid *unigraf_read_edid(uint32_t stream, uint32_t *edid_size);
+
+/**
+ * unigraf_write_edid() - Write EDID data to the specified stream
+ * @stream: The stream ID to write the EDID to
+ * @edid: Pointer to the EDID structure to write
+ * @edid_size: Size of the EDID data in bytes
+ *
+ * This function writes the provided EDID data to the specified stream.
+ */
+void unigraf_write_edid(uint32_t stream, const struct edid *edid, uint32_t edid_size);
+
 /**
  * unigraf_hpd_deassert() - Deassert Hot Plug Detect signal
  *
Signature · 1 line
2.50.0
#20 lore raw

PATCH v2 20/26 lib/unigraf: Add connector configuration

In reply to Louis Chauvet

As multiple connectors can be present on the DUT, add a configuration to tell which connector is used by the Unigraf.

The configuration will look like:

[Unigraf]
Device=UCD-500 [2434C620]
Role=DisplayPort Source and Sink
Input=DP RX
Connector=DP-4

---
 lib/unigraf/unigraf.c | 18 ++++++++++++++++++
 lib/unigraf/unigraf.h | 11 +++++++++++
 2 files changed, 29 insertions(+)
lib/unigraf/unigraf.c +18 -0
index 6df48da4672c1774bd85125076fcc63e9891b6cc..b59a3627af30642899fcf3e4c9e5b53fb4e54eeb 100644
@@ -10,6 +10,7 @@
 #include "unigraf.h"
 #include "TSI_types.h"
 #include "TSI.h"
+#include "igt_kms.h"
 #include "igt_rc.h"
 
 #define unigraf_debug(fmt, ...)	igt_debug("TSI:%p: " fmt, unigraf_device,##__VA_ARGS__)
@@ -44,6 +45,11 @@ static char *unigraf_connector_name;
  */
 #define UNIGRAF_CONFIG_INPUT_NAME "Input"
 
+/**
+ * UNIGRAF_CONFIG_CONNECTOR_NAME - Key of the connector name in the configuration file
+ */
+#define UNIGRAF_CONFIG_CONNECTOR_NAME "Connector"
+
 /**
  * UNIGRAF_DEFAULT_ROLE_NAME - Default role name to search on the unigraf device
  */
@@ -159,6 +165,11 @@ static int unigraf_find_input(char *request) {
 	return chosen_input;
 }
 
+drmModeConnectorPtr unigraf_get_connector(int drm_fd)
+{
+	return igt_get_connector_from_name(drm_fd, unigraf_connector_name);
+}
+
 bool unigraf_open_device(void)
 {
 	TSI_RESULT r;
@@ -215,6 +226,13 @@ bool unigraf_open_device(void)
 			unigraf_debug("No input name configured.\n");
 			cfg_input = NULL;
 		}
+
+		cfg_error = NULL;
+		unigraf_connector_name = g_key_file_get_string(igt_key_file, cfg_group, UNIGRAF_CONFIG_CONNECTOR_NAME, &cfg_error);
+		if (cfg_error) {
+			unigraf_debug("No connector name configured, will autodetect.\n");
+			unigraf_connector_name = NULL;
+		}
 	}
 
 	unigraf_assert(TSIX_DEV_RescanDevices(0, TSI_DEVCAP_VIDEO_CAPTURE, 0));
lib/unigraf/unigraf.h +11 -0
index e843aa8f2badddcfaeceb8773d5ad19e572e37d9..e014ead67b57e860907bd0cd3521fb5842240594 100644
@@ -5,6 +5,7 @@
 
 #include <stdbool.h>
 #include <stdint.h>
+#include <xf86drmMode.h>
 
 /**
  * unigraf_assert: Helper macro to assert a TSI return value and retrieve a detailed error message.
@@ -45,6 +46,16 @@ bool unigraf_open_device(void);
  */
 void unigraf_require_device(void);
 
+/**
+ * unigraf_get_connector() - Get a DRM connector for the Unigraf device
+ * @drm_fd: DRM file descriptor
+ *
+ * Returns: A pointer to the drmModeConnector connected to the unigraf device,
+ * or NULL if the operation failed. The caller is responsible for freeing this
+ * pointer with drmModeFreeConnector().
+ */
+drmModeConnectorPtr unigraf_get_connector(int drm_fd);
+
 /**
  * unigraf_read_edid() - Read the EDID from the specified input
  * @dev: The device handle
Signature · 1 line
2.50.0
#21 lore raw

PATCH v2 21/26 lib/unigraf: Add connector autodetection

In reply to Louis Chauvet

In order to avoid writing custom configuration for each DUT, add a simple autodetection algorithm.

---
 lib/unigraf/unigraf.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 50 insertions(+)
lib/unigraf/unigraf.c +50 -0
index b59a3627af30642899fcf3e4c9e5b53fb4e54eeb..10f8c5ab671d0e8ccf27d333f6ea66c8219b0892 100644
@@ -165,8 +165,58 @@ static int unigraf_find_input(char *request) {
 	return chosen_input;
 }
 
+static void unigraf_autodetect_connector(int drm_fd)
+{
+	int newly_connected_count, already_connected_count, diff_len;
+	uint32_t *newly_connected = NULL, *already_connected = NULL;
+	drmModeConnectorPtr connector;
+	uint32_t *diff = NULL;
+	igt_assert(drm_fd);
+
+	unigraf_set_sst();
+	unigraf_hpd_deassert();
+
+	/*
+	 * Hard sleep is required here as we don't know how long it will take for the device under
+	 * test to properly detect the port disconnection.
+	 */
+	sleep(igt_default_display_detect_timeout());
+
+	already_connected_count = igt_get_connected_connectors(drm_fd, &already_connected);
+
+	unigraf_hpd_assert();
+
+	newly_connected_count = kms_wait_for_new_connectors(&newly_connected,
+							    already_connected,
+							    already_connected_count,
+							    drm_fd);
+
+	diff_len = get_list_diff(newly_connected, newly_connected_count,
+				 already_connected, already_connected_count, &diff);
+
+	if (diff_len == 0) {
+		unigraf_debug("No newly connected connector, assuming that the unigraf is not connected.\n");
+	} else if (diff_len > 1) {
+		unigraf_debug("More than one new connectors connected, this is not supported by autodetection.\n");
+	} else {
+		unigraf_debug("Found one connector (%d) connected to the chamelium\n", diff[0]);
+		connector = drmModeGetConnector(drm_fd, diff[0]);
+		igt_assert(connector);
+		igt_assert(asprintf(&unigraf_connector_name, "%s-%u",
+				    kmstest_connector_type_str(connector->connector_type),
+				    connector->connector_type_id) != -1);
+		drmModeFreeConnector(connector);
+	}
+
+	free(already_connected);
+	free(newly_connected);
+	free(diff);
+}
+
 drmModeConnectorPtr unigraf_get_connector(int drm_fd)
 {
+	if(!unigraf_connector_name)
+		unigraf_autodetect_connector(drm_fd);
 	return igt_get_connector_from_name(drm_fd, unigraf_connector_name);
 }
 
Signature · 1 line
2.50.0
#22 lore raw

PATCH v2 22/26 lib/unigraf: Add edid configuration

In reply to Louis Chauvet

As unigraf could be used as a simple screen for all tests, add a default EDID configuration to connect the unigraf by default on every tests using this EDID.

---
 lib/unigraf/unigraf.c | 34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)
lib/unigraf/unigraf.c +34 -0
index 10f8c5ab671d0e8ccf27d333f6ea66c8219b0892..add5d5b2b1379bb34ff73505ee917e51398f4b66 100644
@@ -10,8 +10,10 @@
 #include "unigraf.h"
 #include "TSI_types.h"
 #include "TSI.h"
+#include "igt_edid.h"
 #include "igt_kms.h"
 #include "igt_rc.h"
+#include "monitor_edids/monitor_edids_helper.h"
 
 #define unigraf_debug(fmt, ...)	igt_debug("TSI:%p: " fmt, unigraf_device,##__VA_ARGS__)
 
@@ -50,6 +52,11 @@ static char *unigraf_connector_name;
  */
 #define UNIGRAF_CONFIG_CONNECTOR_NAME "Connector"
 
+/**
+ * UNIGRAF_CONFIG_EDID_NAME - Key of the EDID name in the configuration file
+ */
+#define UNIGRAF_CONFIG_EDID_NAME "EDID"
+
 /**
  * UNIGRAF_DEFAULT_ROLE_NAME - Default role name to search on the unigraf device
  */
@@ -165,6 +172,17 @@ static int unigraf_find_input(char *request) {
 	return chosen_input;
 }
 
+static void unigraf_load_default_edid(void)
+{
+	struct edid *edid = get_edid_by_name(unigraf_default_edid);
+	if (edid) {
+		unigraf_write_edid(0, edid, edid_get_size(edid));
+	} else {
+		igt_warn("Impossible to find an edid named \"%s\"", unigraf_default_edid);
+		list_edid_names(IGT_LOG_WARN);
+	}
+}
+
 static void unigraf_autodetect_connector(int drm_fd)
 {
 	int newly_connected_count, already_connected_count, diff_len;
@@ -228,6 +246,7 @@ bool unigraf_open_device(void)
 	char *cfg_device = NULL;
 	char *cfg_role = NULL;
 	char *cfg_input = NULL;
+	char *cfg_edid_name = NULL;
 	int device_count;
 	int chosen_device;
 	int chosen_role;
@@ -283,6 +302,13 @@ bool unigraf_open_device(void)
 			unigraf_debug("No connector name configured, will autodetect.\n");
 			unigraf_connector_name = NULL;
 		}
+
+		cfg_error = NULL;
+		cfg_edid_name = g_key_file_get_string(igt_key_file, cfg_group, UNIGRAF_CONFIG_EDID_NAME, &cfg_error);
+		if (cfg_error) {
+			unigraf_debug("No default EDID set, use IGT default.\n");
+			unigraf_connector_name = NULL;
+		}
 	}
 
 	unigraf_assert(TSIX_DEV_RescanDevices(0, TSI_DEVCAP_VIDEO_CAPTURE, 0));
@@ -341,6 +367,14 @@ bool unigraf_open_device(void)
 	unigraf_assert(TSIX_VIN_Select(unigraf_device, chosen_input));
 	unigraf_assert(TSIX_VIN_Enable(unigraf_device, chosen_input));
 
+	if (cfg_edid_name == NULL) {
+		cfg_edid_name = strdup("DEL_16543_DELL_P2314T_DP");
+	}
+	unigraf_default_edid = cfg_edid_name;
+
+	unigraf_set_sst();
+	unigraf_load_default_edid();
+
 	return true;
 }
 
Signature · 1 line
2.50.0
#23 lore raw

PATCH v2 23/26 tests/unigraf: Add basic unigraf tests

In reply to Louis Chauvet

Adds two tests to validate unigraf communication.

unigraf-connected checks if the device is connected and if the EDID is properly applied.

ungiraf-disconnect checks if the device can be connected/reconnected using SST and MST configurations.

---
 lib/igt_kms.c                        |   9 +--
 tests/meson.build                    |   4 ++
 tests/unigraf/meson.build            |  12 ++++
 tests/unigraf/unigraf_connectivity.c | 126 +++++++++++++++++++++++++++++++++++
 4 files changed, 145 insertions(+), 6 deletions(-)
lib/igt_kms.c +3 -6
index 95ad7885a7dc284031e2f0fda2b0655474f295d2..8d8d4da593e60a1072305c4a04a4d430798a3379 100644
@@ -65,6 +65,9 @@
 #ifdef HAVE_CHAMELIUM
 #include "igt_chamelium.h"
 #endif
+#ifdef HAVE_UNIGRAF
+#include "unigraf/unigraf.h"
+#endif
 
 /**
  * SECTION:igt_kms
@@ -2926,12 +2929,6 @@ void igt_display_require(igt_display_t *display, int drm_fd)
 	int i;
 	bool is_intel_dev;
 
-#ifdef HAVE_UNIGRAF
-	if (unigraf_open_device()) {
-		sleep(1);
-	}
-#endif
-
 	memset(display, 0, sizeof(igt_display_t));
 
 	LOG_INDENT(display, "init");
tests/meson.build +4 -0
index 55bcf57ec58b2903fcf77e629901f9ed450981da..87dd3cc6dff62b73273e90122db0bbc14cdadb4c 100644
@@ -454,6 +454,10 @@ foreach prog : intel_progs
 	endif
 endforeach
 
+if libtsi.found()
+	subdir('unigraf')
+endif
+
 if chamelium.found()
 	foreach prog : chamelium_progs
 		testexe = executable(prog,
tests/unigraf/meson.build new file +12 -0
new file mode 100644
index 0000000000000000000000000000000000000000..4ef8c32151e4368cf20d1b2b6bbf4228240fa3ef
@@ -0,0 +1,12 @@
+unigraf_progs = [
+	'unigraf_connectivity',
+]
+
+foreach prog : unigraf_progs
+	test_executables += executable(prog, prog + '.c',
+				       dependencies : test_deps,
+				       install_dir : unigrafdir,
+				       install_rpath : unigraf_rpathdir,
+				       install : true)
+	test_list += join_paths('unigraf', prog)
+endforeach
tests/unigraf/unigraf_connectivity.c new file +126 -0

126 lines not on this page · raw message

Signature · 1 line
2.50.0
#24 lore raw

PATCH v2 24/26 lib/unigraf: Add unigraf CRC grab

In reply to Louis Chauvet

As unigraf devices are able to grab a CRC for the current video stream, add an helper to read the CRC.

---
 lib/unigraf/unigraf.c | 15 +++++++++++++++
 lib/unigraf/unigraf.h | 10 ++++++++++
 2 files changed, 25 insertions(+)
lib/unigraf/unigraf.c +15 -0
index add5d5b2b1379bb34ff73505ee917e51398f4b66..9ccd53e55ab5d261d236348fa8a3c7721e87698f 100644
@@ -12,6 +12,7 @@
 #include "TSI.h"
 #include "igt_edid.h"
 #include "igt_kms.h"
+#include "igt_pipe_crc.h"
 #include "igt_rc.h"
 #include "monitor_edids/monitor_edids_helper.h"
 
@@ -499,3 +500,17 @@ void unigraf_select_stream(int stream)
 	igt_assert(unigraf_device);
 	unigraf_write(TSI_DPRX_STREAM_SELECT, &stream, sizeof(stream));
 }
+
+bool unigraf_use_crc(void)
+{
+	return unigraf_crc;
+}
+
+void unigraf_read_crc(igt_crc_t *out)
+{
+	igt_assert(unigraf_device);
+	unigraf_assert(TSIX_TS_GetConfigItem(unigraf_device, TSI_DPRX_CRC_R_R, &out->crc[0], sizeof(out->crc[0])));
+	unigraf_assert(TSIX_TS_GetConfigItem(unigraf_device, TSI_DPRX_CRC_G_R, &out->crc[1], sizeof(out->crc[1])));
+	unigraf_assert(TSIX_TS_GetConfigItem(unigraf_device, TSI_DPRX_CRC_B_R, &out->crc[2], sizeof(out->crc[2])));
+	out->n_words = 3;
+}
lib/unigraf/unigraf.h +10 -0
index e014ead67b57e860907bd0cd3521fb5842240594..11e483312699fd9f304586bffcc5616c10fb637d 100644
@@ -3,6 +3,7 @@
 #ifndef UNIGRAF_H
 #define UNIGRAF_H
 
+#include "igt_fb.h"
 #include <stdbool.h>
 #include <stdint.h>
 #include <xf86drmMode.h>
@@ -147,4 +148,13 @@ bool unigraf_set_mst_stream_count(int count);
  */
 int unigraf_get_mst_stream_max_count(void);
 
+/**
+ * unigraf_read_crc() - Read the CRC values from the Unigraf device
+ * @out: Pointer to an igt_crc_t structure where the CRC values will be stored
+ *
+ * This function reads the CRC values from the Unigraf device and stores them in the
+ * provided igt_crc_t structure.
+ */
+void unigraf_read_crc(igt_crc_t *out);
+
 #endif // UNIGRAF_H
Signature · 1 line
2.50.0
#25 lore raw

PATCH v2 25/26 lib/unigraf: Add configuration for CRC usage

In reply to Louis Chauvet

As Unigraf devices are able to compute a CRC for the input image, add a configuration file option to use them.

---
 lib/unigraf/unigraf.c | 14 ++++++++++++++
 lib/unigraf/unigraf.h |  8 ++++++++
 2 files changed, 22 insertions(+)
lib/unigraf/unigraf.c +14 -0
index 9ccd53e55ab5d261d236348fa8a3c7721e87698f..caff77293b6820c8dd179c8abd3def894c3bb879 100644
@@ -22,6 +22,7 @@ static int unigraf_open_count;
 static TSI_HANDLE unigraf_device;
 static char *unigraf_default_edid;
 static char *unigraf_connector_name;
+static bool unigraf_crc;
 
 /**
  * UNIGRAF_NAME_MAX - Maximum name length to be used for TSI functions
@@ -58,6 +59,11 @@ static char *unigraf_connector_name;
  */
 #define UNIGRAF_CONFIG_EDID_NAME "EDID"
 
+/**
+ * UNIGRAF_CONFIG_USE_CRC_NAME - Key of the CRC selection in the configuration file
+ */
+#define UNIGRAF_CONFIG_USE_CRC_NAME "UseCRC"
+
 /**
  * UNIGRAF_DEFAULT_ROLE_NAME - Default role name to search on the unigraf device
  */
@@ -276,6 +282,7 @@ bool unigraf_open_device(void)
 		cfg_role = NULL;
 		cfg_input = NULL;
 		unigraf_connector_name = NULL;
+		unigraf_crc = true;
 	} else {
 		cfg_device = g_key_file_get_string(igt_key_file, cfg_group, UNIGRAF_CONFIG_DEVICE_NAME, &cfg_error);
 		if (cfg_error) {
@@ -310,6 +317,13 @@ bool unigraf_open_device(void)
 			unigraf_debug("No default EDID set, use IGT default.\n");
 			unigraf_connector_name = NULL;
 		}
+
+		cfg_error = NULL;
+		unigraf_crc = g_key_file_get_boolean(igt_key_file, cfg_group, UNIGRAF_CONFIG_USE_CRC_NAME, &cfg_error);
+		if (cfg_error) {
+			unigraf_debug("CRC usage not configured, using unigraf CRC.\n");
+			unigraf_crc = true;
+		}
 	}
 
 	unigraf_assert(TSIX_DEV_RescanDevices(0, TSI_DEVCAP_VIDEO_CAPTURE, 0));
lib/unigraf/unigraf.h +8 -0
index 11e483312699fd9f304586bffcc5616c10fb637d..2ff3dc5f3b8b06d2df7d1fd9b58e2b3a9b8b6729 100644
@@ -157,4 +157,12 @@ int unigraf_get_mst_stream_max_count(void);
  */
 void unigraf_read_crc(igt_crc_t *out);
 
+/**
+ * unigraf_use_crc() - Check if Unigraf device should be used for CRC computation
+ *
+ * Returns: true if the Unigraf device should be used for CRC computation,
+ *          false otherwise.
+ */
+bool unigraf_use_crc(void);
+
 #endif // UNIGRAF_H
Signature · 1 line
2.50.0
#26 lore raw

PATCH v2 26/26 lib/igt_pipe_crc: Add ungiraf crc calculation

In reply to Louis Chauvet

Unigraf can read crc from the physical output, use this CRC instead of internal CRC when configured. This allows to also test the hardware signal generation.

This small addition allows to use the unigraf device for most of the kms_* tests.

---
 lib/igt_pipe_crc.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
lib/igt_pipe_crc.c +22 -0
index 866bf2881cbd04df0ae0cc8fe91fe0626367144f..76244d00934ea09fd79cfd23734196f11eee1e1a 100644
@@ -3,6 +3,8 @@
  * Copyright © 2013 Intel Corporation
  */
 
+#include "igt_core.h"
+#include "unigraf/unigraf.h"
 #include <inttypes.h>
 #include <sys/stat.h>
 #include <sys/mount.h>
@@ -348,6 +350,17 @@ static int read_crc(igt_pipe_crc_t *pipe_crc, igt_crc_t *out)
 	return bytes_read;
 }
 
+#if HAVE_UNIGRAF
+static int read_crc_unigraf(igt_pipe_crc_t *pipe_crc, igt_crc_t *out)
+{
+	unigraf_read_crc(out);
+
+	out->has_valid_frame = true;
+
+	return out->n_words;
+}
+#endif
+
 static void read_one_crc(igt_pipe_crc_t *pipe_crc, igt_crc_t *out)
 {
 	int ret;
@@ -359,6 +372,15 @@ static void read_one_crc(igt_pipe_crc_t *pipe_crc, igt_crc_t *out)
 	} while (ret == -EINTR);
 
 	fcntl(pipe_crc->crc_fd, F_SETFL, pipe_crc->flags);
+	printf("crc: 0x%x\n", out->crc[0]);
+
+#if HAVE_UNIGRAF
+	if (unigraf_open_device() && unigraf_use_crc()) {
+		read_crc_unigraf(pipe_crc, out);
+
+		return;
+	}
+#endif
 }
 
 /**
Signature · 1 line
2.50.0
#27 lore raw
In reply to Louis Chauvet

+CC Mark, Khaled

Sorry, I forgot to add you both in copy...

Le 17/07/2025 à 20:46, Louis Chauvet a écrit :

Quoted 105 lines

Hi everyone,

I am excited to share I currently have access to a Unigraf device, which I believe could significantly enhance the capabilities within IGT. This device has the potential to enable testing of low-level hardware features that are currently not covered. Specifically, Unigraf devices can assist in testing link training, signal integrity, HDCP, DSC, and more.

It's important to note that the Unigraf SDK is not open-source, and the communication protocol with the device is proprietary. As a result, I have utilized the libTSI.so library, which can be downloaded from [1]. In this RFC, I have not used the official TSI_types.h header because it was incompatible with C, so I hardcoded some necessary values. The next iteration will use the official TSI_types.h (they plan to fix it for the next release).

This RFC is intentionally concise to gather initial feedback from the community regarding the integration of a proprietary device into the test suite. I plan to expand on this work by adding more features and pushing the developments upstream.

I have also started to work on MST testing (hotplug, link training, bandwith limitation), but I have a big issue: connector detection is very strange when changing MST configurat (MST->SST, sink count...).

If I use the Unigraf GUI or my own C script outside IGT, everything seems
fine: watch -n0 modetest -c update connector status almost immediatly after a HDP pulse, never hang and always have the correct result.

But if I do the same in IGT (same script in igt_main), igt have too much/not all connectors, and some of them are broken (no EDID property for example). I tried to run watch -n0 modetest -c in parallel, but modetest can:
- hang
- only update once igt test is finished.

Do you have any hint about something I missed in IGT to properly enumerate connectors? I tried close/open the DRM device, added a lot of delay everywhere, emulate plug/unplug... I used kms_wait_for_new_connectors (in this series) and for_each_connected_output to get list the connectors.

Looking forward to your thoughts and suggestions!

Thanks,
Louis Chauvet

---
Changes in v2:
- Splitted in many commits
- Add CRC support
- Link to v1: https://lore.kernel.org/r/[email protected]

---
Louis Chauvet (26):
lib/igt_kms: Add a detect timeout value
lib/igt_kms: Add helper to wait for a specific status on a connector lib/igt_kms: Add function to list connected connectors lib/igt_kms: Add helper to obtain a connector by its name or MST path lib/igt_kms: Add helper to wait for new connectors lib/monitor_edids: Add helper functions for using monitor_edid objects lib/monitor_edids: Add helper to get an EDID by its name lib/monitor_edids: Add helper to print all available EDID names [DO NOT MERGE] lib/unigraf: Add used defines for TSI_Types lib/unigraf: Add TSI.h
lib/unigraf: Initial Unigraf support
lib/igt_kms: Automatically connect unigraf on display require lib/unigraf: Introduce device configuration
lib/unigraf: Introduce role configuration
lib/unigraf: Introduce input configuration
lib/unigraf: Add unigraf assert and deassert helpers lib/unigraf: Add plug/unplug helpers
lib/unigraf: Allows sst/mst configuration
lib/unigraf: Add helpers to read and write edid lib/unigraf: Add connector configuration
lib/unigraf: Add connector autodetection
lib/unigraf: Add edid configuration
tests/unigraf: Add basic unigraf tests
lib/unigraf: Add unigraf CRC grab
lib/unigraf: Add configuration for CRC usage lib/igt_pipe_crc: Add ungiraf crc calculation

  lib/igt_core.c                           |   4 +
  lib/igt_kms.c                            | 346 ++++++++++++++++++++
  lib/igt_kms.h                            |  23 ++
  lib/igt_pipe_crc.c                       |  22 ++
  lib/meson.build                          |  10 +
  lib/monitor_edids/dp_edids.h             |   3 +
  lib/monitor_edids/hdmi_edids.h           |   3 +
  lib/monitor_edids/monitor_edids_helper.c | 127 ++++++++
  lib/monitor_edids/monitor_edids_helper.h |  10 +-
  lib/unigraf/TSI.h                        | 227 +++++++++++++
  lib/unigraf/TSI_types.h                  |  44 +++
  lib/unigraf/unigraf.c                    | 530 +++++++++++++++++++++++++++++++
  lib/unigraf/unigraf.h                    | 168 ++++++++++
  meson.build                              |  14 +
  tests/meson.build                        |   4 +
  tests/unigraf/meson.build                |  12 +
  tests/unigraf/unigraf_connectivity.c     | 126 ++++++++
  17 files changed, 1672 insertions(+), 1 deletion(-)

---
base-commit: b4e1ccd32037008012d5c41ac6bb04da22082302
change-id: 20250425-unigraf-integration-11ed330755d5

Best regards,

Signature · 3 lines
Louis Chauvet, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
#28 lore raw

✗ Fi.CI.BUILD: failure for Unigraf integration

In reply to Louis Chauvet
== Series Details ==

== Series Details ==

Series: Unigraf integration
URL : https://patchwork.freedesktop.org/series/151772/
State : failure

== Summary ==

Applying: lib/igt_kms: Add a detect timeout value
Using index info to reconstruct a base tree...
M lib/igt_core.c
M lib/igt_kms.c
M lib/igt_kms.h
Falling back to patching base and 3-way merge... Auto-merging lib/igt_kms.h
CONFLICT (content): Merge conflict in lib/igt_kms.h Auto-merging lib/igt_kms.c
CONFLICT (content): Merge conflict in lib/igt_kms.c Auto-merging lib/igt_core.c
Patch failed at 0001 lib/igt_kms: Add a detect timeout value When you have resolved this problem, run "git am --continue". If you prefer to skip this patch, run "git am --skip" instead. To restore the original branch and stop patching, run "git am --abort".