Commit 9b5c7e8b authored by Louis Chauvet's avatar Louis Chauvet Committed by Simon Ser
Browse files

drm/vkms: Add config for default plane pipeline



With the introduction of color pipeline in VKMS, the default device may
have planes with color pipelines. To avoid breaking existing uAPI,
create a kernel argument to disable them by default and a vkms_config
field to configure the plane.

This field is not definitive and will be replaced once the uAPI will be
able to configure color pipelines. For now devices created with ConfigFS
will not have any color pipeline so we can decide later how the uAPI
will look like.

Reviewed-by: default avatarAlex Hung <alex.hung@amd.com>
Signed-off-by: default avatarLouis Chauvet <louis.chauvet@bootlin.com>
Signed-off-by: default avatarSimon Ser <contact@emersion.fr>
Link: https://patch.msgid.link/20251115000237.3561250-17-alex.hung@amd.com
parent c1e578bd
Loading
Loading
Loading
Loading
+30 −17
Original line number Diff line number Diff line
@@ -83,6 +83,7 @@ struct default_config_case {
	bool enable_cursor;
	bool enable_writeback;
	bool enable_overlay;
	bool enable_plane_pipeline;
};

static void vkms_config_test_empty_config(struct kunit *test)
@@ -108,14 +109,22 @@ static void vkms_config_test_empty_config(struct kunit *test)
}

static struct default_config_case default_config_cases[] = {
	{ false, false, false },
	{ true, false, false },
	{ true, true, false },
	{ true, false, true },
	{ false, true, false },
	{ false, true, true },
	{ false, false, true },
	{ true, true, true },
	{ false, false, false, false },
	{ true, false, false, false },
	{ true, true, false, false },
	{ true, false, true, false },
	{ false, true, false, false },
	{ false, true, true, false },
	{ false, false, true, false },
	{ true, true, true, false },
	{ false, false, false, true },
	{ true, false, false, true },
	{ true, true, false, true },
	{ true, false, true, true },
	{ false, true, false, true },
	{ false, true, true, true },
	{ false, false, true, true },
	{ true, true, true, true },
};

KUNIT_ARRAY_PARAM(default_config, default_config_cases, NULL);
@@ -132,11 +141,15 @@ static void vkms_config_test_default_config(struct kunit *test)

	config = vkms_config_default_create(params->enable_cursor,
					    params->enable_writeback,
					    params->enable_overlay);
					    params->enable_overlay,
					    params->enable_plane_pipeline);
	KUNIT_ASSERT_NOT_ERR_OR_NULL(test, config);

	/* Planes */
	vkms_config_for_each_plane(config, plane_cfg) {
		KUNIT_EXPECT_EQ(test,
				vkms_config_plane_get_default_pipeline(plane_cfg),
				params->enable_plane_pipeline);
		switch (vkms_config_plane_get_type(plane_cfg)) {
		case DRM_PLANE_TYPE_PRIMARY:
			n_primaries++;
@@ -368,7 +381,7 @@ static void vkms_config_test_invalid_plane_number(struct kunit *test)
	struct vkms_config_plane *plane_cfg;
	int n;

	config = vkms_config_default_create(false, false, false);
	config = vkms_config_default_create(false, false, false, false);
	KUNIT_ASSERT_NOT_ERR_OR_NULL(test, config);

	/* Invalid: No planes */
@@ -393,7 +406,7 @@ static void vkms_config_test_valid_plane_type(struct kunit *test)
	struct vkms_config_encoder *encoder_cfg;
	int err;

	config = vkms_config_default_create(false, false, false);
	config = vkms_config_default_create(false, false, false, false);
	KUNIT_ASSERT_NOT_ERR_OR_NULL(test, config);

	plane_cfg = get_first_plane(config);
@@ -474,7 +487,7 @@ static void vkms_config_test_valid_plane_possible_crtcs(struct kunit *test)
	struct vkms_config_plane *plane_cfg;
	struct vkms_config_crtc *crtc_cfg;

	config = vkms_config_default_create(false, false, false);
	config = vkms_config_default_create(false, false, false, false);
	KUNIT_ASSERT_NOT_ERR_OR_NULL(test, config);

	plane_cfg = get_first_plane(config);
@@ -493,7 +506,7 @@ static void vkms_config_test_invalid_crtc_number(struct kunit *test)
	struct vkms_config_crtc *crtc_cfg;
	int n;

	config = vkms_config_default_create(false, false, false);
	config = vkms_config_default_create(false, false, false, false);
	KUNIT_ASSERT_NOT_ERR_OR_NULL(test, config);

	/* Invalid: No CRTCs */
@@ -516,7 +529,7 @@ static void vkms_config_test_invalid_encoder_number(struct kunit *test)
	struct vkms_config_encoder *encoder_cfg;
	int n;

	config = vkms_config_default_create(false, false, false);
	config = vkms_config_default_create(false, false, false, false);
	KUNIT_ASSERT_NOT_ERR_OR_NULL(test, config);

	/* Invalid: No encoders */
@@ -541,7 +554,7 @@ static void vkms_config_test_valid_encoder_possible_crtcs(struct kunit *test)
	struct vkms_config_encoder *encoder_cfg;
	int err;

	config = vkms_config_default_create(false, false, false);
	config = vkms_config_default_create(false, false, false, false);
	KUNIT_ASSERT_NOT_ERR_OR_NULL(test, config);

	crtc_cfg1 = get_first_crtc(config);
@@ -587,7 +600,7 @@ static void vkms_config_test_invalid_connector_number(struct kunit *test)
	struct vkms_config_connector *connector_cfg;
	int n;

	config = vkms_config_default_create(false, false, false);
	config = vkms_config_default_create(false, false, false, false);
	KUNIT_ASSERT_NOT_ERR_OR_NULL(test, config);

	/* Invalid: No connectors */
@@ -610,7 +623,7 @@ static void vkms_config_test_valid_connector_possible_encoders(struct kunit *tes
	struct vkms_config_encoder *encoder_cfg;
	struct vkms_config_connector *connector_cfg;

	config = vkms_config_default_create(false, false, false);
	config = vkms_config_default_create(false, false, false, false);
	KUNIT_ASSERT_NOT_ERR_OR_NULL(test, config);

	encoder_cfg = get_first_encoder(config);
+6 −1
Original line number Diff line number Diff line
@@ -33,7 +33,8 @@ EXPORT_SYMBOL_IF_KUNIT(vkms_config_create);

struct vkms_config *vkms_config_default_create(bool enable_cursor,
					       bool enable_writeback,
					       bool enable_overlay)
					       bool enable_overlay,
					       bool enable_plane_pipeline)
{
	struct vkms_config *config;
	struct vkms_config_plane *plane_cfg;
@@ -58,6 +59,7 @@ struct vkms_config *vkms_config_default_create(bool enable_cursor,

	if (vkms_config_plane_attach_crtc(plane_cfg, crtc_cfg))
		goto err_alloc;
	vkms_config_plane_set_default_pipeline(plane_cfg, enable_plane_pipeline);

	if (enable_overlay) {
		for (n = 0; n < NUM_OVERLAY_PLANES; n++) {
@@ -67,6 +69,7 @@ struct vkms_config *vkms_config_default_create(bool enable_cursor,

			vkms_config_plane_set_type(plane_cfg,
						   DRM_PLANE_TYPE_OVERLAY);
			vkms_config_plane_set_default_pipeline(plane_cfg, enable_plane_pipeline);

			if (vkms_config_plane_attach_crtc(plane_cfg, crtc_cfg))
				goto err_alloc;
@@ -79,6 +82,7 @@ struct vkms_config *vkms_config_default_create(bool enable_cursor,
			goto err_alloc;

		vkms_config_plane_set_type(plane_cfg, DRM_PLANE_TYPE_CURSOR);
		vkms_config_plane_set_default_pipeline(plane_cfg, enable_plane_pipeline);

		if (vkms_config_plane_attach_crtc(plane_cfg, crtc_cfg))
			goto err_alloc;
@@ -389,6 +393,7 @@ struct vkms_config_plane *vkms_config_create_plane(struct vkms_config *config)
		return ERR_PTR(-ENOMEM);

	plane_cfg->config = config;
	plane_cfg->default_pipeline = false;
	vkms_config_plane_set_type(plane_cfg, DRM_PLANE_TYPE_OVERLAY);
	xa_init_flags(&plane_cfg->possible_crtcs, XA_FLAGS_ALLOC);

+27 −1
Original line number Diff line number Diff line
@@ -49,6 +49,7 @@ struct vkms_config_plane {

	enum drm_plane_type type;
	struct xarray possible_crtcs;
	bool default_pipeline;

	/* Internal usage */
	struct vkms_plane *plane;
@@ -203,7 +204,8 @@ struct vkms_config *vkms_config_create(const char *dev_name);
 */
struct vkms_config *vkms_config_default_create(bool enable_cursor,
					       bool enable_writeback,
					       bool enable_overlay);
					       bool enable_overlay,
					       bool enable_plane_pipeline);

/**
 * vkms_config_destroy() - Free a VKMS configuration
@@ -288,6 +290,30 @@ vkms_config_plane_set_type(struct vkms_config_plane *plane_cfg,
	plane_cfg->type = type;
}

/**
 * vkms_config_plane_get_default_pipeline() - Return if the plane will
 * be created with the default pipeline
 * @plane_cfg: Plane to get the information from
 */
static inline bool
vkms_config_plane_get_default_pipeline(struct vkms_config_plane *plane_cfg)
{
	return plane_cfg->default_pipeline;
}

/**
 * vkms_config_plane_set_default_pipeline() - Set if the plane will
 * be created with the default pipeline
 * @plane_cfg: Plane to configure the pipeline
 * @default_pipeline: New default pipeline value
 */
static inline void
vkms_config_plane_set_default_pipeline(struct vkms_config_plane *plane_cfg,
				       bool default_pipeline)
{
	plane_cfg->default_pipeline = default_pipeline;
}

/**
 * vkms_config_plane_attach_crtc - Attach a plane to a CRTC
 * @plane_cfg: Plane to attach
+6 −1
Original line number Diff line number Diff line
@@ -51,6 +51,10 @@ static bool enable_overlay;
module_param_named(enable_overlay, enable_overlay, bool, 0444);
MODULE_PARM_DESC(enable_overlay, "Enable/Disable overlay support");

static bool enable_plane_pipeline;
module_param_named(enable_plane_pipeline, enable_plane_pipeline, bool, 0444);
MODULE_PARM_DESC(enable_plane_pipeline, "Enable/Disable plane pipeline support");

static bool create_default_dev = true;
module_param_named(create_default_dev, create_default_dev, bool, 0444);
MODULE_PARM_DESC(create_default_dev, "Create or not the default VKMS device");
@@ -227,7 +231,8 @@ static int __init vkms_init(void)
	if (!create_default_dev)
		return 0;

	config = vkms_config_default_create(enable_cursor, enable_writeback, enable_overlay);
	config = vkms_config_default_create(enable_cursor, enable_writeback,
					    enable_overlay, enable_plane_pipeline);
	if (IS_ERR(config))
		return PTR_ERR(config);

+2 −1
Original line number Diff line number Diff line
@@ -246,6 +246,7 @@ struct vkms_plane *vkms_plane_init(struct vkms_device *vkmsdev,
					  DRM_COLOR_YCBCR_BT601,
					  DRM_COLOR_YCBCR_FULL_RANGE);

	if (vkms_config_plane_get_default_pipeline(plane_cfg))
		vkms_initialize_colorops(&plane->base);

	return plane;