[igt-dev] [PATCH v4 11/13] chamelium: Add format support

Maxime Ripard
2018-07-26T10:42:47Z

In order to introduce CRC subtests for DRM formats, we need to take an
intermediate step.

The current code will generate a pattern in XR24, and will try to compare
the CRC returned by the Chamelium for each frames.

This CRC is computed on an XR24 format as well, so it works. However, as
soon as we will start implementing other formats, if we just change the
format of the pattern, the raw content of the buffer, and therefore the
CRC's won't match anymore.

In order to address that, we will need an intermediate step, and we will
now still create the XR24 pattern, and compute its CRC, then convert it to
the format we want to test, and finally retrieve the CRC from the Chamelium
to compare it with the one from the XR24 pattern.

The current code is converted to the new prototype that will take the
fourcc of the format to test, even though we're still using XR24 everywhere
for now.

Reviewed-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com>
Signed-off-by: Maxime Ripard <maxime.ripard@bootlin.com>
---
tests/kms_chamelium.c | 37 ++++++++++++++++++++++++-------------
1 file changed, 24 insertions(+), 13 deletions(-)

diff --git a/tests/kms_chamelium.c b/tests/kms_chamelium.c
index 4f4984b51b41..aa0aa4fd89ef 100644
--- a/tests/kms_chamelium.c
+++ b/tests/kms_chamelium.c
@@ -524,21 +524,25 @@ static int chamelium_get_pattern_fb(data_t *data, drmModeModeInfo *mode,

static void do_test_display_crc(data_t *data, struct chamelium_port *port,
igt_output_t *output, drmModeModeInfo *mode,
- int count)
+ uint32_t fourcc, int count)
{
igt_crc_t *crc;
igt_crc_t *expected_crc;
struct chamelium_fb_crc_async_data *fb_crc;
- struct igt_fb fb;
+ struct igt_fb frame_fb, fb;
int i, fb_id, captured_frame_count;
+ int frame_id;

fb_id = chamelium_get_pattern_fb(data, mode, DRM_FORMAT_XRGB8888, &fb);
igt_assert(fb_id > 0);

+ frame_id = igt_fb_convert(&frame_fb, &fb, fourcc);
+ igt_assert(frame_id > 0);
+
fb_crc = chamelium_calculate_fb_crc_async_start(data->drm_fd,
&fb);

- enable_output(data, port, output, mode, &fb);
+ enable_output(data, port, output, mode, &frame_fb);

/* We want to keep the display running for a little bit, since
* there's always the potential the driver isn't able to keep
@@ -562,6 +566,7 @@ static void do_test_display_crc(data_t *data, struct chamelium_port *port,
free(expected_crc);
free(crc);

+ igt_remove_fb(data->drm_fd, &frame_fb);
igt_remove_fb(data->drm_fd, &fb);
}

@@ -580,7 +585,7 @@ static drmModeModeInfo *find_preferred_mode(drmModeConnector *connector)
}

static void test_display_crc_one_mode(data_t *data, struct chamelium_port *port,
- int count)
+ uint32_t fourcc, int count)
{
igt_output_t *output;
drmModeConnector *connector;
@@ -597,13 +602,13 @@ static void test_display_crc_one_mode(data_t *data, struct chamelium_port *port,
mode = find_preferred_mode(connector);
igt_assert(mode);

- do_test_display_crc(data, port, output, mode, count);
+ do_test_display_crc(data, port, output, mode, fourcc, count);

drmModeFreeConnector(connector);
}

static void test_display_crc_all_modes(data_t *data, struct chamelium_port *port,
- int count)
+ uint32_t fourcc, int count)
{
igt_output_t *output;
igt_plane_t *primary;
@@ -620,7 +625,7 @@ static void test_display_crc_all_modes(data_t *data, struct chamelium_port *port
for (i = 0; i < connector->count_modes; i++) {
drmModeModeInfo *mode = &connector->modes[i];

- do_test_display_crc(data, port, output, mode, count);
+ do_test_display_crc(data, port, output, mode, fourcc, count);
}

drmModeFreeConnector(connector);
@@ -881,13 +886,16 @@ igt_main
edid_id, alt_edid_id);

connector_subtest("dp-crc-single", DisplayPort)
- test_display_crc_all_modes(&data, port, 1);
+ test_display_crc_all_modes(&data, port,
+ DRM_FORMAT_XRGB8888, 1);

connector_subtest("dp-crc-fast", DisplayPort)
- test_display_crc_one_mode(&data, port, 1);
+ test_display_crc_one_mode(&data, port,
+ DRM_FORMAT_XRGB8888, 1);

connector_subtest("dp-crc-multiple", DisplayPort)
- test_display_crc_all_modes(&data, port, 3);
+ test_display_crc_all_modes(&data, port,
+ DRM_FORMAT_XRGB8888, 3);

connector_subtest("dp-frame-dump", DisplayPort)
test_display_frame_dump(&data, port);
@@ -945,13 +953,16 @@ igt_main
edid_id, alt_edid_id);

connector_subtest("hdmi-crc-single", HDMIA)
- test_display_crc_all_modes(&data, port, 1);
+ test_display_crc_all_modes(&data, port,
+ DRM_FORMAT_XRGB8888, 1);

connector_subtest("hdmi-crc-fast", HDMIA)
- test_display_crc_one_mode(&data, port, 1);
+ test_display_crc_one_mode(&data, port,
+ DRM_FORMAT_XRGB8888, 1);

connector_subtest("hdmi-crc-multiple", HDMIA)
- test_display_crc_all_modes(&data, port, 3);
+ test_display_crc_all_modes(&data, port,
+ DRM_FORMAT_XRGB8888, 3);

connector_subtest("hdmi-frame-dump", HDMIA)
test_display_frame_dump(&data, port);