[PATCH 2/3] lib: consolidate pipe crc exit handler

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



No need to sprinkle this all over:
- exit handlers will only be registered once
- they're always called when exiting, so no need to explictly call
  them.

This allows us to hide all the pipe crc cleanup in the library.

Cc: Damien Lespiau <damien.lespiau@xxxxxxxxx>
Signed-off-by: Daniel Vetter <daniel.vetter@xxxxxxxx>
---
 lib/igt_debugfs.c        | 52 ++++++++++++++++++++++++++----------------------
 lib/igt_debugfs.h        |  1 -
 tests/debugfs_pipe_crc.c |  7 -------
 tests/kms_cursor_crc.c   |  7 -------
 4 files changed, 28 insertions(+), 39 deletions(-)

diff --git a/lib/igt_debugfs.c b/lib/igt_debugfs.c
index 7efb415..b41db12 100644
--- a/lib/igt_debugfs.c
+++ b/lib/igt_debugfs.c
@@ -177,6 +177,32 @@ static bool igt_pipe_crc_do_start(igt_pipe_crc_t *pipe_crc)
 	return true;
 }
 
+static void igt_pipe_crc_pipe_off(int fd, enum pipe pipe)
+{
+	char buf[32];
+
+	sprintf(buf, "pipe %c none", pipe_name(pipe));
+	write(fd, buf, strlen(buf));
+}
+
+static void igt_pipe_crc_reset(void)
+{
+	igt_debugfs_t debugfs;
+	int fd;
+
+	igt_debugfs_init(&debugfs);
+	fd = igt_debugfs_open(&debugfs, "i915_display_crc_ctl", O_WRONLY);
+
+	igt_pipe_crc_pipe_off(fd, PIPE_A);
+	igt_pipe_crc_pipe_off(fd, PIPE_B);
+	igt_pipe_crc_pipe_off(fd, PIPE_C);
+}
+
+static void pipe_crc_exit_handler(int sig)
+{
+	igt_pipe_crc_reset();
+}
+
 igt_pipe_crc_t *
 igt_pipe_crc_new(igt_debugfs_t *debugfs, int drm_fd, enum pipe pipe,
 		 enum intel_pipe_crc_source source)
@@ -184,6 +210,8 @@ igt_pipe_crc_new(igt_debugfs_t *debugfs, int drm_fd, enum pipe pipe,
 	igt_pipe_crc_t *pipe_crc;
 	char buf[128];
 
+	do_or_die(igt_install_exit_handler(pipe_crc_exit_handler));
+
 	pipe_crc = calloc(1, sizeof(struct _igt_pipe_crc));
 
 	pipe_crc->ctl_fd = igt_debugfs_open(debugfs,
@@ -211,30 +239,6 @@ igt_pipe_crc_new(igt_debugfs_t *debugfs, int drm_fd, enum pipe pipe,
 	return pipe_crc;
 }
 
-static void igt_pipe_crc_pipe_off(int fd, enum pipe pipe)
-{
-	char buf[32];
-
-	sprintf(buf, "pipe %c none", pipe_name(pipe));
-	write(fd, buf, strlen(buf));
-}
-
-/*
- * Turn off everything
- */
-void igt_pipe_crc_reset(void)
-{
-	igt_debugfs_t debugfs;
-	int fd;
-
-	igt_debugfs_init(&debugfs);
-	fd = igt_debugfs_open(&debugfs, "i915_display_crc_ctl", O_WRONLY);
-
-	igt_pipe_crc_pipe_off(fd, PIPE_A);
-	igt_pipe_crc_pipe_off(fd, PIPE_B);
-	igt_pipe_crc_pipe_off(fd, PIPE_C);
-}
-
 void igt_pipe_crc_free(igt_pipe_crc_t *pipe_crc)
 {
 	if (!pipe_crc)
diff --git a/lib/igt_debugfs.h b/lib/igt_debugfs.h
index 4e82a2c..c2810ee 100644
--- a/lib/igt_debugfs.h
+++ b/lib/igt_debugfs.h
@@ -73,7 +73,6 @@ char *igt_crc_to_string(igt_crc_t *crc);
 igt_pipe_crc_t *
 igt_pipe_crc_new(igt_debugfs_t *debugfs, int drm_fd, enum pipe pipe,
 		 enum intel_pipe_crc_source source);
-void igt_pipe_crc_reset(void);
 void igt_pipe_crc_free(igt_pipe_crc_t *pipe_crc);
 bool igt_pipe_crc_start(igt_pipe_crc_t *pipe_crc);
 void igt_pipe_crc_stop(igt_pipe_crc_t *pipe_crc);
diff --git a/tests/debugfs_pipe_crc.c b/tests/debugfs_pipe_crc.c
index 7f51724..fe14c6c 100644
--- a/tests/debugfs_pipe_crc.c
+++ b/tests/debugfs_pipe_crc.c
@@ -206,11 +206,6 @@ static void test_read_crc(data_t *data, int pipe, unsigned flags)
 
 }
 
-static void exit_handler(int sig)
-{
-	igt_pipe_crc_reset();
-}
-
 int main(int argc, char **argv)
 {
 	data_t data = {0, };
@@ -224,7 +219,6 @@ int main(int argc, char **argv)
 
 		data.drm_fd = drm_open_any();
 		do_or_die(igt_set_vt_graphics_mode());
-		do_or_die(igt_install_exit_handler(exit_handler));
 
 		display_init(&data);
 
@@ -260,7 +254,6 @@ int main(int argc, char **argv)
 	}
 
 	igt_fixture {
-		igt_pipe_crc_reset();
 		display_fini(&data);
 		fclose(data.ctl);
 	}
diff --git a/tests/kms_cursor_crc.c b/tests/kms_cursor_crc.c
index cddfe10..c82d3e7 100644
--- a/tests/kms_cursor_crc.c
+++ b/tests/kms_cursor_crc.c
@@ -304,11 +304,6 @@ static void run_test(data_t *data, enum cursor_type cursor_type, bool onscreen)
 	igt_require_f(valid_tests, "no valid crtc/connector combinations found\n");
 }
 
-static void exit_handler(int sig)
-{
-	igt_pipe_crc_reset();
-}
-
 static void create_cursor_fb(data_t *data,
 			     enum cursor_type cursor_type,
 			     double r, double g, double b, double a)
@@ -340,7 +335,6 @@ int main(int argc, char **argv)
 
 		data.drm_fd = drm_open_any();
 		do_or_die(igt_set_vt_graphics_mode());
-		do_or_die(igt_install_exit_handler(exit_handler));
 
 		igt_debugfs_init(&data.debugfs);
 		data.ctl = igt_debugfs_fopen(&data.debugfs,
@@ -378,7 +372,6 @@ int main(int argc, char **argv)
 		run_test(&data, BLACK_INVISIBLE, false);
 
 	igt_fixture {
-		igt_pipe_crc_reset();
 		display_fini(&data);
 		fclose(data.ctl);
 	}
-- 
1.8.4.rc3

_______________________________________________
Intel-gfx mailing list
Intel-gfx@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/intel-gfx




[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]
  Powered by Linux