Skip to contentSkip to conversation

tests/chamelium: Integrate the chamelium v3

PATCH Superseded Louis Chauvet 4 participants 51 messages Jul 9, 2024 – Aug 28, 2024

Subsystems (2)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

v2 cover tests/chamelium: Integrate the chamelium v3

Hi all,

This patch series introduces a new wrapper for the Chameleon v3 board, a testing tool used primarily for Chromebooks, but also by community members to increase test coverage of graphic devices. The Chameleon v3 is an upgrade from its predecessor, with the ability to emulate 2 HDMI and 2 DisplayPort devices, including MST devices.

The board can read and analyze any stream on the DisplayPort and HDMI cables, and even take captures, making it an ideal tool for testing hardware, driver, and user space behavior in specific situations, such as screen hotplugging and multiple MST screens. However, the changes between the v2 and v3, such as the addition of MST support and the removal of CRC for screen captures, would require significant modifications to the existing tests and wrappers.

To avoid this complexity and ensure that the Chameleon v3 is fully supported and the v2 is not broken, I wrote a new wrapper with simplicity and ease of use in mind. The Chameleon v3 wrapper should only manage the Chameleon itself, without the need for DRM displays, EDID caching/modifications, or state machines. This approach will make it easier for developers to use the Chameleon v3 and contribute to its development.

I will use this work to create many new tests (that will come in future series):
- MST managment
- Tiled displays emulation
- Suspend/Resume
- Hardware overlay planes

This series can be divided in multiple parts:
- PATCH 1-5: Adding few helpers to igt_kms
- PATCH 6-10: Add few helpers to minotor_edid
- PATCH 10-14: Split chamelium v2 and chamelium v3 support
- PATCH 15-18: Create a basic test listing available port on the chamelium
- PATCH 19-27: Add port mapping configuration and autodetection
- PATCH 28-38: Add basic EDID tests
- PATCH 39: Add documentation

As most of the series is preparation work, I sent all the patches today, but if required I can split the series in multiple smallest series.

---
Changes in v2:
- Mainly splitting and cleaning work since the RFC,
EDITME: describe what is new in this series revision.
- EDITME: use bulletpoints and terse descriptions.
- Link to v1: https://lore.kernel.org/r/[email protected]

---
Louis Chauvet (39):
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 function to get valid pipe for specific output 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 lib/monitor_edids: Fix missing names in some monitor EDID lib/monitor_edids: Add new EDID for HDMI 4k
tests/chamelium: Extract Chamelium v2 tests into a separate directory lib/chamelium/v2: Extract chamelium v2 wrapper into its own directory lib/chamelium/v2: Modify build options to separate Chamelium v2 and v3 lib/chamelium/v3: Introduce the foundation for the Chamelium v3 wrapper lib/chamelium/v3: Introduce initialization and cleanup of Chamelium-related structures lib/chamelium/v3: Add method to discover Chamelium ports lib/chamelium/v3: Implement method to retrieve Chamelium port names tests/chamelium/v3: Implement a basic Chamelium v3 accessibility test lib/chamelium/v3: Implement Chamelium reinitialization via Reset RPC call lib/chamelium/v3: Implement methods for plugging Chamelium ports lib/chamelium/v3: Implement methods for managing Chamelium EDID lib/chamelium/v3: Implement Chamelium configuration parsing lib/chamelium/v3: Log port mapping for debugging purposes lib/chamelium/v3: Introduce new configuration format for MST support lib/chamelium/v3: Provide access to port_mapping via method call lib/chamelium/v3: Implement helper function to get port mapping from Chameleon port id lib/chamelium/v3: Implement helper function to retrieve connector from port mapping lib/chamelium/v3: Plug specific ports for all tests
lib/chamelium/v3: Implement Chamelium port autodetection algorithm lib/chamelium/v3: Add save option to avoid doing autodetection every time tests/chamelium/v3: Implement basic EDID handling test tests/chamelium/v3: Implement 4K EDID stress test
tests/chamelium/v3: Implement non-4K EDID stress test
lib/chamelium/v3: Implement method to discover video signal status tests/chamelium/v3: Implement test for DRM device resolution lib/chamelium/v3: Implement hot plug toggle scheduling method tests/chamelium/v3: Add test for display change detection during sleep tests/chamelium/v3: Add MST EDID reading test
docs: Add Chamelium v3

 docs/chamelium.txt                              |   90 +-
 docs/testplan/meson.build                       |    4 +-
 lib/{ => chamelium/v2}/igt_chamelium.c          |    2 +-
 lib/{ => chamelium/v2}/igt_chamelium.h          |    0
 lib/{ => chamelium/v2}/igt_chamelium_stream.c   |    2 +-
 lib/{ => chamelium/v2}/igt_chamelium_stream.h   |    0
 lib/chamelium/v3/igt_chamelium.c                | 1191 +++++++++++++++++++++++
 lib/chamelium/v3/igt_chamelium.h                |   89 ++
 lib/igt.h                                       |    6 +-
 lib/igt_core.c                                  |    3 +
 lib/igt_kms.c                                   |  287 +++++-
 lib/igt_kms.h                                   |   17 +
 lib/meson.build                                 |   16 +-
 lib/monitor_edids/dp_edids.h                    |    3 +
 lib/monitor_edids/hdmi_edids.h                  |   27 +-
 lib/monitor_edids/monitor_edids_helper.c        |   92 +-
 lib/monitor_edids/monitor_edids_helper.h        |   10 +-
 lib/tests/meson.build                           |    8 +-
 meson.build                                     |   45 +-
 meson_options.txt                               |    8 +-
 tests/chamelium/{ => v2}/kms_chamelium_audio.c  |    0
 tests/chamelium/{ => v2}/kms_chamelium_color.c  |    0
 tests/chamelium/{ => v2}/kms_chamelium_edid.c   |    2 +-
 tests/chamelium/{ => v2}/kms_chamelium_frames.c |    0
 tests/chamelium/{ => v2}/kms_chamelium_helper.c |    0
 tests/chamelium/{ => v2}/kms_chamelium_helper.h |    0
 tests/chamelium/{ => v2}/kms_chamelium_hpd.c    |    0
 tests/chamelium/v3/kms_chamelium_v3_basic.c     |   30 +
 tests/chamelium/v3/kms_chamelium_v3_edid.c      |  419 ++++++++
 tests/kms_color_helper.h                        |    2 +-
 tests/kms_feature_discovery.c                   |    6 +-
 tests/kms_tiled_display.c                       |    6 +-
 tests/meson.build                               |   45 +-
 33 files changed, 2348 insertions(+), 62 deletions(-)

---
base-commit: 9683de1314f7fb9204fc4d8baf193a52adda9b59
change-id: 20240522-dev-remove-static-ports-9382ffbbf146

Best regards,

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

PATCH v2 1/39 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 |  3 +++
 lib/igt_kms.c  | 24 ++++++++++++++++++++++++
 lib/igt_kms.h  |  9 +++++++++
 3 files changed, 36 insertions(+)
lib/igt_core.c +3 -0
index 3ff3e0392316..5f5adb553629 100644
@@ -260,6 +260,9 @@
  *	&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)
+ *	DetectTimeout=10.0
  * ]|
  *
  * Some specific configuration options may be used by specific parts of IGT,
lib/igt_kms.c +24 -0
index 64318ef7fb15..4877da4c6c9d 100644
@@ -57,6 +57,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
@@ -6662,3 +6663,26 @@ int get_num_scalers(int drm_fd, enum pipe pipe)
 
 	return num_scalers;
 }
+
+/**
+ * igt_default_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.
+ */
+float igt_default_detect_timeout(void)
+{
+	static double timeout = 0.0;
+	static bool first_call = true;
+
+	if (first_call) {
+		if (igt_key_file)
+			timeout = g_key_file_get_double(igt_key_file, "DUT", "DetectTimeout", NULL);
+		else
+			timeout = DEFAULT_DETECT_TIMEOUT;
+
+		first_call = false;
+	}
+
+	return timeout;
+}
lib/igt_kms.h +9 -0
index 501d48763fb6..f89e1be86b30 100644
@@ -39,6 +39,13 @@
 #include "igt_fb.h"
 #include "ioctl_wrappers.h"
 
+/**
+ * define DEFAULT_DETECT_TIMEOUT - Default timeout used for some 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 */
 
 /**
@@ -1224,4 +1231,6 @@ bool igt_check_output_is_dp_mst(igt_output_t *output);
 int igt_get_dp_mst_connector_id(igt_output_t *output);
 int get_num_scalers(int drm_fd, enum pipe pipe);
 
+float igt_default_detect_timeout(void);
+
 #endif /* __IGT_KMS_H__ */
Signature · 1 line
2.44.2
Reviewed-by on v2 1/39
#2 lore raw

Re: [PATCH i-g-t v2 01/39] lib/igt_kms: Add a detect timeout value

Hi Louis,

Quoted 5 lines · Louis Chauvet

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.

Could you split this series into smaller chunks for easier review? +cc Vignesh

I also spotted one file with GPL licence, in IGT it should have MIT or at least 'GPL or MIT'

This particular patch LGTM,

Btw for patches which touch KMS libs please add few other kms developers, for example Bhanu and Juha-Pekka:

Cc Juha-Pekka Heikkila <[email protected]>
Cc Bhanuprakash Modem <[email protected]>

Regards,
Kamil

Quoted 88 lines
---
 lib/igt_core.c |  3 +++
 lib/igt_kms.c  | 24 ++++++++++++++++++++++++
 lib/igt_kms.h  |  9 +++++++++
 3 files changed, 36 insertions(+)
lib/igt_core.c +3 -0
index 3ff3e0392316..5f5adb553629 100644
@@ -260,6 +260,9 @@
  *	&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)
+ *	DetectTimeout=10.0
  * ]|
  *
  * Some specific configuration options may be used by specific parts of IGT,
lib/igt_kms.c +24 -0
index 64318ef7fb15..4877da4c6c9d 100644
@@ -57,6 +57,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
@@ -6662,3 +6663,26 @@ int get_num_scalers(int drm_fd, enum pipe pipe)
 
 	return num_scalers;
 }
+
+/**
+ * igt_default_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.
+ */
+float igt_default_detect_timeout(void)
+{
+	static double timeout = 0.0;
+	static bool first_call = true;
+
+	if (first_call) {
+		if (igt_key_file)
+			timeout = g_key_file_get_double(igt_key_file, "DUT", "DetectTimeout", NULL);
+		else
+			timeout = DEFAULT_DETECT_TIMEOUT;
+
+		first_call = false;
+	}
+
+	return timeout;
+}
lib/igt_kms.h +9 -0
index 501d48763fb6..f89e1be86b30 100644
@@ -39,6 +39,13 @@
 #include "igt_fb.h"
 #include "ioctl_wrappers.h"
 
+/**
+ * define DEFAULT_DETECT_TIMEOUT - Default timeout used for some 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 */
 
 /**
@@ -1224,4 +1231,6 @@ bool igt_check_output_is_dp_mst(igt_output_t *output);
 int igt_get_dp_mst_connector_id(igt_output_t *output);
 int get_num_scalers(int drm_fd, enum pipe pipe);
 
+float igt_default_detect_timeout(void);
+
 #endif /* __IGT_KMS_H__ */
Signature · 2 lines
-- 
2.44.2
#3 lore raw

Re: [PATCH i-g-t v2 01/39] lib/igt_kms: Add a detect timeout value

Quoted 10 lines · Kamil Konieczny

Hi Louis,

Quoted 5 lines · Louis Chauvet

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.

Could you split this series into smaller chunks for easier review? +cc Vignesh

I will try to split and extract igt_kms and monitor_edids series at least. For the chamelium part I don't know yet.

Quoted 2 lines

I also spotted one file with GPL licence, in IGT it should have MIT or at least 'GPL or MIT'

I will fix it for the v2.

Quoted 2 lines

This particular patch LGTM,

Thanks!

Quoted 5 lines

Btw for patches which touch KMS libs please add few other kms developers, for example Bhanu and Juha-Pekka:

Cc Juha-Pekka Heikkila <[email protected]>
Cc Bhanuprakash Modem <[email protected]>

Thanks for the information, I will add them!

Quoted 91 lines

Regards,
Kamil

Quoted 88 lines
---
 lib/igt_core.c |  3 +++
 lib/igt_kms.c  | 24 ++++++++++++++++++++++++
 lib/igt_kms.h  |  9 +++++++++
 3 files changed, 36 insertions(+)
lib/igt_core.c +3 -0
index 3ff3e0392316..5f5adb553629 100644
@@ -260,6 +260,9 @@
  *	&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)
+ *	DetectTimeout=10.0
  * ]|
  *
  * Some specific configuration options may be used by specific parts of IGT,
lib/igt_kms.c +24 -0
index 64318ef7fb15..4877da4c6c9d 100644
@@ -57,6 +57,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
@@ -6662,3 +6663,26 @@ int get_num_scalers(int drm_fd, enum pipe pipe)
 
 	return num_scalers;
 }
+
+/**
+ * igt_default_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.
+ */
+float igt_default_detect_timeout(void)
+{
+	static double timeout = 0.0;
+	static bool first_call = true;
+
+	if (first_call) {
+		if (igt_key_file)
+			timeout = g_key_file_get_double(igt_key_file, "DUT", "DetectTimeout", NULL);
+		else
+			timeout = DEFAULT_DETECT_TIMEOUT;
+
+		first_call = false;
+	}
+
+	return timeout;
+}
lib/igt_kms.h +9 -0
index 501d48763fb6..f89e1be86b30 100644
@@ -39,6 +39,13 @@
 #include "igt_fb.h"
 #include "ioctl_wrappers.h"
 
+/**
+ * define DEFAULT_DETECT_TIMEOUT - Default timeout used for some 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 */
 
 /**
@@ -1224,4 +1231,6 @@ bool igt_check_output_is_dp_mst(igt_output_t *output);
 int igt_get_dp_mst_connector_id(igt_output_t *output);
 int get_num_scalers(int drm_fd, enum pipe pipe);
 
+float igt_default_detect_timeout(void);
+
 #endif /* __IGT_KMS_H__ */
Signature · 2 lines
-- 
2.44.2
Signature · 3 lines
Louis Chauvet, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
#4 lore raw

PATCH v2 2/39 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 new status without notifier systems (which can fail if hot plug detection is not working properly on the device under test.

---
 lib/igt_kms.c | 38 ++++++++++++++++++++++++++++++++++++++
 lib/igt_kms.h |  3 +++
 2 files changed, 41 insertions(+)
lib/igt_kms.c +38 -0
index 4877da4c6c9d..bb4c065ab4ed 100644
@@ -6686,3 +6686,41 @@ float igt_default_detect_timeout(void)
 
 	return timeout;
 }
+
+/**
+ * igt_wait_for_connector_status - Wait for at most @timeout that the connector @connector_id
+ * status become @drm_mode
+ *
+ * @drm_fd: drm file descriptor
+ * @connector_id: connector to monitor
+ * @timeout: maximum duration to wait, in second
+ * @drm_mode: mode to wait for, see enum drmModeConnection
+ *
+ * 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 == 0.0)
+		timeout = igt_default_detect_timeout();
+
+	clock_gettime(CLOCK_MONOTONIC, &start);
+	clock_gettime(CLOCK_MONOTONIC, &end);
+
+	while (igt_time_elapsed(&start, &end) <= timeout) {
+		connector = drmModeGetConnector(drm_fd, connector_id);
+		if (connector && connector->connection == drm_mode) {
+			free(connector);
+			return true;
+		}
+		free(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 f89e1be86b30..ba8658ce45e5 100644
@@ -1233,4 +1233,7 @@ int get_num_scalers(int drm_fd, enum pipe pipe);
 
 float igt_default_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.44.2
#5 lore raw

PATCH v2 3/39 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 | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 lib/igt_kms.h |  1 +
 2 files changed, 55 insertions(+)
lib/igt_kms.c +54 -0
index bb4c065ab4ed..f1eadf190168 100644
@@ -6724,3 +6724,57 @@ bool igt_wait_for_connector_status(int drm_fd, unsigned int connector_id, double
 		  connector_id);
 	return false;
 }
+
+/**
+ * igt_get_connected_connectors - List all connectors reported as CONNECTED by DRM.
+ *
+ * @drm_fd: DRM file description
+ * @connector_ids: out pointer for the list of connector ids connected. It must be freed by the
+ * caller.
+ *
+ * The returns value is the number of connectors
+ */
+int igt_get_connected_connectors(int drm_fd, uint32_t **connector_ids)
+{
+	int connected_count = 0;
+	drmModeResPtr resources;
+	struct timespec start, end;
+
+	*connector_ids = malloc(0);
+
+	resources = drmModeGetResources(drm_fd);
+	for (int j = 0; j < resources->count_connectors; j++) {
+		drmModeConnectorPtr connector = NULL;
+
+		connector = drmModeGetConnector(drm_fd, resources->connectors[j]);
+		/*
+		 * This time is required as sometimes some id in the connector list are not totally
+		 * ready or can disappear
+		 */
+		clock_gettime(CLOCK_MONOTONIC, &start);
+		clock_gettime(CLOCK_MONOTONIC, &end);
+		while (!connector &&
+		       igt_time_elapsed(&start, &end) < igt_default_detect_timeout()) {
+			connector = drmModeGetConnector(drm_fd, resources->connectors[j]);
+			clock_gettime(CLOCK_MONOTONIC, &end);
+		}
+
+		if (igt_time_elapsed(&start, &end) < igt_default_detect_timeout()) {
+			igt_assert(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 ba8658ce45e5..1964c725161e 100644
@@ -1235,5 +1235,6 @@ float igt_default_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.44.2
#6 lore raw

PATCH v2 4/39 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 | 97 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 lib/igt_kms.h |  3 ++
 2 files changed, 100 insertions(+)
lib/igt_kms.c +97 -0
index f1eadf190168..9669b5004e39 100644
@@ -6778,3 +6778,100 @@ int igt_get_connected_connectors(int drm_fd, uint32_t **connector_ids)
 	return
 	    connected_count;
 }
+
+drmModeConnectorPtr igt_get_connector_from_name(int drm_fd, const char *port_name)
+{
+	drmModeResPtr res = drmModeGetResources(drm_fd);
+	struct timespec start, end;
+	int i;
+
+	if (!res)
+		return 0;
+
+	for (i = 0; i < res->count_connectors; i++) {
+		char name[50];
+
+		drmModeConnectorPtr connector = drmModeGetConnector(drm_fd, res->connectors[i]);
+		/*
+		 * This time is required as sometimes some id in the connector list are not totally
+		 * ready or can disappear
+		 */
+		clock_gettime(CLOCK_MONOTONIC, &start);
+		clock_gettime(CLOCK_MONOTONIC, &end);
+		while (!connector &&
+		       igt_time_elapsed(&start, &end) < igt_default_detect_timeout()) {
+			connector = drmModeGetConnector(drm_fd, res->connectors[i]);
+			clock_gettime(CLOCK_MONOTONIC, &end);
+		}
+
+		if (igt_time_elapsed(&start, &end) < igt_default_detect_timeout()) {
+			igt_assert(connector);
+
+			/* We have to generate the connector name on our own */
+			snprintf(name, 50, "%s-%u",
+				 kmstest_connector_type_str(connector->connector_type),
+				 connector->connector_type_id);
+
+			if (strcmp(port_name, name) == 0) {
+				drmModeFreeResources(res);
+				return connector;
+			}
+			drmModeFreeConnector(connector);
+		}
+	}
+	drmModeFreeResources(res);
+	return NULL;
+}
+
+/**
+ * igt_get_connector_id_from_name - Get a connector ID from a connector name
+ * @drm_fd: DRM file descriptor
+ * @port_name: Port name to find in the connector
+ *
+ * Returns 0 when no connector is found with the correct name
+ */
+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) {
+		int connector_id = connector->connector_id;
+
+		drmModeFreeConnector(connector);
+		return connector_id;
+	}
+	return 0;
+}
+
+/**
+ * igt_get_connector_id_from_mst_path - Get a connector ID from a 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 (strcmp(path_blob->data, mst_path) == 0) {
+				drmModeFreePropertyBlob(path_blob);
+				drmModeFreeResources(res);
+				return connector_id;
+			}
+			drmModeFreePropertyBlob(path_blob);
+		}
+	}
+	drmModeFreeResources(res);
+	return 0;
+}
lib/igt_kms.h +3 -0
index 1964c725161e..a7c80372ec6b 100644
@@ -1236,5 +1236,8 @@ float igt_default_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.44.2
#7 lore raw

PATCH v2 5/39 lib/igt_kms: Add function to get valid pipe for specific output

In reply to Louis Chauvet

Introduces a new function igt_get_pipe_for_output in igt_kms. The function is designed to retrieve a valid pipe for a specific output in a display.

---
 lib/igt_kms.c | 19 +++++++++++++++++++
 lib/igt_kms.h |  1 +
 2 files changed, 20 insertions(+)
lib/igt_kms.c +19 -0
index 9669b5004e39..45e0eec72d12 100644
@@ -6875,3 +6875,22 @@ uint32_t igt_get_connector_id_from_mst_path(int drm_fd, const void *mst_path)
 	drmModeFreeResources(res);
 	return 0;
 }
+
+/**
+ * igt_get_pipe_for_output - Get a valid pipe for a specific output
+ * @display: display to fetch the pipes
+ * @output: output to use
+ */
+enum pipe igt_get_pipe_for_output(igt_display_t *display,
+				  igt_output_t *output)
+{
+	enum pipe pipe;
+
+	for_each_pipe(display, pipe) {
+		if ((igt_output_is_connected((output)) &&
+		     (output->config.valid_crtc_idx_mask & (1 << (pipe)))))
+			return pipe;
+	}
+
+	igt_assert_f(false, "No pipe found for output %s\n", igt_output_name(output));
+}
lib/igt_kms.h +1 -0
index a7c80372ec6b..bfa1ca41e5a4 100644
@@ -1239,5 +1239,6 @@ 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);
+enum pipe igt_get_pipe_for_output(igt_display_t *display, igt_output_t *output);
 
 #endif /* __IGT_KMS_H__ */
Signature · 1 line
2.44.2
#8 lore raw

PATCH v2 6/39 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/monitor_edids_helper.c | 61 +++++++++++++++++++++++++++++++-
 lib/monitor_edids/monitor_edids_helper.h |  5 +++
 2 files changed, 65 insertions(+), 1 deletion(-)
lib/monitor_edids/monitor_edids_helper.c +60 -1
index 1cbf1c22f0bb..0e0c2a9badcf 100644
@@ -14,7 +14,10 @@
 #include <string.h>
 #include <assert.h>
 
-#include "igt_core.h"
+#include "igt.h"
+#include "igt_edid.h"
+#include "dp_edids.h"
+#include "hdmi_edids.h"
 
 static uint8_t convert_hex_char_to_byte(char c)
 {
@@ -90,3 +93,59 @@ void free_chamelium_edid_from_monitor_edid(struct chamelium_edid *edid)
 	free(edid);
 	edid = NULL;
 }
+
+struct edid *edid_from_monitor_edid(const monitor_edid *mon_edid)
+{
+	uint8_t *raw_edid;
+	size_t edid_size;
+	int i;
+
+	edid_size = strlen(mon_edid->edid) / 2; /* each ascii is a nibble. */
+	raw_edid = malloc(edid_size);
+	igt_assert(raw_edid);
+
+	for (i = 0; i < edid_size; i++) {
+		raw_edid[i] = convert_hex_char_to_byte(mon_edid->edid[i * 2]) << 4 |
+			      convert_hex_char_to_byte(mon_edid->edid[i * 2 + 1]);
+	}
+
+	if (edid_get_size((struct edid *)raw_edid) > edid_size) {
+		uint8_t *new_edid;
+
+		igt_warn("The edid size stored in the raw edid is shorter than the edid stored in the table.");
+		new_edid = realloc(raw_edid, edid_get_size((struct edid *)raw_edid));
+		igt_assert(new_edid);
+		raw_edid = new_edid;
+	}
+
+	return (struct edid *)raw_edid;
+}
+
+struct monitor_edid *get_edids_for_connector_type(uint32_t type, size_t *count, bool four_k)
+{
+	if (four_k) {
+		switch (type) {
+		case DRM_MODE_CONNECTOR_DisplayPort:
+			*count = ARRAY_SIZE(DP_EDIDS_4K);
+			return DP_EDIDS_4K;
+		case DRM_MODE_CONNECTOR_HDMIA:
+			*count = ARRAY_SIZE(HDMI_EDIDS_4K);
+			return HDMI_EDIDS_4K;
+		default:
+			igt_assert_f(0, "No 4k EDID for the connector %s\n",
+				     kmstest_connector_type_str(type));
+		}
+	} else {
+		switch (type) {
+		case DRM_MODE_CONNECTOR_DisplayPort:
+			*count = ARRAY_SIZE(DP_EDIDS_NON_4K);
+			return DP_EDIDS_NON_4K;
+		case DRM_MODE_CONNECTOR_HDMIA:
+			*count = ARRAY_SIZE(HDMI_EDIDS_NON_4K);
+			return HDMI_EDIDS_NON_4K;
+		default:
+			igt_assert_f(0, "No EDID for the connector %s\n",
+				     kmstest_connector_type_str(type));
+		}
+	}
+}
lib/monitor_edids/monitor_edids_helper.h +5 -0
index 05679f0897f3..2ec7aee5f13f 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);
 
+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_ */
\ No newline at end of file
Signature · 1 line
2.44.2
#9 lore raw

PATCH v2 7/39 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/dp_edids.h             |  3 +++
 lib/monitor_edids/hdmi_edids.h           |  3 +++
 lib/monitor_edids/monitor_edids_helper.c | 21 +++++++++++++++++++++
 lib/monitor_edids/monitor_edids_helper.h |  1 +
 4 files changed, 28 insertions(+)
lib/monitor_edids/dp_edids.h +3 -0
index 144907558be1..d11a81d167fc 100644
@@ -194,4 +194,7 @@ monitor_edid DP_EDIDS_NON_4K[] = {
 
  };
 
+const int DP_EDID_NON_4K_COUNT = ARRAY_SIZE(DP_EDIDS_NON_4K);
+const int DP_EDID_4K_COUNT = ARRAY_SIZE(DP_EDIDS_4K);
+
 #endif /* TESTS_CHAMELIUM_MONITOR_EDIDS_DP_EDIDS_H_ */
lib/monitor_edids/hdmi_edids.h +3 -0
index 9d75cfa989b6..573e2149d5d3 100644
@@ -604,4 +604,7 @@ monitor_edid HDMI_EDIDS_NON_4K[] = {
 		  "1620582c2500baac4200009e0000006b" },
 };
 
+const int HDMI_EDID_4K_COUNT = ARRAY_SIZE(HDMI_EDIDS_4K);
+const int HDMI_EDID_NON_4K_COUNT = ARRAY_SIZE(HDMI_EDIDS_NON_4K);
+
 #endif /* TESTS_CHAMELIUM_MONITOR_EDIDS_HDMI_EDIDS_H_ */
lib/monitor_edids/monitor_edids_helper.c +21 -0
index 0e0c2a9badcf..0f92ced64d06 100644
@@ -19,6 +19,16 @@
 #include "dp_edids.h"
 #include "hdmi_edids.h"
 
+struct {
+	struct monitor_edid *edid_list;
+	int list_size;
+} ALL_EDIDS[] = {
+	{DP_EDIDS_NON_4K,	DP_EDID_NON_4K_COUNT},
+	{DP_EDIDS_4K,		DP_EDID_4K_COUNT},
+	{HDMI_EDIDS_NON_4K,	HDMI_EDID_NON_4K_COUNT},
+	{HDMI_EDIDS_4K,		HDMI_EDID_4K_COUNT},
+};
+
 static uint8_t convert_hex_char_to_byte(char c)
 {
 	if (c >= '0' && c <= '9')
@@ -149,3 +159,14 @@ struct monitor_edid *get_edids_for_connector_type(uint32_t type, size_t *count,
 		}
 	}
 }
+
+struct edid *get_edid_by_name(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 2ec7aee5f13f..cd0e5a7b2645 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(char *name);
 
 #endif /* TESTS_CHAMELIUM_MONITOR_EDIDS_MONITOR_EDIDS_HELPER_H_ */
\ No newline at end of file
Signature · 1 line
2.44.2
#10 lore raw

PATCH v2 8/39 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 | 10 ++++++++++
 lib/monitor_edids/monitor_edids_helper.h |  2 ++
 2 files changed, 12 insertions(+)
lib/monitor_edids/monitor_edids_helper.c +10 -0
index 0f92ced64d06..ca2f5006eada 100644
@@ -170,3 +170,13 @@ struct edid *get_edid_by_name(char *name)
 	}
 	return NULL;
 }
+
+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 cd0e5a7b2645..50b08530826a 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(char *name);
+void list_edid_names(enum igt_log_level level);
 
 #endif /* TESTS_CHAMELIUM_MONITOR_EDIDS_MONITOR_EDIDS_HELPER_H_ */
\ No newline at end of file
Signature · 1 line
2.44.2
#11 lore raw

PATCH v2 9/39 lib/monitor_edids: Fix missing names in some monitor EDID

In reply to Louis Chauvet

Some HDMI EDID did not have a good name identifier. Add one to avoid confusion.

---
 lib/monitor_edids/hdmi_edids.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
lib/monitor_edids/hdmi_edids.h +3 -3
index 573e2149d5d3..8bcd1f31b458 100644
@@ -241,7 +241,7 @@ monitor_edid HDMI_EDIDS_NON_4K[] = {
 		  "33333633493056465320000000fc0044"
 		  "454c4c20323430354650570a000000fd"
 		  "00384c1e5111000a20202020202000e9" },
-	{ .name = "`",
+	{ .name = "DEL_DELL_2407WFP_HDMI",
 	  .edid = "00ffffffffffff0010ac17a053575930"
 		  "0511010380342178eeee91a3544c9926"
 		  "0f5054a54b008180a940714fb3000101"
@@ -438,7 +438,7 @@ monitor_edid HDMI_EDIDS_NON_4K[] = {
 		  "60350000003200001c011d8018711c16"
 		  "20582c2500c48e2100009e0000000000"
 		  "0000000000000000000000000000000a" },
-	{ .name = "",
+	{ .name = "GSM_50294_M3704C_HDMI",
 	  .edid = "00ffffffffffff001e6d76c401010101"
 		  "2514010380522e78eaac27a355499b25"
 		  "10474aa1080081807140614045403140"
@@ -490,7 +490,7 @@ monitor_edid HDMI_EDIDS_NON_4K[] = {
 		  "5011000a202020202020000000fc0048"
 		  "50205a5232343430770a2020000000ff"
 		  "00434e34333132303836580a2020007f" },
-	{ .name = "",
+	{ .name = "HWP_10582_HP_ZR2440w_HDMI",
 	  .edid = "00ffffffffffff0022f0562901010101"
 		  "0b170103803420782afc81a4554d9d25"
 		  "125054210800d1c081c0814081809500"
Signature · 1 line
2.44.2
#12 lore raw

PATCH v2 10/39 lib/monitor_edids: Add new EDID for HDMI 4k

In reply to Louis Chauvet

Add EDID for the HDMI screen LG HDR 4K.

---
 lib/monitor_edids/hdmi_edids.h | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)
lib/monitor_edids/hdmi_edids.h +17 -1
index 8bcd1f31b458..cc6820d96231 100644
@@ -49,7 +49,23 @@ monitor_edid HDMI_EDIDS_4K[] = {
 		  "5E00A0A0A0295030203500C48F210000"
 		  "1EEF5100A0F070198030203500C48F21"
 		  "00001E000000000000000000000000A8" },
-
+	{ .name = "4K_GSM_LG_HDR_4K_HDMI",
+	  .edid = "00ffffffffffff001e6d4f77c75f1500"
+		  "0521010380462878ea7ba1ae4f44a926"
+		  "0c5054210800d1c06140454001010101"
+		  "010101010101a0cb0046f0703e802010"
+		  "3500b9882100001a000000fd00283c1e"
+		  "873c000a202020202020000000fc004c"
+		  "472048445220344b0a202020000000ff"
+		  "003330354d414e4a43335a37350a01e4"
+		  "0203427223090707830100004d010304"
+		  "10121f202261605f5e5d6d030c001000"
+		  "b83c20006001020367d85dc401788003"
+		  "e30f0003e2006ae305c000e606050159"
+		  "5952a36600a0f0701f8030203500b988"
+		  "2100001a565e00a0a0a0295030203500"
+		  "b9882100001a023a801871382d40582c"
+		  "4500b9882100001a00000000000000af" },
 };
 
 monitor_edid HDMI_EDIDS_NON_4K[] = {
Signature · 1 line
2.44.2
#13 lore raw

PATCH v2 11/39 tests/chamelium: Extract Chamelium v2 tests into a separate directory

In reply to Louis Chauvet

In preparation for Chamelium v3, the Chamelium v2 tests have been moved to their own directory.

The two Chamelium versions have different sets of functionality (audio, MST, CRC computation, etc.). Since most of the tests will need to be rewritten to work with Chamelium v3, it is simpler to create new ones for v3 to avoid breaking the existing tests.

The following complexities necessitate a thorough rework of the existing v2 tests:

- Not all ports are discoverable in v3 (MST ports are not physical ports, but they can have EDID, be plugged, etc.), and they can change over time.
- The v3 is unable to perform CRC computation.
- Not all ports can be plugged at once, which is a feature used by the existing v2 wrapper to set up the Chamelium.

---
 tests/chamelium/{ => v2}/kms_chamelium_audio.c  |  0
 tests/chamelium/{ => v2}/kms_chamelium_color.c  |  0
 tests/chamelium/{ => v2}/kms_chamelium_edid.c   |  0
 tests/chamelium/{ => v2}/kms_chamelium_frames.c |  0
 tests/chamelium/{ => v2}/kms_chamelium_helper.c |  0
 tests/chamelium/{ => v2}/kms_chamelium_helper.h |  0
 tests/chamelium/{ => v2}/kms_chamelium_hpd.c    |  0
 tests/meson.build                               | 10 +++++-----
 8 files changed, 5 insertions(+), 5 deletions(-)
tests/chamelium/v2/kms_chamelium_audio.c renamed from tests/chamelium/kms_chamelium_audio.c +0 -0
similarity index 100%
rename from tests/chamelium/kms_chamelium_audio.c
rename to tests/chamelium/v2/kms_chamelium_audio.c
tests/chamelium/v2/kms_chamelium_color.c renamed from tests/chamelium/kms_chamelium_color.c +0 -0
similarity index 100%
rename from tests/chamelium/kms_chamelium_color.c
rename to tests/chamelium/v2/kms_chamelium_color.c
tests/chamelium/v2/kms_chamelium_edid.c renamed from tests/chamelium/kms_chamelium_edid.c +0 -0
similarity index 100%
rename from tests/chamelium/kms_chamelium_edid.c
rename to tests/chamelium/v2/kms_chamelium_edid.c
tests/chamelium/v2/kms_chamelium_frames.c renamed from tests/chamelium/kms_chamelium_frames.c +0 -0
similarity index 100%
rename from tests/chamelium/kms_chamelium_frames.c
rename to tests/chamelium/v2/kms_chamelium_frames.c
tests/chamelium/v2/kms_chamelium_helper.c renamed from tests/chamelium/kms_chamelium_helper.c +0 -0
similarity index 100%
rename from tests/chamelium/kms_chamelium_helper.c
rename to tests/chamelium/v2/kms_chamelium_helper.c
tests/chamelium/v2/kms_chamelium_helper.h renamed from tests/chamelium/kms_chamelium_helper.h +0 -0
similarity index 100%
rename from tests/chamelium/kms_chamelium_helper.h
rename to tests/chamelium/v2/kms_chamelium_helper.h
tests/chamelium/v2/kms_chamelium_hpd.c renamed from tests/chamelium/kms_chamelium_hpd.c +0 -0
similarity index 100%
rename from tests/chamelium/kms_chamelium_hpd.c
rename to tests/chamelium/v2/kms_chamelium_hpd.c
tests/meson.build +5 -5
index 357db2723005..30cd7982ea77 100644
@@ -342,11 +342,11 @@ extra_sources = {
 	'dumb_buffer': ['dumb_buffer.c' ],
 	'testdisplay': [ 'testdisplay_hotplug.c' ],
 	'kms_color':  [ 'kms_color_helper.c' ],
-	'kms_chamelium_audio': [ join_paths ('chamelium', 'kms_chamelium_helper.c') ],
+	'kms_chamelium_audio': [ join_paths ('chamelium', 'v2', 'kms_chamelium_helper.c') ],
 	'kms_chamelium_color':  [ 'kms_color_helper.c' ],
-	'kms_chamelium_edid': [ join_paths ('chamelium', 'kms_chamelium_helper.c') ],
-	'kms_chamelium_frames': [ join_paths ('chamelium', 'kms_chamelium_helper.c') ],
-	'kms_chamelium_hpd': [ join_paths ('chamelium', 'kms_chamelium_helper.c') ],
+	'kms_chamelium_edid': [ join_paths ('chamelium', 'v2', 'kms_chamelium_helper.c') ],
+	'kms_chamelium_frames': [ join_paths ('chamelium', 'v2', 'kms_chamelium_helper.c') ],
+	'kms_chamelium_hpd': [ join_paths ('chamelium', 'v2', 'kms_chamelium_helper.c') ],
 	'kms_dsc': [ join_paths ('intel', 'kms_dsc_helper.c') ],
 	'kms_psr2_sf':  [ join_paths ('intel', 'kms_dsc_helper.c') ],
 }
@@ -422,7 +422,7 @@ endforeach
 if chamelium.found()
 	foreach prog : chamelium_progs
 		testexe = executable(prog,
-				 [join_paths('chamelium', prog + '.c')] + extra_sources.get(prog, []),
+				 [join_paths('chamelium', 'v2', prog + '.c')] + extra_sources.get(prog, []),
 				 dependencies : test_deps + extra_dependencies.get(prog, []),
 				 install_dir : libexecdir,
 				 install_rpath : libexecdir_rpathdir,
Signature · 1 line
2.44.2
#14 lore raw

PATCH v2 12/39 lib/chamelium/v2: Extract chamelium v2 wrapper into its own directory

In reply to Louis Chauvet

In preparation for the Chamelium v3, the support for Chamelium v2 is being extracted into its own directory.

The two Chamelium versions have different sets of functionality (audio, MST, CRC computation, etc.). As the current wrapper is already complex, extracting the v2 part into its own directory allows for the v3 wrapper to be written without breaking any existing tests or complicating the existing code.

The current identified complexities that necessitate a thorough rework of the existing v2 wrapper are:

- Not all ports are discoverable in v3 (MST ports are not physical ports, but they can have EDID, be plugged, etc.), and they can change over time.
- The v3 is unable to perform CRC computation, so many tests must be rewritten or adapted to work.
- Not all ports can be plugged at once, which is a feature used by the existing v2 wrapper to set up the Chamelium.

---
 lib/{ => chamelium/v2}/igt_chamelium.c        | 2 +-
 lib/{ => chamelium/v2}/igt_chamelium.h        | 0
 lib/{ => chamelium/v2}/igt_chamelium_stream.c | 2 +-
 lib/{ => chamelium/v2}/igt_chamelium_stream.h | 0
 lib/igt.h                                     | 4 ++--
 lib/igt_kms.c                                 | 2 +-
 lib/meson.build                               | 5 ++++-
 lib/monitor_edids/monitor_edids_helper.h      | 2 +-
 tests/chamelium/v2/kms_chamelium_edid.c       | 2 +-
 tests/kms_feature_discovery.c                 | 2 +-
 10 files changed, 12 insertions(+), 9 deletions(-)
lib/chamelium/v2/igt_chamelium.c renamed from lib/igt_chamelium.c +1 -1
similarity index 99%
rename from lib/igt_chamelium.c
rename to lib/chamelium/v2/igt_chamelium.c
index 620fbbf7d94f..2218c6cd694d 100644
@@ -37,7 +37,7 @@
 #include <pixman.h>
 #include <cairo.h>
 
-#include "igt_chamelium.h"
+#include "chamelium/v2/igt_chamelium.h"
 #include "igt_core.h"
 #include "igt_aux.h"
 #include "igt_edid.h"
lib/chamelium/v2/igt_chamelium.h renamed from lib/igt_chamelium.h +0 -0
similarity index 100%
rename from lib/igt_chamelium.h
rename to lib/chamelium/v2/igt_chamelium.h
lib/chamelium/v2/igt_chamelium_stream.c renamed from lib/igt_chamelium_stream.c +1 -1
similarity index 99%
rename from lib/igt_chamelium_stream.c
rename to lib/chamelium/v2/igt_chamelium_stream.c
index a8cd19e51b0b..8d96e654947d 100644
@@ -33,7 +33,7 @@
 #include <sys/types.h>
 #include <sys/socket.h>
 
-#include "igt_chamelium_stream.h"
+#include "chamelium/v2/igt_chamelium_stream.h"
 #include "igt_core.h"
 #include "igt_rc.h"
 
lib/chamelium/v2/igt_chamelium_stream.h renamed from lib/igt_chamelium_stream.h +0 -0
similarity index 100%
rename from lib/igt_chamelium_stream.h
rename to lib/chamelium/v2/igt_chamelium_stream.h
lib/igt.h +2 -2
index 7af3d10cbcd3..cf91e92eb2d4 100644
@@ -45,8 +45,8 @@
 #ifdef HAVE_CHAMELIUM
 #include "igt_alsa.h"
 #include "igt_audio.h"
-#include "igt_chamelium.h"
-#include "igt_chamelium_stream.h"
+#include "chamelium/v2/igt_chamelium.h"
+#include "chamelium/v2/igt_chamelium_stream.h"
 #endif
 #include "instdone.h"
 #include "intel_batchbuffer.h"
lib/igt_kms.c +1 -1
index 45e0eec72d12..e12ac94c423f 100644
@@ -61,7 +61,7 @@
 #include "igt_sysfs.h"
 #include "sw_sync.h"
 #ifdef HAVE_CHAMELIUM
-#include "igt_chamelium.h"
+#include "chamelium/v2/igt_chamelium.h"
 #endif
 
 /**
lib/meson.build +4 -1
index 7577bee9d35e..c617a92a6a6e 100644
@@ -190,7 +190,10 @@ endif
 
 if chamelium.found()
 	lib_deps += chamelium
-	lib_sources += [ 'igt_chamelium.c', 'igt_chamelium_stream.c' ]
+	lib_sources += [
+		'chamelium/v2/igt_chamelium.c',
+		'chamelium/v2/igt_chamelium_stream.c'
+	]
 	lib_sources += 'monitor_edids/monitor_edids_helper.c'
 endif
 
lib/monitor_edids/monitor_edids_helper.h +1 -1
index 50b08530826a..fed9a676fd97 100644
@@ -16,7 +16,7 @@
 #include <stdbool.h>
 
 #include "igt_core.h"
-#include "igt_chamelium.h"
+#include "chamelium/v2/igt_chamelium.h"
 
 /* Max Length can be increased as needed, when new EDIDs are added. */
 #define EDID_NAME_MAX_LEN 28
tests/chamelium/v2/kms_chamelium_edid.c +1 -1
index 8438f5f156b7..772654f37de8 100644
@@ -41,7 +41,7 @@
 
 #include "config.h"
 #include "igt.h"
-#include "igt_chamelium.h"
+#include "chamelium/v2/igt_chamelium.h"
 #include "igt_edid.h"
 #include "igt_eld.h"
 #include "igt_vc4.h"
tests/kms_feature_discovery.c +1 -1
index 5bca9ad76684..edb0186361a8 100644
@@ -36,7 +36,7 @@
 
 #include "igt.h"
 #ifdef HAVE_CHAMELIUM
-#include "igt_chamelium.h"
+#include "chamelium/v2/igt_chamelium.h"
 #endif
 #include "igt_kms.h"
 #include "igt_psr.h"
Signature · 1 line
2.44.2
#15 lore raw

PATCH v2 13/39 lib/chamelium/v2: Modify build options to separate Chamelium v2 and v3

In reply to Louis Chauvet

Rename the Chamelium option to "chamelium_v2" in preparation for the introduction of the v3 wrapper. Additionally, rename the "HAVE_CHAMELIUM" define to prevent conflicts when v3 is introduced.

---
 docs/testplan/meson.build     |  4 ++--
 lib/igt.h                     |  2 +-
 lib/igt_kms.c                 |  4 ++--
 lib/meson.build               |  4 ++--
 lib/tests/meson.build         |  4 ++--
 meson.build                   | 30 +++++++++++++++---------------
 meson_options.txt             |  4 ++--
 tests/kms_color_helper.h      |  2 +-
 tests/kms_feature_discovery.c |  4 ++--
 tests/kms_tiled_display.c     |  6 +++---
 tests/meson.build             |  8 ++++----
 11 files changed, 36 insertions(+), 36 deletions(-)
docs/testplan/meson.build +2 -2
index 5560347f1337..f60c82ad139c 100644
@@ -21,8 +21,8 @@ if build_tests
 		build_info += 'Will Check if documentation is in sync with testlist'
 		check_testlist = [ '--check-testlist', '--igt-build-path', build_root ]
 
-		if not chamelium.found()
-			warning('WARNING: Will not check if documentation is in sync for KMS as chamelium is disabled')
+		if not chamelium_v2.found()
+			warning('WARNING: Will not check if documentation is in sync for KMS as chamelium v2 is disabled')
 		else
 			kms_check_testlist = check_testlist
 		endif
lib/igt.h +1 -1
index cf91e92eb2d4..390e59cd9b92 100644
@@ -42,7 +42,7 @@
 #include "igt_sizes.h"
 #include "igt_stats.h"
 #include "igt_dsc.h"
-#ifdef HAVE_CHAMELIUM
+#ifdef HAVE_CHAMELIUM_V2
 #include "igt_alsa.h"
 #include "igt_audio.h"
 #include "chamelium/v2/igt_chamelium.h"
lib/igt_kms.c +2 -2
index e12ac94c423f..059c61bf222a 100644
@@ -60,7 +60,7 @@
 #include "igt_rc.h"
 #include "igt_sysfs.h"
 #include "sw_sync.h"
-#ifdef HAVE_CHAMELIUM
+#ifdef HAVE_CHAMELIUM_V2
 #include "chamelium/v2/igt_chamelium.h"
 #endif
 
@@ -2883,7 +2883,7 @@ void igt_display_require(igt_display_t *display, int drm_fd)
 	if (!resources)
 		goto out;
 
-#ifdef HAVE_CHAMELIUM
+#ifdef HAVE_CHAMELIUM_V2
 	{
 		struct chamelium *chamelium;
 
lib/meson.build +2 -2
index c617a92a6a6e..714990e96485 100644
@@ -188,8 +188,8 @@ if alsa.found()
 	lib_sources += 'igt_alsa.c'
 endif
 
-if chamelium.found()
-	lib_deps += chamelium
+if chamelium_v2.found()
+	lib_deps += chamelium_v2
 	lib_sources += [
 		'chamelium/v2/igt_chamelium.c',
 		'chamelium/v2/igt_chamelium_stream.c'
lib/tests/meson.build +2 -2
index fa3d81de6cef..f98c948bc827 100644
@@ -34,8 +34,8 @@ lib_fail_tests = [
 
 lib_tests_deps = igt_deps
 
-if chamelium.found()
-	lib_deps += chamelium
+if chamelium_v2.found()
+	lib_deps += chamelium_v2
 	lib_tests += 'igt_audio'
 endif
 
meson.build +15 -15
index 25bf1e4426fb..1fbbe4802ad3 100644
@@ -86,7 +86,7 @@ foreach cc_arg : cc_args
   endif
 endforeach
 
-build_chamelium = get_option('chamelium')
+build_chamelium_v2 = get_option('chamelium_v2')
 build_docs = get_option('docs')
 build_tests = not get_option('tests').disabled()
 build_xe = not get_option('xe_driver').disabled()
@@ -172,28 +172,28 @@ if not xmlrpc.found() and xmlrpc_cmd.found()
 	endif
 endif
 
-if build_chamelium.enabled() and not (xmlrpc.found() and xmlrpc_util.found() and xmlrpc_client.found())
+if build_chamelium_v2.enabled() and not (xmlrpc.found() and xmlrpc_util.found() and xmlrpc_client.found())
 	error('Chamelium build forced and required dependency xmlrpc not found')
 endif
 
-gsl = dependency('gsl', required : build_chamelium)
-alsa = dependency('alsa', required : build_chamelium)
-libcurl = dependency('libcurl', required : build_chamelium)
+gsl = dependency('gsl', required : build_chamelium_v2)
+alsa = dependency('alsa', required : build_chamelium_v2)
+libcurl = dependency('libcurl', required : build_chamelium_v2)
 
 if xmlrpc.found() and xmlrpc_util.found() and xmlrpc_client.found() and gsl.found() and alsa.found() and libcurl.found()
-	config.set('HAVE_CHAMELIUM', 1)
-	chamelium = declare_dependency(dependencies : [
-		xmlrpc,
-		xmlrpc_util,
-		xmlrpc_client,
-		gsl,
-		alsa,
-	])
+	config.set('HAVE_CHAMELIUM_V2', 1)
+	chamelium_v2 = declare_dependency(dependencies : [
+										  xmlrpc,
+										  xmlrpc_util,
+										  xmlrpc_client,
+										  gsl,
+										  alsa,
+									  ])
 else
-	chamelium = disabler()
+	chamelium_v2 = disabler()
 endif
 
-build_info += 'Build Chamelium test: @0@'.format(chamelium.found())
+build_info += 'Build Chamelium v2 test: @0@'.format(chamelium_v2.found())
 
 pthreads = dependency('threads')
 math = cc.find_library('m')
meson_options.txt +2 -2
index 6a9493ea6ecd..fea91fb129aa 100644
@@ -8,9 +8,9 @@ option('overlay_backends',
        choices : [ 'auto', 'x', 'xv' ],
        description : 'Overlay backends to enable')
 
-option('chamelium',
+option('chamelium_v2',
        type : 'feature',
-       description : 'Build Chamelium test')
+       description : 'Build Chamelium v2 test')
 
 option('valgrind',
        type : 'feature',
tests/kms_color_helper.h +1 -1
index 23463b944b6f..910de27bf61f 100644
@@ -57,7 +57,7 @@ typedef struct {
 	uint32_t color_depth;
 	uint64_t degamma_lut_size;
 	uint64_t gamma_lut_size;
-	#ifdef HAVE_CHAMELIUM
+	#ifdef HAVE_CHAMELIUM_V2
 	struct chamelium *chamelium;
 	struct chamelium_port **ports;
 	int port_count;
tests/kms_feature_discovery.c +2 -2
index edb0186361a8..76e958c84d51 100644
@@ -35,7 +35,7 @@
  */
 
 #include "igt.h"
-#ifdef HAVE_CHAMELIUM
+#ifdef HAVE_CHAMELIUM_V2
 #include "chamelium/v2/igt_chamelium.h"
 #endif
 #include "igt_kms.h"
@@ -140,7 +140,7 @@ igt_main {
 			}
 		}
 
-#ifdef HAVE_CHAMELIUM
+#ifdef HAVE_CHAMELIUM_V2
 		igt_describe("Make sure that Chamelium is configured and reachable.");
 		igt_subtest("chamelium") {
 			struct chamelium *chamelium =
tests/kms_tiled_display.c +3 -3
index 2c9d637994d4..834b3e2f18a7 100644
@@ -82,7 +82,7 @@ typedef struct {
 	struct timeval first_ts;
 	int linetime_us;
 
-#ifdef HAVE_CHAMELIUM
+#ifdef HAVE_CHAMELIUM_V2
 	struct chamelium *chamelium;
 	struct chamelium_port **ports;
 	int port_count;
@@ -394,7 +394,7 @@ static bool got_all_page_flips(data_t *data)
 	return true;
 }
 
-#ifdef HAVE_CHAMELIUM
+#ifdef HAVE_CHAMELIUM_V2
 static void test_with_chamelium(data_t *data)
 {
 	int i, count = 0;
@@ -607,7 +607,7 @@ igt_main
 		test_cleanup(&data);
 	}
 
-#ifdef HAVE_CHAMELIUM
+#ifdef HAVE_CHAMELIUM_V2
 	igt_describe("Make sure the Tiled CRTCs are synchronized and we get "
 		     "page flips for all tiled CRTCs in one vblank (executes on chamelium).");
 	igt_subtest_f("basic-test-pattern-with-chamelium") {
tests/meson.build +4 -4
index 30cd7982ea77..e7c8416dabcf 100644
@@ -316,7 +316,7 @@ intel_xe_progs = [
 	'xe_sysfs_scheduler',
 ]
 
-chamelium_progs = [
+chamelium_v2_progs = [
 	'kms_chamelium_audio',
 	'kms_chamelium_color',
 	'kms_chamelium_edid',
@@ -419,8 +419,8 @@ foreach prog : intel_progs
 	endif
 endforeach
 
-if chamelium.found()
-	foreach prog : chamelium_progs
+if chamelium_v2.found()
+	foreach prog : chamelium_v2_progs
 		testexe = executable(prog,
 				 [join_paths('chamelium', 'v2', prog + '.c')] + extra_sources.get(prog, []),
 				 dependencies : test_deps + extra_dependencies.get(prog, []),
@@ -438,7 +438,7 @@ if chamelium.found()
 				    output : name + '.testlist')
 		endif
 	endforeach
-	test_deps += chamelium
+	test_deps += chamelium_v2
 endif
 
 subdir('amdgpu')
Signature · 1 line
2.44.2
#16 lore raw

PATCH v2 14/39 lib/chamelium/v3: Introduce the foundation for the Chamelium v3 wrapper

In reply to Louis Chauvet

Adds a build option to enable building the Chamelium v3 wrapper.

---
 lib/chamelium/v3/igt_chamelium.c |  9 +++++++++
 lib/chamelium/v3/igt_chamelium.h |  8 ++++++++
 lib/igt_kms.c                    |  8 ++++++++
 lib/meson.build                  |  7 +++++++
 lib/tests/meson.build            |  4 ++++
 meson.build                      | 17 ++++++++++++++++-
 meson_options.txt                |  4 ++++
 tests/meson.build                | 25 +++++++++++++++++++++++++
 8 files changed, 81 insertions(+), 1 deletion(-)
lib/chamelium/v3/igt_chamelium.c new file +9 -0
new file mode 100644
index 000000000000..9579bd2cd9f8
@@ -0,0 +1,9 @@
+// SPDX-License-Identifier: GPL-2.0
+
+#include <igt_core.h>
+#include "igt_chamelium.h"
+
+void chamelium_v3_init(void)
+{
+	igt_info("Using chamelium v3\n");
+}
lib/chamelium/v3/igt_chamelium.h new file +8 -0
new file mode 100644
index 000000000000..1848f66b574f
@@ -0,0 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+
+#ifndef V3_IGT_CHAMELIUM_H
+#define V3_IGT_CHAMELIUM_H
+
+void chamelium_v3_init(void);
+
+#endif //V3_IGT_CHAMELIUM_H
lib/igt_kms.c +8 -0
index 059c61bf222a..6c2b7cc4f5bd 100644
@@ -2883,7 +2883,14 @@ void igt_display_require(igt_display_t *display, int drm_fd)
 	if (!resources)
 		goto out;
 
+/*
+ * FIXME: Dirty hack to avoid those lines when chamelium v3 is used
+ *
+ * Must be replaced with a configuration file information, so the end user can choose if the
+ * chamelium must be connected or not.
+ */
 #ifdef HAVE_CHAMELIUM_V2
+#ifndef HAVE_CHAMELIUM_V3
 	{
 		struct chamelium *chamelium;
 
@@ -2898,6 +2905,7 @@ void igt_display_require(igt_display_t *display, int drm_fd)
 			chamelium_deinit_rpc_only(chamelium);
 		}
 	}
+#endif
 #endif
 
 	igt_require_f(resources->count_crtcs <= IGT_MAX_PIPES,
lib/meson.build +7 -0
index 714990e96485..968f1164bf61 100644
@@ -197,6 +197,13 @@ if chamelium_v2.found()
 	lib_sources += 'monitor_edids/monitor_edids_helper.c'
 endif
 
+if chamelium_v3.found()
+	lib_deps += chamelium_v3
+	lib_sources += [
+		'chamelium/v3/igt_chamelium.c',
+	]
+endif
+
 if libprocps.found()
 	lib_deps += libprocps
 else
lib/tests/meson.build +4 -0
index f98c948bc827..15f484ba0d54 100644
@@ -39,6 +39,10 @@ if chamelium_v2.found()
 	lib_tests += 'igt_audio'
 endif
 
+if chamelium_v3.found()
+	lib_deps += chamelium_v3
+endif
+
 foreach lib_test : lib_tests
 	exec = executable(lib_test, lib_test + '.c', install : false,
 			dependencies : igt_deps)
meson.build +16 -1
index 1fbbe4802ad3..0bb4853535cf 100644
@@ -87,6 +87,7 @@ foreach cc_arg : cc_args
 endforeach
 
 build_chamelium_v2 = get_option('chamelium_v2')
+build_chamelium_v3 = get_option('chamelium_v3')
 build_docs = get_option('docs')
 build_tests = not get_option('tests').disabled()
 build_xe = not get_option('xe_driver').disabled()
@@ -172,7 +173,7 @@ if not xmlrpc.found() and xmlrpc_cmd.found()
 	endif
 endif
 
-if build_chamelium_v2.enabled() and not (xmlrpc.found() and xmlrpc_util.found() and xmlrpc_client.found())
+if (build_chamelium_v2.enabled() or build_chamelium_v3.enabled()) and not (xmlrpc.found() and xmlrpc_util.found() and xmlrpc_client.found())
 	error('Chamelium build forced and required dependency xmlrpc not found')
 endif
 
@@ -195,6 +196,20 @@ endif
 
 build_info += 'Build Chamelium v2 test: @0@'.format(chamelium_v2.found())
 
+
+if xmlrpc.found() and xmlrpc_util.found() and xmlrpc_client.found() and libcurl.found()
+	config.set('HAVE_CHAMELIUM_V3', 1)
+	chamelium_v3 = declare_dependency(dependencies : [
+										  xmlrpc,
+										  xmlrpc_util,
+										  xmlrpc_client,
+										  gsl,
+										  alsa,
+									  ])
+else
+	chamelium_v3 = disabler()
+endif
+
 pthreads = dependency('threads')
 math = cc.find_library('m')
 realtime = cc.find_library('rt')
meson_options.txt +4 -0
index fea91fb129aa..4d4047407854 100644
@@ -12,6 +12,10 @@ option('chamelium_v2',
        type : 'feature',
        description : 'Build Chamelium v2 test')
 
+option('chamelium_v3',
+       type : 'feature',
+       description : 'Build Chamelium v3 tests')
+
 option('valgrind',
        type : 'feature',
        description : 'Build with support for valgrind annotations')
tests/meson.build +25 -0
index e7c8416dabcf..6a736d1defd1 100644
@@ -324,6 +324,9 @@ chamelium_v2_progs = [
 	'kms_chamelium_hpd',
 ]
 
+chamelium_v3_progs = [
+]
+
 test_deps = [ igt_deps ]
 
 if libdrm_nouveau.found()
@@ -441,6 +444,28 @@ if chamelium_v2.found()
 	test_deps += chamelium_v2
 endif
 
+if chamelium_v3.found()
+	foreach prog : chamelium_v3_progs
+		testexe = executable(prog,
+				 [join_paths('chamelium', 'v3', prog + '.c')],
+				 dependencies : test_deps,
+				 install_dir : libexecdir,
+				 install_rpath : libexecdir_rpathdir,
+				 install : true)
+		test_list += prog
+		test_executables += testexe
+		name = prog.split('/').get(-1)
+		if not meson.is_cross_build()
+			testlist_files += custom_target(name + '.testlist',
+				    build_by_default : true,
+				    command : [testexe, '--show-testlist'],
+				    capture : true,
+				    output : name + '.testlist')
+		endif
+	endforeach
+	test_deps += chamelium_v3
+endif
+
 subdir('amdgpu')
 
 subdir('msm')
Signature · 1 line
2.44.2
#17 lore raw

Re: [PATCH i-g-t v2 14/39] lib/chamelium/v3: Introduce the foundation for the Chamelium v3 wrapper

Hi Louis,

Quoted 75 lines · Louis Chauvet

Adds a build option to enable building the Chamelium v3 wrapper.

---
  lib/chamelium/v3/igt_chamelium.c |  9 +++++++++
  lib/chamelium/v3/igt_chamelium.h |  8 ++++++++
  lib/igt_kms.c                    |  8 ++++++++
  lib/meson.build                  |  7 +++++++
  lib/tests/meson.build            |  4 ++++
  meson.build                      | 17 ++++++++++++++++-
  meson_options.txt                |  4 ++++
  tests/meson.build                | 25 +++++++++++++++++++++++++
  8 files changed, 81 insertions(+), 1 deletion(-)
lib/chamelium/v3/igt_chamelium.c new file +9 -0
new file mode 100644
index 000000000000..9579bd2cd9f8
@@ -0,0 +1,9 @@
+// SPDX-License-Identifier: GPL-2.0
+
+#include <igt_core.h>
+#include "igt_chamelium.h"
+
+void chamelium_v3_init(void)
+{
+	igt_info("Using chamelium v3\n");
+}
lib/chamelium/v3/igt_chamelium.h new file +8 -0
new file mode 100644
index 000000000000..1848f66b574f
@@ -0,0 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+
+#ifndef V3_IGT_CHAMELIUM_H
+#define V3_IGT_CHAMELIUM_H
+
+void chamelium_v3_init(void);
+
+#endif //V3_IGT_CHAMELIUM_H
lib/igt_kms.c +8 -0
index 059c61bf222a..6c2b7cc4f5bd 100644
@@ -2883,7 +2883,14 @@ void igt_display_require(igt_display_t *display, int drm_fd)
  	if (!resources)
  		goto out;
 
+/*
+ * FIXME: Dirty hack to avoid those lines when chamelium v3 is used
+ *
+ * Must be replaced with a configuration file information, so the end user can choose if the
+ * chamelium must be connected or not.
+ */
  #ifdef HAVE_CHAMELIUM_V2
+#ifndef HAVE_CHAMELIUM_V3
  	{
  		struct chamelium *chamelium;
 
@@ -2898,6 +2905,7 @@ void igt_display_require(igt_display_t *display, int drm_fd)
  			chamelium_deinit_rpc_only(chamelium);
  		}
  	}
+#endif
  #endif
 
  	igt_require_f(resources->count_crtcs <= IGT_MAX_PIPES,
lib/meson.build +0 -0
index 714990e96485..968f1164bf61 100644

lib/meson.build if chamelium_v2.found() · line 204

Quoted 8 lines
lib/meson.build +5 -0
@@ -197,6 +197,13 @@ if chamelium_v2.found()
  	lib_sources += 'monitor_edids/monitor_edids_helper.c'
  endif
 
+if chamelium_v3.found()
+	lib_deps += chamelium_v3
+	lib_sources += [
+		'chamelium/v3/igt_chamelium.c',
+	]

We need to add "lib_sources += 'monitor_edids/monitor_edids_helper.c'" to fix undefined reference to error.

Quoted 44 lines
lib/meson.build +2 -0
+endif
+
  if libprocps.found()
  	lib_deps += libprocps
  else
lib/tests/meson.build +4 -0
index f98c948bc827..15f484ba0d54 100644
@@ -39,6 +39,10 @@ if chamelium_v2.found()
  	lib_tests += 'igt_audio'
  endif
 
+if chamelium_v3.found()
+	lib_deps += chamelium_v3
+endif
+
  foreach lib_test : lib_tests
  	exec = executable(lib_test, lib_test + '.c', install : false,
  			dependencies : igt_deps)
meson.build +2 -1
index 1fbbe4802ad3..0bb4853535cf 100644
@@ -87,6 +87,7 @@ foreach cc_arg : cc_args
  endforeach
 
  build_chamelium_v2 = get_option('chamelium_v2')
+build_chamelium_v3 = get_option('chamelium_v3')
  build_docs = get_option('docs')
  build_tests = not get_option('tests').disabled()
  build_xe = not get_option('xe_driver').disabled()
@@ -172,7 +173,7 @@ if not xmlrpc.found() and xmlrpc_cmd.found()
  	endif
  endif
 
-if build_chamelium_v2.enabled() and not (xmlrpc.found() and xmlrpc_util.found() and xmlrpc_client.found())
+if (build_chamelium_v2.enabled() or build_chamelium_v3.enabled()) and not (xmlrpc.found() and xmlrpc_util.found() and xmlrpc_client.found())
  	error('Chamelium build forced and required dependency xmlrpc not found')
  endif
 
@@ -195,6 +196,20 @@ endif
 
  build_info += 'Build Chamelium v2 test: @0@'.format(chamelium_v2.found())

meson.build endif · line 207

Quoted 10 lines
meson.build +9 -0
 
+
+if xmlrpc.found() and xmlrpc_util.found() and xmlrpc_client.found() and libcurl.found()
+	config.set('HAVE_CHAMELIUM_V3', 1)
+	chamelium_v3 = declare_dependency(dependencies : [
+										  xmlrpc,
+										  xmlrpc_util,
+										  xmlrpc_client,
+										  gsl,
+										  alsa,

gsl and alsa can be removed for v3?

Quoted 57 lines
meson.build +5 -0
+									  ])
+else
+	chamelium_v3 = disabler()
+endif
+
  pthreads = dependency('threads')
  math = cc.find_library('m')
  realtime = cc.find_library('rt')
meson_options.txt +4 -0
index fea91fb129aa..4d4047407854 100644
@@ -12,6 +12,10 @@ option('chamelium_v2',
         type : 'feature',
         description : 'Build Chamelium v2 test')
 
+option('chamelium_v3',
+       type : 'feature',
+       description : 'Build Chamelium v3 tests')
+
  option('valgrind',
         type : 'feature',
         description : 'Build with support for valgrind annotations')
tests/meson.build +18 -0
index e7c8416dabcf..6a736d1defd1 100644
@@ -324,6 +324,9 @@ chamelium_v2_progs = [
  	'kms_chamelium_hpd',
  ]
 
+chamelium_v3_progs = [
+]
+
  test_deps = [ igt_deps ]
 
  if libdrm_nouveau.found()
@@ -441,6 +444,28 @@ if chamelium_v2.found()
  	test_deps += chamelium_v2
  endif
 
+if chamelium_v3.found()
+	foreach prog : chamelium_v3_progs
+		testexe = executable(prog,
+				 [join_paths('chamelium', 'v3', prog + '.c')],
+				 dependencies : test_deps,
+				 install_dir : libexecdir,
+				 install_rpath : libexecdir_rpathdir,
+				 install : true)
+		test_list += prog
+		test_executables += testexe
+		name = prog.split('/').get(-1)
+		if not meson.is_cross_build()
+			testlist_files += custom_target(name + '.testlist',
+				    build_by_default : true,
+				    command : [testexe, '--show-testlist'],

tests/meson.build if chamelium_v2.found() · line 471

Quoted 10 lines
tests/meson.build +7 -0
+				    capture : true,
+				    output : name + '.testlist')
+		endif
+	endforeach
+	test_deps += chamelium_v3
+endif
+
  subdir('amdgpu')
 
  subdir('msm')

Regards,
Vignesh

#18 lore raw

Re: [PATCH i-g-t v2 14/39] lib/chamelium/v3: Introduce the foundation for the Chamelium v3 wrapper

Quoted 81 lines · Vignesh Raman

Hi Louis,

Quoted 78 lines · Louis Chauvet

Adds a build option to enable building the Chamelium v3 wrapper.

---
  lib/chamelium/v3/igt_chamelium.c |  9 +++++++++
  lib/chamelium/v3/igt_chamelium.h |  8 ++++++++
  lib/igt_kms.c                    |  8 ++++++++
  lib/meson.build                  |  7 +++++++
  lib/tests/meson.build            |  4 ++++
  meson.build                      | 17 ++++++++++++++++-
  meson_options.txt                |  4 ++++
  tests/meson.build                | 25 +++++++++++++++++++++++++
  8 files changed, 81 insertions(+), 1 deletion(-)
lib/chamelium/v3/igt_chamelium.c new file +9 -0
new file mode 100644
index 000000000000..9579bd2cd9f8
@@ -0,0 +1,9 @@
+// SPDX-License-Identifier: GPL-2.0
+
+#include <igt_core.h>
+#include "igt_chamelium.h"
+
+void chamelium_v3_init(void)
+{
+	igt_info("Using chamelium v3\n");
+}
lib/chamelium/v3/igt_chamelium.h new file +8 -0
new file mode 100644
index 000000000000..1848f66b574f
@@ -0,0 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+
+#ifndef V3_IGT_CHAMELIUM_H
+#define V3_IGT_CHAMELIUM_H
+
+void chamelium_v3_init(void);
+
+#endif //V3_IGT_CHAMELIUM_H
lib/igt_kms.c +8 -0
index 059c61bf222a..6c2b7cc4f5bd 100644
@@ -2883,7 +2883,14 @@ void igt_display_require(igt_display_t *display, int drm_fd)
  	if (!resources)
  		goto out;
 
+/*
+ * FIXME: Dirty hack to avoid those lines when chamelium v3 is used
+ *
+ * Must be replaced with a configuration file information, so the end user can choose if the
+ * chamelium must be connected or not.
+ */
  #ifdef HAVE_CHAMELIUM_V2
+#ifndef HAVE_CHAMELIUM_V3
  	{
  		struct chamelium *chamelium;
 
@@ -2898,6 +2905,7 @@ void igt_display_require(igt_display_t *display, int drm_fd)
  			chamelium_deinit_rpc_only(chamelium);
  		}
  	}
+#endif
  #endif
 
  	igt_require_f(resources->count_crtcs <= IGT_MAX_PIPES,
lib/meson.build +0 -0
index 714990e96485..968f1164bf61 100644
@@ -197,6 +197,13 @@ if chamelium_v2.found()
  	lib_sources += 'monitor_edids/monitor_edids_helper.c'
  endif
 
Quoted 8 lines

lib/meson.build if chamelium_v2.found() · line 204

Quoted 5 lines
lib/meson.build +5 -0
+if chamelium_v3.found()
+	lib_deps += chamelium_v3
+	lib_sources += [
+		'chamelium/v3/igt_chamelium.c',
+	]

We need to add "lib_sources += 'monitor_edids/monitor_edids_helper.c'" to fix undefined reference to error.

Will be fixed for v2.

Quoted 45 lines
Quoted 45 lines
lib/meson.build +2 -0
+endif
+
  if libprocps.found()
  	lib_deps += libprocps
  else
lib/tests/meson.build +4 -0
index f98c948bc827..15f484ba0d54 100644
@@ -39,6 +39,10 @@ if chamelium_v2.found()
  	lib_tests += 'igt_audio'
  endif
 
+if chamelium_v3.found()
+	lib_deps += chamelium_v3
+endif
+
  foreach lib_test : lib_tests
  	exec = executable(lib_test, lib_test + '.c', install : false,
  			dependencies : igt_deps)
meson.build +2 -1
index 1fbbe4802ad3..0bb4853535cf 100644
@@ -87,6 +87,7 @@ foreach cc_arg : cc_args
  endforeach
 
  build_chamelium_v2 = get_option('chamelium_v2')
+build_chamelium_v3 = get_option('chamelium_v3')
  build_docs = get_option('docs')
  build_tests = not get_option('tests').disabled()
  build_xe = not get_option('xe_driver').disabled()
@@ -172,7 +173,7 @@ if not xmlrpc.found() and xmlrpc_cmd.found()
  	endif
  endif
 
-if build_chamelium_v2.enabled() and not (xmlrpc.found() and xmlrpc_util.found() and xmlrpc_client.found())
+if (build_chamelium_v2.enabled() or build_chamelium_v3.enabled()) and not (xmlrpc.found() and xmlrpc_util.found() and xmlrpc_client.found())
  	error('Chamelium build forced and required dependency xmlrpc not found')
  endif
 
@@ -195,6 +196,20 @@ endif
 
  build_info += 'Build Chamelium v2 test: @0@'.format(chamelium_v2.found())
 
Quoted 11 lines

meson.build endif · line 207

Quoted 9 lines
meson.build +9 -0
+
+if xmlrpc.found() and xmlrpc_util.found() and xmlrpc_client.found() and libcurl.found()
+	config.set('HAVE_CHAMELIUM_V3', 1)
+	chamelium_v3 = declare_dependency(dependencies : [
+										  xmlrpc,
+										  xmlrpc_util,
+										  xmlrpc_client,
+										  gsl,
+										  alsa,

gsl and alsa can be removed for v3?

Yes, I missed it, thanks!

Quoted 70 lines
Quoted 57 lines
meson.build +5 -0
+									  ])
+else
+	chamelium_v3 = disabler()
+endif
+
  pthreads = dependency('threads')
  math = cc.find_library('m')
  realtime = cc.find_library('rt')
meson_options.txt +4 -0
index fea91fb129aa..4d4047407854 100644
@@ -12,6 +12,10 @@ option('chamelium_v2',
         type : 'feature',
         description : 'Build Chamelium v2 test')
 
+option('chamelium_v3',
+       type : 'feature',
+       description : 'Build Chamelium v3 tests')
+
  option('valgrind',
         type : 'feature',
         description : 'Build with support for valgrind annotations')
tests/meson.build +18 -0
index e7c8416dabcf..6a736d1defd1 100644
@@ -324,6 +324,9 @@ chamelium_v2_progs = [
  	'kms_chamelium_hpd',
  ]
 
+chamelium_v3_progs = [
+]
+
  test_deps = [ igt_deps ]
 
  if libdrm_nouveau.found()
@@ -441,6 +444,28 @@ if chamelium_v2.found()
  	test_deps += chamelium_v2
  endif
 
+if chamelium_v3.found()
+	foreach prog : chamelium_v3_progs
+		testexe = executable(prog,
+				 [join_paths('chamelium', 'v3', prog + '.c')],
+				 dependencies : test_deps,
+				 install_dir : libexecdir,
+				 install_rpath : libexecdir_rpathdir,
+				 install : true)
+		test_list += prog
+		test_executables += testexe
+		name = prog.split('/').get(-1)
+		if not meson.is_cross_build()
+			testlist_files += custom_target(name + '.testlist',
+				    build_by_default : true,
+				    command : [testexe, '--show-testlist'],

tests/meson.build if chamelium_v2.found() · line 471

Quoted 10 lines
tests/meson.build +7 -0
+				    capture : true,
+				    output : name + '.testlist')
+		endif
+	endforeach
+	test_deps += chamelium_v3
+endif
+
  subdir('amdgpu')
 
  subdir('msm')

Regards,
Vignesh

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

PATCH v2 15/39 lib/chamelium/v3: Introduce initialization and cleanup of Chamelium-related structures

In reply to Louis Chauvet

In preparation for utilizing the Chamelium in tests, this commit introduces a few helper functions to read the Chamelium configuration from a file and initialize RPC-related structures.

---
 lib/chamelium/v3/igt_chamelium.c | 148 ++++++++++++++++++++++++++++++++++++++-
 lib/chamelium/v3/igt_chamelium.h |  39 ++++++++++-
 2 files changed, 183 insertions(+), 4 deletions(-)
lib/chamelium/v3/igt_chamelium.c +145 -3
index 9579bd2cd9f8..7a5a1ff19e4b 100644
@@ -1,9 +1,151 @@
 // SPDX-License-Identifier: GPL-2.0
 
-#include <igt_core.h>
+#include <xmlrpc-c/base.h>
+#include <xmlrpc-c/client.h>
+
 #include "igt_chamelium.h"
+#include "igt_core.h"
+#include "igt_rc.h"
+
+#define CHAMELIUM_CONFIG_SECTION "Chameliumv3"
+#define CHAMELIUM_CONFIG_URL "URL"
+
+struct igt_chamelium_v3 {
+	xmlrpc_env env;
+	xmlrpc_client *client;
+	char *url;
+
+	struct igt_list_head port_mapping;
+};
+
+/**
+ * chamelium_v3_port_mapping_alloc - Allocate a port mapping with some default values
+ *
+ * @port_mapping: port mapping to free. The caller must remove the element from the list.
+ */
+static struct chamelium_v3_port_mapping *chamelium_v3_port_mapping_alloc(void)
+{
+	struct chamelium_v3_port_mapping *port_mapping = malloc(sizeof(*port_mapping));
+
+	igt_assert(port_mapping);
+	port_mapping->connector_name = NULL;
+	port_mapping->mst_path = NULL;
+	port_mapping->port_id = 0;
+	port_mapping->parent_id = 0;
+	port_mapping->is_children = false;
+	return port_mapping;
+}
 
-void chamelium_v3_init(void)
+/**
+ * chamelium_v3_port_mapping_free - Free memory assiciated with a port mapping
+ *
+ * @port_mapping: port mapping to free. The caller must remove the element from the list.
+ */
+static void chamelium_v3_port_mapping_free(struct chamelium_v3_port_mapping *port_mapping)
 {
-	igt_info("Using chamelium v3\n");
+	if (port_mapping->connector_name)
+		free(port_mapping->connector_name);
+	if (port_mapping->mst_path)
+		free(port_mapping->mst_path);
+	free(port_mapping);
 }
+
+/**
+ * chamelium_v3_init() - Initialize the RPC connexion with a chamelium
+ *
+ * @url: URL to connect to the chamelium
+ *
+ * Returns a igt_chamelium_v3 pointer, which must be freed by chamelium_v3_uninit.
+ */
+struct igt_chamelium_v3 *chamelium_v3_init(char *url)
+{
+	struct igt_chamelium_v3 *chamelium = malloc(sizeof(struct igt_chamelium_v3));
+	struct xmlrpc_clientparms clientparms;
+	struct xmlrpc_curl_xportparms curlparms;
+
+	if (!chamelium)
+		return NULL;
+
+	memset(chamelium, 0, sizeof(*chamelium));
+	memset(&clientparms, 0, sizeof(clientparms));
+	memset(&curlparms, 0, sizeof(curlparms));
+
+	/* curl's timeout is in milliseconds */
+	curlparms.timeout = 10 * 1000;
+
+	clientparms.transport = "curl";
+	clientparms.transportparmsP = &curlparms;
+	clientparms.transportparm_size = XMLRPC_CXPSIZE(timeout);
+
+	/* Setup the libxmlrpc context */
+	xmlrpc_env_init(&chamelium->env);
+	xmlrpc_client_setup_global_const(&chamelium->env);
+	xmlrpc_client_create(&chamelium->env, XMLRPC_CLIENT_NO_FLAGS, PACKAGE,
+			     PACKAGE_VERSION, &clientparms, 0, &chamelium->client);
+	if (chamelium->env.fault_occurred) {
+		igt_debug("Failed to init xmlrpc: %s\n",
+			  chamelium->env.fault_string);
+		goto error;
+	}
+
+	chamelium->url = strdup(url);
+	IGT_INIT_LIST_HEAD(&chamelium->port_mapping);
+
+	return chamelium;
+error:
+	chamelium_v3_uninit(chamelium);
+	return NULL;
+}
+
+/**
+ * chamelium_v3_init_from_config() - Initialize the RPC connexion with a chamelium from the config
+ * file
+ *
+ * Returns a igt_chamelium_v3 pointer, which must be freed by chamelium_v3_uninit.
+ */
+struct igt_chamelium_v3 *chamelium_v3_init_from_config(void)
+{
+	struct igt_chamelium_v3 *chamelium;
+	GError *error = NULL;
+	char *url;
+
+	if (!igt_key_file) {
+		igt_debug("No configuration file available for chamelium\n");
+		return NULL;
+	}
+
+	url = g_key_file_get_string(igt_key_file, CHAMELIUM_CONFIG_SECTION, CHAMELIUM_CONFIG_URL,
+				    &error);
+	if (!url) {
+		igt_debug("Couldn't read chamelium URL from config file: %s\n", error->message);
+		return false;
+	}
+
+	chamelium = chamelium_v3_init(url);
+	free(url);
+	return chamelium;
+}
+
+/**
+ * chamelium_v3_uninit() - Free the resources used by a chamelium
+ *
+ * @chamelium: The Chamelium instance to free
+ *
+ * Frees the resources used by a connection to the chamelium that was set up
+ * with chamelium_rpc_init().
+ */
+void chamelium_v3_uninit(struct igt_chamelium_v3 *chamelium)
+{
+	struct chamelium_v3_port_mapping *port_mapping, *tmp_port_mapping;
+
+	/* Destroy any mapping we created to make sure we don't leak them */
+	igt_list_for_each_entry_safe(port_mapping, tmp_port_mapping, &chamelium->port_mapping,
+				     link) {
+		chamelium_v3_port_mapping_free(port_mapping);
+	}
+	xmlrpc_client_destroy(chamelium->client);
+	xmlrpc_env_clean(&chamelium->env);
+	free(chamelium->url);
+	free(chamelium);
+}
+
lib/chamelium/v3/igt_chamelium.h +38 -1
index 1848f66b574f..759a1f4d59e2 100644
@@ -3,6 +3,43 @@
 #ifndef V3_IGT_CHAMELIUM_H
 #define V3_IGT_CHAMELIUM_H
 
-void chamelium_v3_init(void);
+#include <stdint.h>
+
+#include "igt_list.h"
+
+struct igt_chamelium_v3;
+typedef uint32_t chamelium_v3_port_id;
+
+/** struct chamelium_v3_port_mapping - Represent a mapping between a DRM connector and a port on
+ * the chamelium
+ *
+ * @port_id: Chamelium port ID.
+ * @connector_name: DRM connector name, used to identify the connector in DRM, mutually exclusive
+ *		    with @mst_path
+ * @mst_path: MST path property, used to identify the connector in DRM, mutually exclusive with
+ *	      @mst_path
+ * @is_children: Used to indicate that this chamelium port is a children and can't be plugged alone
+ * @parent_id: Used when @is_children is true to point to the correct parent in chamelium
+ * @link: Linked list structure
+ */
+struct chamelium_v3_port_mapping {
+	chamelium_v3_port_id port_id;
+
+	/* For normal DRM connector */
+	char *connector_name;
+
+	/* For MST connector  */
+	char *mst_path;
+	bool is_children;
+	chamelium_v3_port_id parent_id;
+
+	/* Implementation details */
+	struct igt_list_head link;
+};
+
+struct igt_chamelium_v3 *chamelium_v3_init(char *url);
+struct igt_chamelium_v3 *chamelium_v3_init_from_config(void);
+
+void chamelium_v3_uninit(struct igt_chamelium_v3 *chamelium);
 
 #endif //V3_IGT_CHAMELIUM_H
Signature · 1 line
2.44.2
#20 lore raw

PATCH v2 16/39 lib/chamelium/v3: Add method to discover Chamelium ports

In reply to Louis Chauvet

Since Chamelium v3 ports can change (recently added MST ports, for example), they need to be discovered to prevent using an incorrect port.

This commit introduces the RPC calls GetSupportedPorts, IsMst, and GetChildren to list all ports, check if a port is MST-capable, and fetch the child ports of MST ports, respectively.

---
 lib/chamelium/v3/igt_chamelium.c | 133 +++++++++++++++++++++++++++++++++++++++
 lib/chamelium/v3/igt_chamelium.h |   6 ++
 2 files changed, 139 insertions(+)
lib/chamelium/v3/igt_chamelium.c +133 -0
index 7a5a1ff19e4b..c4c75c57fa64 100644
@@ -149,3 +149,136 @@ void chamelium_v3_uninit(struct igt_chamelium_v3 *chamelium)
 	free(chamelium);
 }
 
+/**
+ * __chamelium_rpc - Call a remote function on the chamelium
+ *
+ * @chamelium: Chamelium to call the function on
+ * @method_name: RPC endpoint name
+ * @format_str: RPC parameters description
+ * @...: RPC parameters
+ *
+ * Returns a xmlrpc_value that contains the call result.
+ */
+static xmlrpc_value *__chamelium_rpc(struct igt_chamelium_v3 *chamelium,
+				     const char *method_name,
+				     const char *format_str,
+				     ...)
+{
+	xmlrpc_value *res;
+	va_list va_args;
+
+	if (chamelium->env.fault_occurred) {
+		xmlrpc_env_clean(&chamelium->env);
+		xmlrpc_env_init(&chamelium->env);
+	}
+	va_start(va_args, format_str);
+	xmlrpc_client_call2f_va(&chamelium->env, chamelium->client,
+				chamelium->url, method_name, format_str, &res,
+				va_args);
+	va_end(va_args);
+	igt_assert_f(!chamelium->env.fault_occurred,
+		     "Chamelium RPC call[%s] failed: %s\n", method_name,
+		     chamelium->env.fault_string);
+	return res;
+}
+
+/*
+ * For the RPC calls, please refer to the python code [1] for documentation.
+ *
+ * [1]: https://chromium.googlesource.com/chromiumos/platform/chameleon/+/refs/heads/main/v3/chameleond/v3.py
+ */
+
+/**
+ * chamelium_v3_get_supported_ports - Get the list of ports on the chamelium
+ *
+ * @chamelium: Chamelium to get the ports from
+ * @port_ids: Out pointer for the list of port ids
+ *
+ * Returns the number of element stored in @port_ids. The caller must free this pointer when not
+ * used anymore.
+ */
+int chamelium_v3_get_supported_ports(struct igt_chamelium_v3 *chamelium,
+				     chamelium_v3_port_id **port_ids)
+{
+	xmlrpc_value *res, *res_port;
+	int port_count, i;
+
+	igt_assert(port_ids);
+
+	igt_debug("RPC GetSupportedPorts()\n");
+	res = __chamelium_rpc(chamelium, "GetSupportedPorts", "()");
+
+	port_count = xmlrpc_array_size(&chamelium->env, res);
+	*port_ids = calloc(port_count, sizeof(**port_ids));
+
+	for (i = 0; i < port_count; i++) {
+		xmlrpc_array_read_item(&chamelium->env, res, i, &res_port);
+		xmlrpc_read_int(&chamelium->env, res_port, (int *)&(*port_ids)[i]);
+		xmlrpc_DECREF(res_port);
+	}
+	xmlrpc_DECREF(res);
+
+	return port_count;
+}
+
+/**
+ * chamelium_v3_get_supported_ports - Get the list of children port for a specific port on the
+ *	chamelium
+ *
+ * @chamelium: Chamelium to get the ports from
+ * @port_id: Parent port id to get the children port from
+ * @port_ids: Out pointer for the list of port ids
+ *
+ * MST ports on the chamelium have children ports that can be plugged independently, but are always
+ * connected with a parent connector.
+ *
+ * Returns the number of element stored in @port_ids. The caller must free this pointer when not
+ * used anymore.
+ */
+int chamelium_v3_get_children(struct igt_chamelium_v3 *chamelium, chamelium_v3_port_id port_id,
+			      chamelium_v3_port_id **port_ids)
+{
+	xmlrpc_value *res, *res_port;
+	int port_count, i;
+
+	igt_debug("RPC GetChildren(%d)\n", port_id);
+	res = __chamelium_rpc(chamelium, "GetChildren", "(i)", port_id);
+
+	port_count = xmlrpc_array_size(&chamelium->env, res);
+	*port_ids = calloc(port_count, sizeof(**port_ids));
+
+	for (i = 0; i < port_count; i++) {
+		xmlrpc_array_read_item(&chamelium->env, res, i, &res_port);
+		xmlrpc_read_int(&chamelium->env, res_port, (int *)&(*port_ids)[i]);
+		xmlrpc_DECREF(res_port);
+	}
+	xmlrpc_DECREF(res);
+
+	return port_count;
+}
+
+/**
+ * chamelium_v3_is_mst - Get the MST support for a specific port
+ *
+ * @chamelium: Chamelium to get the ports from
+ * @port_id: Port to get the support from
+ *
+ * Not all ports on the chamelium support MST. This functions allows checking if a specific port
+ * supports MST.
+ *
+ * Returns true if the @port_id supports MST.
+ */
+bool chamelium_v3_is_mst(struct igt_chamelium_v3 *chamelium, chamelium_v3_port_id port_id)
+{
+	xmlrpc_value *res;
+	xmlrpc_bool is_mst;
+
+	igt_debug("RPC IsMst(%d)\n", port_id);
+	res = __chamelium_rpc(chamelium, "IsMst", "(i)", port_id);
+
+	xmlrpc_read_bool(&chamelium->env, res, &is_mst);
+
+	xmlrpc_DECREF(res);
+
+	return is_mst;
+}
lib/chamelium/v3/igt_chamelium.h +6 -0
index 759a1f4d59e2..763ab4bc0304 100644
@@ -42,4 +42,10 @@ struct igt_chamelium_v3 *chamelium_v3_init_from_config(void);
 
 void chamelium_v3_uninit(struct igt_chamelium_v3 *chamelium);
 
+int chamelium_v3_get_supported_ports(struct igt_chamelium_v3 *chamelium,
+				     chamelium_v3_port_id **port_ids);
+int chamelium_v3_get_children(struct igt_chamelium_v3 *chamelium, chamelium_v3_port_id port_id,
+			      chamelium_v3_port_id **port_ids);
+bool chamelium_v3_is_mst(struct igt_chamelium_v3 *chamelium, chamelium_v3_port_id port_id);
+
 #endif //V3_IGT_CHAMELIUM_H
Signature · 1 line
2.44.2
#21 lore raw

PATCH v2 17/39 lib/chamelium/v3: Implement method to retrieve Chamelium port names

In reply to Louis Chauvet

Chamelium ports have descriptive names associated with them. This commit introduces an RPC call to fetch these names, facilitating easier debugging and better understanding of the port configuration.

---
 lib/chamelium/v3/igt_chamelium.c | 25 +++++++++++++++++++++++++
 lib/chamelium/v3/igt_chamelium.h |  1 +
 2 files changed, 26 insertions(+)
lib/chamelium/v3/igt_chamelium.c +25 -0
index c4c75c57fa64..5a7e42334e81 100644
@@ -282,3 +282,28 @@ bool chamelium_v3_is_mst(struct igt_chamelium_v3 *chamelium, chamelium_v3_port_i
 
 	return is_mst;
 }
+
+/**
+ * chamelium_v3_get_port_name - Get the port name from its id
+ *
+ * @chamelium: Chamelium to get the ports from
+ * @port_id: Port to get the name
+ *
+ * Returns a string containing the port name for @port_id. The caller must free this pointer when
+ * not used anymore.
+ */
+char *chamelium_v3_get_port_name(struct igt_chamelium_v3 *chamelium,
+				 chamelium_v3_port_id port_id)
+{
+	xmlrpc_value *res;
+	char *port_name;
+
+	igt_debug("RPC GetPortName(%d)\n", port_id);
+	res = __chamelium_rpc(chamelium, "GetPortName", "(i)", port_id);
+
+	xmlrpc_read_string(&chamelium->env, res, (const char **)&port_name);
+
+	xmlrpc_DECREF(res);
+
+	return port_name;
+}
lib/chamelium/v3/igt_chamelium.h +1 -0
index 763ab4bc0304..ae3225873bfb 100644
@@ -47,5 +47,6 @@ int chamelium_v3_get_supported_ports(struct igt_chamelium_v3 *chamelium,
 int chamelium_v3_get_children(struct igt_chamelium_v3 *chamelium, chamelium_v3_port_id port_id,
 			      chamelium_v3_port_id **port_ids);
 bool chamelium_v3_is_mst(struct igt_chamelium_v3 *chamelium, chamelium_v3_port_id port_id);
+char *chamelium_v3_get_port_name(struct igt_chamelium_v3 *chamelium, chamelium_v3_port_id port_id);
 
 #endif //V3_IGT_CHAMELIUM_H
Signature · 1 line
2.44.2
#22 lore raw

PATCH v2 18/39 tests/chamelium/v3: Implement a basic Chamelium v3 accessibility test

In reply to Louis Chauvet

Utilizing the RPC calls introduced earlier, this commit adds a simple test to verify if the Chamelium v3 device is accessible.

---
 tests/chamelium/v3/kms_chamelium_v3_basic.c | 30 +++++++++++++++++++++++++++++
 tests/meson.build                           |  1 +
 2 files changed, 31 insertions(+)
tests/chamelium/v3/kms_chamelium_v3_basic.c new file +30 -0
new file mode 100644
index 000000000000..4d48e68e2936
@@ -0,0 +1,30 @@
+// SPDX-License-Identifier: MIT
+
+#include <igt.h>
+#include "chamelium/v3/igt_chamelium.h"
+
+igt_main
+{
+	struct igt_chamelium_v3 *chamelium;
+
+	igt_describe("Test if the chamelium can list all the ports.");
+	igt_subtest("chamelium-list-ports") {
+		chamelium_v3_port_id *ports;
+		int port_count;
+
+		chamelium = chamelium_v3_init_from_config();
+
+		port_count = chamelium_v3_get_supported_ports(chamelium, &ports);
+
+		for (int i = 0; i < port_count; i++) {
+			char *name = chamelium_v3_get_port_name(chamelium, ports[i]);
+
+			igt_info("Port %d: name: %s\n", ports[i], name);
+			free(name);
+		}
+
+		free(ports);
+
+		chamelium_v3_uninit(chamelium);
+	}
+}
tests/meson.build +1 -0
index 6a736d1defd1..e36ae9b18ffc 100644
@@ -325,6 +325,7 @@ chamelium_v2_progs = [
 ]
 
 chamelium_v3_progs = [
+	'kms_chamelium_v3_basic',
 ]
 
 test_deps = [ igt_deps ]
Signature · 1 line
2.44.2
#23 lore raw

PATCH v2 19/39 lib/chamelium/v3: Implement Chamelium reinitialization via Reset RPC call

In reply to Louis Chauvet

Introduce the Reset RPC function to reinitialize the Chamelium, ensuring it returns to a known state. This feature is particularly useful for testing and debugging purposes.

---
 lib/chamelium/v3/igt_chamelium.c | 16 ++++++++++++++++
 lib/chamelium/v3/igt_chamelium.h |  1 +
 2 files changed, 17 insertions(+)
lib/chamelium/v3/igt_chamelium.c +16 -0
index 5a7e42334e81..af6ab5c6c9b7 100644
@@ -188,6 +188,22 @@ static xmlrpc_value *__chamelium_rpc(struct igt_chamelium_v3 *chamelium,
  * [1]: https://chromium.googlesource.com/chromiumos/platform/chameleon/+/refs/heads/main/v3/chameleond/v3.py
  */
 
+/**
+ * chamelium_v3_reset - Reset the chamelium
+ *
+ * @chamelium: Chamelium to reset
+ *
+ * Reset the chamelium to a know state (no plugged ports, no EDID applied...).
+ *
+ * Note: The current chamelium firmware does not reset scheduled hot plug, this may cause issue in
+ * some situations.
+ */
+void chamelium_v3_reset(struct igt_chamelium_v3 *chamelium)
+{
+	igt_debug("RPC Reset()\n");
+	xmlrpc_DECREF(__chamelium_rpc(chamelium, "Reset", "()"));
+}
+
 /**
  * chamelium_v3_get_supported_ports - Get the list of ports on the chamelium
  *
lib/chamelium/v3/igt_chamelium.h +1 -0
index ae3225873bfb..88b407dfd1ae 100644
@@ -42,6 +42,7 @@ struct igt_chamelium_v3 *chamelium_v3_init_from_config(void);
 
 void chamelium_v3_uninit(struct igt_chamelium_v3 *chamelium);
 
+void chamelium_v3_reset(struct igt_chamelium_v3 *chamelium);
 int chamelium_v3_get_supported_ports(struct igt_chamelium_v3 *chamelium,
 				     chamelium_v3_port_id **port_ids);
 int chamelium_v3_get_children(struct igt_chamelium_v3 *chamelium, chamelium_v3_port_id port_id,
Signature · 1 line
2.44.2
#24 lore raw

PATCH v2 20/39 lib/chamelium/v3: Implement methods for plugging Chamelium ports

In reply to Louis Chauvet

Introduce two new RPC calls, Plug and PlugWithChildren, to manage Chamelium port connections. The Plug method enables plugging physical ports (HDMI1/2, DP1/2), while the PlugWithChildren method allows plugging MST connectors (DP1 and its MST children).

---
 lib/chamelium/v3/igt_chamelium.c | 51 ++++++++++++++++++++++++++++++++++++++++
 lib/chamelium/v3/igt_chamelium.h |  4 ++++
 2 files changed, 55 insertions(+)
lib/chamelium/v3/igt_chamelium.c +51 -0
index af6ab5c6c9b7..334098d4dea6 100644
@@ -323,3 +323,54 @@ char *chamelium_v3_get_port_name(struct igt_chamelium_v3 *chamelium,
 
 	return port_name;
 }
+
+/**
+ * chamelium_v3_plug - Emulate a plug action on a specific port id
+ *
+ * @chamelium: Chamelium to get the ports from
+ * @port_id: Port to plug
+ *
+ * Emulate a connection action on the chamelium. It should have the same effect as physically
+ * plugging a connector.
+ *
+ * Note: The current chamelium have some issue with port 1: the plug/unplug action does not seems to
+ * works reliably. However, it works fine with port 5 (same physical connector, but use a different
+ * component to emulate MST).
+ */
+void chamelium_v3_plug(struct igt_chamelium_v3 *chamelium, chamelium_v3_port_id port_id)
+{
+	igt_debug("RPC Plug(%d)\n", port_id);
+	xmlrpc_DECREF(__chamelium_rpc(chamelium, "Plug", "(i)", port_id));
+}
+
+/**
+ * chamelium_v3_plug_with_children - Emulate a plug action on a specific port with MST children
+ *
+ * @chamelium: Chamelium to get the ports from
+ * @port_id: Parent port for MST
+ * @children: List of children port to plug. It must not include the parent port id.
+ * @children_port_count: Number of ports in @children
+ *
+ * Emulate a connection action on the chamelium using a MST device. The parent connector will always
+ * be plugged.
+ *
+ * The children pointer is not freed by this function and must be managed by the caller.
+ */
+void chamelium_v3_plug_with_children(struct igt_chamelium_v3 *chamelium,
+				     chamelium_v3_port_id port_id, chamelium_v3_port_id *children,
+				     size_t children_port_count)
+{
+	xmlrpc_value *tmp;
+	xmlrpc_value *children_array = xmlrpc_array_new(&chamelium->env);
+
+	for (int i = 0; i < children_port_count; i++) {
+		tmp = xmlrpc_int_new(&chamelium->env, (int) children[i]);
+		xmlrpc_array_append_item(&chamelium->env, children_array, tmp);
+		xmlrpc_DECREF(tmp);
+	}
+
+	igt_debug("RPC PlugWithChildren(%d, ...)\n", port_id);
+	xmlrpc_DECREF(__chamelium_rpc(chamelium, "PlugWithChildren", "(iA)", port_id,
+				      children_array));
+	xmlrpc_DECREF(children_array);
+}
lib/chamelium/v3/igt_chamelium.h +4 -0
index 88b407dfd1ae..9bad733b717b 100644
@@ -49,5 +49,9 @@ int chamelium_v3_get_children(struct igt_chamelium_v3 *chamelium, chamelium_v3_p
 			      chamelium_v3_port_id **port_ids);
 bool chamelium_v3_is_mst(struct igt_chamelium_v3 *chamelium, chamelium_v3_port_id port_id);
 char *chamelium_v3_get_port_name(struct igt_chamelium_v3 *chamelium, chamelium_v3_port_id port_id);
+void chamelium_v3_plug(struct igt_chamelium_v3 *chamelium, chamelium_v3_port_id port_id);
+void chamelium_v3_plug_with_children(struct igt_chamelium_v3 *chamelium,
+				     chamelium_v3_port_id port_id, chamelium_v3_port_id *children,
+				     size_t children_port_count);
 
 #endif //V3_IGT_CHAMELIUM_H
Signature · 1 line
2.44.2
#25 lore raw

PATCH v2 21/39 lib/chamelium/v3: Implement methods for managing Chamelium EDID

In reply to Louis Chauvet

Introduce functionality to apply different EDIDs to each Chamelium port. This includes uploading EDIDs and assigning identifiers for applying them to specific connectors. This feature allows for greater flexibility in configuring and testing display setups.

---
 lib/chamelium/v3/igt_chamelium.c | 47 +++++++++++++++++++++++++++++++++++++++-
 lib/chamelium/v3/igt_chamelium.h |  8 +++++++
 2 files changed, 54 insertions(+), 1 deletion(-)
lib/chamelium/v3/igt_chamelium.c +46 -1
index 334098d4dea6..767dfcfcb182 100644
@@ -364,7 +364,7 @@ void chamelium_v3_plug_with_children(struct igt_chamelium_v3 *chamelium,
 	xmlrpc_value *children_array = xmlrpc_array_new(&chamelium->env);
 
 	for (int i = 0; i < children_port_count; i++) {
-		tmp = xmlrpc_int_new(&chamelium->env, (int) children[i]);
+		tmp = xmlrpc_int_new(&chamelium->env, (int)children[i]);
 		xmlrpc_array_append_item(&chamelium->env, children_array, tmp);
 		xmlrpc_DECREF(tmp);
 	}
@@ -374,3 +374,48 @@ void chamelium_v3_plug_with_children(struct igt_chamelium_v3 *chamelium,
 				      children_array));
 	xmlrpc_DECREF(children_array);
 }
+
+/**
+ * chamelium_v3_create_edid - Upload an EDID to the chamelium
+ *
+ * @chamelium: Chamelium to get the ports from
+ * @edid: EDID to upload
+ *
+ * Upload an EDID to the chamelium. The returned value must then be used with
+ * chamelium_v3_apply_edid to associate this EDID with a port.
+ *
+ * If you prefer to not upload, the chamelium already has a default EDID that you can apply by using
+ * the value CHAMELIUM_V3_EDID_DEFAULT.
+ */
+chamelium_edid_id chamelium_v3_create_edid(struct igt_chamelium_v3 *chamelium,
+					   const struct edid *edid)
+{
+	xmlrpc_value *res;
+	chamelium_edid_id edid_id;
+
+	igt_debug("RPC CreateEdid(...)\n");
+	res = __chamelium_rpc(chamelium, "CreateEdid", "(6)",
+			      edid, edid_get_size(edid));
+	xmlrpc_read_int(&chamelium->env, res, &edid_id);
+	xmlrpc_DECREF(res);
+
+	return edid_id;
+}
+
+/**
+ * chamelium_v3_apply_edid - Set an EDID to a specific port
+ *
+ * @chamelium: Chamelium to get the ports from
+ * @port_id: Port to apply the EDID
+ * @edid_id: EDID to apply
+ *
+ * Apply a specific EDID to a port. The @edid_id is the value returned by a call to
+ * chamelium_v3_create_edid. For simplicity you can also use CHAMELIUM_V3_EDID_DEFAULT to use the
+ * default EDID.
+ */
+void chamelium_v3_apply_edid(struct igt_chamelium_v3 *chamelium,
+			     chamelium_v3_port_id port_id, chamelium_edid_id edid_id)
+{
+	igt_debug("RPC ApplyEdid(%d, %d)\n", port_id, edid_id);
+	xmlrpc_DECREF(__chamelium_rpc(chamelium, "ApplyEdid", "(ii)", port_id, edid_id));
+}
lib/chamelium/v3/igt_chamelium.h +8 -0
index 9bad733b717b..cab33e43aadd 100644
@@ -5,10 +5,14 @@
 
 #include <stdint.h>
 
+#include "igt_edid.h"
 #include "igt_list.h"
 
 struct igt_chamelium_v3;
 typedef uint32_t chamelium_v3_port_id;
+typedef int chamelium_edid_id;
+
+#define CHAMELIUM_V3_EDID_DEFAULT 0
 
 /** struct chamelium_v3_port_mapping - Represent a mapping between a DRM connector and a port on
  * the chamelium
@@ -53,5 +57,9 @@ void chamelium_v3_plug(struct igt_chamelium_v3 *chamelium, chamelium_v3_port_id
 void chamelium_v3_plug_with_children(struct igt_chamelium_v3 *chamelium,
 				     chamelium_v3_port_id port_id, chamelium_v3_port_id *children,
 				     size_t children_port_count);
+chamelium_edid_id chamelium_v3_create_edid(struct igt_chamelium_v3 *chamelium,
+					   const struct edid *edid);
+void chamelium_v3_apply_edid(struct igt_chamelium_v3 *chamelium, chamelium_v3_port_id port_id,
+			     chamelium_edid_id edid_id);
 
 #endif //V3_IGT_CHAMELIUM_H
Signature · 1 line
2.44.2
#26 lore raw

PATCH v2 22/39 lib/chamelium/v3: Implement Chamelium configuration parsing

In reply to Louis Chauvet

The mapping between DRM connectors and Chamelium ports can differ among setups. To avoid using a time-consuming algorithm for auto-detecting the configuration, this commit introduces parsing of the port mapping from a configuration file. The format used is the same as in Chamelium v2.

---
 lib/chamelium/v3/igt_chamelium.c | 72 ++++++++++++++++++++++++++++++++++++++++
 lib/chamelium/v3/igt_chamelium.h |  2 ++
 2 files changed, 74 insertions(+)
lib/chamelium/v3/igt_chamelium.c +72 -0
index 767dfcfcb182..e5a6a438924d 100644
@@ -10,6 +10,9 @@
 #define CHAMELIUM_CONFIG_SECTION "Chameliumv3"
 #define CHAMELIUM_CONFIG_URL "URL"
 
+#define CHAMELIUM_V2_CONFIG_PREFIX "Chamelium"
+#define CHAMELIUM_V2_CONFIG_PORT_ID "ChameliumPortID"
+
 struct igt_chamelium_v3 {
 	xmlrpc_env env;
 	xmlrpc_client *client;
@@ -126,6 +129,75 @@ struct igt_chamelium_v3 *chamelium_v3_init_from_config(void)
 	return chamelium;
 }
 
+/**
+ * chamelium_v3_fill_port_mapping_from_config_v2() - Read the configuration file using the chamelium
+ *	v2 format
+ *
+ * @chamelium: chamelium to store the port mapping into
+ *
+ * Read the configuration file to search a chamelium configuration, using the Cv2 format. It will
+ * ignore any malformed entry.
+ */
+static void chamelium_v3_fill_port_mapping_from_config_v2(struct igt_chamelium_v3 *chamelium)
+{
+	char **group_list;
+
+	igt_assert(igt_key_file);
+
+	group_list = g_key_file_get_groups(igt_key_file, NULL);
+	for (int group_idx = 0; group_list[group_idx]; group_idx++) {
+		if (strstr(group_list[group_idx], CHAMELIUM_V2_CONFIG_PREFIX ":")) {
+			struct chamelium_v3_port_mapping *port_mapping = NULL;
+			GError *error = NULL;
+			char *port_name_str =
+			    group_list[group_idx] + (sizeof(CHAMELIUM_V2_CONFIG_PREFIX ":") - 1);
+
+			errno = 0;
+
+			port_mapping = chamelium_v3_port_mapping_alloc();
+			port_mapping->connector_name = strdup(port_name_str);
+
+			if (g_key_file_has_key(igt_key_file, group_list[group_idx],
+					       CHAMELIUM_V2_CONFIG_PORT_ID, NULL)) {
+				port_mapping->port_id = g_key_file_get_integer(igt_key_file,
+									       group_list[group_idx],
+									       CHAMELIUM_V2_CONFIG_PORT_ID,
+									       &error);
+				if (error) {
+					igt_info("Skipping malformed entry %s: %s\n",
+						 group_list[group_idx], error->message);
+					chamelium_v3_port_mapping_free(port_mapping);
+				} else {
+					igt_list_add(&port_mapping->link, &chamelium->port_mapping);
+				}
+			} else {
+				igt_warn("Skipping malformed entry %s: Missing "
+					 CHAMELIUM_V2_CONFIG_PORT_ID "\n",
+					 group_list[group_idx]);
+				chamelium_v3_port_mapping_free(port_mapping);
+			}
+
+			if (error)
+				free(error);
+		}
+
+		free(group_list[group_idx]);
+	}
+	free(group_list);
+}
+
+/**
+ * chamelium_v3_fill_port_mapping() - Read the configuration file and fill the port_mapping
+ *	structure.
+ *
+ * @chamelium: chamelium to store the port mapping into
+ */
+void chamelium_v3_fill_port_mapping(struct igt_chamelium_v3 *chamelium)
+{
+	if (igt_key_file)
+		chamelium_v3_fill_port_mapping_from_config_v2(chamelium);
+}
+
 /**
  * chamelium_v3_uninit() - Free the resources used by a chamelium
  *
lib/chamelium/v3/igt_chamelium.h +2 -0
index cab33e43aadd..3aaf51dd38db 100644
@@ -44,6 +44,8 @@ struct chamelium_v3_port_mapping {
 struct igt_chamelium_v3 *chamelium_v3_init(char *url);
 struct igt_chamelium_v3 *chamelium_v3_init_from_config(void);
 
+void chamelium_v3_fill_port_mapping(struct igt_chamelium_v3 *chamelium);
+
 void chamelium_v3_uninit(struct igt_chamelium_v3 *chamelium);
 
 void chamelium_v3_reset(struct igt_chamelium_v3 *chamelium);
Signature · 1 line
2.44.2
#27 lore raw

PATCH v2 23/39 lib/chamelium/v3: Log port mapping for debugging purposes

In reply to Louis Chauvet

Port mapping is crucial information when attempting to understand why a test is failing, as issues may arise from incorrect mapping. This commit adds logging of the actual port mapping to aid in debugging and problem resolution.

---
 lib/chamelium/v3/igt_chamelium.c | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)
lib/chamelium/v3/igt_chamelium.c +23 -0
index e5a6a438924d..d528b40ca0c7 100644
@@ -186,6 +186,27 @@ static void chamelium_v3_fill_port_mapping_from_config_v2(struct igt_chamelium_v
 	free(group_list);
 }
 
+/**
+ * chamelium_v3_port_mapping_info_list() - Display the current configured port mapping for the
+ *	chamelium
+ *
+ * @chamelium: chamelium to read the port mapping from
+ */
+static void chamelium_v3_port_mapping_info_list(struct igt_list_head *head)
+{
+	struct chamelium_v3_port_mapping *tmp, *pos;
+
+	igt_list_for_each_entry_safe(pos, tmp, head, link) {
+		if (pos->mst_path)
+			igt_info("\t%s: port_id=%d parent_id=%d is_children=%d\n",
+				 pos->mst_path, pos->port_id, pos->parent_id, pos->is_children);
+		else
+			igt_info("\t%s: port_id=%d parent_id=%d is_children=%d\n",
+				 pos->connector_name, pos->port_id, pos->parent_id,
+				 pos->is_children);
+	}
+}
+
 /**
  * chamelium_v3_fill_port_mapping() - Read the configuration file and fill the port_mapping
  *	structure.
@@ -196,6 +217,8 @@ void chamelium_v3_fill_port_mapping(struct igt_chamelium_v3 *chamelium)
 {
 	if (igt_key_file)
 		chamelium_v3_fill_port_mapping_from_config_v2(chamelium);
+
+	chamelium_v3_port_mapping_info_list(&chamelium->port_mapping);
 }
 
 /**
Signature · 1 line
2.44.2
#28 lore raw

PATCH v2 24/39 lib/chamelium/v3: Introduce new configuration format for MST support

In reply to Louis Chauvet

The current Chamelium v2 configuration format does not accommodate MST usage. To maintain compatibility with existing configuration files, this commit introduces a new format with a distinct prefix for Chamelium v3 port mapping.

Support for the Chamelium v2 format is retained to facilitate the transition between Chamelium v2 and v3. The v2 format will be used if the v3 format is not present in the file.

---
 lib/chamelium/v3/igt_chamelium.c | 126 ++++++++++++++++++++++++++++++++++++++-
 1 file changed, 123 insertions(+), 3 deletions(-)
lib/chamelium/v3/igt_chamelium.c +123 -3
index d528b40ca0c7..26f6b83cd10a 100644
@@ -13,6 +13,11 @@
 #define CHAMELIUM_V2_CONFIG_PREFIX "Chamelium"
 #define CHAMELIUM_V2_CONFIG_PORT_ID "ChameliumPortID"
 
+#define CHAMELIUM_V3_CONFIG_PORT_NAME "PortName"
+#define CHAMELIUM_V3_CONFIG_MST_PATH "MstPath"
+#define CHAMELIUM_V3_CONFIG_PARENT_ID "ChameliumParentID"
+#define CHAMELIUM_V3_CONFIG_AUTODETECT_SAVE "ChameliumAutodetectSave"
+
 struct igt_chamelium_v3 {
 	xmlrpc_env env;
 	xmlrpc_client *client;
@@ -172,7 +177,7 @@ static void chamelium_v3_fill_port_mapping_from_config_v2(struct igt_chamelium_v
 				}
 			} else {
 				igt_warn("Skipping malformed entry %s: Missing "
-					 CHAMELIUM_V2_CONFIG_PORT_ID "\n",
+					     CHAMELIUM_V2_CONFIG_PORT_ID "\n",
 					 group_list[group_idx]);
 				chamelium_v3_port_mapping_free(port_mapping);
 			}
@@ -186,6 +191,115 @@ static void chamelium_v3_fill_port_mapping_from_config_v2(struct igt_chamelium_v
 	free(group_list);
 }
 
+/**
+ * chamelium_v3_fill_port_mapping_from_config_v2() - Read the configuration file using the chamelium
+ *	v3 format
+ *
+ * @chamelium: chamelium to store the port mapping into
+ *
+ * Read the configuration file to search a chamelium configuration, using the Cv3 format. It will
+ * ignore any malformed entry.
+ */
+static void chamelium_v3_fill_port_mapping_from_config_v3(struct igt_chamelium_v3 *chamelium)
+{
+	char **group_list;
+
+	igt_assert(igt_key_file);
+
+	group_list = g_key_file_get_groups(igt_key_file, NULL);
+	for (int group_idx = 0; group_list[group_idx]; group_idx++) {
+		if (strstr(group_list[group_idx], CHAMELIUM_CONFIG_SECTION ":")) {
+			struct chamelium_v3_port_mapping *port_mapping = NULL;
+			uint32_t chamelium_port_id;
+			char *tmp_end;
+			GError *error = NULL;
+			char *chamelium_port_id_str =
+			    group_list[group_idx] + (sizeof(CHAMELIUM_CONFIG_SECTION ":") - 1);
+
+			errno = 0;
+			chamelium_port_id = strtoul(chamelium_port_id_str, &tmp_end, 0);
+
+			if (chamelium_port_id_str == tmp_end) {
+				igt_warn("Failed to read config file, expecting ["
+					     CHAMELIUM_CONFIG_SECTION ":<int>], found %s\n",
+					 group_list[group_idx]);
+				goto exit_loop;
+			} else if (errno == ERANGE) {
+				igt_warn("Range error during parsing of number, expecting \"%.*s\", strtolu returned %d",
+					 (int)(tmp_end - chamelium_port_id_str),
+					 chamelium_port_id_str, chamelium_port_id);
+				goto exit_loop;
+			}
+
+			port_mapping = chamelium_v3_port_mapping_alloc();
+			port_mapping->port_id = chamelium_port_id;
+
+			if (g_key_file_has_key(igt_key_file, group_list[group_idx],
+					       CHAMELIUM_V3_CONFIG_PORT_NAME, NULL)) {
+				port_mapping->connector_name = g_key_file_get_string(igt_key_file,
+										     group_list[group_idx],
+										     CHAMELIUM_V3_CONFIG_PORT_NAME,
+										     &error);
+				if (error) {
+					igt_info("Skipping malformed entry %s: %s\n",
+						 group_list[group_idx], error->message);
+					goto exit_loop;
+				}
+			}
+
+			if (g_key_file_has_key(igt_key_file, group_list[group_idx],
+					       CHAMELIUM_V3_CONFIG_MST_PATH, NULL)) {
+				port_mapping->mst_path = g_key_file_get_string(igt_key_file,
+									       group_list[group_idx],
+									       CHAMELIUM_V3_CONFIG_MST_PATH,
+									       &error);
+				if (error) {
+					igt_warn("Skipping malformed entry %s: %s\n",
+						 group_list[group_idx], error->message);
+					goto exit_loop;
+				}
+			}
+
+			if (g_key_file_has_key(igt_key_file, group_list[group_idx],
+					       CHAMELIUM_V3_CONFIG_PARENT_ID, NULL)) {
+				port_mapping->parent_id = g_key_file_get_integer(igt_key_file,
+										 group_list[group_idx],
+										 CHAMELIUM_V3_CONFIG_PARENT_ID,
+										 &error);
+				port_mapping->is_children = true;
+				if (error) {
+					igt_warn("Skipping malformed entry %s: %s\n",
+						 group_list[group_idx],
+						 error->message);
+					goto exit_loop;
+				}
+			}
+
+			if (port_mapping->is_children && !port_mapping->mst_path) {
+				igt_warn("If the port have a " CHAMELIUM_V3_CONFIG_PARENT_ID
+					     ", it must also have an " CHAMELIUM_V3_CONFIG_MST_PATH
+					     ". Skipping malformed entry %s.\n",
+					 group_list[group_idx]);
+				goto exit_loop;
+			}
+
+			igt_list_add(&port_mapping->link, &chamelium->port_mapping);
+
+			if (error)
+				free(error);
+			continue;
+exit_loop:
+			if (error)
+				free(error);
+			if (port_mapping)
+				chamelium_v3_port_mapping_free(port_mapping);
+		}
+
+		free(group_list[group_idx]);
+	}
+	free(group_list);
+}
+
 /**
  * chamelium_v3_port_mapping_info_list() - Display the current configured port mapping for the
  *	chamelium
@@ -212,11 +326,17 @@ static void chamelium_v3_port_mapping_info_list(struct igt_list_head *head)
  *	structure.
  *
  * @chamelium: chamelium to store the port mapping into
+ *
+ * It will read the configuration file searching for a Cv3 configuration. If this configuration does
+ * not exist or is empty, it will try to read a Cv2 configuration.
  */
 void chamelium_v3_fill_port_mapping(struct igt_chamelium_v3 *chamelium)
 {
-	if (igt_key_file)
-		chamelium_v3_fill_port_mapping_from_config_v2(chamelium);
+	if (igt_key_file) {
+		chamelium_v3_fill_port_mapping_from_config_v3(chamelium);
+		if (igt_list_length(&chamelium->port_mapping) == 0)
+			chamelium_v3_fill_port_mapping_from_config_v2(chamelium);
+	}
 
 	chamelium_v3_port_mapping_info_list(&chamelium->port_mapping);
 }
Signature · 1 line
2.44.2
#29 lore raw

PATCH v2 25/39 lib/chamelium/v3: Provide access to port_mapping via method call

In reply to Louis Chauvet

Since the chamelium_rpc structure is private, this commit introduces a method to access the port mapping.

---
 lib/chamelium/v3/igt_chamelium.c | 5 +++++
 lib/chamelium/v3/igt_chamelium.h | 1 +
 2 files changed, 6 insertions(+)
lib/chamelium/v3/igt_chamelium.c +5 -0
index 26f6b83cd10a..fb559f29a72e 100644
@@ -364,6 +364,11 @@ void chamelium_v3_uninit(struct igt_chamelium_v3 *chamelium)
 	free(chamelium);
 }
 
+struct igt_list_head *chamelium_v3_get_port_mapping(struct igt_chamelium_v3 *chamelium)
+{
+	return &chamelium->port_mapping;
+}
+
 /**
  * __chamelium_rpc - Call a remote function on the chamelium
  *
lib/chamelium/v3/igt_chamelium.h +1 -0
index 3aaf51dd38db..b29221c460f0 100644
@@ -45,6 +45,7 @@ struct igt_chamelium_v3 *chamelium_v3_init(char *url);
 struct igt_chamelium_v3 *chamelium_v3_init_from_config(void);
 
 void chamelium_v3_fill_port_mapping(struct igt_chamelium_v3 *chamelium);
+struct igt_list_head *chamelium_v3_get_port_mapping(struct igt_chamelium_v3 *chamelium);
 
 void chamelium_v3_uninit(struct igt_chamelium_v3 *chamelium);
 
Signature · 1 line
2.44.2
#30 lore raw

PATCH v2 26/39 lib/chamelium/v3: Implement helper function to get port mapping from Chameleon port id

In reply to Louis Chauvet

Introduces a new helper function in the Chameleon V3 wrapper to retrieve the port mapping from a Chameleon port id. This function is useful for certain tests, such as when listing MST children, as it simplifies the process of obtaining the port mapping based on the Chameleon port id.

---
 lib/chamelium/v3/igt_chamelium.c | 23 +++++++++++++++++++++++
 lib/chamelium/v3/igt_chamelium.h |  4 +++-
 2 files changed, 26 insertions(+), 1 deletion(-)
lib/chamelium/v3/igt_chamelium.c +23 -0
index fb559f29a72e..fc9520466de5 100644
@@ -341,6 +341,29 @@ void chamelium_v3_fill_port_mapping(struct igt_chamelium_v3 *chamelium)
 	chamelium_v3_port_mapping_info_list(&chamelium->port_mapping);
 }
 
+/**
+ * chamelium_v3_get_port_mapping_for_chamelium_port_id() - Get a port mapping from a chamelium port
+ * id
+ *
+ * @chamelium: Chamelium to search the port ID
+ * @port_id: Port ID to search for
+ *
+ * Returns the pointer to a port mapping
+ */
+struct chamelium_v3_port_mapping *
+chamelium_v3_get_port_mapping_for_chamelium_port_id(struct igt_chamelium_v3 *chamelium,
+						    chamelium_v3_port_id port_id)
+{
+	struct chamelium_v3_port_mapping *port_mapping, *tmp;
+
+	igt_list_for_each_entry_safe(port_mapping, tmp, &chamelium->port_mapping, link) {
+		if (port_mapping->port_id == port_id)
+			return port_mapping;
+	}
+
+	return NULL;
+}
+
 /**
  * chamelium_v3_uninit() - Free the resources used by a chamelium
  *
lib/chamelium/v3/igt_chamelium.h +3 -1
index b29221c460f0..5e035bdd10bf 100644
@@ -46,7 +46,9 @@ struct igt_chamelium_v3 *chamelium_v3_init_from_config(void);
 
 void chamelium_v3_fill_port_mapping(struct igt_chamelium_v3 *chamelium);
 struct igt_list_head *chamelium_v3_get_port_mapping(struct igt_chamelium_v3 *chamelium);
-
+struct chamelium_v3_port_mapping *
+chamelium_v3_get_port_mapping_for_chamelium_port_id(struct igt_chamelium_v3 *chamelium,
+						    chamelium_v3_port_id port_id);
 void chamelium_v3_uninit(struct igt_chamelium_v3 *chamelium);
 
 void chamelium_v3_reset(struct igt_chamelium_v3 *chamelium);
Signature · 1 line
2.44.2
#31 lore raw

PATCH v2 27/39 lib/chamelium/v3: Implement helper function to retrieve connector from port mapping

In reply to Louis Chauvet

This commit introduces a helper function that utilizes igt_kms helpers to easily obtain the connector object from a given port mapping in Chamelium, simplifying the process for users.

---
 lib/chamelium/v3/igt_chamelium.c | 43 ++++++++++++++++++++++++++++++++++++++++
 lib/chamelium/v3/igt_chamelium.h |  7 +++++++
 2 files changed, 50 insertions(+)
lib/chamelium/v3/igt_chamelium.c +43 -0
index fc9520466de5..51b3a610e358 100644
@@ -5,6 +5,7 @@
 
 #include "igt_chamelium.h"
 #include "igt_core.h"
+#include "igt_kms.h"
 #include "igt_rc.h"
 
 #define CHAMELIUM_CONFIG_SECTION "Chameliumv3"
@@ -392,6 +393,48 @@ struct igt_list_head *chamelium_v3_get_port_mapping(struct igt_chamelium_v3 *cha
 	return &chamelium->port_mapping;
 }
 
+/**
+ * chamelium_v3_port_mapping_get_connector - Get a drm connector from a port mapping
+ *
+ * @port_mapping: Port mapping to retrieve the connector from
+ * @drm_fd: drm file descriptor to use when requesting the connector
+ *
+ * This function only works with non-MST port mapping.
+ *
+ * Returns a drm connector that must be freed with drmModeConnectorFree when not needed anymore.
+ * A null pointer means that the connector can't be found.
+ */
+drmModeConnectorPtr
+chamelium_v3_port_mapping_get_connector(const struct chamelium_v3_port_mapping *port_mapping,
+					int drm_fd)
+{
+	if (port_mapping->mst_path) {
+		igt_warn("Directly getting a connector from its MST path is not supported");
+		return NULL;
+	} else {
+		return igt_get_connector_from_name(drm_fd, port_mapping->connector_name);
+	}
+}
+
+/**
+ * chamelium_v3_port_mapping_get_connector_id - Get a drm connector id from a port mapping
+ *
+ * @port_mapping: Port mapping to retrieve the connector id from
+ * @drm_fd: drm file descriptor to use when requesting the connector id
+ *
+ * Returns a drm connector id that represent the port mapping given in parameter. A connector id of
+ * zero means that the connector is not found.
+ */
+uint32_t
+chamelium_v3_port_mapping_get_connector_id(const struct chamelium_v3_port_mapping *port_mapping,
+					   int drm_fd)
+{
+	if (port_mapping->mst_path)
+		return igt_get_connector_id_from_mst_path(drm_fd, port_mapping->mst_path);
+	else
+		return igt_get_connector_id_from_name(drm_fd, port_mapping->connector_name);
+}
+
 /**
  * __chamelium_rpc - Call a remote function on the chamelium
  *
lib/chamelium/v3/igt_chamelium.h +7 -0
index 5e035bdd10bf..90d2a7473894 100644
@@ -49,6 +49,13 @@ struct igt_list_head *chamelium_v3_get_port_mapping(struct igt_chamelium_v3 *cha
 struct chamelium_v3_port_mapping *
 chamelium_v3_get_port_mapping_for_chamelium_port_id(struct igt_chamelium_v3 *chamelium,
 						    chamelium_v3_port_id port_id);
+uint32_t
+chamelium_v3_port_mapping_get_connector_id(const struct chamelium_v3_port_mapping *port_mapping,
+					   int drm_fd);
+drmModeConnectorPtr
+chamelium_v3_port_mapping_get_connector(const struct chamelium_v3_port_mapping *port_mapping,
+					int drm_fd);
+
 void chamelium_v3_uninit(struct igt_chamelium_v3 *chamelium);
 
 void chamelium_v3_reset(struct igt_chamelium_v3 *chamelium);
Signature · 1 line
2.44.2
#32 lore raw

PATCH v2 28/39 lib/chamelium/v3: Plug specific ports for all tests

In reply to Louis Chauvet

As the chamelium v3 does not support plugging all ports at the same time, something is required to identify which port must be plugged during non-chamelium specific tests.

Add two options in port configuration:
- ConnectOnAnyTest: force this port to be plugged during any test
- EDID: Set a specific EDID for this port

---
 lib/chamelium/v3/igt_chamelium.c | 19 ++++++++++++++
 lib/chamelium/v3/igt_chamelium.h |  7 +++++
 lib/igt_kms.c                    | 55 +++++++++++++++++++++++++++++++++++-----
 3 files changed, 74 insertions(+), 7 deletions(-)
lib/chamelium/v3/igt_chamelium.c +19 -0
index 51b3a610e358..736e593a465e 100644
@@ -18,6 +18,8 @@
 #define CHAMELIUM_V3_CONFIG_MST_PATH "MstPath"
 #define CHAMELIUM_V3_CONFIG_PARENT_ID "ChameliumParentID"
 #define CHAMELIUM_V3_CONFIG_AUTODETECT_SAVE "ChameliumAutodetectSave"
+#define CHAMELIUM_V3_CONFIG_CONNECT_ON_ANY_TEST "ConnectOnAnyTest"
+#define CHAMELIUM_V3_CONFIG_EDID "EDID"
 
 struct igt_chamelium_v3 {
 	xmlrpc_env env;
@@ -234,6 +236,23 @@ static void chamelium_v3_fill_port_mapping_from_config_v3(struct igt_chamelium_v
 
 			port_mapping = chamelium_v3_port_mapping_alloc();
 			port_mapping->port_id = chamelium_port_id;
+			port_mapping->connect_on_any_test = g_key_file_get_boolean(igt_key_file,
+										   group_list[group_idx],
+										   CHAMELIUM_V3_CONFIG_CONNECT_ON_ANY_TEST,
+										   NULL);
+
+			if (g_key_file_has_key(igt_key_file, group_list[group_idx],
+					       CHAMELIUM_V3_CONFIG_EDID, NULL)) {
+				port_mapping->edid_name = g_key_file_get_string(igt_key_file,
+										group_list[group_idx],
+										CHAMELIUM_V3_CONFIG_EDID,
+										&error);
+				if (error) {
+					igt_info("Skipping malformed entry %s: %s\n",
+						 group_list[group_idx], error->message);
+					goto exit_loop;
+				}
+			}
 
 			if (g_key_file_has_key(igt_key_file, group_list[group_idx],
 					       CHAMELIUM_V3_CONFIG_PORT_NAME, NULL)) {
lib/chamelium/v3/igt_chamelium.h +7 -0
index 90d2a7473894..834f446f4317 100644
@@ -18,6 +18,9 @@ typedef int chamelium_edid_id;
  * the chamelium
  *
  * @port_id: Chamelium port ID.
+ * @connect_on_any_test: if true, this port will be connected, even for tests that are not
+ *                       chamelium-specific
+ * @edid_name: When using @connect_on_any_test, set this specific EDID to the port
  * @connector_name: DRM connector name, used to identify the connector in DRM, mutually exclusive
  *		    with @mst_path
  * @mst_path: MST path property, used to identify the connector in DRM, mutually exclusive with
@@ -29,6 +32,10 @@ typedef int chamelium_edid_id;
 struct chamelium_v3_port_mapping {
 	chamelium_v3_port_id port_id;
 
+	/* Using chamelium to emulate a display */
+	bool connect_on_any_test;
+	char *edid_name;
+
 	/* For normal DRM connector */
 	char *connector_name;
 
lib/igt_kms.c +48 -7

74 lines not on this page · raw message

Signature · 1 line
2.44.2
#33 lore raw

Re: [PATCH i-g-t v2 28/39] lib/chamelium/v3: Plug specific ports for all tests

Hi Louis,

Quoted 82 lines · Louis Chauvet

As the chamelium v3 does not support plugging all ports at the same time, something is required to identify which port must be plugged during non-chamelium specific tests.

Add two options in port configuration:
- ConnectOnAnyTest: force this port to be plugged during any test
- EDID: Set a specific EDID for this port

---
  lib/chamelium/v3/igt_chamelium.c | 19 ++++++++++++++
  lib/chamelium/v3/igt_chamelium.h |  7 +++++
  lib/igt_kms.c                    | 55 +++++++++++++++++++++++++++++++++++-----
  3 files changed, 74 insertions(+), 7 deletions(-)
lib/chamelium/v3/igt_chamelium.c +19 -0
index 51b3a610e358..736e593a465e 100644
@@ -18,6 +18,8 @@
  #define CHAMELIUM_V3_CONFIG_MST_PATH "MstPath"
  #define CHAMELIUM_V3_CONFIG_PARENT_ID "ChameliumParentID"
  #define CHAMELIUM_V3_CONFIG_AUTODETECT_SAVE "ChameliumAutodetectSave"
+#define CHAMELIUM_V3_CONFIG_CONNECT_ON_ANY_TEST "ConnectOnAnyTest"
+#define CHAMELIUM_V3_CONFIG_EDID "EDID"
 
  struct igt_chamelium_v3 {
  	xmlrpc_env env;
@@ -234,6 +236,23 @@ static void chamelium_v3_fill_port_mapping_from_config_v3(struct igt_chamelium_v
 
  			port_mapping = chamelium_v3_port_mapping_alloc();
  			port_mapping->port_id = chamelium_port_id;
+			port_mapping->connect_on_any_test = g_key_file_get_boolean(igt_key_file,
+										   group_list[group_idx],
+										   CHAMELIUM_V3_CONFIG_CONNECT_ON_ANY_TEST,
+										   NULL);
+
+			if (g_key_file_has_key(igt_key_file, group_list[group_idx],
+					       CHAMELIUM_V3_CONFIG_EDID, NULL)) {
+				port_mapping->edid_name = g_key_file_get_string(igt_key_file,
+										group_list[group_idx],
+										CHAMELIUM_V3_CONFIG_EDID,
+										&error);
+				if (error) {
+					igt_info("Skipping malformed entry %s: %s\n",
+						 group_list[group_idx], error->message);
+					goto exit_loop;
+				}
+			}
 
  			if (g_key_file_has_key(igt_key_file, group_list[group_idx],
  					       CHAMELIUM_V3_CONFIG_PORT_NAME, NULL)) {
lib/chamelium/v3/igt_chamelium.h +7 -0
index 90d2a7473894..834f446f4317 100644
@@ -18,6 +18,9 @@ typedef int chamelium_edid_id;
   * the chamelium
   *
   * @port_id: Chamelium port ID.
+ * @connect_on_any_test: if true, this port will be connected, even for tests that are not
+ *                       chamelium-specific
+ * @edid_name: When using @connect_on_any_test, set this specific EDID to the port
   * @connector_name: DRM connector name, used to identify the connector in DRM, mutually exclusive
   *		    with @mst_path
   * @mst_path: MST path property, used to identify the connector in DRM, mutually exclusive with
@@ -29,6 +32,10 @@ typedef int chamelium_edid_id;
  struct chamelium_v3_port_mapping {
  	chamelium_v3_port_id port_id;
 
+	/* Using chamelium to emulate a display */
+	bool connect_on_any_test;
+	char *edid_name;
+
  	/* For normal DRM connector */
  	char *connector_name;
 
lib/igt_kms.c +0 -0
index 6c2b7cc4f5bd..a30bb483594c 100644

lib/igt_kms.c line 53

Quoted 5 lines
lib/igt_kms.c +2 -0
@@ -49,6 +49,8 @@
  #include <time.h>
 
  #include <i915_drm.h>
+#include <chamelium/v3/igt_chamelium.h>
+#include <monitor_edids/monitor_edids_helper.h>

Should this be in ifdef HAVE_CHAMELIUM_V3 ?

Quoted 28 lines
lib/igt_kms.c +6 -7
  #include "drmtest.h"
  #include "igt_kms.h"
@@ -2883,14 +2885,7 @@ void igt_display_require(igt_display_t *display, int drm_fd)
  	if (!resources)
  		goto out;
 
-/*
- * FIXME: Dirty hack to avoid those lines when chamelium v3 is used
- *
- * Must be replaced with a configuration file information, so the end user can choose if the
- * chamelium must be connected or not.
- */
  #ifdef HAVE_CHAMELIUM_V2
-#ifndef HAVE_CHAMELIUM_V3
  	{
  		struct chamelium *chamelium;
 
@@ -2906,6 +2901,52 @@ void igt_display_require(igt_display_t *display, int drm_fd)
  		}
  	}
  #endif
+
+#ifdef HAVE_CHAMELIUM_V3
+	{
+		struct igt_chamelium_v3 *chamelium = chamelium_v3_init_from_config();
+
+		if (chamelium) {

lib/igt_kms.c void igt_display_require(igt_display_t *display, int drm_fd) · line 2919

Quoted 10 lines
lib/igt_kms.c +10 -0
+			struct chamelium_v3_port_mapping *mapping, *tmp;
+
+			chamelium_v3_reset(chamelium);
+			chamelium_v3_fill_port_mapping(chamelium);
+
+			igt_list_for_each_entry_safe(mapping, tmp,
+						     chamelium_v3_get_port_mapping(chamelium),
+						     link) {
+				if (mapping->connect_on_any_test && !chamelium_v3_is_mst(chamelium, mapping->port_id)) {
+					int edid_id = CHAMELIUM_DEFAULT_EDID;

Need to use CHAMELIUM_V3_EDID_DEFAULT from lib/chamelium/v3/igt_chamelium.h.

Quoted 4 lines
lib/igt_kms.c +4 -0
+
+					igt_info("Plugging port %s\n", mapping->connector_name);
+					if (mapping->edid_name) {
+						struct edid *edid = get_edid_by_name(mapping->edid_name);

lib/igt_kms.c void igt_display_require(igt_display_t *display, int drm_fd) · line 2933

Quoted 10 lines
lib/igt_kms.c +10 -0
+
+						if (edid)
+							edid_id = chamelium_v3_create_edid(chamelium,
+											   edid);
+						else
+							igt_warn("Impossible to find an edid named \"%s\". Available names:\n",
+								 mapping->edid_name);
+							list_edid_names(IGT_LOG_WARN);
+					}
+					if (edid_id == CHAMELIUM_DEFAULT_EDID)

Same as above.

Quoted 10 lines
lib/igt_kms.c +9 -0
+						igt_info("\tUsing default EDID\n");
+					else
+						igt_info("\tUsing edid: %s\n", mapping->edid_name);
+
+					chamelium_v3_apply_edid(chamelium, mapping->port_id,
+								edid_id);
+					chamelium_v3_plug(chamelium, mapping->port_id);
+					igt_require(igt_wait_for_connector_status(drm_fd,
+										  chamelium_v3_port_mapping_get_connector_id(mapping, drm_fd),

lib/igt_kms.c void igt_display_require(igt_display_t *display, int drm_fd) · line 2952

Quoted 10 lines
lib/igt_kms.c +7 -0
+										  igt_default_detect_timeout(),
+										  DRM_MODE_CONNECTED));
+				}
+			}
+			chamelium_v3_uninit(chamelium);
+		}
+	}
  #endif
 
  	igt_require_f(resources->count_crtcs <= IGT_MAX_PIPES,

Regards,
Vignesh

#34 lore raw

Re: [PATCH i-g-t v2 28/39] lib/chamelium/v3: Plug specific ports for all tests

Quoted 87 lines · Vignesh Raman

Hi Louis,

Quoted 84 lines · Louis Chauvet

As the chamelium v3 does not support plugging all ports at the same time, something is required to identify which port must be plugged during non-chamelium specific tests.

Add two options in port configuration:
- ConnectOnAnyTest: force this port to be plugged during any test
- EDID: Set a specific EDID for this port

---
  lib/chamelium/v3/igt_chamelium.c | 19 ++++++++++++++
  lib/chamelium/v3/igt_chamelium.h |  7 +++++
  lib/igt_kms.c                    | 55 +++++++++++++++++++++++++++++++++++-----
  3 files changed, 74 insertions(+), 7 deletions(-)
lib/chamelium/v3/igt_chamelium.c +19 -0
index 51b3a610e358..736e593a465e 100644
@@ -18,6 +18,8 @@
  #define CHAMELIUM_V3_CONFIG_MST_PATH "MstPath"
  #define CHAMELIUM_V3_CONFIG_PARENT_ID "ChameliumParentID"
  #define CHAMELIUM_V3_CONFIG_AUTODETECT_SAVE "ChameliumAutodetectSave"
+#define CHAMELIUM_V3_CONFIG_CONNECT_ON_ANY_TEST "ConnectOnAnyTest"
+#define CHAMELIUM_V3_CONFIG_EDID "EDID"
 
  struct igt_chamelium_v3 {
  	xmlrpc_env env;
@@ -234,6 +236,23 @@ static void chamelium_v3_fill_port_mapping_from_config_v3(struct igt_chamelium_v
 
  			port_mapping = chamelium_v3_port_mapping_alloc();
  			port_mapping->port_id = chamelium_port_id;
+			port_mapping->connect_on_any_test = g_key_file_get_boolean(igt_key_file,
+										   group_list[group_idx],
+										   CHAMELIUM_V3_CONFIG_CONNECT_ON_ANY_TEST,
+										   NULL);
+
+			if (g_key_file_has_key(igt_key_file, group_list[group_idx],
+					       CHAMELIUM_V3_CONFIG_EDID, NULL)) {
+				port_mapping->edid_name = g_key_file_get_string(igt_key_file,
+										group_list[group_idx],
+										CHAMELIUM_V3_CONFIG_EDID,
+										&error);
+				if (error) {
+					igt_info("Skipping malformed entry %s: %s\n",
+						 group_list[group_idx], error->message);
+					goto exit_loop;
+				}
+			}
 
  			if (g_key_file_has_key(igt_key_file, group_list[group_idx],
  					       CHAMELIUM_V3_CONFIG_PORT_NAME, NULL)) {
lib/chamelium/v3/igt_chamelium.h +7 -0
index 90d2a7473894..834f446f4317 100644
@@ -18,6 +18,9 @@ typedef int chamelium_edid_id;
   * the chamelium
   *
   * @port_id: Chamelium port ID.
+ * @connect_on_any_test: if true, this port will be connected, even for tests that are not
+ *                       chamelium-specific
+ * @edid_name: When using @connect_on_any_test, set this specific EDID to the port
   * @connector_name: DRM connector name, used to identify the connector in DRM, mutually exclusive
   *		    with @mst_path
   * @mst_path: MST path property, used to identify the connector in DRM, mutually exclusive with
@@ -29,6 +32,10 @@ typedef int chamelium_edid_id;
  struct chamelium_v3_port_mapping {
  	chamelium_v3_port_id port_id;
 
+	/* Using chamelium to emulate a display */
+	bool connect_on_any_test;
+	char *edid_name;
+
  	/* For normal DRM connector */
  	char *connector_name;
 
lib/igt_kms.c +0 -0
index 6c2b7cc4f5bd..a30bb483594c 100644
@@ -49,6 +49,8 @@
  #include <time.h>
 
Quoted 5 lines

lib/igt_kms.c line 53

Quoted 3 lines
lib/igt_kms.c +2 -0
  #include <i915_drm.h>
+#include <chamelium/v3/igt_chamelium.h>
+#include <monitor_edids/monitor_edids_helper.h>

Should this be in ifdef HAVE_CHAMELIUM_V3 ?

Yes, those includes are not needed, thanks

Quoted 32 lines
Quoted 32 lines
lib/igt_kms.c +10 -7
  #include "drmtest.h"
  #include "igt_kms.h"
@@ -2883,14 +2885,7 @@ void igt_display_require(igt_display_t *display, int drm_fd)
  	if (!resources)
  		goto out;
 
-/*
- * FIXME: Dirty hack to avoid those lines when chamelium v3 is used
- *
- * Must be replaced with a configuration file information, so the end user can choose if the
- * chamelium must be connected or not.
- */
  #ifdef HAVE_CHAMELIUM_V2
-#ifndef HAVE_CHAMELIUM_V3
  	{
  		struct chamelium *chamelium;
 
@@ -2906,6 +2901,52 @@ void igt_display_require(igt_display_t *display, int drm_fd)
  		}
  	}
  #endif
+
+#ifdef HAVE_CHAMELIUM_V3
+	{
+		struct igt_chamelium_v3 *chamelium = chamelium_v3_init_from_config();
+
+		if (chamelium) {
+			struct chamelium_v3_port_mapping *mapping, *tmp;
+
+			chamelium_v3_reset(chamelium);
+			chamelium_v3_fill_port_mapping(chamelium);
Quoted 8 lines

lib/igt_kms.c void igt_display_require(igt_display_t *display, int drm_fd) · line 2919

Quoted 6 lines
lib/igt_kms.c +6 -0
+
+			igt_list_for_each_entry_safe(mapping, tmp,
+						     chamelium_v3_get_port_mapping(chamelium),
+						     link) {
+				if (mapping->connect_on_any_test && !chamelium_v3_is_mst(chamelium, mapping->port_id)) {
+					int edid_id = CHAMELIUM_DEFAULT_EDID;

Need to use CHAMELIUM_V3_EDID_DEFAULT from lib/chamelium/v3/igt_chamelium.h.

Yes, sorry!

Quoted 8 lines
Quoted 8 lines
lib/igt_kms.c +8 -0
+
+					igt_info("Plugging port %s\n", mapping->connector_name);
+					if (mapping->edid_name) {
+						struct edid *edid = get_edid_by_name(mapping->edid_name);
+
+						if (edid)
+							edid_id = chamelium_v3_create_edid(chamelium,
+											   edid);
Quoted 8 lines

lib/igt_kms.c void igt_display_require(igt_display_t *display, int drm_fd) · line 2933

Quoted 6 lines
lib/igt_kms.c +6 -0
+						else
+							igt_warn("Impossible to find an edid named \"%s\". Available names:\n",
+								 mapping->edid_name);
+							list_edid_names(IGT_LOG_WARN);
+					}
+					if (edid_id == CHAMELIUM_DEFAULT_EDID)

Same as above.

Fixed!

Quoted 23 lines
Quoted 10 lines
lib/igt_kms.c +9 -0
+						igt_info("\tUsing default EDID\n");
+					else
+						igt_info("\tUsing edid: %s\n", mapping->edid_name);
+
+					chamelium_v3_apply_edid(chamelium, mapping->port_id,
+								edid_id);
+					chamelium_v3_plug(chamelium, mapping->port_id);
+					igt_require(igt_wait_for_connector_status(drm_fd,
+										  chamelium_v3_port_mapping_get_connector_id(mapping, drm_fd),

lib/igt_kms.c void igt_display_require(igt_display_t *display, int drm_fd) · line 2952

Quoted 10 lines
lib/igt_kms.c +7 -0
+										  igt_default_detect_timeout(),
+										  DRM_MODE_CONNECTED));
+				}
+			}
+			chamelium_v3_uninit(chamelium);
+		}
+	}
  #endif
 
  	igt_require_f(resources->count_crtcs <= IGT_MAX_PIPES,

Regards,
Vignesh

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

PATCH v2 29/39 lib/chamelium/v3: Implement Chamelium port autodetection algorithm

In reply to Louis Chauvet

To streamline the usage of Chamelium, this commit introduces an autodetection algorithm. Please note that the algorithm may be somewhat slow, as it needs to identify each port individually.

Note for future contributors: As of now, the RPC call IsPhysicalConnected is known to be broken. Although it could potentially avoid testing all ports, it cannot be used at this time.

---
 lib/chamelium/v3/igt_chamelium.c | 348 ++++++++++++++++++++++++++++++++++++++-
 lib/chamelium/v3/igt_chamelium.h |   2 +-
 lib/igt_kms.c                    |   2 +-
 3 files changed, 349 insertions(+), 3 deletions(-)
lib/chamelium/v3/igt_chamelium.c +347 -1
index 736e593a465e..e5810e06dbc6 100644
@@ -7,6 +7,7 @@
 #include "igt_core.h"
 #include "igt_kms.h"
 #include "igt_rc.h"
+#include "igt_kms.h"
 
 #define CHAMELIUM_CONFIG_SECTION "Chameliumv3"
 #define CHAMELIUM_CONFIG_URL "URL"
@@ -341,6 +342,330 @@ static void chamelium_v3_port_mapping_info_list(struct igt_list_head *head)
 	}
 }
 
+/**
+ * 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);
+	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.
+ */
+static 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);
+	igt_assert(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;
+}
+
+/**
+ * chamelium_v3_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.
+ */
+static int chamelium_v3_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(already_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_detect_timeout());
+
+	return newly_connected_count;
+}
+
+/**
+ * chamelium_v3_autodetect_non_mst_port() - Attempt to detect a port without MST
+ *
+ * @chamelium: Chamelium to use
+ * @drm_fd: drm file descriptor used to get the connected connectors
+ * @port: Chamlium port to use
+ *
+ * It will plug the chamelium @port and attempt to find a newly connected connector in DRM. It will
+ * add this mapping in the chamelium structure.
+ */
+static void
+chamelium_v3_autodetect_non_mst_port(struct igt_chamelium_v3 *chamelium, int drm_fd,
+				     chamelium_v3_port_id port)
+{
+	int newly_connected_count, already_connected_count, diff_len;
+	uint32_t *newly_connected = NULL, *already_connected = NULL;
+	struct chamelium_v3_port_mapping *mapping;
+	drmModeConnectorPtr connector;
+	char *port_name;
+	uint32_t *diff = NULL;
+
+	port_name = chamelium_v3_get_port_name(chamelium, port);
+	chamelium_v3_reset(chamelium);
+
+	/*
+	 * 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_detect_timeout());
+
+	already_connected_count = igt_get_connected_connectors(drm_fd, &already_connected);
+
+	chamelium_v3_apply_edid(chamelium, port, 0);
+	chamelium_v3_plug(chamelium, port);
+
+	newly_connected_count = chamelium_v3_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) {
+		igt_info("\t\t\tNo newly connected connector, assuming this port is not connected.\n");
+	} else if (diff_len > 1) {
+		igt_info("\t\t\tMore than one new connectors connected, this is not supported by autodetection.\n");
+	} else {
+		igt_info("\t\t\tFound one connector (%d) connected to the port %d (%s)\n", diff[0],
+			 port, port_name);
+
+		connector = drmModeGetConnector(drm_fd, diff[0]);
+		igt_assert(connector);
+		mapping = chamelium_v3_port_mapping_alloc();
+		mapping->port_id = port;
+		igt_assert(asprintf(&mapping->connector_name, "%s-%u",
+				    kmstest_connector_type_str(connector->connector_type),
+				    connector->connector_type_id) != -1);
+		igt_list_add(&mapping->link, &chamelium->port_mapping);
+		drmModeFreeConnector(connector);
+	}
+
+	free(already_connected);
+	free(newly_connected);
+	free(diff);
+	free(port_name);
+}
+
+/**
+ * chamelium_v3_autodetect_mst_children_port() - Attempt to find the mapping between a children port
+ *	and a MST path
+ *
+ * @chamelium: Chamelium to use
+ * @drm_fd: drm file descriptor to detect the connector
+ * @port: parent port of the children port
+ * @children: children port
+ *
+ * It will plug the chamelium @port and @children and attempt to find a newly connected connector in
+ * DRM. It will add this mapping in the chamelium structure.
+ */
+static void
+chamelium_v3_autodetect_mst_children_port(struct igt_chamelium_v3 *chamelium, int drm_fd,
+					  chamelium_v3_port_id port, chamelium_v3_port_id children)
+{
+	struct chamelium_v3_port_mapping *mapping;
+	drmModePropertyBlobPtr path_blob;
+	struct timespec start, end;
+	uint32_t *newly_connected = NULL;
+	char *port_name;
+
+	igt_assert(chamelium);
+	igt_assert(drm_fd);
+
+	port_name = chamelium_v3_get_port_name(chamelium, children);
+	chamelium_v3_reset(chamelium);
+	chamelium_v3_apply_edid(chamelium, port, 0);
+	chamelium_v3_apply_edid(chamelium, children, 0);
+	chamelium_v3_plug_with_children(chamelium, port, &children, 1);
+
+	/*
+	 * Waiting for a connector not already in the mappings
+	 */
+	clock_gettime(CLOCK_MONOTONIC, &start);
+	clock_gettime(CLOCK_MONOTONIC, &end);
+	while (igt_time_elapsed(&start, &end) <= igt_default_detect_timeout()) {
+		if (newly_connected)
+			free(newly_connected);
+
+		for (int i = 0; i < igt_get_connected_connectors(drm_fd, &newly_connected); i++) {
+			path_blob = kmstest_get_path_blob(drm_fd, newly_connected[i]);
+
+			if (path_blob) {
+				struct chamelium_v3_port_mapping *tmp, *pos;
+				bool found = false;
+
+				igt_list_for_each_entry_safe(pos, tmp, &chamelium->port_mapping,
+							     link) {
+					if (strcmp((const char *)path_blob->data, pos->mst_path)
+					    == 0) {
+						found = true;
+					}
+				}
+				if (!found) {
+					igt_info("\t\t\tFound one children connector (%d) connected to the port %d (%s)\n",
+						 newly_connected[i], children, port_name);
+
+					mapping = chamelium_v3_port_mapping_alloc();
+					mapping->port_id = children;
+					mapping->is_children = true;
+					mapping->parent_id = port;
+					mapping->mst_path = strndup(path_blob->data,
+								    path_blob->length);
+					drmModeFreePropertyBlob(path_blob);
+					igt_list_add(&mapping->link, &chamelium->port_mapping);
+					free(port_name);
+					return;
+				}
+				drmModeFreePropertyBlob(path_blob);
+			}
+		}
+
+		clock_gettime(CLOCK_MONOTONIC, &end);
+	}
+	free(port_name);
+}
+
+/**
+ * chamelium_v3_autodetect_mst_children_port() - Attempt to find the mapping between a MST port, its
+ *	children and their MST path
+ *
+ * @chamelium: Chamelium to use
+ * @drm_fd: drm file descriptor to detect the connector
+ * @port: MST port
+ *
+ * It will plug the chamelium @port and its children and attempt to find a mapping between them and
+ * a drm connector. It will add this mapping in the chamelium structure.
+ */
+static void
+chamelium_v3_autodetect_mst_port(struct igt_chamelium_v3 *chamelium, int drm_fd,
+				 chamelium_v3_port_id port)
+{
+	int already_connected_count, newly_connected_count;
+	uint32_t *already_connected = NULL, *newly_connected = NULL;
+	chamelium_v3_port_id *children_ports = NULL;
+	struct chamelium_v3_port_mapping *mapping;
+	int diff_len, children_port_count;
+	drmModePropertyBlobPtr path_blob;
+	char *port_name;
+	uint32_t *diff = NULL;
+
+	port_name = chamelium_v3_get_port_name(chamelium, port);
+	chamelium_v3_reset(chamelium);
+
+	/*
+	 * 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_detect_timeout());
+
+	already_connected_count = igt_get_connected_connectors(drm_fd, &already_connected);
+
+	chamelium_v3_apply_edid(chamelium, port, 0);
+	chamelium_v3_plug(chamelium, port);
+
+	newly_connected_count = chamelium_v3_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) {
+		igt_info("\t\t\tNo newly connected connector, assuming this port is not connected.\n");
+	} else if (diff_len > 1) {
+		igt_info("\t\t\tMore than one new connectors connected, this is not supported by autodetection.\n");
+	} else {
+		igt_info("\t\t\tFound one connector (%d) connected to the port %d (%s). Autodetecting MST children...\n",
+			 diff[0], port, port_name);
+		path_blob = kmstest_get_path_blob(drm_fd, diff[0]);
+
+		if (path_blob) {
+			mapping = chamelium_v3_port_mapping_alloc();
+			mapping->port_id = port;
+			mapping->is_children = false;
+			mapping->mst_path = strndup(path_blob->data, path_blob->length);
+			drmModeFreePropertyBlob(path_blob);
+			igt_list_add(&mapping->link, &chamelium->port_mapping);
+
+			children_port_count = chamelium_v3_get_children(chamelium, port,
+									&children_ports);
+
+			for (int i = 0; i < children_port_count; i++) {
+				chamelium_v3_autodetect_mst_children_port(chamelium, drm_fd, port,
+									  children_ports[i]);
+			}
+
+			free(children_ports);
+		} else {
+			igt_info("\t\t\tNo PATH blob found for this connector. Assuming this DUT does not support MST and skip this port.\n");
+		}
+	}
+
+	free(already_connected);
+	free(newly_connected);
+	free(diff);
+	free(port_name);
+}
+
 /**
  * chamelium_v3_fill_port_mapping() - Read the configuration file and fill the port_mapping
  *	structure.
@@ -350,7 +675,7 @@ static void chamelium_v3_port_mapping_info_list(struct igt_list_head *head)
  * It will read the configuration file searching for a Cv3 configuration. If this configuration does
  * not exist or is empty, it will try to read a Cv2 configuration.
  */
-void chamelium_v3_fill_port_mapping(struct igt_chamelium_v3 *chamelium)
+void chamelium_v3_fill_port_mapping(struct igt_chamelium_v3 *chamelium, int drm_fd)
 {
 	if (igt_key_file) {
 		chamelium_v3_fill_port_mapping_from_config_v3(chamelium);
@@ -358,6 +683,27 @@ void chamelium_v3_fill_port_mapping(struct igt_chamelium_v3 *chamelium)
 			chamelium_v3_fill_port_mapping_from_config_v2(chamelium);
 	}
 
+	if (igt_list_empty(&chamelium->port_mapping)) {
+		chamelium_v3_port_id *ports;
+		char *port_name;
+		int port_count;
+
+		igt_info("Chamelium configuration empty, autodetecting...\n");
+		igt_info("\tAutodetect ports:\n");
+		ports = NULL;
+		port_count = chamelium_v3_get_supported_ports(chamelium, &ports);
+		for (int i = 0; i < port_count; i++) {
+			port_name = chamelium_v3_get_port_name(chamelium, ports[i]);
+			igt_info("\t\tAutodetect port %d (%s)...\n", ports[i], port_name);
+			if (!chamelium_v3_is_mst(chamelium, ports[i]))
+				chamelium_v3_autodetect_non_mst_port(chamelium, drm_fd, ports[i]);
+			else
+				chamelium_v3_autodetect_mst_port(chamelium, drm_fd, ports[i]);
+			free(port_name);
+		}
+		free(ports);
+	}
+
 	chamelium_v3_port_mapping_info_list(&chamelium->port_mapping);
 }
 
lib/chamelium/v3/igt_chamelium.h +1 -1
index 834f446f4317..0d2e481f6cca 100644
@@ -51,7 +51,7 @@ struct chamelium_v3_port_mapping {
 struct igt_chamelium_v3 *chamelium_v3_init(char *url);
 struct igt_chamelium_v3 *chamelium_v3_init_from_config(void);
 
-void chamelium_v3_fill_port_mapping(struct igt_chamelium_v3 *chamelium);
+void chamelium_v3_fill_port_mapping(struct igt_chamelium_v3 *chamelium, int drm_fd);
 struct igt_list_head *chamelium_v3_get_port_mapping(struct igt_chamelium_v3 *chamelium);
 struct chamelium_v3_port_mapping *
 chamelium_v3_get_port_mapping_for_chamelium_port_id(struct igt_chamelium_v3 *chamelium,
lib/igt_kms.c +1 -1
index a30bb483594c..974d9c5f02e7 100644
@@ -2910,7 +2910,7 @@ void igt_display_require(igt_display_t *display, int drm_fd)
 			struct chamelium_v3_port_mapping *mapping, *tmp;
 
 			chamelium_v3_reset(chamelium);
-			chamelium_v3_fill_port_mapping(chamelium);
+			chamelium_v3_fill_port_mapping(chamelium, drm_fd);
 
 			igt_list_for_each_entry_safe(mapping, tmp,
 						     chamelium_v3_get_port_mapping(chamelium),
Signature · 1 line
2.44.2
#36 lore raw

PATCH v2 30/39 lib/chamelium/v3: Add save option to avoid doing autodetection every time

In reply to Louis Chauvet

Autodetection algorithm is slow. To help writing configuration files, add an option save the configuration after an autodetection.

---
 lib/chamelium/v3/igt_chamelium.c | 49 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 49 insertions(+)
lib/chamelium/v3/igt_chamelium.c +49 -0
index e5810e06dbc6..cf9eb330efe4 100644
@@ -666,6 +666,43 @@ chamelium_v3_autodetect_mst_port(struct igt_chamelium_v3 *chamelium, int drm_fd,
 	free(port_name);
 }
 
+static void chamelium_v3_save_mapping(struct igt_chamelium_v3 *chamelium)
+{
+	struct chamelium_v3_port_mapping *tmp, *pos;
+	char *key_file_loc = NULL;
+	char *key_file_env = NULL;
+
+	igt_assert(chamelium);
+	igt_assert(igt_key_file);
+
+	igt_list_for_each_entry_safe(pos, tmp, &chamelium->port_mapping, link) {
+		char *section_name = NULL;
+
+		asprintf(&section_name, CHAMELIUM_CONFIG_SECTION ":%d", pos->port_id);
+		igt_assert(section_name);
+
+		if (pos->mst_path) {
+			g_key_file_set_string(igt_key_file, section_name,
+					      CHAMELIUM_V3_CONFIG_MST_PATH, pos->mst_path);
+			g_key_file_set_integer(igt_key_file, section_name,
+					       CHAMELIUM_V3_CONFIG_PARENT_ID, pos->parent_id);
+		} else {
+			g_key_file_set_string(igt_key_file, section_name,
+					      CHAMELIUM_V3_CONFIG_PORT_NAME, pos->connector_name);
+		}
+	}
+
+	key_file_env = getenv("IGT_CONFIG_PATH");
+	if (key_file_env) {
+		key_file_loc = key_file_env;
+	} else {
+		key_file_loc = malloc(100);
+		snprintf(key_file_loc, 100, "%s/.igtrc", g_get_home_dir());
+	}
+
+	g_key_file_save_to_file(igt_key_file, key_file_loc, NULL);
+}
+
 /**
  * chamelium_v3_fill_port_mapping() - Read the configuration file and fill the port_mapping
  *	structure.
@@ -705,6 +742,18 @@ void chamelium_v3_fill_port_mapping(struct igt_chamelium_v3 *chamelium, int drm_
 	}
 
 	chamelium_v3_port_mapping_info_list(&chamelium->port_mapping);
+
+	if (igt_key_file) {
+		if (g_key_file_get_boolean(igt_key_file, CHAMELIUM_CONFIG_SECTION, CHAMELIUM_V3_CONFIG_AUTODETECT_SAVE, NULL)) {
+			/*
+			 * Delete this option to avoid rewriting again the same configuration over
+			 * existing config file
+			 */
+			g_key_file_set_boolean(igt_key_file, CHAMELIUM_CONFIG_SECTION,
+					       CHAMELIUM_V3_CONFIG_AUTODETECT_SAVE, false);
+			chamelium_v3_save_mapping(chamelium);
+		}
+	}
 }
 
 /**
Signature · 1 line
2.44.2
#37 lore raw

PATCH v2 31/39 tests/chamelium/v3: Implement basic EDID handling test

In reply to Louis Chauvet

This commit introduces a new Chamelium v3 test to validate the proper handling of EDID data. The test uploads a custom EDID to the Chamelium and then confirms that the EDID data can be accurately read back from the kernel.

This test is adapted from the v2 version.

---
 tests/chamelium/v3/kms_chamelium_v3_edid.c | 95 ++++++++++++++++++++++++++++++
 tests/meson.build                          |  1 +
 2 files changed, 96 insertions(+)
tests/chamelium/v3/kms_chamelium_v3_edid.c new file +95 -0
new file mode 100644
index 000000000000..b8d750ad771d
@@ -0,0 +1,95 @@
+// SPDX-License-Identifier: MIT
+
+#include <igt.h>
+#include "chamelium/v3/igt_chamelium.h"
+
+static void collect_and_compare_edid(int drm_fd,
+				     const struct chamelium_v3_port_mapping *port_mapping,
+				     const struct edid *edid)
+{
+	drmModePropertyBlobPtr edid_blob = NULL;
+	uint64_t edid_blob_id;
+
+	uint32_t connector_id = chamelium_v3_port_mapping_get_connector_id(port_mapping, drm_fd);
+
+	/* Force refresh of properties */
+	drmModeFreeConnector(drmModeGetConnector(drm_fd, connector_id));
+	igt_assert(kmstest_get_property(drm_fd, connector_id,
+					DRM_MODE_OBJECT_CONNECTOR, "EDID", NULL,
+					&edid_blob_id, NULL));
+	igt_assert(edid_blob_id);
+	edid_blob = drmModeGetPropertyBlob(drm_fd, edid_blob_id);
+	igt_assert(edid_blob);
+	igt_assert(memcmp(edid, edid_blob->data, edid_get_size(edid)) == 0);
+
+	drmModeFreePropertyBlob(edid_blob);
+}
+
+static void upload_and_read_edid(int drm_fd, struct igt_chamelium_v3 *chamelium,
+				 const struct chamelium_v3_port_mapping *port_mapping,
+				 const struct edid *edid)
+{
+	uint32_t connector_id;
+
+	int edid_id;
+
+	chamelium_v3_reset(chamelium);
+	edid_id = chamelium_v3_create_edid(chamelium, edid);
+	chamelium_v3_apply_edid(chamelium, port_mapping->port_id, edid_id);
+	chamelium_v3_plug(chamelium, port_mapping->port_id);
+
+	connector_id = chamelium_v3_port_mapping_get_connector_id(port_mapping, drm_fd);
+	igt_assert(igt_wait_for_connector_status(drm_fd, connector_id, 10.0,
+						 DRM_MODE_CONNECTED));
+
+	collect_and_compare_edid(drm_fd, port_mapping, edid);
+}
+
+static void igt_custom_edid_type_read(int drm_fd, struct igt_chamelium_v3 *chamelium,
+				      struct chamelium_v3_port_mapping *port_mapping,
+				      enum igt_custom_edid_type edid)
+{
+	upload_and_read_edid(drm_fd, chamelium, port_mapping, igt_kms_get_custom_edid(edid));
+}
+
+igt_main
+{
+	struct igt_chamelium_v3 *chamelium;
+	int drm_fd;
+
+	igt_fixture {
+		chamelium = chamelium_v3_init_from_config();
+		igt_assert(chamelium);
+		drm_fd = drm_open_driver(DRIVER_ANY);
+		igt_assert(drm_fd);
+		chamelium_v3_fill_port_mapping(chamelium, drm_fd);
+	}
+
+	igt_describe("Read basic EDID from the chamelium.");
+	igt_subtest_with_dynamic("edid-read-basic") {
+		struct chamelium_v3_port_mapping *port, *tmp;
+
+		igt_list_for_each_entry_safe(port, tmp, chamelium_v3_get_port_mapping(chamelium),
+					     link) {
+			igt_dynamic_f("port-%d", port->port_id) {
+				char *name;
+
+				igt_require(!chamelium_v3_is_mst(chamelium, port->port_id));
+
+				name = chamelium_v3_get_port_name(chamelium, port->port_id);
+				igt_info("Testing port %s (%s)\n", port->connector_name, name);
+				free(name);
+
+				igt_custom_edid_type_read(drm_fd, chamelium, port,
+							  IGT_CUSTOM_EDID_BASE);
+				igt_custom_edid_type_read(drm_fd, chamelium, port,
+							  IGT_CUSTOM_EDID_ALT);
+			}
+		}
+	}
+
+	igt_fixture {
+		chamelium_v3_uninit(chamelium);
+		drm_close_driver(drm_fd);
+	}
+}
tests/meson.build +1 -0
index e36ae9b18ffc..ebaf1cb9ebb2 100644
@@ -326,6 +326,7 @@ chamelium_v2_progs = [
 
 chamelium_v3_progs = [
 	'kms_chamelium_v3_basic',
+	'kms_chamelium_v3_edid',
 ]
 
 test_deps = [ igt_deps ]
Signature · 1 line
2.44.2
#38 lore raw

PATCH v2 32/39 tests/chamelium/v3: Implement 4K EDID stress test

In reply to Louis Chauvet

This commit introduces helper functions to utilize monitor EDIDs and upload them to the Chamelium.

The existing EDID test has been enhanced to also test 4K screens. The current EDID database includes entries for HDMI and DP ports.

---
 tests/chamelium/v3/kms_chamelium_v3_edid.c | 46 ++++++++++++++++++++++++++++++
 1 file changed, 46 insertions(+)
tests/chamelium/v3/kms_chamelium_v3_edid.c +46 -0
index b8d750ad771d..deef04d97bec 100644
@@ -1,6 +1,8 @@
 // SPDX-License-Identifier: MIT
 
 #include <igt.h>
+
+#include "monitor_edids/monitor_edids_helper.h"
 #include "chamelium/v3/igt_chamelium.h"
 
 static void collect_and_compare_edid(int drm_fd,
@@ -52,6 +54,21 @@ static void igt_custom_edid_type_read(int drm_fd, struct igt_chamelium_v3 *chame
 	upload_and_read_edid(drm_fd, chamelium, port_mapping, igt_kms_get_custom_edid(edid));
 }
 
+static void edid_stress_resolution(int drm_fd, struct igt_chamelium_v3 *chamelium,
+				   struct chamelium_v3_port_mapping *port_mapping,
+				   monitor_edid edids_list[],
+				   size_t edids_list_len)
+{
+	for (int i = 0; i < edids_list_len; i++) {
+		struct edid *edid = edid_from_monitor_edid(&edids_list[i]);
+
+		igt_info("Testing out the EDID for %s\n",
+			 monitor_edid_get_name(&edids_list[i]));
+		upload_and_read_edid(drm_fd, chamelium, port_mapping, edid);
+		free(edid);
+	}
+}
+
 igt_main
 {
 	struct igt_chamelium_v3 *chamelium;
@@ -88,6 +105,35 @@ igt_main
 		}
 	}
 
+	igt_describe("Read many different 4k EDID from the chamelium");
+	igt_subtest_with_dynamic("edid-stress-4k") {
+		struct chamelium_v3_port_mapping *port, *tmp;
+
+		igt_list_for_each_entry_safe(port, tmp, chamelium_v3_get_port_mapping(chamelium),
+					     link) {
+			igt_dynamic_f("port-%d", port->port_id) {
+				drmModeConnectorPtr connector;
+				size_t edid_count = 0;
+				char *name;
+
+				igt_require(!chamelium_v3_is_mst(chamelium, port->port_id));
+
+				name = chamelium_v3_get_port_name(chamelium, port->port_id);
+				igt_info("Testing port %s (%s)\n", port->connector_name, name);
+				free(name);
+
+				connector = chamelium_v3_port_mapping_get_connector(port, drm_fd);
+				igt_assert(connector);
+				edid_stress_resolution(drm_fd, chamelium, port,
+						       get_edids_for_connector_type(connector->connector_type,
+										    &edid_count,
+										    true),
+						       edid_count);
+				drmModeFreeConnector(connector);
+			}
+		}
+	}
+
 	igt_fixture {
 		chamelium_v3_uninit(chamelium);
 		drm_close_driver(drm_fd);
Signature · 1 line
2.44.2
#39 lore raw

PATCH v2 33/39 tests/chamelium/v3: Implement non-4K EDID stress test

In reply to Louis Chauvet

The existing EDID test has been enhanced to also test non-4K screens. The current EDID database includes entries for HDMI and DP ports.

---
 tests/chamelium/v3/kms_chamelium_v3_edid.c | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)
tests/chamelium/v3/kms_chamelium_v3_edid.c +29 -0
index deef04d97bec..b6660769897f 100644
@@ -134,6 +134,35 @@ igt_main
 		}
 	}
 
+	igt_describe("Read many different non-4k EDID from the chamelium");
+	igt_subtest_with_dynamic("edid-stress-non-4k") {
+		struct chamelium_v3_port_mapping *port, *tmp;
+
+		igt_list_for_each_entry_safe(port, tmp, chamelium_v3_get_port_mapping(chamelium),
+					     link) {
+			igt_dynamic_f("port-%d", port->port_id) {
+				drmModeConnectorPtr connector;
+				size_t edid_count = 0;
+				char *name;
+
+				igt_require(!chamelium_v3_is_mst(chamelium, port->port_id));
+
+				name = chamelium_v3_get_port_name(chamelium, port->port_id);
+				igt_info("Testing port %s (%s)\n", port->connector_name, name);
+				free(name);
+
+				connector = chamelium_v3_port_mapping_get_connector(port, drm_fd);
+				igt_assert(connector);
+				edid_stress_resolution(drm_fd, chamelium, port,
+						       get_edids_for_connector_type(connector->connector_type,
+										    &edid_count,
+										    false),
+						       edid_count);
+				drmModeFreeConnector(connector);
+			}
+		}
+	}
+
 	igt_fixture {
 		chamelium_v3_uninit(chamelium);
 		drm_close_driver(drm_fd);
Signature · 1 line
2.44.2
#40 lore raw

PATCH v2 34/39 lib/chamelium/v3: Implement method to discover video signal status

In reply to Louis Chauvet

The Chamelium can record signals received on its ports. This commit introduces DetectResolution and WaitVideoInputStable RPC calls to utilize this functionality, allowing users to monitor and manage video signal status.

---
 lib/chamelium/v3/igt_chamelium.c | 54 ++++++++++++++++++++++++++++++++++++++++
 lib/chamelium/v3/igt_chamelium.h |  5 +++-
 2 files changed, 58 insertions(+), 1 deletion(-)
lib/chamelium/v3/igt_chamelium.c +54 -0
index cf9eb330efe4..436a3cba139e 100644
@@ -1119,3 +1119,57 @@ void chamelium_v3_apply_edid(struct igt_chamelium_v3 *chamelium,
 	igt_debug("RPC ApplyEdid(%d, %d)\n", port_id, edid_id);
 	xmlrpc_DECREF(__chamelium_rpc(chamelium, "ApplyEdid", "(ii)", port_id, edid_id));
 }
+
+/**
+ * chamelium_v3_port_get_resolution - Get the resolution of a signal on a specific port
+ *
+ * @chamelium: Chamelium to use
+ * @port_id: Port to fetch the resolution
+ * @x: Out parameter for the width of the signal
+ * @y: Out parameter for the height of the signal
+ */
+void chamelium_v3_port_get_resolution(struct igt_chamelium_v3 *chamelium,
+				      chamelium_v3_port_id port_id,
+				      int *x, int *y)
+{
+	xmlrpc_value *res, *res_x, *res_y;
+
+	igt_debug("RPC DetectResolution(%d)\n", port_id);
+	res = __chamelium_rpc(chamelium, "DetectResolution", "(i)",
+			      port_id);
+
+	xmlrpc_array_read_item(&chamelium->env, res, 0, &res_x);
+	xmlrpc_array_read_item(&chamelium->env, res, 1, &res_y);
+	xmlrpc_read_int(&chamelium->env, res_x, x);
+	xmlrpc_read_int(&chamelium->env, res_y, y);
+
+	xmlrpc_DECREF(res_x);
+	xmlrpc_DECREF(res_y);
+	xmlrpc_DECREF(res);
+}
+
+/**
+ * chamelium_v3_port_wait_video_input_stable - Get the resolution of a signal on a specific port
+ *
+ * @chamelium: Chamelium to use
+ * @port_id: Port to fetch the resolution
+ * @timeout_secs: Timeout to wait before returning
+ *
+ * Returns true if a signal is properly detected by the chamelium on the port @port_id
+ */
+bool chamelium_v3_port_wait_video_input_stable(struct igt_chamelium_v3 *chamelium,
+					       chamelium_v3_port_id port_id,
+					       int timeout_secs)
+{
+	xmlrpc_value *res;
+	xmlrpc_bool is_on;
+
+	igt_debug("RPC WaitVideoInputStable(%d, %d)\n", port_id, timeout_secs);
+	res = __chamelium_rpc(chamelium, "WaitVideoInputStable", "(ii)",
+			      port_id, timeout_secs);
+
+	xmlrpc_read_bool(&chamelium->env, res, &is_on);
+	xmlrpc_DECREF(res);
+
+	return is_on;
+}
lib/chamelium/v3/igt_chamelium.h +4 -1
index 0d2e481f6cca..bc0645f882c0 100644
@@ -80,5 +80,8 @@ chamelium_edid_id chamelium_v3_create_edid(struct igt_chamelium_v3 *chamelium,
 					   const struct edid *edid);
 void chamelium_v3_apply_edid(struct igt_chamelium_v3 *chamelium, chamelium_v3_port_id port_id,
 			     chamelium_edid_id edid_id);
-
+void chamelium_v3_port_get_resolution(struct igt_chamelium_v3 *chamelium,
+				      chamelium_v3_port_id port_id, int *x, int *y);
+bool chamelium_v3_port_wait_video_input_stable(struct igt_chamelium_v3 *chamelium,
+					       chamelium_v3_port_id port_id, int timeout_secs);
 #endif //V3_IGT_CHAMELIUM_H
Signature · 1 line
2.44.2
#41 lore raw

PATCH v2 35/39 tests/chamelium/v3: Implement test for DRM device resolution

In reply to Louis Chauvet

This commit introduces a new test to verify that the resolution listed and used by the DRM device is accurate according to the EDID.

The test is inspired by the v2 version.

---
 tests/chamelium/v3/kms_chamelium_v3_edid.c | 104 +++++++++++++++++++++++++++++
 1 file changed, 104 insertions(+)
tests/chamelium/v3/kms_chamelium_v3_edid.c +104 -0
index b6660769897f..c03829b43aca 100644
@@ -69,6 +69,90 @@ static void edid_stress_resolution(int drm_fd, struct igt_chamelium_v3 *chameliu
 	}
 }
 
+static void edid_resolution_list(int drm_fd, struct igt_chamelium_v3 *chamelium,
+				 struct chamelium_v3_port_mapping *port_mapping)
+{
+	int screen_res_w, screen_res_h;
+	drmModeConnector *connector;
+	chamelium_edid_id edid_id;
+	drmModeModeInfoPtr modes;
+	struct igt_fb fb = {0};
+	igt_display_t display;
+	bool is_video_stable;
+	igt_output_t *output;
+	igt_plane_t *primary;
+	int count_modes, i;
+	enum pipe pipe;
+	uint32_t connector_id;
+
+	chamelium_v3_reset(chamelium);
+
+	edid_id = chamelium_v3_create_edid(chamelium,
+					   igt_kms_get_custom_edid(IGT_CUSTOM_EDID_BASE));
+	chamelium_v3_apply_edid(chamelium, port_mapping->port_id, edid_id);
+
+	chamelium_v3_plug(chamelium, port_mapping->port_id);
+
+	connector_id = chamelium_v3_port_mapping_get_connector_id(port_mapping, drm_fd);
+	igt_assert(igt_wait_for_connector_status(drm_fd, connector_id, 10.0,
+						 DRM_MODE_CONNECTED));
+
+	connector = chamelium_v3_port_mapping_get_connector(port_mapping, drm_fd);
+	modes = connector->modes;
+	count_modes = connector->count_modes;
+
+	igt_display_require(&display, drm_fd);
+	igt_require(display.is_atomic);
+	igt_display_require_output(&display);
+
+	for (i = 0; i < count_modes; ++i)
+		igt_debug("#%d %s %uHz\n", i, modes[i].name, modes[i].vrefresh);
+
+	for (i = 0; i < count_modes; ++i) {
+		igt_info("Testing #%d %s %uHz\n", i, modes[i].name,
+			 modes[i].vrefresh);
+
+		igt_display_reset(&display);
+
+		output = igt_output_from_connector(&display, connector);
+		igt_assert(output);
+		pipe = igt_get_pipe_for_output(&display, output);
+		igt_output_set_pipe(output, pipe);
+
+		/* Set the screen mode with the one we chose. */
+		igt_create_color_fb(drm_fd, modes[i].hdisplay, modes[i].vdisplay,
+				    DRM_FORMAT_XRGB8888, DRM_FORMAT_MOD_LINEAR, 1, 0, 0, &fb);
+
+		primary = igt_output_get_plane_type(output, DRM_PLANE_TYPE_PRIMARY);
+		igt_assert(primary);
+
+		igt_plane_set_fb(primary, &fb);
+		igt_fb_set_size(&fb, primary, modes[i].hdisplay, modes[i].vdisplay);
+		igt_plane_set_size(primary, modes[i].hdisplay, modes[i].vdisplay);
+
+		igt_output_override_mode(output, &modes[i]);
+
+		igt_display_commit2(output->display, COMMIT_ATOMIC);
+
+		is_video_stable = chamelium_v3_port_wait_video_input_stable(chamelium,
+									    port_mapping->port_id,
+									    10);
+		igt_assert(is_video_stable);
+
+		chamelium_v3_port_get_resolution(chamelium, port_mapping->port_id, &screen_res_w,
+						 &screen_res_h);
+		igt_assert_eq(screen_res_w, modes[i].hdisplay);
+		igt_assert_eq(screen_res_h, modes[i].vdisplay);
+
+		igt_remove_fb(drm_fd, &fb);
+	}
+
+	igt_modeset_disable_all_outputs(&display);
+
+	igt_display_fini(&display);
+	drmModeFreeConnector(connector);
+}
+
 igt_main
 {
 	struct igt_chamelium_v3 *chamelium;
@@ -163,6 +247,26 @@ igt_main
 		}
 	}
 
+	igt_describe("Set a basic EDID and check if resolution are correct");
+	igt_subtest_with_dynamic("edid-resolution-list") {
+		struct chamelium_v3_port_mapping *port, *tmp;
+
+		igt_list_for_each_entry_safe(port, tmp, chamelium_v3_get_port_mapping(chamelium),
+					     link) {
+			igt_dynamic_f("port-%d", port->port_id) {
+				char *name;
+
+				igt_require(!chamelium_v3_is_mst(chamelium, port->port_id));
+
+				name = chamelium_v3_get_port_name(chamelium, port->port_id);
+				igt_info("Testing port %s (%s)\n", port->connector_name, name);
+				free(name);
+
+				edid_resolution_list(drm_fd, chamelium, port);
+			}
+		}
+	}
+
 	igt_fixture {
 		chamelium_v3_uninit(chamelium);
 		drm_close_driver(drm_fd);
Signature · 1 line
2.44.2
#42 lore raw

PATCH v2 36/39 lib/chamelium/v3: Implement hot plug toggle scheduling method

In reply to Louis Chauvet

This commit adds a new method to the Chameleon V3 wrapper to schedule hot plug detect (HPD) toggle events. This feature is useful for testing suspend and resume behaviors, as it allows the simulation of device connection and disconnection events at specified times.

---
 lib/chamelium/v3/igt_chamelium.c | 16 ++++++++++++++++
 lib/chamelium/v3/igt_chamelium.h |  2 ++
 2 files changed, 18 insertions(+)
lib/chamelium/v3/igt_chamelium.c +16 -0
index 436a3cba139e..fa70e2c1e296 100644
@@ -1173,3 +1173,19 @@ bool chamelium_v3_port_wait_video_input_stable(struct igt_chamelium_v3 *chameliu
 
 	return is_on;
 }
+
+/**
+ * chamelium_v3_schedule_hpd_toggle - Schedule an hotplug detect toggle
+ *
+ * @chamelium: Chamelium to use
+ * @port_id: Port to schedule the hpd toggle
+ * @delay_ms: Delay before triggering the toggle
+ * @end_level: HPD status after the toggle, where true is connected
+ */
+void chamelium_v3_schedule_hpd_toggle(struct igt_chamelium_v3 *chamelium,
+				      chamelium_v3_port_id port_id, int delay_ms, bool end_level)
+{
+	igt_debug("RPC ScheduleHpdToggle(%d, %d, %d)\n", port_id, delay_ms, end_level);
+	xmlrpc_DECREF(__chamelium_rpc(chamelium, "ScheduleHpdToggle", "(iib)", port_id,
+				      delay_ms, end_level));
+}
lib/chamelium/v3/igt_chamelium.h +2 -0
index bc0645f882c0..fb600e1d771f 100644
@@ -84,4 +84,6 @@ void chamelium_v3_port_get_resolution(struct igt_chamelium_v3 *chamelium,
 				      chamelium_v3_port_id port_id, int *x, int *y);
 bool chamelium_v3_port_wait_video_input_stable(struct igt_chamelium_v3 *chamelium,
 					       chamelium_v3_port_id port_id, int timeout_secs);
+void chamelium_v3_schedule_hpd_toggle(struct igt_chamelium_v3 *chamelium,
+				      chamelium_v3_port_id port_id, int delay_ms, bool end_level);
 #endif //V3_IGT_CHAMELIUM_H
Signature · 1 line
2.44.2
#43 lore raw

PATCH v2 37/39 tests/chamelium/v3: Add test for display change detection during sleep

In reply to Louis Chauvet

This commit introduces a new test for the Chameleon V3 display adapter to ensure that it properly detects display changes during sleep. The test verifies that if the display is disconnected/reconnected while the device is in sleep mode, the new display is correctly detected upon waking up.

This test is inspired by a similar test in the Chameleon V2 version.

---
 tests/chamelium/v3/kms_chamelium_v3_edid.c | 59 ++++++++++++++++++++++++++++++
 1 file changed, 59 insertions(+)
tests/chamelium/v3/kms_chamelium_v3_edid.c +59 -0
index c03829b43aca..a73875214915 100644
@@ -153,6 +153,43 @@ static void edid_resolution_list(int drm_fd, struct igt_chamelium_v3 *chamelium,
 	drmModeFreeConnector(connector);
 }
 
+static void test_suspend_resume_edid_change(int drm_fd, struct igt_chamelium_v3 *chamelium,
+					    struct chamelium_v3_port_mapping *port_mapping,
+					    enum igt_suspend_state state,
+					    enum igt_suspend_test test)
+{
+	chamelium_edid_id base_edid, alt_edid;
+	uint32_t connector_id;
+
+	chamelium_v3_reset(chamelium);
+
+	base_edid = chamelium_v3_create_edid(chamelium, igt_kms_get_base_edid());
+	igt_assert(base_edid);
+	alt_edid = chamelium_v3_create_edid(chamelium, igt_kms_get_alt_edid());
+	igt_assert(alt_edid);
+
+	chamelium_v3_apply_edid(chamelium, port_mapping->port_id, base_edid);
+	chamelium_v3_plug(chamelium, port_mapping->port_id);
+	connector_id = chamelium_v3_port_mapping_get_connector_id(port_mapping, drm_fd);
+	igt_assert(igt_wait_for_connector_status(drm_fd, connector_id, 10.0,
+						 DRM_MODE_CONNECTED));
+	collect_and_compare_edid(drm_fd, port_mapping, igt_kms_get_base_edid());
+
+	chamelium_v3_apply_edid(chamelium, port_mapping->port_id, alt_edid);
+
+	// Schedule the hpd pulse during the sleep state
+	chamelium_v3_schedule_hpd_toggle(chamelium, port_mapping->port_id,
+					 igt_get_autoresume_delay(state) * 1000 / 2,
+					 true);
+	igt_system_suspend_autoresume(state, test);
+
+	connector_id = chamelium_v3_port_mapping_get_connector_id(port_mapping, drm_fd);
+	igt_assert(igt_wait_for_connector_status(drm_fd, connector_id, 10.0,
+						 DRM_MODE_CONNECTED));
+
+	collect_and_compare_edid(drm_fd, port_mapping, igt_kms_get_alt_edid());
+}
+
 igt_main
 {
 	struct igt_chamelium_v3 *chamelium;
@@ -267,6 +304,28 @@ igt_main
 		}
 	}
 
+	igt_describe("Check if hotplug during sleeping are correctly handled");
+	igt_subtest_with_dynamic("edid-edid-suspend-mem") {
+		struct chamelium_v3_port_mapping *port, *tmp;
+
+		igt_list_for_each_entry_safe(port, tmp, chamelium_v3_get_port_mapping(chamelium),
+					     link) {
+			igt_dynamic_f("port-%d", port->port_id) {
+				char *name;
+
+				igt_require(!chamelium_v3_is_mst(chamelium, port->port_id));
+
+				name = chamelium_v3_get_port_name(chamelium, port->port_id);
+				igt_info("Testing port %s (%s)\n", port->connector_name, name);
+				free(name);
+
+				test_suspend_resume_edid_change(drm_fd, chamelium, port,
+								SUSPEND_STATE_MEM,
+								SUSPEND_TEST_NONE);
+			}
+		}
+	}
+
 	igt_fixture {
 		chamelium_v3_uninit(chamelium);
 		drm_close_driver(drm_fd);
Signature · 1 line
2.44.2
#44 lore raw

PATCH v2 38/39 tests/chamelium/v3: Add MST EDID reading test

In reply to Louis Chauvet

This commit introduces a new test for the Chameleon V3 display adapter to ensure that EDID is correctly read from MST ports.

---
 tests/chamelium/v3/kms_chamelium_v3_edid.c | 86 ++++++++++++++++++++++++++++++
 1 file changed, 86 insertions(+)
tests/chamelium/v3/kms_chamelium_v3_edid.c +86 -0
index a73875214915..51dcdcb9e892 100644
@@ -190,6 +190,70 @@ static void test_suspend_resume_edid_change(int drm_fd, struct igt_chamelium_v3
 	collect_and_compare_edid(drm_fd, port_mapping, igt_kms_get_alt_edid());
 }
 
+static void edid_mst(int drm_fd, struct igt_chamelium_v3 *chamelium, chamelium_v3_port_id port_id)
+{
+	const struct edid *edid = igt_kms_get_base_edid();
+	chamelium_v3_port_id *children_port_ids;
+	struct chamelium_v3_port_mapping *chamelium_port_mapping;
+	drmModeResPtr res;
+	int edid_id;
+	int children_port_count = chamelium_v3_get_children(chamelium, port_id,
+							    &children_port_ids);
+
+	struct edid **modified_edids;
+
+	modified_edids = calloc(children_port_count + 1, sizeof(*modified_edids));
+	igt_assert(modified_edids);
+
+	for (int i = 0; i <= children_port_count; i++) {
+		modified_edids[i] = malloc(edid_get_size(edid));
+		memcpy(modified_edids[i], edid, edid_get_size(edid));
+		modified_edids[i]->serial[0] = i;
+		modified_edids[i]->serial[1] = i;
+		modified_edids[i]->serial[2] = i;
+		modified_edids[i]->serial[3] = i;
+		edid_update_checksum(modified_edids[i]);
+	}
+
+	chamelium_v3_reset(chamelium);
+
+	edid_id = chamelium_v3_create_edid(chamelium, modified_edids[0]);
+	igt_assert(edid_id);
+	chamelium_v3_apply_edid(chamelium, port_id, edid_id);
+
+	for (int i = 0; i < children_port_count; i++) {
+		edid_id = chamelium_v3_create_edid(chamelium, modified_edids[i + 1]);
+		igt_assert(edid_id);
+		chamelium_v3_apply_edid(chamelium, children_port_ids[i], edid_id);
+	}
+
+	chamelium_v3_plug_with_children(chamelium, port_id, children_port_ids,
+					children_port_count);
+	sleep(3);
+
+	res = drmModeGetResources(drm_fd);
+
+	chamelium_port_mapping = chamelium_v3_get_port_mapping_for_chamelium_port_id(chamelium,
+										     port_id);
+	igt_assert(chamelium_port_mapping);
+	igt_assert(chamelium_port_mapping->mst_path);
+	collect_and_compare_edid(drm_fd, chamelium_port_mapping, modified_edids[0]);
+	free(modified_edids[0]);
+
+	for (int i = 0; i < children_port_count; i++) {
+		chamelium_port_mapping = chamelium_v3_get_port_mapping_for_chamelium_port_id(chamelium,
+											     children_port_ids[i]);
+		igt_assert(chamelium_port_mapping);
+		igt_assert(chamelium_port_mapping->mst_path);
+		collect_and_compare_edid(drm_fd, chamelium_port_mapping, modified_edids[i + 1]);
+		free(modified_edids[i + 1]);
+	}
+
+	drmModeFreeResources(res);
+	free(modified_edids);
+	free(children_port_ids);
+}
+
 igt_main
 {
 	struct igt_chamelium_v3 *chamelium;
@@ -326,6 +390,28 @@ igt_main
 		}
 	}
 
+	igt_describe("Check if hotplug during sleeping are correctly handled");
+	igt_subtest_with_dynamic("DP-MST-edid-read") {
+		chamelium_v3_port_id *port_ids;
+		int port_count;
+
+		port_count = chamelium_v3_get_supported_ports(chamelium, &port_ids);
+		for (int j = 0; j < port_count; j++) {
+			igt_dynamic_f("port-%d", port_ids[j]) {
+				char *name;
+
+				igt_require(chamelium_v3_is_mst(chamelium, port_ids[j]));
+
+				name = chamelium_v3_get_port_name(chamelium, port_ids[j]);
+				igt_info("Testing port %s\n", name);
+				free(name);
+
+				edid_mst(drm_fd, chamelium, port_ids[j]);
+			}
+		}
+		free(port_ids);
+	}
+
 	igt_fixture {
 		chamelium_v3_uninit(chamelium);
 		drm_close_driver(drm_fd);
Signature · 1 line
2.44.2
#45 lore raw

PATCH v2 39/39 docs: Add Chamelium v3

In reply to Louis Chauvet

Add documentation around the Chamelium v3, its new features and its capabilities.

---
 docs/chamelium.txt | 90 +++++++++++++++++++++++++++++++++++++++++++++++++-----
 1 file changed, 83 insertions(+), 7 deletions(-)
docs/chamelium.txt +83 -7
index 64f851c2841c..3179b39dc155 100644
@@ -19,7 +19,10 @@ part of the ChromeOS effort under the name Chameleon and was later made external
 as part of the ChromiumOS effort, under the name Chamelium.
 
 A new Chamelium V3 (Cv3) was released in 2022, which is built with different
-hardware while maintaining software backwards compatibility with v2.
+hardware, using almost the same API with chamelium v2. Some features are not
+present in the chamelium v3: plug all ports at the same time, take a screen
+capture of a small part of the screen, audio recording... The main goal of the
+Cv3 is to bring MST support.
 
 Chamelium V2
 ------------
@@ -41,7 +44,7 @@ While the FPGA is used for logic control, the CPU runs daemons that allow the
 board to be controlled over the network via a XMLRPC interface.
 
 [Current limitation] Cv3 hardware uses an ITE chip which allows only 1 port to
-be plugged in a time. This limitation will be fixed in the upcoming iteration. 
+be plugged in a time. This limitation will be fixed in the upcoming iteration.
 
 Chamelium V2 Documentation
 --------------------------
@@ -50,6 +53,12 @@ Documentation about the Chamelium is made available by Google through the
 ChromiumOS projet wiki:
 https://www.chromium.org/chromium-os/developer-library/guides/hardware-schematics/chamelium/
 
+Chamelium V2 Documentation
+--------------------------
+
+Documentation about the Cv3 is made available by Google directly in the git
+repository: https://source.chromium.org/chromiumos/chromiumos/codesearch/+/main:src/platform/chameleon/v3/doc/
+
 Setting up Chamelium V2
 -----------------------
 
@@ -76,6 +85,16 @@ and then configure eth0 like so:
 This document supposes that target PC's network IP has "192.168.1.1/24" and
 the Chamelium's network IP has "192.168.1.2/24".
 
+Setting up Chamelium V3
+-----------------------
+
+To setup the chamelium software, you can refer to the chamelium documentation:
+https://source.chromium.org/chromiumos/chromiumos/codesearch/+/main:src/platform/chameleon/v3/doc/first_boot.md
+
+Once setup you can define a static IP address with network manager (a nice TUI
+is installed: `nmtui`) or use DHCP to set a stable one. It is required as the IGT
+tests will need to communicate with the chamelium.
+
 Deploying the Chamelium With IGT
 --------------------------------
 
@@ -115,6 +134,16 @@ example (only Chamelium.URL is mandatory):
     # The URL used for connecting to the Chamelium's RPC server
     URL=http://192.168.1.2:9992
 
+
+By default, the IGT tests will perform autodiscovery. As it can take some time, you can
+manually define a static configuration. This configuration will be trusted by the test
+and no autodetection will be performed, so if the physical connexion is not exactly
+the same the tests will fail.
+
+As the Cv3 brings support for MST, two different configuration format are used.
+
+For chamelium v2:
+
     # The rest of the sections are used for defining connector mappings. This
     # is optional if the same connector type (ex. DP-DP) is used on both sides,
     # the mappings will be discovered automatically.
@@ -142,6 +171,38 @@ example (only Chamelium.URL is mandatory):
     [Chamelium:VGA-1]
     ChameliumPortID=4
 
+For chamelium v3:
+
+    # For physical ports
+    [Chameliumv3:<port_id>]
+    PortName=<drm connector name>
+
+    # For MST parent ports
+    [Chameliumv3:<port_id>]
+    MstPath=<mst path of this port>
+
+    # For MST children ports
+    [Chameliumv3:<port_id>]
+    MstPath=<mst path of this port>
+    ChameliumParentID=<parent id on the chamelium side>
+
+To generate the Cv3 configuration, you can use this minimal file, the
+first chamelium test will perform an autodetection and save the result in igtrc:
+
+    [Chamelium]
+    # The URL used for connecting to the Chamelium's RPC server
+    URL=http://192.168.1.2:9992
+    ChameliumAutodetectSave=1
+
+As the chamelium is also used for emulating display, it can be useful to plug some ports during "normal" testings. To do
+so, you have to use the options ConnectOnAnyTest and, if needed, EDID. This does not work yet for MST.
+
+    [Chameliumv3:<port_id>]
+    PortName=<drm connector name>
+    ConnectOnAnyTest=true
+    EDID=<EDID name you want to plug, leave empty to get the list of supported EDID>
+
+
 Chamelium V2 Port IDs
 ---------------------
 defined at: https://chromium.googlesource.com/chromiumos/platform/chameleon/+/master/chameleond/utils/ids.py
@@ -150,12 +211,27 @@ DP2 (located next to the VGA connector) = 2
 HDMI = 3
 VGA = 4
 
-Cv3 Port IDs
+Chamelium V3 Port IDs
 ---------------------
-DP1 (top left) = 0
-DP2 (top right) = 1
-HDMI1 (bottom left) = 2
-HDMI2 (bottom right) = 3
+
+Four ports are available with the Cv3: 2 DP and 2 HDMI. With MST, 4 more virtual ports
+are available. Obviously, as the same physical port is connected to different hardware
+emulation, you can't plug all the chamelium ports at the same time.
+
+
+DP1, at the top left, can be used as:
+- Physical DP, port_id = 0
+- Emulated DP, port_id = 4
+
+DP2, at the top right can be used as:
+- Physical DP, port_id = 1
+- MST DP, port_id = 5, and its children 6, 7, 8
+
+HDMI1 (bottom left):
+- Physical HDMI, port_id = 2
+
+HDMI2 (bottom right):
+- Physical HDMI, port_id = 3
 
 Running the Chamelium With IGT
 ------------------------------
Signature · 1 line
2.44.2
#46 lore raw
In reply to Louis Chauvet
Quoted 44 lines · Louis Chauvet

Hi all,

This patch series introduces a new wrapper for the Chameleon v3 board, a testing tool used primarily for Chromebooks, but also by community members to increase test coverage of graphic devices. The Chameleon v3 is an upgrade from its predecessor, with the ability to emulate 2 HDMI and 2 DisplayPort devices, including MST devices.

The board can read and analyze any stream on the DisplayPort and HDMI cables, and even take captures, making it an ideal tool for testing hardware, driver, and user space behavior in specific situations, such as screen hotplugging and multiple MST screens. However, the changes between the v2 and v3, such as the addition of MST support and the removal of CRC for screen captures, would require significant modifications to the existing tests and wrappers.

To avoid this complexity and ensure that the Chameleon v3 is fully supported and the v2 is not broken, I wrote a new wrapper with simplicity and ease of use in mind. The Chameleon v3 wrapper should only manage the Chameleon itself, without the need for DRM displays, EDID caching/modifications, or state machines. This approach will make it easier for developers to use the Chameleon v3 and contribute to its development.

I will use this work to create many new tests (that will come in future series):
- MST managment
- Tiled displays emulation
- Suspend/Resume
- Hardware overlay planes

This series can be divided in multiple parts:
- PATCH 1-5: Adding few helpers to igt_kms
- PATCH 6-10: Add few helpers to minotor_edid
- PATCH 10-14: Split chamelium v2 and chamelium v3 support
- PATCH 15-18: Create a basic test listing available port on the chamelium
- PATCH 19-27: Add port mapping configuration and autodetection
- PATCH 28-38: Add basic EDID tests
- PATCH 39: Add documentation

As most of the series is preparation work, I sent all the patches today, but if required I can split the series in multiple smallest series.

Quoted 6 lines

---
Changes in v2:
- Mainly splitting and cleaning work since the RFC,
EDITME: describe what is new in this series revision.
- EDITME: use bulletpoints and terse descriptions.
- Link to v1: https://lore.kernel.org/r/[email protected]

Ooops, I forgot to edit this part, sorry

Changes in v2:
- Since the RFC, a lot of work has been done to split commits, document functions, configuration format and cleanup
- Changed the autodetection algorithm to make it a bit faster and less complex
- Introduce new setting to plug specific port during "normal" tests
- Solved build failures, this should be bissectable

Quoted 84 lines

---
Louis Chauvet (39):
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 function to get valid pipe for specific output 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 lib/monitor_edids: Fix missing names in some monitor EDID lib/monitor_edids: Add new EDID for HDMI 4k
tests/chamelium: Extract Chamelium v2 tests into a separate directory lib/chamelium/v2: Extract chamelium v2 wrapper into its own directory lib/chamelium/v2: Modify build options to separate Chamelium v2 and v3 lib/chamelium/v3: Introduce the foundation for the Chamelium v3 wrapper lib/chamelium/v3: Introduce initialization and cleanup of Chamelium-related structures lib/chamelium/v3: Add method to discover Chamelium ports lib/chamelium/v3: Implement method to retrieve Chamelium port names tests/chamelium/v3: Implement a basic Chamelium v3 accessibility test lib/chamelium/v3: Implement Chamelium reinitialization via Reset RPC call lib/chamelium/v3: Implement methods for plugging Chamelium ports lib/chamelium/v3: Implement methods for managing Chamelium EDID lib/chamelium/v3: Implement Chamelium configuration parsing lib/chamelium/v3: Log port mapping for debugging purposes lib/chamelium/v3: Introduce new configuration format for MST support lib/chamelium/v3: Provide access to port_mapping via method call lib/chamelium/v3: Implement helper function to get port mapping from Chameleon port id lib/chamelium/v3: Implement helper function to retrieve connector from port mapping lib/chamelium/v3: Plug specific ports for all tests
lib/chamelium/v3: Implement Chamelium port autodetection algorithm lib/chamelium/v3: Add save option to avoid doing autodetection every time tests/chamelium/v3: Implement basic EDID handling test tests/chamelium/v3: Implement 4K EDID stress test
tests/chamelium/v3: Implement non-4K EDID stress test
lib/chamelium/v3: Implement method to discover video signal status tests/chamelium/v3: Implement test for DRM device resolution lib/chamelium/v3: Implement hot plug toggle scheduling method tests/chamelium/v3: Add test for display change detection during sleep tests/chamelium/v3: Add MST EDID reading test
docs: Add Chamelium v3

 docs/chamelium.txt                              |   90 +-
 docs/testplan/meson.build                       |    4 +-
 lib/{ => chamelium/v2}/igt_chamelium.c          |    2 +-
 lib/{ => chamelium/v2}/igt_chamelium.h          |    0
 lib/{ => chamelium/v2}/igt_chamelium_stream.c   |    2 +-
 lib/{ => chamelium/v2}/igt_chamelium_stream.h   |    0
 lib/chamelium/v3/igt_chamelium.c                | 1191 +++++++++++++++++++++++
 lib/chamelium/v3/igt_chamelium.h                |   89 ++
 lib/igt.h                                       |    6 +-
 lib/igt_core.c                                  |    3 +
 lib/igt_kms.c                                   |  287 +++++-
 lib/igt_kms.h                                   |   17 +
 lib/meson.build                                 |   16 +-
 lib/monitor_edids/dp_edids.h                    |    3 +
 lib/monitor_edids/hdmi_edids.h                  |   27 +-
 lib/monitor_edids/monitor_edids_helper.c        |   92 +-
 lib/monitor_edids/monitor_edids_helper.h        |   10 +-
 lib/tests/meson.build                           |    8 +-
 meson.build                                     |   45 +-
 meson_options.txt                               |    8 +-
 tests/chamelium/{ => v2}/kms_chamelium_audio.c  |    0
 tests/chamelium/{ => v2}/kms_chamelium_color.c  |    0
 tests/chamelium/{ => v2}/kms_chamelium_edid.c   |    2 +-
 tests/chamelium/{ => v2}/kms_chamelium_frames.c |    0
 tests/chamelium/{ => v2}/kms_chamelium_helper.c |    0
 tests/chamelium/{ => v2}/kms_chamelium_helper.h |    0
 tests/chamelium/{ => v2}/kms_chamelium_hpd.c    |    0
 tests/chamelium/v3/kms_chamelium_v3_basic.c     |   30 +
 tests/chamelium/v3/kms_chamelium_v3_edid.c      |  419 ++++++++
 tests/kms_color_helper.h                        |    2 +-
 tests/kms_feature_discovery.c                   |    6 +-
 tests/kms_tiled_display.c                       |    6 +-
 tests/meson.build                               |   45 +-
 33 files changed, 2348 insertions(+), 62 deletions(-)

---
base-commit: 9683de1314f7fb9204fc4d8baf193a52adda9b59
change-id: 20240522-dev-remove-static-ports-9382ffbbf146

Best regards,

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

✗ Fi.CI.BUILD: failure for tests/chamelium: Integrate the chamelium v3

In reply to Louis Chauvet
== Series Details ==

== Series Details ==

Series: tests/chamelium: Integrate the chamelium v3
URL : https://patchwork.freedesktop.org/series/135910/
State : failure

== Summary ==

IGT patchset build failed on latest successful build a7ef4e2bacb168f19605851986629d462b097df6 lib/i915/perf: Add ARL support in IGT perf library

Tail of build.log:
[381/1759] Compiling C object 'lib/76b5a35@@igt-igt_v3d_c@sta/igt_v3d.c.o'.
[382/1759] Compiling C object 'lib/76b5a35@@igt-gpu_cmds_c@sta/gpu_cmds.c.o'.
[383/1759] Compiling C object 'tests/59830eb@@kms_selftest@exe/kms_selftest.c.o'.
[384/1759] Compiling C object 'lib/76b5a35@@igt-rendercopy_gen7_c@sta/rendercopy_gen7.c.o'. [385/1759] Compiling C object 'tests/59830eb@@kms_sysfs_edid_timing@exe/kms_sysfs_edid_timing.c.o'. [386/1759] Compiling C object 'tests/59830eb@@gem_softpin@exe/intel_gem_softpin.c.o'. [387/1759] Compiling C object 'tests/59830eb@@kms_scaling_modes@exe/kms_scaling_modes.c.o'. [388/1759] Compiling C object 'lib/76b5a35@@igt-igt_draw_c@sta/igt_draw.c.o'.
[389/1759] Compiling C object 'lib/76b5a35@@igt-rendercopy_gen6_c@sta/rendercopy_gen6.c.o'. [390/1759] Compiling C object 'lib/76b5a35@@igt-intel_compute_c@sta/intel_compute.c.o'. [391/1759] Compiling C object 'tests/59830eb@@kms_plane_multiple@exe/kms_plane_multiple.c.o'. [392/1759] Compiling C object 'tests/59830eb@@kms_tv_load_detect@exe/kms_tv_load_detect.c.o'. [393/1759] Compiling C object 'tests/59830eb@@kms_rmfb@exe/kms_rmfb.c.o'.
[394/1759] Compiling C object 'tests/59830eb@@kms_plane_cursor@exe/kms_plane_cursor.c.o'. [395/1759] Compiling C object 'tests/59830eb@@kms_plane_lowres@exe/kms_plane_lowres.c.o'. [396/1759] Compiling C object 'lib/76b5a35@@igt-intel_bufops_c@sta/intel_bufops.c.o'. [397/1759] Compiling C object 'tests/59830eb@@kms_pipe_crc_basic@exe/kms_pipe_crc_basic.c.o'. [398/1759] Compiling C object 'lib/76b5a35@@igt-igt_pm_c@sta/igt_pm.c.o'.
[399/1759] Compiling C object 'tests/59830eb@@kms_prop_blob@exe/kms_prop_blob.c.o'.
[400/1759] Compiling C object 'tests/59830eb@@kms_plane_alpha_blend@exe/kms_plane_alpha_blend.c.o'. [401/1759] Compiling C object 'tests/59830eb@@kms_prime@exe/kms_prime.c.o'.
[402/1759] Compiling C object 'lib/76b5a35@@igt-igt_amd_c@sta/igt_amd.c.o'.
[403/1759] Generating i915-perf-registers-acmgt3 with a custom command.
[404/1759] Compiling C object 'lib/76b5a35@@igt-igt_vmwgfx_c@sta/igt_vmwgfx.c.o'.
[405/1759] Compiling C object 'tests/59830eb@@kms_tiled_display@exe/kms_tiled_display.c.o'. [406/1759] Compiling C object 'tests/59830eb@@kms_sequence@exe/kms_sequence.c.o'.
[407/1759] Compiling C object 'tests/59830eb@@gem_concurrent_blit@exe/intel_gem_concurrent_blit.c.o'. [408/1759] Compiling C object 'lib/76b5a35@@xe_oa@sha/meson-generated_.._xe_oa_equations.c.o'. [409/1759] Compiling C object 'tests/59830eb@@kms_flip@exe/kms_flip.c.o'.
[410/1759] Compiling C object 'lib/76b5a35@@igt-intel_blt_c@sta/intel_blt.c.o'.
[411/1759] Compiling C object 'tests/59830eb@@kms_plane@exe/kms_plane.c.o'.
[412/1759] Generating i915-perf-metrics-acmgt3 with a custom command.
[413/1759] Compiling C object 'lib/76b5a35@@igt-igt_kmod_c@sta/igt_kmod.c.o'.
[414/1759] Compiling C object 'tests/59830eb@@kms_properties@exe/kms_properties.c.o'. [415/1759] Compiling C object 'tests/59830eb@@kms_setmode@exe/kms_setmode.c.o'.
[416/1759] Compiling C object 'tests/59830eb@@kms_plane_scaling@exe/kms_plane_scaling.c.o'. [417/1759] Compiling C object 'tests/59830eb@@kms_lease@exe/kms_lease.c.o'.
[418/1759] Compiling C object 'lib/76b5a35@@igt-chamelium_v2_igt_chamelium_c@sta/chamelium_v2_igt_chamelium.c.o'. [419/1759] Compiling C object 'tests/59830eb@@kms_rotation_crc@exe/kms_rotation_crc.c.o'. [420/1759] Compiling C object 'tests/59830eb@@kms_atomic@exe/kms_atomic.c.o'.
[421/1759] Compiling C object 'lib/76b5a35@@igt-rendercopy_gen8_c@sta/rendercopy_gen8.c.o'. [422/1759] Compiling C object 'tests/59830eb@@kms_cursor_legacy@exe/kms_cursor_legacy.c.o'. [423/1759] Compiling C object 'lib/76b5a35@@igt-igt_core_c@sta/igt_core.c.o'.
[424/1759] Compiling C object 'lib/76b5a35@@igt-intel_batchbuffer_c@sta/intel_batchbuffer.c.o'. [425/1759] Compiling C object 'lib/76b5a35@@igt-rendercopy_gen9_c@sta/rendercopy_gen9.c.o'. [426/1759] Compiling C object 'lib/76b5a35@@igt-igt_fb_c@sta/igt_fb.c.o'.
[427/1759] Compiling C object 'lib/76b5a35@@igt-i915_intel_decode_c@sta/i915_intel_decode.c.o'. [428/1759] Compiling C object 'lib/76b5a35@@igt-igt_kms_c@sta/igt_kms.c.o'.
[429/1759] Generating i915-perf-equations with a custom command.
ninja: build stopped: subcommand failed.

#48 lore raw

Re: ✗ Fi.CI.BUILD: failure for tests/chamelium: Integrate the chamelium v3

Hi all,

It seems like I forgot to include errno.h. Should I send a new version or wait for comments before?

lib/chamelium/v3/igt_chamelium.c +2 -0
index fa70e2c1e296..4ed408a49afb 100644
@@ -1,5 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0
 
+#include <errno.h>
+
 #include <xmlrpc-c/base.h>
 #include <xmlrpc-c/client.h>
 

This morning I attempted to run the CI locally to avoid more errors, it was a bit tricky (gitlab-runner deprecated the exec option to run the CI locally, the images used are in the private docker repository, I had to rebuild docker image myself).

With the following diff, the fedora build seems to pass, but I have some timeout on tests, this timeout is also present on master.

 PASS  build:tests-fedora
 PASS  build:tests-fedora-no-libunwind
 PASS  build:tests-fedora-oldest-meson
 PASS  build:tests-fedora-no-libdrm-nouveau
 PASS  build:tests-fedora-clang
 PASS  test:list-undocumented-tests
 PASS  test:verify-blacklists
 FAIL  test:ninja-test
Quoted 3 lines
Skipped:               0
Timeout:               1

Full log written to /gcl-builds/build/meson-logs/testlog.txt

FAIL test:ninja-test-clang

Quoted 3 lines
Skipped:               0
Timeout:               1

Full log written to /gcl-builds/build/meson-logs/testlog.txt

For test:ninja-test
419/431 runner TIMEOUT 300.01 s

For test:ninja-test-clang
419/431 runner TIMEOUT 300.00 s

I am not able to run debian images, I tried to build the Dockerfile, but the debian version seems too old (404 during apt update), and I am not able to fetch prebuild images from gitlab (it seems to require API keys).

I will send a series to explain how to run the CI locally.

Quoted 64 lines

== Series Details ==

Series: tests/chamelium: Integrate the chamelium v3
URL : https://patchwork.freedesktop.org/series/135910/
State : failure

== Summary ==

IGT patchset build failed on latest successful build a7ef4e2bacb168f19605851986629d462b097df6 lib/i915/perf: Add ARL support in IGT perf library

Tail of build.log:
[381/1759] Compiling C object 'lib/76b5a35@@igt-igt_v3d_c@sta/igt_v3d.c.o'.
[382/1759] Compiling C object 'lib/76b5a35@@igt-gpu_cmds_c@sta/gpu_cmds.c.o'.
[383/1759] Compiling C object 'tests/59830eb@@kms_selftest@exe/kms_selftest.c.o'.
[384/1759] Compiling C object 'lib/76b5a35@@igt-rendercopy_gen7_c@sta/rendercopy_gen7.c.o'. [385/1759] Compiling C object 'tests/59830eb@@kms_sysfs_edid_timing@exe/kms_sysfs_edid_timing.c.o'. [386/1759] Compiling C object 'tests/59830eb@@gem_softpin@exe/intel_gem_softpin.c.o'. [387/1759] Compiling C object 'tests/59830eb@@kms_scaling_modes@exe/kms_scaling_modes.c.o'. [388/1759] Compiling C object 'lib/76b5a35@@igt-igt_draw_c@sta/igt_draw.c.o'.
[389/1759] Compiling C object 'lib/76b5a35@@igt-rendercopy_gen6_c@sta/rendercopy_gen6.c.o'. [390/1759] Compiling C object 'lib/76b5a35@@igt-intel_compute_c@sta/intel_compute.c.o'. [391/1759] Compiling C object 'tests/59830eb@@kms_plane_multiple@exe/kms_plane_multiple.c.o'. [392/1759] Compiling C object 'tests/59830eb@@kms_tv_load_detect@exe/kms_tv_load_detect.c.o'. [393/1759] Compiling C object 'tests/59830eb@@kms_rmfb@exe/kms_rmfb.c.o'.
[394/1759] Compiling C object 'tests/59830eb@@kms_plane_cursor@exe/kms_plane_cursor.c.o'. [395/1759] Compiling C object 'tests/59830eb@@kms_plane_lowres@exe/kms_plane_lowres.c.o'. [396/1759] Compiling C object 'lib/76b5a35@@igt-intel_bufops_c@sta/intel_bufops.c.o'. [397/1759] Compiling C object 'tests/59830eb@@kms_pipe_crc_basic@exe/kms_pipe_crc_basic.c.o'. [398/1759] Compiling C object 'lib/76b5a35@@igt-igt_pm_c@sta/igt_pm.c.o'.
[399/1759] Compiling C object 'tests/59830eb@@kms_prop_blob@exe/kms_prop_blob.c.o'.
[400/1759] Compiling C object 'tests/59830eb@@kms_plane_alpha_blend@exe/kms_plane_alpha_blend.c.o'. [401/1759] Compiling C object 'tests/59830eb@@kms_prime@exe/kms_prime.c.o'.
[402/1759] Compiling C object 'lib/76b5a35@@igt-igt_amd_c@sta/igt_amd.c.o'.
[403/1759] Generating i915-perf-registers-acmgt3 with a custom command.
[404/1759] Compiling C object 'lib/76b5a35@@igt-igt_vmwgfx_c@sta/igt_vmwgfx.c.o'.
[405/1759] Compiling C object 'tests/59830eb@@kms_tiled_display@exe/kms_tiled_display.c.o'. [406/1759] Compiling C object 'tests/59830eb@@kms_sequence@exe/kms_sequence.c.o'.
[407/1759] Compiling C object 'tests/59830eb@@gem_concurrent_blit@exe/intel_gem_concurrent_blit.c.o'. [408/1759] Compiling C object 'lib/76b5a35@@xe_oa@sha/meson-generated_.._xe_oa_equations.c.o'. [409/1759] Compiling C object 'tests/59830eb@@kms_flip@exe/kms_flip.c.o'.
[410/1759] Compiling C object 'lib/76b5a35@@igt-intel_blt_c@sta/intel_blt.c.o'.
[411/1759] Compiling C object 'tests/59830eb@@kms_plane@exe/kms_plane.c.o'.
[412/1759] Generating i915-perf-metrics-acmgt3 with a custom command.
[413/1759] Compiling C object 'lib/76b5a35@@igt-igt_kmod_c@sta/igt_kmod.c.o'.
[414/1759] Compiling C object 'tests/59830eb@@kms_properties@exe/kms_properties.c.o'. [415/1759] Compiling C object 'tests/59830eb@@kms_setmode@exe/kms_setmode.c.o'.
[416/1759] Compiling C object 'tests/59830eb@@kms_plane_scaling@exe/kms_plane_scaling.c.o'. [417/1759] Compiling C object 'tests/59830eb@@kms_lease@exe/kms_lease.c.o'.
[418/1759] Compiling C object 'lib/76b5a35@@igt-chamelium_v2_igt_chamelium_c@sta/chamelium_v2_igt_chamelium.c.o'. [419/1759] Compiling C object 'tests/59830eb@@kms_rotation_crc@exe/kms_rotation_crc.c.o'. [420/1759] Compiling C object 'tests/59830eb@@kms_atomic@exe/kms_atomic.c.o'.
[421/1759] Compiling C object 'lib/76b5a35@@igt-rendercopy_gen8_c@sta/rendercopy_gen8.c.o'. [422/1759] Compiling C object 'tests/59830eb@@kms_cursor_legacy@exe/kms_cursor_legacy.c.o'. [423/1759] Compiling C object 'lib/76b5a35@@igt-igt_core_c@sta/igt_core.c.o'.
[424/1759] Compiling C object 'lib/76b5a35@@igt-intel_batchbuffer_c@sta/intel_batchbuffer.c.o'. [425/1759] Compiling C object 'lib/76b5a35@@igt-rendercopy_gen9_c@sta/rendercopy_gen9.c.o'. [426/1759] Compiling C object 'lib/76b5a35@@igt-igt_fb_c@sta/igt_fb.c.o'.
[427/1759] Compiling C object 'lib/76b5a35@@igt-i915_intel_decode_c@sta/i915_intel_decode.c.o'. [428/1759] Compiling C object 'lib/76b5a35@@igt-igt_kms_c@sta/igt_kms.c.o'.
[429/1759] Generating i915-perf-equations with a custom command.
ninja: build stopped: subcommand failed.

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

Re: ✗ Fi.CI.BUILD: failure for tests/chamelium: Integrate the chamelium v3

Hi Louis,

Quoted 45 lines · Louis Chauvet

Hi all,

It seems like I forgot to include errno.h. Should I send a new version or wait for comments before?

lib/chamelium/v3/igt_chamelium.c +2 -0
index fa70e2c1e296..4ed408a49afb 100644
@@ -1,5 +1,7 @@
  // SPDX-License-Identifier: GPL-2.0
 
+#include <errno.h>
+
  #include <xmlrpc-c/base.h>
  #include <xmlrpc-c/client.h>
 

This morning I attempted to run the CI locally to avoid more errors, it was a bit tricky (gitlab-runner deprecated the exec option to run the CI locally, the images used are in the private docker repository, I had to rebuild docker image myself).

With the following diff, the fedora build seems to pass, but I have some timeout on tests, this timeout is also present on master.

  PASS  build:tests-fedora
  PASS  build:tests-fedora-no-libunwind
  PASS  build:tests-fedora-oldest-meson
  PASS  build:tests-fedora-no-libdrm-nouveau
  PASS  build:tests-fedora-clang
  PASS  test:list-undocumented-tests
  PASS  test:verify-blacklists
  FAIL  test:ninja-test
Quoted 3 lines
Skipped:               0
Timeout:               1

Full log written to /gcl-builds/build/meson-logs/testlog.txt

FAIL test:ninja-test-clang

Quoted 3 lines
Skipped:               0
Timeout:               1

Full log written to /gcl-builds/build/meson-logs/testlog.txt

For test:ninja-test
419/431 runner TIMEOUT 300.01 s

Quoted 6 lines

For test:ninja-test-clang
419/431 runner TIMEOUT 300.00 s

I am not able to run debian images, I tried to build the Dockerfile, but the debian version seems too old (404 during apt update), and I am not able to fetch prebuild images from gitlab (it seems to require API keys).

Thanks for this series.

I'm able to add your patches in a test branch and build it in drm-ci using debian images. There are some failures seen in lib/igt_kms.c and I sent some review comments for your patches. Please could you send an updated series. Thank you.

Regards,
Vignesh

Quoted 68 lines

I will send a series to explain how to run the CI locally.

Quoted 64 lines

== Series Details ==

Series: tests/chamelium: Integrate the chamelium v3
URL : https://patchwork.freedesktop.org/series/135910/
State : failure

== Summary ==

IGT patchset build failed on latest successful build a7ef4e2bacb168f19605851986629d462b097df6 lib/i915/perf: Add ARL support in IGT perf library

Tail of build.log:
[381/1759] Compiling C object 'lib/76b5a35@@igt-igt_v3d_c@sta/igt_v3d.c.o'.
[382/1759] Compiling C object 'lib/76b5a35@@igt-gpu_cmds_c@sta/gpu_cmds.c.o'.
[383/1759] Compiling C object 'tests/59830eb@@kms_selftest@exe/kms_selftest.c.o'.
[384/1759] Compiling C object 'lib/76b5a35@@igt-rendercopy_gen7_c@sta/rendercopy_gen7.c.o'. [385/1759] Compiling C object 'tests/59830eb@@kms_sysfs_edid_timing@exe/kms_sysfs_edid_timing.c.o'. [386/1759] Compiling C object 'tests/59830eb@@gem_softpin@exe/intel_gem_softpin.c.o'. [387/1759] Compiling C object 'tests/59830eb@@kms_scaling_modes@exe/kms_scaling_modes.c.o'. [388/1759] Compiling C object 'lib/76b5a35@@igt-igt_draw_c@sta/igt_draw.c.o'.
[389/1759] Compiling C object 'lib/76b5a35@@igt-rendercopy_gen6_c@sta/rendercopy_gen6.c.o'. [390/1759] Compiling C object 'lib/76b5a35@@igt-intel_compute_c@sta/intel_compute.c.o'. [391/1759] Compiling C object 'tests/59830eb@@kms_plane_multiple@exe/kms_plane_multiple.c.o'. [392/1759] Compiling C object 'tests/59830eb@@kms_tv_load_detect@exe/kms_tv_load_detect.c.o'. [393/1759] Compiling C object 'tests/59830eb@@kms_rmfb@exe/kms_rmfb.c.o'.
[394/1759] Compiling C object 'tests/59830eb@@kms_plane_cursor@exe/kms_plane_cursor.c.o'. [395/1759] Compiling C object 'tests/59830eb@@kms_plane_lowres@exe/kms_plane_lowres.c.o'. [396/1759] Compiling C object 'lib/76b5a35@@igt-intel_bufops_c@sta/intel_bufops.c.o'. [397/1759] Compiling C object 'tests/59830eb@@kms_pipe_crc_basic@exe/kms_pipe_crc_basic.c.o'. [398/1759] Compiling C object 'lib/76b5a35@@igt-igt_pm_c@sta/igt_pm.c.o'.
[399/1759] Compiling C object 'tests/59830eb@@kms_prop_blob@exe/kms_prop_blob.c.o'.
[400/1759] Compiling C object 'tests/59830eb@@kms_plane_alpha_blend@exe/kms_plane_alpha_blend.c.o'. [401/1759] Compiling C object 'tests/59830eb@@kms_prime@exe/kms_prime.c.o'.
[402/1759] Compiling C object 'lib/76b5a35@@igt-igt_amd_c@sta/igt_amd.c.o'.
[403/1759] Generating i915-perf-registers-acmgt3 with a custom command.
[404/1759] Compiling C object 'lib/76b5a35@@igt-igt_vmwgfx_c@sta/igt_vmwgfx.c.o'.
[405/1759] Compiling C object 'tests/59830eb@@kms_tiled_display@exe/kms_tiled_display.c.o'. [406/1759] Compiling C object 'tests/59830eb@@kms_sequence@exe/kms_sequence.c.o'.
[407/1759] Compiling C object 'tests/59830eb@@gem_concurrent_blit@exe/intel_gem_concurrent_blit.c.o'. [408/1759] Compiling C object 'lib/76b5a35@@xe_oa@sha/meson-generated_.._xe_oa_equations.c.o'. [409/1759] Compiling C object 'tests/59830eb@@kms_flip@exe/kms_flip.c.o'.
[410/1759] Compiling C object 'lib/76b5a35@@igt-intel_blt_c@sta/intel_blt.c.o'.
[411/1759] Compiling C object 'tests/59830eb@@kms_plane@exe/kms_plane.c.o'.
[412/1759] Generating i915-perf-metrics-acmgt3 with a custom command.
[413/1759] Compiling C object 'lib/76b5a35@@igt-igt_kmod_c@sta/igt_kmod.c.o'.
[414/1759] Compiling C object 'tests/59830eb@@kms_properties@exe/kms_properties.c.o'. [415/1759] Compiling C object 'tests/59830eb@@kms_setmode@exe/kms_setmode.c.o'.
[416/1759] Compiling C object 'tests/59830eb@@kms_plane_scaling@exe/kms_plane_scaling.c.o'. [417/1759] Compiling C object 'tests/59830eb@@kms_lease@exe/kms_lease.c.o'.
[418/1759] Compiling C object 'lib/76b5a35@@igt-chamelium_v2_igt_chamelium_c@sta/chamelium_v2_igt_chamelium.c.o'. [419/1759] Compiling C object 'tests/59830eb@@kms_rotation_crc@exe/kms_rotation_crc.c.o'. [420/1759] Compiling C object 'tests/59830eb@@kms_atomic@exe/kms_atomic.c.o'.
[421/1759] Compiling C object 'lib/76b5a35@@igt-rendercopy_gen8_c@sta/rendercopy_gen8.c.o'. [422/1759] Compiling C object 'tests/59830eb@@kms_cursor_legacy@exe/kms_cursor_legacy.c.o'. [423/1759] Compiling C object 'lib/76b5a35@@igt-igt_core_c@sta/igt_core.c.o'.
[424/1759] Compiling C object 'lib/76b5a35@@igt-intel_batchbuffer_c@sta/intel_batchbuffer.c.o'. [425/1759] Compiling C object 'lib/76b5a35@@igt-rendercopy_gen9_c@sta/rendercopy_gen9.c.o'. [426/1759] Compiling C object 'lib/76b5a35@@igt-igt_fb_c@sta/igt_fb.c.o'.
[427/1759] Compiling C object 'lib/76b5a35@@igt-i915_intel_decode_c@sta/i915_intel_decode.c.o'. [428/1759] Compiling C object 'lib/76b5a35@@igt-igt_kms_c@sta/igt_kms.c.o'.
[429/1759] Generating i915-perf-equations with a custom command.
ninja: build stopped: subcommand failed.

#50 lore raw

✗ GitLab.Pipeline: warning for tests/chamelium: Integrate the chamelium v3

In reply to Louis Chauvet
== Series Details ==

== Series Details ==

Series: tests/chamelium: Integrate the chamelium v3
URL : https://patchwork.freedesktop.org/series/135910/
State : warning

== Summary ==

Pipeline status: FAILED.

see https://gitlab.freedesktop.org/gfx-ci/igt-ci-tags/-/pipelines/1220486 for the overview.

build:tests-debian-meson has failed (https://gitlab.freedesktop.org/gfx-ci/igt-ci-tags/-/jobs/60848890):
#include "igt_kms.h"
../lib/chamelium/v3/igt_chamelium.c:164:4:

      errno = 0;
      ^~~~~
  ../lib/chamelium/v3/igt_chamelium.c:164:4: note: each undeclared identifier is reported only once for each function it appears in
  ../lib/chamelium/v3/igt_chamelium.c: In function ‘chamelium_v3_fill_port_mapping_from_config_v3’:
  ../lib/chamelium/v3/igt_chamelium.c:223:4: error: ‘errno’ undeclared (first use in this function)
      errno = 0;
      ^~~~~
  ../lib/chamelium/v3/igt_chamelium.c:223:4: note: ‘errno’ is defined in header ‘<errno.h>’; did you forget to ‘#include <errno.h>’?
  ../lib/chamelium/v3/igt_chamelium.c:231:24: error: ‘ERANGE’ undeclared (first use in this function)
      } else if (errno == ERANGE) {
                          ^~~~~~

ninja: build stopped: subcommand failed. section_end:1720541868:step_script section_start:1720541868:cleanup_file_variables Cleaning up project directory and file based variables section_end:1720541869:cleanup_file_variables
ERROR: Job failed: exit code 1

build:tests-fedora has failed (https://gitlab.freedesktop.org/gfx-ci/igt-ci-tags/-/jobs/60848885):

    +++ |+#include <errno.h>
     10 | #include "igt_kms.h"
  ../lib/chamelium/v3/igt_chamelium.c:164:4: note: each undeclared identifier is reported only once for each function it appears in
    164 |    errno = 0;
        |    ^~~~~
  ../lib/chamelium/v3/igt_chamelium.c: In function ‘chamelium_v3_fill_port_mapping_from_config_v3’:
  ../lib/chamelium/v3/igt_chamelium.c:223:4: error: ‘errno’ undeclared (first use in this function)
    223 |    errno = 0;
        |    ^~~~~
  ../lib/chamelium/v3/igt_chamelium.c:223:4: note: ‘errno’ is defined in header ‘<errno.h>’; did you forget to ‘#include <errno.h>’?
  ../lib/chamelium/v3/igt_chamelium.c:231:24: error: ‘ERANGE’ undeclared (first use in this function)
    231 |    } else if (errno == ERANGE) {
        |                        ^~~~~~

ninja: build stopped: subcommand failed. section_end:1720541858:step_script section_start:1720541858:cleanup_file_variables Cleaning up project directory and file based variables section_end:1720541859:cleanup_file_variables
ERROR: Job failed: exit code 1

build:tests-fedora-clang has failed (https://gitlab.freedesktop.org/gfx-ci/igt-ci-tags/-/jobs/60848889):

                          errno = 0;
                          ^
  ../lib/chamelium/v3/igt_chamelium.c:231:15: error: use of undeclared identifier 'errno'; did you mean 'error'?
                          } else if (errno == ERANGE) {
                                     ^~~~~
                                     error
  ../lib/chamelium/v3/igt_chamelium.c:219:12: note: 'error' declared here
                          GError *error = NULL;
                                  ^
  ../lib/chamelium/v3/igt_chamelium.c:231:24: error: use of undeclared identifier 'ERANGE'
                          } else if (errno == ERANGE) {
                                              ^

4 errors generated.
ninja: build stopped: subcommand failed. section_end:1720541870:step_script section_start:1720541870:cleanup_file_variables Cleaning up project directory and file based variables section_end:1720541870:cleanup_file_variables
ERROR: Job failed: exit code 1

build:tests-fedora-no-libdrm-nouveau has failed (https://gitlab.freedesktop.org/gfx-ci/igt-ci-tags/-/jobs/60848888):

    +++ |+#include <errno.h>
     10 | #include "igt_kms.h"
  ../lib/chamelium/v3/igt_chamelium.c:164:4: note: each undeclared identifier is reported only once for each function it appears in
    164 |    errno = 0;
        |    ^~~~~
  ../lib/chamelium/v3/igt_chamelium.c: In function ‘chamelium_v3_fill_port_mapping_from_config_v3’:
  ../lib/chamelium/v3/igt_chamelium.c:223:4: error: ‘errno’ undeclared (first use in this function)
    223 |    errno = 0;
        |    ^~~~~
  ../lib/chamelium/v3/igt_chamelium.c:223:4: note: ‘errno’ is defined in header ‘<errno.h>’; did you forget to ‘#include <errno.h>’?
  ../lib/chamelium/v3/igt_chamelium.c:231:24: error: ‘ERANGE’ undeclared (first use in this function)
    231 |    } else if (errno == ERANGE) {
        |                        ^~~~~~

ninja: build stopped: subcommand failed. section_end:1720541872:step_script section_start:1720541872:cleanup_file_variables Cleaning up project directory and file based variables section_end:1720541873:cleanup_file_variables
ERROR: Job failed: exit code 1

build:tests-fedora-no-libunwind has failed (https://gitlab.freedesktop.org/gfx-ci/igt-ci-tags/-/jobs/60848886):

    +++ |+#include <errno.h>
     10 | #include "igt_kms.h"
  ../lib/chamelium/v3/igt_chamelium.c:164:4: note: each undeclared identifier is reported only once for each function it appears in
    164 |    errno = 0;
        |    ^~~~~
  ../lib/chamelium/v3/igt_chamelium.c: In function ‘chamelium_v3_fill_port_mapping_from_config_v3’:
  ../lib/chamelium/v3/igt_chamelium.c:223:4: error: ‘errno’ undeclared (first use in this function)
    223 |    errno = 0;
        |    ^~~~~
  ../lib/chamelium/v3/igt_chamelium.c:223:4: note: ‘errno’ is defined in header ‘<errno.h>’; did you forget to ‘#include <errno.h>’?
  ../lib/chamelium/v3/igt_chamelium.c:231:24: error: ‘ERANGE’ undeclared (first use in this function)
    231 |    } else if (errno == ERANGE) {
        |                        ^~~~~~

ninja: build stopped: subcommand failed. section_end:1720541855:step_script section_start:1720541855:cleanup_file_variables Cleaning up project directory and file based variables section_end:1720541856:cleanup_file_variables
ERROR: Job failed: exit code 1

build:tests-fedora-oldest-meson has failed (https://gitlab.freedesktop.org/gfx-ci/igt-ci-tags/-/jobs/60848887):

    +++ |+#include <errno.h>
     10 | #include "igt_kms.h"
  ../lib/chamelium/v3/igt_chamelium.c:164:4: note: each undeclared identifier is reported only once for each function it appears in
    164 |    errno = 0;
        |    ^~~~~
  ../lib/chamelium/v3/igt_chamelium.c: In function ‘chamelium_v3_fill_port_mapping_from_config_v3’:
  ../lib/chamelium/v3/igt_chamelium.c:223:4: error: ‘errno’ undeclared (first use in this function)
    223 |    errno = 0;
        |    ^~~~~
  ../lib/chamelium/v3/igt_chamelium.c:223:4: note: ‘errno’ is defined in header ‘<errno.h>’; did you forget to ‘#include <errno.h>’?
  ../lib/chamelium/v3/igt_chamelium.c:231:24: error: ‘ERANGE’ undeclared (first use in this function)
    231 |    } else if (errno == ERANGE) {
        |                        ^~~~~~

ninja: build stopped: subcommand failed. section_end:1720541853:step_script section_start:1720541853:cleanup_file_variables Cleaning up project directory and file based variables section_end:1720541854:cleanup_file_variables
ERROR: Job failed: exit code 1

== Logs ==

For more details see: https://gitlab.freedesktop.org/gfx-ci/igt-ci-tags/-/pipelines/1220486