[PATCH i-g-t] RFC: Converting subtests of kms_plane into dynamic subtests
Pranay Samala
pranay.samala at intel.com
Mon Mar 25 09:16:46 UTC 2024
The pixel-format subtest runs on all the supported pixel formats and modifiers.
By converting the pixel-format subtest into dynamic subtests by performing
permutations and combinations on pixel-formats and modifiers we can reduce
the execution time of each subtest.
Signed-off-by: Pranay Samala <pranay.samala at intel.com>
---
tests/kms_plane.c | 393 +++++++++++++++++++++++++++++++++++++++-------
1 file changed, 333 insertions(+), 60 deletions(-)
diff --git a/tests/kms_plane.c b/tests/kms_plane.c
index 406aecc04..4a28d3174 100644
--- a/tests/kms_plane.c
+++ b/tests/kms_plane.c
@@ -84,16 +84,58 @@
*
* arg[1]:
*
- * @format:
* @format-source-clamping: with source clamping
*/
+/**
+ * SUBTEST: pixel-%s-%s
+ * Description: verify the pixel formats for given plane and pipe
+ * Functionality: pixel_formats, plane
+ *
+ * arg[1]:
+ *
+ * @format:
+ *
+ * arg[2]:
+ *
+ * @XR24:
+ * @C8:
+ * @RG16:
+ * @XB24:
+ * @AR24:
+ * @AB24:
+ * @XR30:
+ * @XB30:
+ * @AR30:
+ * @AB30:
+ * @XR4H:
+ * @XB4H:
+ * @AR4H:
+ * @AB4H:
+ * @YUYV:
+ * @YVYU:
+ * @UYVY:
+ * @VYUY:
+ * @NV12:
+ * @P010:
+ * @P012:
+ * @P016:
+ * @Y210:
+ * @Y212:
+ * @Y216:
+ * @XYUV:
+ * @XV30:
+ * @XV36:
+ * @XV48:
+ */
+
/*
* Throw away enough lsbs in pixel formats tests
* to get a match despite some differences between
* the software and hardware YCbCr<->RGB conversion
* routines.
*/
+
#define LUT_MASK 0xf800
/* restricted pipe count */
@@ -129,6 +171,27 @@ static color_t red = { 1.0f, 0.0f, 0.0f };
static color_t green = { 0.0f, 1.0f, 0.0f };
static color_t blue = { 0.0f, 0.0f, 1.0f };
+/*
+ * format_num represents each format supported
+ */
+int format_num[29] = {875713112, 538982467, 909199186, 875709016, 875713089, 875708993,
+ 808669784, 808665688, 808669761, 808665665, 1211388504, 1211384408, 1211388481,
+ 1211384385, 1448695129, 1431918169, 1498831189, 1498765654, 842094158, 808530000,
+ 842084432, 909193296, 808530521, 842084953, 909193817, 1448434008, 808670808,
+ 909334104, 942954072};
+
+/*
+ * mod_num represents each modifier supported
+ */
+long int mod_num[3] = {0, 72057594037927945, 72057594037927937};
+
+char dyna_names[3][8] = {"linear","4","x"};
+
+const char *sub_names[29] = {"XR24", "C8", "RG16", "XB24", "AR24", "AB24", "XR30", "XB30",
+ "AR30", "AB30", "XR4H", "XB4H", "AR4H", "AB4H", "YUYV", "YVYU", "UYVY", "VYUY",
+ "NV12", "P010", "P012", "P016", "Y210", "Y212", "Y216", "XYUV", "XV30", "XV36",
+ "XV48"};
+
/*
* Common code across all tests, acting on data_t
*/
@@ -999,8 +1062,143 @@ static void check_allowed_plane_size_64x64(data_t *data, igt_plane_t *plane,
igt_remove_fb(data->drm_fd, &test_fb);
}
+static bool test_format_plane_sc(data_t *data, enum pipe pipe,
+ igt_output_t *output, igt_plane_t *plane, igt_fb_t *primary_fb)
+{
+ struct igt_fb fb = {};
+ struct igt_fb *clear_fb = plane->type == DRM_PLANE_TYPE_PRIMARY ? primary_fb : NULL;
+ drmModeModeInfo *mode;
+ uint64_t width, height;
+ igt_crc_t ref_crc[MAX_CRC_SET][ARRAY_SIZE(colors_extended)];
+ struct igt_vec tested_formats;
+ struct format_mod ref = {};
+ igt_crc_t* crcset;
+ bool result = true;
+
+ /*
+ * No clamping test for cursor plane
+ */
+ if (data->crop != 0 && plane->type == DRM_PLANE_TYPE_CURSOR)
+ return true;
+
+ igt_vec_init(&tested_formats, sizeof(struct format_mod));
+
+ mode = igt_output_get_mode(output);
+ if (plane->type != DRM_PLANE_TYPE_CURSOR) {
+ width = mode->hdisplay;
+ height = mode->vdisplay;
+ ref.format = DRM_FORMAT_XRGB8888;
+ ref.modifier = DRM_FORMAT_MOD_LINEAR;
+ } else {
+ if (!plane->drm_plane) {
+ igt_debug("Only legacy cursor ioctl supported, skipping cursor plane\n");
+ return true;
+ }
+ do_or_die(drmGetCap(data->drm_fd, DRM_CAP_CURSOR_WIDTH, &width));
+ do_or_die(drmGetCap(data->drm_fd, DRM_CAP_CURSOR_HEIGHT, &height));
+ ref.format = DRM_FORMAT_ARGB8888;
+ ref.modifier = DRM_FORMAT_MOD_LINEAR;
+ }
+
+ igt_debug("Testing connector %s on %s plane %s.%u\n",
+ igt_output_name(output), kmstest_plane_type_name(plane->type),
+ kmstest_pipe_name(pipe), plane->index);
+
+ igt_pipe_crc_start(data->pipe_crc);
+
+ igt_info("Testing format " IGT_FORMAT_FMT " / modifier " IGT_MODIFIER_FMT " on %s.%u\n",
+ IGT_FORMAT_ARGS(ref.format), IGT_MODIFIER_ARGS(ref.modifier),
+ kmstest_pipe_name(pipe), plane->index);
+
+ check_allowed_plane_size_64x64(data, plane, &width, &height, ref.format);
+
+ capture_format_crcs_single(data, pipe, plane, ref.format, ref.modifier,
+ width, height, IGT_COLOR_YCBCR_BT709,
+ IGT_COLOR_YCBCR_LIMITED_RANGE,
+ ref_crc[SINGLE_CRC_SET], &fb);
+
+ capture_format_crcs_multiple(data, pipe, plane, ref.format, ref.modifier,
+ width, height, IGT_COLOR_YCBCR_BT709,
+ IGT_COLOR_YCBCR_LIMITED_RANGE,
+ ref_crc[MULTIPLE_CRC_SET], &fb);
+
+ /*
+ * Make sure we have some difference between the colors. This
+ * at least avoids claiming success when everything is just
+ * black all the time (eg. if the plane is never even on).
+ */
+ igt_require(num_unique_crcs(ref_crc[MULTIPLE_CRC_SET], data->num_colors) > 1);
+
+ for (int i = 0; i < plane->format_mod_count; i++) {
+ struct format_mod f = {
+ .format = plane->formats[i],
+ .modifier = plane->modifiers[i],
+ };
+
+ /* igt doesn't know how to sw generate UBWC: */
+ if (is_msm_device(data->drm_fd) &&
+ f.modifier == DRM_FORMAT_MOD_QCOM_COMPRESSED)
+ continue;
+
+ if (f.format == ref.format &&
+ f.modifier == ref.modifier)
+ continue;
+
+ /* test each format "class" only once in non-extended tests */
+ if (!data->extended && f.modifier != DRM_FORMAT_MOD_LINEAR) {
+ struct format_mod rf = {
+ .format = igt_reduce_format(f.format),
+ .modifier = f.modifier,
+ };
+
+ if (igt_vec_index(&tested_formats, &rf) >= 0) {
+ igt_info("Skipping format " IGT_FORMAT_FMT " / modifier " IGT_MODIFIER_FMT " on %s.%u\n",
+ IGT_FORMAT_ARGS(f.format), IGT_MODIFIER_ARGS(f.modifier),
+ kmstest_pipe_name(pipe), plane->index);
+ continue;
+ }
+
+ igt_vec_push(&tested_formats, &rf);
+ }
+
+ if (f.format == DRM_FORMAT_C8) {
+ if (!set_c8_legacy_lut(data, pipe, LUT_MASK))
+ continue;
+ } else {
+ if (!igt_fb_supported_format(f.format))
+ continue;
+ }
+
+ crcset = ref_crc[use_multiple_colors(data, f.format) ?
+ MULTIPLE_CRC_SET : SINGLE_CRC_SET];
+
+ if (igt_format_is_yuv(f.format))
+ result &= test_format_plane_yuv(data, pipe, plane,
+ f.format, f.modifier,
+ width, height,
+ crcset, &fb);
+ else
+ result &= test_format_plane_rgb(data, pipe, plane,
+ f.format, f.modifier,
+ width, height,
+ crcset, &fb);
+
+ if (f.format == DRM_FORMAT_C8)
+ set_legacy_lut(data, pipe, LUT_MASK);
+ }
+
+ igt_pipe_crc_stop(data->pipe_crc);
+
+ igt_plane_set_fb(plane, clear_fb);
+ igt_remove_fb(data->drm_fd, &fb);
+
+ igt_vec_fini(&tested_formats);
+
+ return result;
+}
+
static bool test_format_plane(data_t *data, enum pipe pipe,
- igt_output_t *output, igt_plane_t *plane, igt_fb_t *primary_fb)
+ igt_output_t *output, igt_plane_t *plane, igt_fb_t *primary_fb, int i, int p)
{
struct igt_fb fb = {};
struct igt_fb *clear_fb = plane->type == DRM_PLANE_TYPE_PRIMARY ? primary_fb : NULL;
@@ -1043,10 +1241,6 @@ static bool test_format_plane(data_t *data, enum pipe pipe,
igt_pipe_crc_start(data->pipe_crc);
- igt_info("Testing format " IGT_FORMAT_FMT " / modifier " IGT_MODIFIER_FMT " on %s.%u\n",
- IGT_FORMAT_ARGS(ref.format), IGT_MODIFIER_ARGS(ref.modifier),
- kmstest_pipe_name(pipe), plane->index);
-
check_allowed_plane_size_64x64(data, plane, &width, &height, ref.format);
capture_format_crcs_single(data, pipe, plane, ref.format, ref.modifier,
@@ -1066,64 +1260,67 @@ static bool test_format_plane(data_t *data, enum pipe pipe,
*/
igt_require(num_unique_crcs(ref_crc[MULTIPLE_CRC_SET], data->num_colors) > 1);
- for (int i = 0; i < plane->format_mod_count; i++) {
- struct format_mod f = {
- .format = plane->formats[i],
- .modifier = plane->modifiers[i],
- };
+ struct format_mod f = {
+ .format = format_num[p],
+ .modifier = mod_num[i],
+ };
- /* igt doesn't know how to sw generate UBWC: */
- if (is_msm_device(data->drm_fd) &&
- f.modifier == DRM_FORMAT_MOD_QCOM_COMPRESSED)
- continue;
+ int flag = 0;
+ for (int l = 0; l < plane->format_mod_count; l++) {
+ if (f.format == plane->formats[l] && f.modifier == plane->modifiers[l])
+ flag++;
+ }
- if (f.format == ref.format &&
- f.modifier == ref.modifier)
- continue;
+ if (flag == 0)
+ return true;
- /* test each format "class" only once in non-extended tests */
- if (!data->extended && f.modifier != DRM_FORMAT_MOD_LINEAR) {
- struct format_mod rf = {
- .format = igt_reduce_format(f.format),
- .modifier = f.modifier,
- };
-
- if (igt_vec_index(&tested_formats, &rf) >= 0) {
- igt_info("Skipping format " IGT_FORMAT_FMT " / modifier " IGT_MODIFIER_FMT " on %s.%u\n",
- IGT_FORMAT_ARGS(f.format), IGT_MODIFIER_ARGS(f.modifier),
- kmstest_pipe_name(pipe), plane->index);
- continue;
- }
+ /* igt doesn't know how to sw generate UBWC: */
+ if (is_msm_device(data->drm_fd) &&
+ f.modifier == DRM_FORMAT_MOD_QCOM_COMPRESSED)
+ return true;
- igt_vec_push(&tested_formats, &rf);
- }
+ /* test each format "class" only once in non-extended tests */
+ if (!data->extended && f.modifier != DRM_FORMAT_MOD_LINEAR) {
+ struct format_mod rf = {
+ .format = igt_reduce_format(f.format),
+ .modifier = f.modifier,
+ };
- if (f.format == DRM_FORMAT_C8) {
- if (!set_c8_legacy_lut(data, pipe, LUT_MASK))
- continue;
- } else {
- if (!igt_fb_supported_format(f.format))
- continue;
+ if (igt_vec_index(&tested_formats, &rf) >= 0) {
+ igt_info("Skipping format " IGT_FORMAT_FMT " / modifier " IGT_MODIFIER_FMT " on %s.%u\n",
+ IGT_FORMAT_ARGS(f.format), IGT_MODIFIER_ARGS(f.modifier),
+ kmstest_pipe_name(pipe), plane->index);
+ return true;
}
- crcset = ref_crc[use_multiple_colors(data, f.format) ?
- MULTIPLE_CRC_SET : SINGLE_CRC_SET];
-
- if (igt_format_is_yuv(f.format))
- result &= test_format_plane_yuv(data, pipe, plane,
- f.format, f.modifier,
- width, height,
- crcset, &fb);
- else
- result &= test_format_plane_rgb(data, pipe, plane,
- f.format, f.modifier,
- width, height,
- crcset, &fb);
-
- if (f.format == DRM_FORMAT_C8)
- set_legacy_lut(data, pipe, LUT_MASK);
+ igt_vec_push(&tested_formats, &rf);
}
+ if (f.format == DRM_FORMAT_C8) {
+ if (!set_c8_legacy_lut(data, pipe, LUT_MASK))
+ return true;
+ } else {
+ if (!igt_fb_supported_format(f.format))
+ return true;
+ }
+
+ crcset = ref_crc[use_multiple_colors(data, f.format) ?
+ MULTIPLE_CRC_SET : SINGLE_CRC_SET];
+
+ if (igt_format_is_yuv(f.format))
+ result &= test_format_plane_yuv(data, pipe, plane,
+ f.format, f.modifier,
+ width, height,
+ crcset, &fb);
+ else
+ result &= test_format_plane_rgb(data, pipe, plane,
+ f.format, f.modifier,
+ width, height,
+ crcset, &fb);
+
+ if (f.format == DRM_FORMAT_C8)
+ set_legacy_lut(data, pipe, LUT_MASK);
+
igt_pipe_crc_stop(data->pipe_crc);
igt_plane_set_fb(plane, clear_fb);
@@ -1172,7 +1369,63 @@ static bool skip_plane(data_t *data, igt_plane_t *plane)
}
static void
-test_pixel_formats(data_t *data, enum pipe pipe)
+test_pixel_formats_sc(data_t *data, enum pipe pipe)
+{
+ struct igt_fb primary_fb;
+ igt_plane_t *primary;
+ drmModeModeInfo *mode;
+ bool result;
+ igt_output_t *output = data->output;
+ igt_plane_t *plane;
+
+ if (data->extended) {
+ data->colors = colors_extended;
+ data->num_colors = ARRAY_SIZE(colors_extended);
+ } else {
+ data->colors = colors_reduced;
+ data->num_colors = ARRAY_SIZE(colors_reduced);
+ }
+
+ igt_info("Using (pipe %s + %s) to run the subtest.\n",
+ kmstest_pipe_name(pipe), igt_output_name(output));
+
+ test_init(data, pipe);
+
+ mode = igt_output_get_mode(output);
+
+ igt_create_fb(data->drm_fd, mode->hdisplay, mode->vdisplay,
+ DRM_FORMAT_XRGB8888, DRM_FORMAT_MOD_LINEAR, &primary_fb);
+
+ igt_output_set_pipe(output, pipe);
+ primary = igt_output_get_plane_type(output, DRM_PLANE_TYPE_PRIMARY);
+ igt_plane_set_fb(primary, &primary_fb);
+
+ igt_display_commit2(&data->display, data->display.is_atomic ? COMMIT_ATOMIC : COMMIT_LEGACY);
+
+ set_legacy_lut(data, pipe, LUT_MASK);
+
+ result = true;
+ for_each_plane_on_pipe(&data->display, pipe, plane) {
+ if (skip_plane(data, plane))
+ continue;
+ result &= test_format_plane_sc(data, pipe, output, plane, &primary_fb);
+ }
+
+ test_fini(data);
+
+ set_legacy_lut(data, pipe, 0xffff);
+
+ igt_plane_set_fb(primary, NULL);
+ igt_output_set_pipe(output, PIPE_NONE);
+ igt_display_commit2(&data->display, data->display.is_atomic ? COMMIT_ATOMIC : COMMIT_LEGACY);
+
+ igt_remove_fb(data->drm_fd, &primary_fb);
+
+ igt_assert_f(result, "At least one CRC mismatch happened\n");
+}
+
+static void
+test_pixel_formats(data_t *data, enum pipe pipe, int i, int p)
{
struct igt_fb primary_fb;
igt_plane_t *primary;
@@ -1211,7 +1464,7 @@ test_pixel_formats(data_t *data, enum pipe pipe)
for_each_plane_on_pipe(&data->display, pipe, plane) {
if (skip_plane(data, plane))
continue;
- result &= test_format_plane(data, pipe, output, plane, &primary_fb);
+ result &= test_format_plane(data, pipe, output, plane, &primary_fb, i, p);
}
test_fini(data);
@@ -1329,13 +1582,33 @@ static void
run_tests_for_pipe_plane(data_t *data)
{
igt_describe("verify the pixel formats for given plane and pipe");
- igt_subtest_with_dynamic_f("pixel-format")
- run_test(data, test_pixel_formats);
+ for (int p = 0; p < 29; p++) {
+ igt_subtest_with_dynamic_f("pixel-format-%s", sub_names[p]) {
+ enum pipe pipe;
+ int count = 0;
+ for_each_pipe_with_single_output(&data->display, pipe, data->output) {
+ igt_display_reset(&data->display);
+
+ igt_output_set_pipe(data->output, pipe);
+ if (!intel_pipe_output_combo_valid(&data->display))
+ continue;
+
+ igt_output_set_pipe(data->output, PIPE_NONE);
+ for (int i = 0; i < 3; i++) {
+ igt_dynamic_f("pipe-%s-%s", kmstest_pipe_name(pipe), dyna_names[i])
+ test_pixel_formats(data, pipe, i, p);
+ }
+
+ if (is_pipe_limit_reached(++count))
+ break;
+ }
+ }
+ }
igt_describe("verify the pixel formats for given plane and pipe with source clamping");
igt_subtest_with_dynamic_f("pixel-format-source-clamping") {
data->crop = 4;
- run_test(data, test_pixel_formats);
+ run_test(data, test_pixel_formats_sc);
}
data->crop = 0;
--
2.34.1
More information about the igt-dev
mailing list