mirror of
https://github.com/torvalds/linux.git
synced 2026-04-22 08:44:02 -04:00
drm/vkms: Allow to configure multiple planes
Add a list of planes to vkms_config and create as many planes as configured during output initialization. For backwards compatibility, add one primary plane and, if configured, one cursor plane and NUM_OVERLAY_PLANES planes to the default configuration. Reviewed-by: Louis Chauvet <louis.chauvet@bootlin.com> Co-developed-by: Louis Chauvet <louis.chauvet@bootlin.com> Signed-off-by: Louis Chauvet <louis.chauvet@bootlin.com> Signed-off-by: José Expósito <jose.exposito89@gmail.com> Link: https://patchwork.freedesktop.org/patch/msgid/20250218101214.5790-9-jose.exposito89@gmail.com Signed-off-by: Maxime Ripard <mripard@kernel.org>
This commit is contained in:
committed by
Maxime Ripard
parent
d1386d721d
commit
bc5b0d5dcc
@@ -6,6 +6,27 @@
|
||||
|
||||
MODULE_IMPORT_NS("EXPORTED_FOR_KUNIT_TESTING");
|
||||
|
||||
static size_t vkms_config_get_num_planes(struct vkms_config *config)
|
||||
{
|
||||
struct vkms_config_plane *plane_cfg;
|
||||
size_t count = 0;
|
||||
|
||||
vkms_config_for_each_plane(config, plane_cfg)
|
||||
count++;
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
static struct vkms_config_plane *get_first_plane(struct vkms_config *config)
|
||||
{
|
||||
struct vkms_config_plane *plane_cfg;
|
||||
|
||||
vkms_config_for_each_plane(config, plane_cfg)
|
||||
return plane_cfg;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct default_config_case {
|
||||
bool enable_cursor;
|
||||
bool enable_writeback;
|
||||
@@ -24,6 +45,10 @@ static void vkms_config_test_empty_config(struct kunit *test)
|
||||
dev_name = NULL;
|
||||
KUNIT_EXPECT_STREQ(test, vkms_config_get_device_name(config), "test");
|
||||
|
||||
KUNIT_EXPECT_EQ(test, vkms_config_get_num_planes(config), 0);
|
||||
|
||||
KUNIT_EXPECT_FALSE(test, vkms_config_is_valid(config));
|
||||
|
||||
vkms_config_destroy(config);
|
||||
}
|
||||
|
||||
@@ -44,16 +69,145 @@ static void vkms_config_test_default_config(struct kunit *test)
|
||||
{
|
||||
const struct default_config_case *params = test->param_value;
|
||||
struct vkms_config *config;
|
||||
struct vkms_config_plane *plane_cfg;
|
||||
int n_primaries = 0;
|
||||
int n_cursors = 0;
|
||||
int n_overlays = 0;
|
||||
|
||||
config = vkms_config_default_create(params->enable_cursor,
|
||||
params->enable_writeback,
|
||||
params->enable_overlay);
|
||||
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, config);
|
||||
|
||||
KUNIT_EXPECT_EQ(test, config->cursor, params->enable_cursor);
|
||||
KUNIT_EXPECT_EQ(test, config->writeback, params->enable_writeback);
|
||||
KUNIT_EXPECT_EQ(test, config->overlay, params->enable_overlay);
|
||||
|
||||
/* Planes */
|
||||
vkms_config_for_each_plane(config, plane_cfg) {
|
||||
switch (vkms_config_plane_get_type(plane_cfg)) {
|
||||
case DRM_PLANE_TYPE_PRIMARY:
|
||||
n_primaries++;
|
||||
break;
|
||||
case DRM_PLANE_TYPE_CURSOR:
|
||||
n_cursors++;
|
||||
break;
|
||||
case DRM_PLANE_TYPE_OVERLAY:
|
||||
n_overlays++;
|
||||
break;
|
||||
default:
|
||||
KUNIT_FAIL_AND_ABORT(test, "Unknown plane type");
|
||||
}
|
||||
}
|
||||
KUNIT_EXPECT_EQ(test, n_primaries, 1);
|
||||
KUNIT_EXPECT_EQ(test, n_cursors, params->enable_cursor ? 1 : 0);
|
||||
KUNIT_EXPECT_EQ(test, n_overlays, params->enable_overlay ? 8 : 0);
|
||||
|
||||
KUNIT_EXPECT_TRUE(test, vkms_config_is_valid(config));
|
||||
|
||||
vkms_config_destroy(config);
|
||||
}
|
||||
|
||||
static void vkms_config_test_get_planes(struct kunit *test)
|
||||
{
|
||||
struct vkms_config *config;
|
||||
struct vkms_config_plane *plane_cfg;
|
||||
struct vkms_config_plane *plane_cfg1, *plane_cfg2;
|
||||
int n_planes = 0;
|
||||
|
||||
config = vkms_config_create("test");
|
||||
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, config);
|
||||
|
||||
vkms_config_for_each_plane(config, plane_cfg)
|
||||
n_planes++;
|
||||
KUNIT_ASSERT_EQ(test, n_planes, 0);
|
||||
|
||||
plane_cfg1 = vkms_config_create_plane(config);
|
||||
vkms_config_for_each_plane(config, plane_cfg) {
|
||||
n_planes++;
|
||||
if (plane_cfg != plane_cfg1)
|
||||
KUNIT_FAIL(test, "Unexpected plane");
|
||||
}
|
||||
KUNIT_ASSERT_EQ(test, n_planes, 1);
|
||||
n_planes = 0;
|
||||
|
||||
plane_cfg2 = vkms_config_create_plane(config);
|
||||
vkms_config_for_each_plane(config, plane_cfg) {
|
||||
n_planes++;
|
||||
if (plane_cfg != plane_cfg1 && plane_cfg != plane_cfg2)
|
||||
KUNIT_FAIL(test, "Unexpected plane");
|
||||
}
|
||||
KUNIT_ASSERT_EQ(test, n_planes, 2);
|
||||
n_planes = 0;
|
||||
|
||||
vkms_config_destroy_plane(plane_cfg1);
|
||||
vkms_config_for_each_plane(config, plane_cfg) {
|
||||
n_planes++;
|
||||
if (plane_cfg != plane_cfg2)
|
||||
KUNIT_FAIL(test, "Unexpected plane");
|
||||
}
|
||||
KUNIT_ASSERT_EQ(test, n_planes, 1);
|
||||
|
||||
vkms_config_destroy(config);
|
||||
}
|
||||
|
||||
static void vkms_config_test_invalid_plane_number(struct kunit *test)
|
||||
{
|
||||
struct vkms_config *config;
|
||||
struct vkms_config_plane *plane_cfg;
|
||||
int n;
|
||||
|
||||
config = vkms_config_default_create(false, false, false);
|
||||
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, config);
|
||||
|
||||
/* Invalid: No planes */
|
||||
plane_cfg = get_first_plane(config);
|
||||
vkms_config_destroy_plane(plane_cfg);
|
||||
KUNIT_EXPECT_FALSE(test, vkms_config_is_valid(config));
|
||||
|
||||
/* Invalid: Too many planes */
|
||||
for (n = 0; n <= 32; n++)
|
||||
vkms_config_create_plane(config);
|
||||
|
||||
KUNIT_EXPECT_FALSE(test, vkms_config_is_valid(config));
|
||||
|
||||
vkms_config_destroy(config);
|
||||
}
|
||||
|
||||
static void vkms_config_test_valid_plane_type(struct kunit *test)
|
||||
{
|
||||
struct vkms_config *config;
|
||||
struct vkms_config_plane *plane_cfg;
|
||||
|
||||
config = vkms_config_default_create(false, false, false);
|
||||
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, config);
|
||||
|
||||
plane_cfg = get_first_plane(config);
|
||||
vkms_config_destroy_plane(plane_cfg);
|
||||
|
||||
/* Invalid: No primary plane */
|
||||
plane_cfg = vkms_config_create_plane(config);
|
||||
vkms_config_plane_set_type(plane_cfg, DRM_PLANE_TYPE_OVERLAY);
|
||||
KUNIT_EXPECT_FALSE(test, vkms_config_is_valid(config));
|
||||
|
||||
/* Invalid: Multiple primary planes */
|
||||
plane_cfg = vkms_config_create_plane(config);
|
||||
vkms_config_plane_set_type(plane_cfg, DRM_PLANE_TYPE_PRIMARY);
|
||||
plane_cfg = vkms_config_create_plane(config);
|
||||
vkms_config_plane_set_type(plane_cfg, DRM_PLANE_TYPE_PRIMARY);
|
||||
KUNIT_EXPECT_FALSE(test, vkms_config_is_valid(config));
|
||||
|
||||
/* Valid: One primary plane */
|
||||
vkms_config_destroy_plane(plane_cfg);
|
||||
KUNIT_EXPECT_TRUE(test, vkms_config_is_valid(config));
|
||||
|
||||
/* Invalid: Multiple cursor planes */
|
||||
plane_cfg = vkms_config_create_plane(config);
|
||||
vkms_config_plane_set_type(plane_cfg, DRM_PLANE_TYPE_CURSOR);
|
||||
plane_cfg = vkms_config_create_plane(config);
|
||||
vkms_config_plane_set_type(plane_cfg, DRM_PLANE_TYPE_CURSOR);
|
||||
KUNIT_EXPECT_FALSE(test, vkms_config_is_valid(config));
|
||||
|
||||
/* Valid: One primary and one cursor plane */
|
||||
vkms_config_destroy_plane(plane_cfg);
|
||||
KUNIT_EXPECT_TRUE(test, vkms_config_is_valid(config));
|
||||
|
||||
vkms_config_destroy(config);
|
||||
@@ -63,6 +217,9 @@ static struct kunit_case vkms_config_test_cases[] = {
|
||||
KUNIT_CASE(vkms_config_test_empty_config),
|
||||
KUNIT_CASE_PARAM(vkms_config_test_default_config,
|
||||
default_config_gen_params),
|
||||
KUNIT_CASE(vkms_config_test_get_planes),
|
||||
KUNIT_CASE(vkms_config_test_invalid_plane_number),
|
||||
KUNIT_CASE(vkms_config_test_valid_plane_type),
|
||||
{}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user