summaryrefslogtreecommitdiff
path: root/tests/kms_chamelium.c
diff options
context:
space:
mode:
authorMaxime Ripard <maxime.ripard@bootlin.com>2018-10-04 14:39:05 +0200
committerArkadiusz Hiler <arkadiusz.hiler@intel.com>2018-10-08 16:58:13 +0300
commitc5262919126a7125b5db6431b4bba2955a13a020 (patch)
tree2801fb1cb389dc0362dd8a68204ae2c6bab90643 /tests/kms_chamelium.c
parentaedb04496f3e91ba88a08cbc7a71e41bcaf0523b (diff)
chamelium: Split CRC test function in two
We have two use cases in our current sub-test suites: the tests that test all the modes exposed by the driver, and the ones just picking up one. Instead of having to deal with this two cases in the same function as it is currently done, move the part that test a single mode into a separate function, and just call it for every mode that we want to test if needs be. This will result in a simpler function that will be easier to extend to support formats. Reviewed-by: Paul Kocialkowski <paul.kocialkowski@bootlin.com> Signed-off-by: Maxime Ripard <maxime.ripard@bootlin.com>
Diffstat (limited to 'tests/kms_chamelium.c')
-rw-r--r--tests/kms_chamelium.c120
1 files changed, 72 insertions, 48 deletions
diff --git a/tests/kms_chamelium.c b/tests/kms_chamelium.c
index 5ebac8dc..14b84d46 100644
--- a/tests/kms_chamelium.c
+++ b/tests/kms_chamelium.c
@@ -486,20 +486,60 @@ enable_output(data_t *data,
drmModeFreeConnector(connector);
}
-static void
-test_display_crc(data_t *data, struct chamelium_port *port, int count,
- bool fast)
+static void do_test_display_crc(data_t *data, struct chamelium_port *port,
+ igt_output_t *output, drmModeModeInfo *mode,
+ int count)
{
- igt_output_t *output;
- igt_plane_t *primary;
igt_crc_t *crc;
igt_crc_t *expected_crc;
struct chamelium_fb_crc_async_data *fb_crc;
struct igt_fb fb;
- drmModeModeInfo *mode;
+ int i, fb_id, captured_frame_count;
+
+ fb_id = igt_create_color_pattern_fb(data->drm_fd,
+ mode->hdisplay,
+ mode->vdisplay,
+ DRM_FORMAT_XRGB8888,
+ LOCAL_DRM_FORMAT_MOD_NONE,
+ 0, 0, 0, &fb);
+ igt_assert(fb_id > 0);
+
+ fb_crc = chamelium_calculate_fb_crc_async_start(data->drm_fd,
+ &fb);
+
+ enable_output(data, port, output, mode, &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
+ * the display running properly for very long
+ */
+ chamelium_capture(data->chamelium, port, 0, 0, 0, 0, count);
+ crc = chamelium_read_captured_crcs(data->chamelium,
+ &captured_frame_count);
+
+ igt_assert(captured_frame_count == count);
+
+ igt_debug("Captured %d frames\n", captured_frame_count);
+
+ expected_crc = chamelium_calculate_fb_crc_async_finish(fb_crc);
+
+ for (i = 0; i < captured_frame_count; i++)
+ chamelium_assert_crc_eq_or_dump(data->chamelium,
+ expected_crc, &crc[i],
+ &fb, i);
+
+ free(expected_crc);
+ free(crc);
+
+ igt_remove_fb(data->drm_fd, &fb);
+}
+
+static void test_display_crc_one_mode(data_t *data, struct chamelium_port *port,
+ int count)
+{
+ igt_output_t *output;
drmModeConnector *connector;
- int fb_id, i, j, captured_frame_count;
- int count_modes;
+ igt_plane_t *primary;
reset_state(data, port);
@@ -508,46 +548,30 @@ test_display_crc(data_t *data, struct chamelium_port *port, int count,
primary = igt_output_get_plane_type(output, DRM_PLANE_TYPE_PRIMARY);
igt_assert(primary);
- count_modes = fast ? 1 : connector->count_modes;
+ do_test_display_crc(data, port, output, &connector->modes[0], count);
- for (i = 0; i < count_modes; i++) {
- mode = &connector->modes[i];
- fb_id = igt_create_color_pattern_fb(data->drm_fd,
- mode->hdisplay,
- mode->vdisplay,
- DRM_FORMAT_XRGB8888,
- LOCAL_DRM_FORMAT_MOD_NONE,
- 0, 0, 0, &fb);
- igt_assert(fb_id > 0);
-
- fb_crc = chamelium_calculate_fb_crc_async_start(data->drm_fd,
- &fb);
-
- enable_output(data, port, output, mode, &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
- * the display running properly for very long
- */
- chamelium_capture(data->chamelium, port, 0, 0, 0, 0, count);
- crc = chamelium_read_captured_crcs(data->chamelium,
- &captured_frame_count);
-
- igt_assert(captured_frame_count == count);
+ drmModeFreeConnector(connector);
+}
- igt_debug("Captured %d frames\n", captured_frame_count);
+static void test_display_crc_all_modes(data_t *data, struct chamelium_port *port,
+ int count)
+{
+ igt_output_t *output;
+ igt_plane_t *primary;
+ drmModeConnector *connector;
+ int i;
- expected_crc = chamelium_calculate_fb_crc_async_finish(fb_crc);
+ reset_state(data, port);
- for (j = 0; j < captured_frame_count; j++)
- chamelium_assert_crc_eq_or_dump(data->chamelium,
- expected_crc, &crc[j],
- &fb, j);
+ output = prepare_output(data, port);
+ connector = chamelium_port_get_connector(data->chamelium, port, false);
+ primary = igt_output_get_plane_type(output, DRM_PLANE_TYPE_PRIMARY);
+ igt_assert(primary);
- free(expected_crc);
- free(crc);
+ for (i = 0; i < connector->count_modes; i++) {
+ drmModeModeInfo *mode = &connector->modes[i];
- igt_remove_fb(data->drm_fd, &fb);
+ do_test_display_crc(data, port, output, mode, count);
}
drmModeFreeConnector(connector);
@@ -808,13 +832,13 @@ igt_main
edid_id, alt_edid_id);
connector_subtest("dp-crc-single", DisplayPort)
- test_display_crc(&data, port, 1, false);
+ test_display_crc_all_modes(&data, port, 1);
connector_subtest("dp-crc-fast", DisplayPort)
- test_display_crc(&data, port, 1, true);
+ test_display_crc_one_mode(&data, port, 1);
connector_subtest("dp-crc-multiple", DisplayPort)
- test_display_crc(&data, port, 3, false);
+ test_display_crc_all_modes(&data, port, 3);
connector_subtest("dp-frame-dump", DisplayPort)
test_display_frame_dump(&data, port);
@@ -872,13 +896,13 @@ igt_main
edid_id, alt_edid_id);
connector_subtest("hdmi-crc-single", HDMIA)
- test_display_crc(&data, port, 1, false);
+ test_display_crc_all_modes(&data, port, 1);
connector_subtest("hdmi-crc-fast", HDMIA)
- test_display_crc(&data, port, 1, true);
+ test_display_crc_one_mode(&data, port, 1);
connector_subtest("hdmi-crc-multiple", HDMIA)
- test_display_crc(&data, port, 3, false);
+ test_display_crc_all_modes(&data, port, 3);
connector_subtest("hdmi-frame-dump", HDMIA)
test_display_frame_dump(&data, port);