[PATCH i-g-t v3 39/41] lib/vkms: Test changing enabled device encoders

Louis Chauvet louis.chauvet at bootlin.com
Wed Jul 16 12:08:11 UTC 2025



Le 15/07/2025 à 12:25, José Expósito a écrit :
> Test that, once a VKMS device is enabled, the encoder values can't
> change and that deleting it or the attached CRTCs doesn't change the
> VKMS device.
> 
> Signed-off-by: José Expósito <jose.exposito89 at gmail.com>

Reviewed-by: Louis Chauvet <louis.chauvet at bootlin.com>

> ---
>   lib/igt_vkms.c             | 12 ++++++++
>   lib/igt_vkms.h             |  1 +
>   tests/vkms/vkms_configfs.c | 62 ++++++++++++++++++++++++++++++++++++++
>   3 files changed, 75 insertions(+)
> 
> diff --git a/lib/igt_vkms.c b/lib/igt_vkms.c
> index 5923e8527..c42b96b11 100644
> --- a/lib/igt_vkms.c
> +++ b/lib/igt_vkms.c
> @@ -862,6 +862,18 @@ void igt_vkms_device_add_encoder(igt_vkms_t *dev, const char *name)
>   	add_pipeline_item(dev, VKMS_PIPELINE_ITEM_ENCODER, name);
>   }
>   
> +/**
> + * igt_vkms_device_remove_encoder:
> + * @dev: Device to remove the encoder from
> + * @name: Encoder name
> + *
> + * Remove an existing encoder from the VKMS device.
> + */
> +bool igt_vkms_device_remove_encoder(igt_vkms_t *dev, const char *name)
> +{
> +	return remove_pipeline_item(dev, VKMS_PIPELINE_ITEM_ENCODER, name);
> +}
> +
>   /**
>    * igt_vkms_encoder_attach_crtc:
>    * @dev: Target device
> diff --git a/lib/igt_vkms.h b/lib/igt_vkms.h
> index 9785a64e9..3081addad 100644
> --- a/lib/igt_vkms.h
> +++ b/lib/igt_vkms.h
> @@ -111,6 +111,7 @@ void igt_vkms_crtc_set_writeback_enabled(igt_vkms_t *dev, const char *name,
>   					 bool writeback);
>   
>   void igt_vkms_device_add_encoder(igt_vkms_t *dev, const char *name);
> +bool igt_vkms_device_remove_encoder(igt_vkms_t *dev, const char *name);
>   bool igt_vkms_encoder_attach_crtc(igt_vkms_t *dev, const char *encoder_name,
>   				  const char *crtc_name);
>   bool igt_vkms_encoder_detach_crtc(igt_vkms_t *dev, const char *encoder_name,
> diff --git a/tests/vkms/vkms_configfs.c b/tests/vkms/vkms_configfs.c
> index 62dfb99be..747b057fe 100644
> --- a/tests/vkms/vkms_configfs.c
> +++ b/tests/vkms/vkms_configfs.c
> @@ -1689,6 +1689,67 @@ static void test_enabled_crtc_cannot_change(void)
>   	igt_vkms_device_destroy(dev);
>   }
>   
> +/**
> + * SUBTEST: enabled-encoder-cannot-change
> + * Description: Test that, once a VKMS device is enabled, the encoder values
> + *              can't change and that deleting it or the attached CRTCs doesn't
> + *              change the VKMS device.
> + */
> +
> +static void test_enabled_encoder_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"},
> +			},
> +			{
> +				.name = "plane1",
> +				.type = DRM_PLANE_TYPE_PRIMARY,
> +				.possible_crtcs = { "crtc1"},
> +			},
> +		},
> +		.crtcs = {
> +			{ .name = "crtc0" },
> +			{ .name = "crtc1" },
> +		},
> +		.encoders = {
> +			{ .name = "encoder0", .possible_crtcs = { "crtc0" } },
> +			{ .name = "encoder1", .possible_crtcs = { "crtc1" } },
> +		},
> +		.connectors = {
> +			{
> +				.name = "connector0",
> +				.possible_encoders = { "encoder0", "encoder1" },
> +			},
> +		},
> +	};
> +
> +	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_assert(!igt_vkms_encoder_attach_crtc(dev, "encoder0", "crtc1"));
> +
> +	/* Deleting pipeline items doesn't affect the device */
> +	igt_assert(igt_vkms_encoder_detach_crtc(dev, "encoder0", "crtc0"));
> +	igt_assert(igt_vkms_connector_detach_encoder(dev, "connector0",
> +						     "encoder0"));
> +	igt_assert(igt_vkms_device_remove_encoder(dev, "encoder0"));
> +	assert_device_config(&cfg);
> +
> +	igt_vkms_device_destroy(dev);
> +}
> +
>   igt_main
>   {
>   	struct {
> @@ -1731,6 +1792,7 @@ igt_main
>   		{ "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 },
> +		{ "enabled-encoder-cannot-change", test_enabled_encoder_cannot_change },
>   	};
>   
>   	igt_fixture {

-- 
Louis Chauvet, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com



More information about the igt-dev mailing list