[igt-dev] [PATCH i-g-t 2/3] tests/kms_plane: Test all YCbCr encodings/ranges

Ville Syrjala
2019-06-28T19:44:47Z

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

Test all support YCbCr encoding/range combinations. So far
we've only been testing one particular combo.

Cc: Uma Shankar <uma.shankar@intel.com>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
tests/kms_plane.c | 153 ++++++++++++++++++++++++++++++++++++----------
1 file changed, 120 insertions(+), 33 deletions(-)

diff --git a/tests/kms_plane.c b/tests/kms_plane.c
index 59d5f1e80cd2..13d36254dfe3 100644
--- a/tests/kms_plane.c
+++ b/tests/kms_plane.c
@@ -427,15 +427,18 @@ static void test_format_plane_color(data_t *data, enum pipe pipe,
igt_plane_t *plane,
uint32_t format, uint64_t modifier,
int width, int height,
+ enum igt_color_encoding color_encoding,
+ enum igt_color_range color_range,
int color, igt_crc_t *crc, struct igt_fb *fb)
{
const color_t *c = &colors[color];
struct igt_fb old_fb = *fb;

if (data->crop == 0 || format == DRM_FORMAT_XRGB8888) {
- igt_create_color_fb(data->drm_fd, width, height,
- format, modifier,
- c->red, c->green, c->blue, fb);
+ igt_create_color_fb_full(data->drm_fd, width, height,
+ format, modifier,
+ color_encoding, color_range,
+ c->red, c->green, c->blue, fb);
} else {
/*
* paint border in inverted color, then visible area in middle
@@ -443,11 +446,11 @@ static void test_format_plane_color(data_t *data, enum pipe pipe,
*/
cairo_t *cr;

- igt_create_fb(data->drm_fd,
- width + data->crop * 2,
- height + data->crop * 2,
- format, modifier, fb);
-
+ igt_create_fb_full(data->drm_fd,
+ width + data->crop * 2,
+ height + data->crop * 2,
+ format, modifier,
+ color_encoding, color_range, fb);
cr = igt_get_cairo_ctx(data->drm_fd, fb);

igt_paint_color(cr, 0, 0,
@@ -500,6 +503,103 @@ static int num_unique_crcs(const igt_crc_t crc[], int num_crc)
return num_unique_crc;
}

+static bool test_format_plane_colors(data_t *data, enum pipe pipe,
+ igt_plane_t *plane,
+ uint32_t format, uint64_t modifier,
+ int width, int height,
+ enum igt_color_encoding encoding,
+ enum igt_color_range range,
+ igt_crc_t ref_crc[ARRAY_SIZE(colors)],
+ struct igt_fb *fb)
+{
+ int crc_mismatch_count = 0;
+ unsigned int crc_mismatch_mask = 0;
+ bool result = true;
+
+ for (int i = 0; i < ARRAY_SIZE(colors); i++) {
+ igt_crc_t crc;
+
+ test_format_plane_color(data, pipe, plane,
+ format, modifier,
+ width, height,
+ encoding, range,
+ i, &crc, fb);
+
+ if (!igt_check_crc_equal(&crc, &ref_crc[i])) {
+ crc_mismatch_count++;
+ crc_mismatch_mask |= (1 << i);
+ result = false;
+ }
+ }
+
+ if (crc_mismatch_count)
+ igt_warn("CRC mismatches with format " IGT_FORMAT_FMT " on %s.%u with %d/%d solid colors tested (0x%X)\n",
+ IGT_FORMAT_ARGS(format), kmstest_pipe_name(pipe),
+ plane->index, crc_mismatch_count, (int)ARRAY_SIZE(colors), crc_mismatch_mask);
+
+ return result;
+}
+
+static bool test_format_plane_rgb(data_t *data, enum pipe pipe,
+ igt_plane_t *plane,
+ uint32_t format, uint64_t modifier,
+ int width, int height,
+ igt_crc_t ref_crc[ARRAY_SIZE(colors)],
+ struct igt_fb *fb)
+{
+ igt_info("Testing format " IGT_FORMAT_FMT " / modifier 0x%" PRIx64 " on %s.%u\n",
+ IGT_FORMAT_ARGS(format), modifier,
+ kmstest_pipe_name(pipe), plane->index);
+
+ return test_format_plane_colors(data, pipe, plane,
+ format, modifier,
+ width, height,
+ IGT_COLOR_YCBCR_BT601,
+ IGT_COLOR_YCBCR_LIMITED_RANGE,
+ ref_crc, fb);
+}
+
+static bool test_format_plane_yuv(data_t *data, enum pipe pipe,
+ igt_plane_t *plane,
+ uint32_t format, uint64_t modifier,
+ int width, int height,
+ igt_crc_t ref_crc[ARRAY_SIZE(colors)],
+ struct igt_fb *fb)
+{
+ bool result = true;
+
+ if (!igt_plane_has_prop(plane, IGT_PLANE_COLOR_ENCODING))
+ return true;
+ if (!igt_plane_has_prop(plane, IGT_PLANE_COLOR_RANGE))
+ return true;
+
+ for (enum igt_color_encoding e = 0; e < IGT_NUM_COLOR_ENCODINGS; e++) {
+ if (!igt_plane_try_prop_enum(plane,
+ IGT_PLANE_COLOR_ENCODING,
+ igt_color_encoding_to_str(e)))
+ continue;
+
+ for (enum igt_color_range r = 0; r < IGT_NUM_COLOR_RANGES; r++) {
+ if (!igt_plane_try_prop_enum(plane,
+ IGT_PLANE_COLOR_RANGE,
+ igt_color_range_to_str(r)))
+ continue;
+
+ igt_info("Testing format " IGT_FORMAT_FMT " / modifier 0x%" PRIx64 " (%s, %s) on %s.%u\n",
+ IGT_FORMAT_ARGS(format), modifier,
+ igt_color_encoding_to_str(e),
+ igt_color_range_to_str(r),
+ kmstest_pipe_name(pipe), plane->index);
+ result &= test_format_plane_colors(data, pipe, plane,
+ format, modifier,
+ width, height,
+ e, r, ref_crc, fb);
+ }
+ }
+
+ return result;
+}
+
static bool test_format_plane(data_t *data, enum pipe pipe,
igt_output_t *output, igt_plane_t *plane)
{
@@ -569,6 +669,8 @@ static bool test_format_plane(data_t *data, enum pipe pipe,
test_format_plane_color(data, pipe, plane,
format, modifier,
width, height,
+ IGT_COLOR_YCBCR_BT709,
+ IGT_COLOR_YCBCR_LIMITED_RANGE,
i, &ref_crc[i], &fb);
}

@@ -580,10 +682,6 @@ static bool test_format_plane(data_t *data, enum pipe pipe,
igt_require(num_unique_crcs(ref_crc, ARRAY_SIZE(colors)) > 1);

for (int i = 0; i < plane->format_mod_count; i++) {
- int crc_mismatch_count = 0;
- int crc_mismatch_mask = 0;
- igt_crc_t crc;
-
format = plane->formats[i];
modifier = plane->modifiers[i];

@@ -599,30 +697,19 @@ static bool test_format_plane(data_t *data, enum pipe pipe,
continue;
}

- igt_info("Testing format " IGT_FORMAT_FMT " / modifier 0x%" PRIx64 " on %s.%u\n",
- IGT_FORMAT_ARGS(format), modifier,
- kmstest_pipe_name(pipe), plane->index);
-
- for (int j = 0; j < ARRAY_SIZE(colors); j++) {
- test_format_plane_color(data, pipe, plane,
- format, modifier,
- width, height,
- j, &crc, &fb);
-
- if (!igt_check_crc_equal(&crc, &ref_crc[j])) {
- crc_mismatch_count++;
- crc_mismatch_mask |= (1 << j);
- result = false;
- }
- }
+ if (igt_format_is_yuv(format))
+ result &= test_format_plane_yuv(data, pipe, plane,
+ format, modifier,
+ width, height,
+ ref_crc, &fb);
+ else
+ result &= test_format_plane_rgb(data, pipe, plane,
+ format, modifier,
+ width, height,
+ ref_crc, &fb);

if (format == DRM_FORMAT_C8)
set_legacy_lut(data, pipe, 0xfc00);
-
- if (crc_mismatch_count)
- igt_warn("CRC mismatches with format " IGT_FORMAT_FMT " on %s.%u with %d/%d solid colors tested (0x%X)\n",
- IGT_FORMAT_ARGS(format), kmstest_pipe_name(pipe),
- plane->index, crc_mismatch_count, (int)ARRAY_SIZE(colors), crc_mismatch_mask);
}

igt_pipe_crc_stop(data->pipe_crc);
--
2.21.0