[PATCH i-g-t 36/39] lib/vkms: Test changing enabled device CRTCs
José Expósito
jose.exposito89 at gmail.com
Tue Feb 18 16:50:08 UTC 2025
Test that, once a VKMS device is enabled, the CRTC values can't change
and that deleting it or the attached planes/encoders doesn't change the
VKMS device.
Signed-off-by: José Expósito <jose.exposito89 at gmail.com>
---
lib/igt_vkms.c | 12 +++++++++
lib/igt_vkms.h | 1 +
tests/vkms/vkms_configfs.c | 55 ++++++++++++++++++++++++++++++++++++++
3 files changed, 68 insertions(+)
diff --git a/lib/igt_vkms.c b/lib/igt_vkms.c
index 3dab7a823..58c71ca08 100644
--- a/lib/igt_vkms.c
+++ b/lib/igt_vkms.c
@@ -586,6 +586,18 @@ void igt_vkms_device_add_crtc(igt_vkms_t *dev, const char *name)
add_pipeline_item(dev, VKMS_PIPELINE_ITEM_CRTC, name);
}
+/**
+ * igt_vkms_device_remove_crtc:
+ * @dev: Device to remove the CRTC from
+ * @name: CRTC name
+ *
+ * Remove an existing CRTC from the VKMS device.
+ */
+bool igt_vkms_device_remove_crtc(igt_vkms_t *dev, const char *name)
+{
+ return remove_pipeline_item(dev, VKMS_PIPELINE_ITEM_CRTC, name);
+}
+
/**
* igt_vkms_crtc_is_writeback_enabled:
* @dev: Device the CRTC belongs to
diff --git a/lib/igt_vkms.h b/lib/igt_vkms.h
index 03f9cb339..e1f63d809 100644
--- a/lib/igt_vkms.h
+++ b/lib/igt_vkms.h
@@ -82,6 +82,7 @@ bool igt_vkms_plane_detach_crtc(igt_vkms_t *dev, const char *plane_name,
const char *crtc_name);
void igt_vkms_device_add_crtc(igt_vkms_t *dev, const char *name);
+bool igt_vkms_device_remove_crtc(igt_vkms_t *dev, const char *name);
bool igt_vkms_crtc_is_writeback_enabled(igt_vkms_t *dev, const char *name);
void igt_vkms_crtc_set_writeback_enabled(igt_vkms_t *dev, const char *name,
bool writeback);
diff --git a/tests/vkms/vkms_configfs.c b/tests/vkms/vkms_configfs.c
index 066911715..d8ae1f073 100644
--- a/tests/vkms/vkms_configfs.c
+++ b/tests/vkms/vkms_configfs.c
@@ -1560,6 +1560,60 @@ static void test_enabled_plane_cannot_change(void)
igt_vkms_device_destroy(dev);
}
+/**
+ * SUBTEST: enabled-crtc-cannot-change
+ * Description: Test that, once a VKMS device is enabled, the CRTC values can't
+ * change and that deleting it or the attached planes/encoders
+ * doesn't change the VKMS device.
+ */
+
+static void test_enabled_crtc_cannot_change(void)
+{
+ igt_vkms_t *dev;
+
+ igt_vkms_config_t cfg = {
+ .device_name = __func__,
+ .planes = {
+ {
+ .name = "plane0",
+ .type = DRM_PLANE_TYPE_PRIMARY,
+ .possible_crtcs = { "crtc0"},
+ },
+ },
+ .crtcs = {
+ { .name = "crtc0", .writeback = true },
+ },
+ .encoders = {
+ { .name = "encoder0", .possible_crtcs = { "crtc0" } },
+ },
+ .connectors = {
+ {
+ .name = "connector0",
+ .possible_encoders = { "encoder0" },
+ },
+ },
+ };
+
+ dev = igt_vkms_device_create_from_config(&cfg);
+ igt_assert(dev);
+
+ igt_vkms_device_set_enabled(dev, true);
+ igt_assert(igt_vkms_device_is_enabled(dev));
+ assert_device_config(&cfg);
+
+ /* Try to change values */
+ igt_vkms_crtc_set_writeback_enabled(dev, "crtc0", false);
+ igt_assert(igt_vkms_crtc_is_writeback_enabled(dev, "crtc0"));
+
+ /* Deleting pipeline items doesn't affect the device */
+ igt_assert(igt_vkms_plane_detach_crtc(dev, "plane0", "crtc0"));
+ igt_assert(igt_vkms_encoder_detach_crtc(dev, "encoder0", "crtc0"));
+ igt_assert(igt_vkms_device_remove_crtc(dev, "crtc0"));
+ assert_device_config(&cfg);
+
+ igt_vkms_device_destroy(dev);
+}
+
igt_main
{
struct {
@@ -1598,6 +1652,7 @@ igt_main
{ "enable-no-connectors", test_enable_no_connectors },
{ "enable-too-many-connectors", test_enable_too_many_connectors },
{ "enabled-plane-cannot-change", test_enabled_plane_cannot_change },
+ { "enabled-crtc-cannot-change", test_enabled_crtc_cannot_change },
};
igt_fixture {
--
2.48.1
More information about the igt-dev
mailing list