From a56a1f6e30ca49a50d4e8c896608ba605ee1f2fd Mon Sep 17 00:00:00 2001 From: Tomeu Vizoso Date: Thu, 8 Sep 2016 09:31:09 +0200 Subject: lib/debugfs: Support new generic ABI for CRC capture The kernel has now a new debugfs ABI that can also allow capturing frame CRCs for drivers other than i915. Add alternative codepaths so the new ABI is used if the kernel is recent enough, and fall back to the legacy ABI if not. Signed-off-by: Tomeu Vizoso Reviewed-by: Robert Foss --- tests/kms_pipe_crc_basic.c | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) (limited to 'tests/kms_pipe_crc_basic.c') diff --git a/tests/kms_pipe_crc_basic.c b/tests/kms_pipe_crc_basic.c index 04d5a134..b106f9bd 100644 --- a/tests/kms_pipe_crc_basic.c +++ b/tests/kms_pipe_crc_basic.c @@ -49,6 +49,8 @@ static void test_bad_command(data_t *data, const char *cmd) size_t written; ctl = igt_debugfs_fopen("i915_display_crc_ctl", "r+"); + igt_require(ctl); + written = fwrite(cmd, 1, strlen(cmd), ctl); fflush(ctl); igt_assert_eq(written, strlen(cmd)); @@ -58,6 +60,30 @@ static void test_bad_command(data_t *data, const char *cmd) fclose(ctl); } +static void test_bad_source(data_t *data) +{ + FILE *f; + size_t written; + const char *source = "foo"; + + f = igt_debugfs_fopen("crtc-0/crc/control", "w"); + if (!f) { + test_bad_command(data, "pipe A foo"); + return; + } + + written = fwrite(source, 1, strlen(source), f); + fflush(f); + igt_assert_eq(written, strlen(source)); + igt_assert(!ferror(f)); + igt_assert(!errno); + fclose(f); + + f = igt_debugfs_fopen("crtc-0/crc/data", "w"); + igt_assert(!f); + igt_assert_eq(errno, EINVAL); +} + #define N_CRCS 3 #define TEST_SEQUENCE (1<<0) @@ -185,7 +211,7 @@ igt_main igt_skip_on_simulation(); igt_fixture { - data.drm_fd = drm_open_driver_master(DRIVER_INTEL); + data.drm_fd = drm_open_driver_master(DRIVER_ANY); igt_enable_connectors(); @@ -200,7 +226,7 @@ igt_main test_bad_command(&data, "pipe D none"); igt_subtest("bad-source") - test_bad_command(&data, "pipe A foo"); + test_bad_source(&data); igt_subtest("bad-nb-words-1") test_bad_command(&data, "pipe foo"); -- cgit v1.2.3