From: Tvrtko Ursulin <tvrtko.ursulin@xxxxxxxxx> Previous patch has marked individual subtests as basic so now rename the test binary name accordingly. Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@xxxxxxxxx> --- tests/Makefile.sources | 2 +- tests/kms_pipe_crc.c | 246 +++++++++++++++++++++++++++++++++++++++++++++ tests/kms_pipe_crc_basic.c | 246 --------------------------------------------- 3 files changed, 247 insertions(+), 247 deletions(-) create mode 100644 tests/kms_pipe_crc.c delete mode 100644 tests/kms_pipe_crc_basic.c diff --git a/tests/Makefile.sources b/tests/Makefile.sources index abcf32558c66..adfec2990af3 100644 --- a/tests/Makefile.sources +++ b/tests/Makefile.sources @@ -92,7 +92,7 @@ TESTS_progs_M = \ kms_mmio_vs_cs_flip \ kms_pipe_b_c_ivb \ kms_pipe_color \ - kms_pipe_crc_basic \ + kms_pipe_crc \ kms_plane \ kms_psr_sink_crc \ kms_render \ diff --git a/tests/kms_pipe_crc.c b/tests/kms_pipe_crc.c new file mode 100644 index 000000000000..291775934758 --- /dev/null +++ b/tests/kms_pipe_crc.c @@ -0,0 +1,246 @@ +/* + * Copyright © 2013 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + * + */ + +#include "igt.h" +#include <errno.h> +#include <stdbool.h> +#include <stdio.h> +#include <string.h> + + +typedef struct { + int drm_fd; + igt_display_t display; + struct igt_fb fb; +} data_t; + +static struct { + double r, g, b; + igt_crc_t crc; +} colors[2] = { + { .r = 0.0, .g = 1.0, .b = 0.0 }, + { .r = 0.0, .g = 1.0, .b = 1.0 }, +}; + +static void test_bad_command(data_t *data, const char *cmd) +{ + FILE *ctl; + size_t written; + + ctl = igt_debugfs_fopen("i915_display_crc_ctl", "r+"); + written = fwrite(cmd, 1, strlen(cmd), ctl); + fflush(ctl); + igt_assert_eq(written, strlen(cmd)); + igt_assert(ferror(ctl)); + igt_assert_eq(errno, EINVAL); + + fclose(ctl); +} + +#define N_CRCS 3 + +#define TEST_SEQUENCE (1<<0) +#define TEST_NONBLOCK (1<<1) + +static int +test_read_crc_for_output(data_t *data, int pipe, igt_output_t *output, + unsigned flags) +{ + igt_display_t *display = &data->display; + igt_plane_t *primary; + drmModeModeInfo *mode; + igt_pipe_crc_t *pipe_crc; + igt_crc_t *crcs = NULL; + int c, j; + + for (c = 0; c < ARRAY_SIZE(colors); c++) { + char *crc_str; + int n_crcs; + + igt_output_set_pipe(output, pipe); + igt_display_commit(display); + + if (!output->valid) { + igt_output_set_pipe(output, PIPE_ANY); + return 0; + } + + igt_debug("Clearing the fb with color (%.02lf,%.02lf,%.02lf)\n", + colors[c].r, colors[c].g, colors[c].b); + + mode = igt_output_get_mode(output); + igt_create_color_fb(data->drm_fd, + mode->hdisplay, mode->vdisplay, + DRM_FORMAT_XRGB8888, + LOCAL_DRM_FORMAT_MOD_NONE, + colors[c].r, + colors[c].g, + colors[c].b, + &data->fb); + + primary = igt_output_get_plane(output, 0); + igt_plane_set_fb(primary, &data->fb); + + igt_display_commit(display); + + if (flags & TEST_NONBLOCK) + pipe_crc = igt_pipe_crc_new_nonblock(pipe, INTEL_PIPE_CRC_SOURCE_AUTO); + else + pipe_crc = igt_pipe_crc_new(pipe, INTEL_PIPE_CRC_SOURCE_AUTO); + + igt_pipe_crc_start(pipe_crc); + + /* wait for N_CRCS vblanks and the corresponding N_CRCS CRCs */ + if (flags & TEST_NONBLOCK) { + int i; + + for (i = 0; i < N_CRCS; i++) + igt_wait_for_vblank(data->drm_fd, pipe); + + n_crcs = igt_pipe_crc_get_crcs(pipe_crc, N_CRCS * 3, &crcs); + /* allow a one frame difference */ + igt_assert_lte(n_crcs, N_CRCS + 1); + igt_assert_lte(N_CRCS, n_crcs + 1); + } else { + n_crcs = igt_pipe_crc_get_crcs(pipe_crc, N_CRCS, &crcs); + igt_assert_eq(n_crcs, N_CRCS); + } + + igt_pipe_crc_stop(pipe_crc); + + /* + * save the CRC in colors so it can be compared to the CRC of + * other fbs + */ + colors[c].crc = crcs[0]; + + crc_str = igt_crc_to_string(&crcs[0]); + igt_debug("CRC for this fb: %s\n", crc_str); + free(crc_str); + + /* and ensure that they'are all equal, we haven't changed the fb */ + for (j = 0; j < (n_crcs - 1); j++) + igt_assert_crc_equal(&crcs[j], &crcs[j + 1]); + + if (flags & TEST_SEQUENCE) + for (j = 0; j < (n_crcs - 1); j++) + igt_assert_eq(crcs[j].frame + 1, crcs[j + 1].frame); + + free(crcs); + igt_pipe_crc_free(pipe_crc); + igt_remove_fb(data->drm_fd, &data->fb); + igt_plane_set_fb(primary, NULL); + + igt_output_set_pipe(output, PIPE_ANY); + } + + return 1; +} + +static void test_read_crc(data_t *data, int pipe, unsigned flags) +{ + igt_display_t *display = &data->display; + int valid_connectors = 0; + igt_output_t *output; + + igt_skip_on(pipe >= data->display.n_pipes); + + for_each_connected_output(display, output) { + + igt_info("%s: Testing connector %s using pipe %s\n", + igt_subtest_name(), igt_output_name(output), + kmstest_pipe_name(pipe)); + + valid_connectors += test_read_crc_for_output(data, pipe, output, flags); + } + + igt_require_f(valid_connectors, "No connector found for pipe %i\n", pipe); +} + +data_t data = {0, }; + +#define test_prefix(i) ((i) == 0 ? "basic-" : "") +#define pipe_name(i) ((i) + 'A') + +igt_main +{ + igt_skip_on_simulation(); + + igt_fixture { + data.drm_fd = drm_open_driver_master(DRIVER_INTEL); + + igt_enable_connectors(); + + kmstest_set_vt_graphics_mode(); + + igt_require_pipe_crc(); + + igt_display_init(&data.display, data.drm_fd); + } + + igt_subtest("basic-bad-pipe") + test_bad_command(&data, "pipe D none"); + + igt_subtest("basic-bad-source") + test_bad_command(&data, "pipe A foo"); + + igt_subtest("basic-bad-nb-words-1") + test_bad_command(&data, "pipe foo"); + + igt_subtest("basic-bad-nb-words-3") + test_bad_command(&data, "pipe A none option"); + + for (int i = 0; i < 3; i++) { + igt_subtest_f("%sread-crc-pipe-%c", test_prefix(i), pipe_name(i)) + test_read_crc(&data, i, 0); + + igt_subtest_f("%sread-crc-pipe-%c-frame-sequence", test_prefix(i), pipe_name(i)) + test_read_crc(&data, i, TEST_SEQUENCE); + + igt_subtest_f("%snonblocking-crc-pipe-%c", test_prefix(i), pipe_name(i)) + test_read_crc(&data, i, TEST_NONBLOCK); + + igt_subtest_f("%snonblocking-crc-pipe-%c-frame-sequence", test_prefix(i), pipe_name(i)) + test_read_crc(&data, i, TEST_SEQUENCE | TEST_NONBLOCK); + + igt_subtest_f("%ssuspend-read-crc-pipe-%c", test_prefix(i), pipe_name(i)) { + igt_skip_on(i >= data.display.n_pipes); + igt_system_suspend_autoresume(); + + test_read_crc(&data, i, 0); + } + + igt_subtest_f("%shang-read-crc-pipe-%c", test_prefix(i), pipe_name(i)) { + igt_hang_ring_t hang = + igt_hang_ring(data.drm_fd, I915_EXEC_RENDER); + test_read_crc(&data, i, 0); + igt_post_hang_ring(data.drm_fd, hang); + test_read_crc(&data, i, 0); + } + } + + igt_fixture { + igt_display_fini(&data.display); + } +} diff --git a/tests/kms_pipe_crc_basic.c b/tests/kms_pipe_crc_basic.c deleted file mode 100644 index 291775934758..000000000000 --- a/tests/kms_pipe_crc_basic.c +++ /dev/null @@ -1,246 +0,0 @@ -/* - * Copyright © 2013 Intel Corporation - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice (including the next - * paragraph) shall be included in all copies or substantial portions of the - * Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS - * IN THE SOFTWARE. - * - */ - -#include "igt.h" -#include <errno.h> -#include <stdbool.h> -#include <stdio.h> -#include <string.h> - - -typedef struct { - int drm_fd; - igt_display_t display; - struct igt_fb fb; -} data_t; - -static struct { - double r, g, b; - igt_crc_t crc; -} colors[2] = { - { .r = 0.0, .g = 1.0, .b = 0.0 }, - { .r = 0.0, .g = 1.0, .b = 1.0 }, -}; - -static void test_bad_command(data_t *data, const char *cmd) -{ - FILE *ctl; - size_t written; - - ctl = igt_debugfs_fopen("i915_display_crc_ctl", "r+"); - written = fwrite(cmd, 1, strlen(cmd), ctl); - fflush(ctl); - igt_assert_eq(written, strlen(cmd)); - igt_assert(ferror(ctl)); - igt_assert_eq(errno, EINVAL); - - fclose(ctl); -} - -#define N_CRCS 3 - -#define TEST_SEQUENCE (1<<0) -#define TEST_NONBLOCK (1<<1) - -static int -test_read_crc_for_output(data_t *data, int pipe, igt_output_t *output, - unsigned flags) -{ - igt_display_t *display = &data->display; - igt_plane_t *primary; - drmModeModeInfo *mode; - igt_pipe_crc_t *pipe_crc; - igt_crc_t *crcs = NULL; - int c, j; - - for (c = 0; c < ARRAY_SIZE(colors); c++) { - char *crc_str; - int n_crcs; - - igt_output_set_pipe(output, pipe); - igt_display_commit(display); - - if (!output->valid) { - igt_output_set_pipe(output, PIPE_ANY); - return 0; - } - - igt_debug("Clearing the fb with color (%.02lf,%.02lf,%.02lf)\n", - colors[c].r, colors[c].g, colors[c].b); - - mode = igt_output_get_mode(output); - igt_create_color_fb(data->drm_fd, - mode->hdisplay, mode->vdisplay, - DRM_FORMAT_XRGB8888, - LOCAL_DRM_FORMAT_MOD_NONE, - colors[c].r, - colors[c].g, - colors[c].b, - &data->fb); - - primary = igt_output_get_plane(output, 0); - igt_plane_set_fb(primary, &data->fb); - - igt_display_commit(display); - - if (flags & TEST_NONBLOCK) - pipe_crc = igt_pipe_crc_new_nonblock(pipe, INTEL_PIPE_CRC_SOURCE_AUTO); - else - pipe_crc = igt_pipe_crc_new(pipe, INTEL_PIPE_CRC_SOURCE_AUTO); - - igt_pipe_crc_start(pipe_crc); - - /* wait for N_CRCS vblanks and the corresponding N_CRCS CRCs */ - if (flags & TEST_NONBLOCK) { - int i; - - for (i = 0; i < N_CRCS; i++) - igt_wait_for_vblank(data->drm_fd, pipe); - - n_crcs = igt_pipe_crc_get_crcs(pipe_crc, N_CRCS * 3, &crcs); - /* allow a one frame difference */ - igt_assert_lte(n_crcs, N_CRCS + 1); - igt_assert_lte(N_CRCS, n_crcs + 1); - } else { - n_crcs = igt_pipe_crc_get_crcs(pipe_crc, N_CRCS, &crcs); - igt_assert_eq(n_crcs, N_CRCS); - } - - igt_pipe_crc_stop(pipe_crc); - - /* - * save the CRC in colors so it can be compared to the CRC of - * other fbs - */ - colors[c].crc = crcs[0]; - - crc_str = igt_crc_to_string(&crcs[0]); - igt_debug("CRC for this fb: %s\n", crc_str); - free(crc_str); - - /* and ensure that they'are all equal, we haven't changed the fb */ - for (j = 0; j < (n_crcs - 1); j++) - igt_assert_crc_equal(&crcs[j], &crcs[j + 1]); - - if (flags & TEST_SEQUENCE) - for (j = 0; j < (n_crcs - 1); j++) - igt_assert_eq(crcs[j].frame + 1, crcs[j + 1].frame); - - free(crcs); - igt_pipe_crc_free(pipe_crc); - igt_remove_fb(data->drm_fd, &data->fb); - igt_plane_set_fb(primary, NULL); - - igt_output_set_pipe(output, PIPE_ANY); - } - - return 1; -} - -static void test_read_crc(data_t *data, int pipe, unsigned flags) -{ - igt_display_t *display = &data->display; - int valid_connectors = 0; - igt_output_t *output; - - igt_skip_on(pipe >= data->display.n_pipes); - - for_each_connected_output(display, output) { - - igt_info("%s: Testing connector %s using pipe %s\n", - igt_subtest_name(), igt_output_name(output), - kmstest_pipe_name(pipe)); - - valid_connectors += test_read_crc_for_output(data, pipe, output, flags); - } - - igt_require_f(valid_connectors, "No connector found for pipe %i\n", pipe); -} - -data_t data = {0, }; - -#define test_prefix(i) ((i) == 0 ? "basic-" : "") -#define pipe_name(i) ((i) + 'A') - -igt_main -{ - igt_skip_on_simulation(); - - igt_fixture { - data.drm_fd = drm_open_driver_master(DRIVER_INTEL); - - igt_enable_connectors(); - - kmstest_set_vt_graphics_mode(); - - igt_require_pipe_crc(); - - igt_display_init(&data.display, data.drm_fd); - } - - igt_subtest("basic-bad-pipe") - test_bad_command(&data, "pipe D none"); - - igt_subtest("basic-bad-source") - test_bad_command(&data, "pipe A foo"); - - igt_subtest("basic-bad-nb-words-1") - test_bad_command(&data, "pipe foo"); - - igt_subtest("basic-bad-nb-words-3") - test_bad_command(&data, "pipe A none option"); - - for (int i = 0; i < 3; i++) { - igt_subtest_f("%sread-crc-pipe-%c", test_prefix(i), pipe_name(i)) - test_read_crc(&data, i, 0); - - igt_subtest_f("%sread-crc-pipe-%c-frame-sequence", test_prefix(i), pipe_name(i)) - test_read_crc(&data, i, TEST_SEQUENCE); - - igt_subtest_f("%snonblocking-crc-pipe-%c", test_prefix(i), pipe_name(i)) - test_read_crc(&data, i, TEST_NONBLOCK); - - igt_subtest_f("%snonblocking-crc-pipe-%c-frame-sequence", test_prefix(i), pipe_name(i)) - test_read_crc(&data, i, TEST_SEQUENCE | TEST_NONBLOCK); - - igt_subtest_f("%ssuspend-read-crc-pipe-%c", test_prefix(i), pipe_name(i)) { - igt_skip_on(i >= data.display.n_pipes); - igt_system_suspend_autoresume(); - - test_read_crc(&data, i, 0); - } - - igt_subtest_f("%shang-read-crc-pipe-%c", test_prefix(i), pipe_name(i)) { - igt_hang_ring_t hang = - igt_hang_ring(data.drm_fd, I915_EXEC_RENDER); - test_read_crc(&data, i, 0); - igt_post_hang_ring(data.drm_fd, hang); - test_read_crc(&data, i, 0); - } - } - - igt_fixture { - igt_display_fini(&data.display); - } -} -- 1.9.1
_______________________________________________ Intel-gfx mailing list Intel-gfx@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/intel-gfx